1
0
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-11-24 07:20:29 +00:00
Commit Graph

588 Commits

Author SHA1 Message Date
Sean Whitton
bc7033f2d1 Replace use of if-let and when-let, obsolete in Emacs 31.0.50
* lisp/ob-R.el (org-babel-R-associate-session):
* lisp/ob-clojure.el (ob-clojure-nbb-command, ob-clojure-cli-command):
* lisp/ob-core.el (org-babel-execute-src-block):
* lisp/ob-exp.el (org-babel-exp-code):
* lisp/ob-julia.el (org-babel-julia-associate-session):
* lisp/ob-python.el
(org-babel-python--python-util-comint-end-of-output-p):
* lisp/ol.el (org-insert-link):
* lisp/org-attach.el (org-attach):
* lisp/org-clock.el (org-clock-select-task):
* lisp/org-compat.el (fboundp):
* lisp/org-element-ast.el (org-element-property-raw)
(org-element-put-property, org-element-copy):
* lisp/org-element.el (org-element-timestamp-interpreter)
(org-element--cache-key):
* lisp/org-goto.el (org-goto-location):
* lisp/org-lint.el (org-lint-suspicious-language-in-src-block)
(org-lint-export-option-keywords):
* lisp/org-macs.el (org-mks):
* lisp/org-persist.el: (org-persist-write:elisp):
* lisp/org-table.el (org-table-fedit-finish, orgtbl--skip)
(orgtbl--skipcols):
* lisp/org.el (org-entry-get-with-inheritance):
* lisp/ox-beamer.el (org-beamer--format-frame):
* lisp/ox-html.el (org-html--reference, org-html--build-mathjax-config)
(org-html-example-block):
* lisp/ox-latex.el (org-latex-table-row):
* lisp/ox.el (org-export--prune-tree)
(org-export--blindly-expand-include):
* testing/lisp/test-duplicates-detector.el
(test-duplicates-detector--find-duplicates):
* testing/lisp/test-ob-haskell-ghci.el
(test-ob-haskell-ghci-checking-buffers):
* testing/lisp/test-ob-python.el
(test-ob-python/async-local-python-shell):
* testing/lisp/test-ob-shell.el (test-ob-shell/bash-uses-assoc-arrays)
(test-ob-shell/bash-uses-assoc-arrays-with-lists)
(test-ob-shell/remote-with-stdin-or-cmdline):
Replace use of if-let and when-let, obsolete in Emacs 31.0.50.
2024-10-24 17:04:40 +08:00
Nick Dokos
8b4b89b14b
org-babel-header-arg-expand: more stringent check for appropriate context
The check for appropriate context in `org-babel-header-arg-expand' was
inadequate: a colon was deemed appropriate anywhere in the source
block, not just in the header.

* lisp/ob-core.el (org-babel-header-arg-expand): The function now uses
`org-babel-in-src-block-header-p' to check for appropriate context.
(org-babel-in-src-block-header-p): New function.

Reported-by: use @Addlai on Emacs SE.
Link: https://list.orgmode.org/orgmode/87zfnrb2nu.fsf@pierrot.dokosmarshall.org/
2024-10-18 19:37:31 +02:00
Ihor Radchenko
aead1f13ab
Merge branch 'bugfix' 2024-10-10 19:42:03 +02:00
Nick Dokos
b457dbfe5a
org-babel: Avoid changing user options by not sharing list structure
* lisp/ob-core.el (org-babel-get-src-block-info): Use `copy-tree'
when using `org-babel-default-header-args*' variables to prepare the
`info' variable used in src block evaluation. The `info' variable gets
modified, and the modifications were affecting the values of the user
variables. In particular, the `:file' setting was modified in the presence
of a `:output-dir' setting, concatenating more and more copies of the directory
every time the block was evaluated.

Reported-by: @lyndhurst on SE Emacs
Link: https://emacs.stackexchange.com/questions/82261/
2024-10-10 19:38:24 +02:00
Ihor Radchenko
10adc2bbd7
Merge branch 'bugfix' 2024-09-22 12:35:28 +02:00
Rodrigo Morales
d8fc26aefa
org-babel-view-src-block-info: Fix querying Org properties in Help buffer
* lisp/ob-core.el (org-babel-view-src-block-info): Query in-buffer
header arguments (`org-entry-get') from Org buffer.  It does nothing
from *Help* buffer.

In the previous version, when the user interactively calls
`org-babel-view-src-block-info' and the point is on a code block, these
two warnings are shown in the buffer *Warnings*:

 Warning (org-element): ‘org-element-at-point’ cannot be used in non-Org buffer #<buffer *Help*> (help-mode)
 Warning (org-element): ‘org-element-at-point’ cannot be used in non-Org buffer #<buffer *Help*> (help-mode)

This happened because `org-babel-view-src-block-info'
calls (org-entry-get (point) "header-args" t) while being in
the *Help* buffer.  `org-babel-view-src-block-info' should call
org-entry-get while being in the Org Mode buffer and then switch to
the *Help* buffer once it has all the information that is then
displayed in the *Help* buffer.

In the introduced changes, we execute (org-entry-get (point)
"header-args" t) while being in the Org Mode buffer and we switch
to *Help* when we have the necessary information that is then shown in
the *Help* buffer.

TINYCHANGE
2024-09-22 12:28:08 +02:00
Ihor Radchenko
482bc31565
org-babel-demarcate-block: Fix keeping BEGIN_SRC/END_SRC case
* lisp/ob-core.el (org-babel-demarcate-block): Keep case in
 #+BEGIN_SRC and #+END_SRC keywords splitting src block.
* testing/lisp/test-ob.el (test-ob/keep-case): New test.

Reported-by: Rudolf Adamkovič <rudolf@adamkovic.org>
Link: https://orgmode.org/list/m2y152f8s3.fsf@adamkovic.org
2024-08-14 11:02:18 +02:00
Ihor Radchenko
f398724bd5
Merge branch 'bugfix' 2024-07-17 16:11:14 +02:00
stardiviner
f2141541b4
ob-core: Unify Org Babel related buffer names using constant variable
* lisp/ob-core.el (org-babel-results-buffer-name): Define constant
variable for buffer name.
(org-babel-open-src-block-result): Use the
`org-babel-results-buffer-name'.
* lisp/ob-eval.el (org-babel-error-buffer-name): Add docstring.
* testing/lisp/test-ob-octave.el (org-babel-error-buffer-name):
(ob-octave/graphics-file):
(ob-octave/graphics-file-session):
(ob-octave/graphics-file-space):
* testing/lisp/test-ob-shell.el (org-babel-error-buffer-name):
(test-ob-shell/dont-error-on-babel-error):
(test-ob-shell/standard-output-after-failure):
(test-ob-shell/error-output-after-success):
(test-ob-shell/error-output-after-failure):
(test-ob-shell/error-output-after-failure-multiple):
(test-ob-shell/exit-code):
(test-ob-shell/exit-code-multiple): Use variable for buffer names.
2024-07-16 19:09:45 +02:00
Kyle Meyer
f308d33d2f Merge branch 'km/from-emacs-30' into bugfix 2024-07-14 12:21:33 -04:00
Stefan Kangas
e14969f629 Backport commit 6757f8e67 from Emacs
* lisp/ob-core.el:
* lisp/ob-exp.el:
* lisp/ob-lob.el:
* lisp/ob-plantuml.el (org-babel-execute:plantuml):
* lisp/ob-python.el (org-babel-python--command)
(org-babel-python-initiate-session-by-key)
(org-babel-python-initiate-session):
* lisp/ob-scheme.el (org-babel-scheme-make-session-name):
* lisp/ob-tangle.el (org-babel-find-file-noselect-refresh)
(org-babel-interpret-file-mode):
* lisp/ob.el:
* lisp/org-agenda.el (org-agenda-mouse-1-follows-link)
(org-agenda-start-with-archives-mode)
(org-agenda-previous-line):
* lisp/org-clock.el (org-clock-save, org-clock-load):
* lisp/org-element-ast.el (org-element-type-p):
* lisp/org-faces.el (org-cycle-level-faces):
* lisp/org-fold-core.el (org-fold-core--isearch-overlays):
* lisp/org-fold.el (org-fold--extend-changed-region):
* lisp/org-goto.el:
* lisp/org-habit.el (org-habit-show-all-today):
* lisp/org-inlinetask.el (org-inlinetask-in-task-p):
* lisp/org-macs.el (org-current-text-column):
* lisp/org-mobile.el (org-mobile-check-setup):
* lisp/org-mouse.el (org-mouse-bolp):
* lisp/org-refile.el (org-refile):
* lisp/org-src.el (org-src-do-key-sequence-at-code-block):
* lisp/org-table.el (orgtbl-after-send-table-hook)
(orgtbl-self-insert-command, orgtbl-to-orgtbl):
* lisp/org.el (org-read-date-popup-calendar, org-finish-function)
(org-occur-parameters, org-self-insert-command, org-ctrl-c-ctrl-c-hook)
(org-ctrl-c-ctrl-c-final-hook, org-submit-bug-report)
(org--single-lines-list-is-paragraph):
* lisp/ox-icalendar.el (org-icalendar--vtodo):
* lisp/ox-latex.el (org-latex-generate-engraved-preamble):
(org-latex-src--engrave-code):
* lisp/ox-publish.el (org-publish-project-alist):
* lisp/ox.el (org-export-data): Various checkdoc fixes.

Checkdoc fixes in Org Mode
6757f8e67d3bdfe338810fc26408a62e7839afe7
Stefan Kangas
Sun Jul 7 17:46:25 2024 +0200
2024-07-14 12:20:46 -04:00
Kyle Meyer
4617d52fad Merge branch 'km/from-emacs-30' into bugfix 2024-07-01 22:33:46 -04:00
Stefan Kangas
5ec1ec3337 Backport commit 45a20d781 from Emacs
; Fix typos in symbols
45a20d781a9b00212609bf0e338bd6b1cc9ea68a
Stefan Kangas
Sat Jun 29 17:29:38 2024 +0200
2024-07-01 22:33:10 -04:00
Ihor Radchenko
83fe95d2ee
org-babel-insert-result: Improve docstring
* lisp/ob-core.el (org-babel-insert-result): Explain that
RESULT-PARAMS is a list.  Clarify the treatment of INFO.  Fix
incorrect :file parameters that is actually not used.  Instead,
document :file-desc parameter that is being used.

Reported-by: Stefan Kangas <stefankangas@gmail.com>
Link: https://orgmode.org/list/871q4fzx0k.fsf@localhost
2024-06-30 11:40:17 +02:00
Kyle Meyer
a091ca9e66 Merge branch 'km/from-emacs-30' into bugfix 2024-06-27 23:14:54 -04:00
Stefan Kangas
fa7d7ec3bd Backport commit fb11294d4 from Emacs
; Fix typos
fb11294d4156a4be45080ff286a8ee0d5a3ede9b
Stefan Kangas
Sun Jun 23 16:40:06 2024 +0200
2024-06-27 23:13:49 -04:00
Matthias Hetzenberger
bd16944e1b
org-babel-merge-params: Rename plists to alists
* lisp/ob-core.el (org-babel-merge-params): Rename PLIST(S)
variables/args to ALIST(S).

TINYCHANGE
2024-06-23 11:11:12 +02:00
Kyle Meyer
165319f584 ob-core: Revert recent indentation change
* lisp/ob-core.el (org-babel-insert-result): Fix indentation change
from e4902995a.
2024-06-15 14:19:28 -04:00
Ihor Radchenko
e4902995a0
org-babel: Reduce verbosity when running in batch mode
* lisp/ob-C.el (org-babel-C-header-to-C):
* lisp/ob-awk.el (org-babel-execute:awk):
* lisp/ob-core.el (org-babel-execute-src-block):
(org-babel-insert-result):
* lisp/ob-ditaa.el (org-babel-execute:ditaa):
* lisp/ob-gnuplot.el (org-babel-execute:gnuplot):
(org-babel-prep-session:gnuplot):
* lisp/ob-groovy.el (org-babel-execute:groovy):
* lisp/ob-maxima.el (org-babel-execute:maxima):
* lisp/ob-screen.el (org-babel-execute:screen):
* lisp/ob-sed.el (org-babel-execute:sed): Suppress progress messages
when running noninteractively (batch export, for example).  This
change follows the existing behavior of `org-babel-exp-src-block'.

Reported-by: Eli Zaretskii <eliz@gnu.org>
Link: https://yhetil.org/emacs-devel/868qzd9hjg.fsf@gnu.org/
2024-06-13 15:16:54 +02:00
Ihor Radchenko
a0950e9432
org-babel-execute-src-block: Handle code block moving point
* lisp/ob-core.el (org-babel-execute-src-block): Make sure that point
remain on src block after evaluation.  The function logic later
implicitly assumes that the point is on the block that has been
evaluated.
2024-06-12 12:47:48 +02:00
Kyle Meyer
ce350490ca ob-core: Fix indentation
* lisp/ob-core.el (org-babel-execute-src-block): Fix indentation of
line.

Emacs's bd80717d8e7 (Re-enable TTY glyph production for batch mode
frames on Android, 2024-06-10) reverted all changes from 8d1d9798f77
(Fix bootstrap of org.texi, 2024-06-10) aside from an indentation fix.
Apply the indentation fix to avoid overwriting it on sync.
2024-06-10 18:28:27 -04:00
Ihor Radchenko
e09ad15a71
org-babel-read: Avoid `save-match-data'
* lisp/ob-core.el (org-babel-read): Avoid fiddling with match data -
it is not used.
2024-05-04 22:20:09 +03:00
Ihor Radchenko
0227e12605
org-babel-read: Read quotes strings ignoring leading/trailing newlines
* lisp/ob-core.el (org-babel-read): When reading "string", ignore
leading/trailing newlines in addition to spaces.
* testing/lisp/test-ob.el (test-ob/org-babel-read): Add more tests.

Reported-by: Max Nikulin <manikulin@gmail.com>
Link: https://orgmode.org/list/v15lva$hhl$1@ciao.gmane.io
2024-05-04 22:19:45 +03:00
Ihor Radchenko
edb5eaaac3
org-babel-read: Allow reading multi-line strings
* lisp/ob-core.el (org-babel-read): Fix regexp for detecting
string-like CELLs.  Avoid calling `read' twice.  Recover gracefully if
`read' errs.
* testing/lisp/test-ob.el (test-ob/org-babel-read): Add more tests.

Reported-by: Max Nikulin <manikulin@gmail.com>
Link: https://orgmode.org/list/v155g2$ncm$1@ciao.gmane.io
2024-05-04 14:46:46 +03:00
Ihor Radchenko
1523e21d82
org-babel-expand-noweb-references: Add trialing newline after comments
* lisp/ob-core.el (org-babel-expand-noweb-references): After closing
comment, when using :comments noweb, leave trailing newline after the
closing comment.
* testing/lisp/test-ob-tangle.el (ob-tangle/comment-noweb-relative):
Modify test to check for the newline.

Reported-by: João Pedro <jpedrodeamorim@gmail.com>
Link: https://orgmode.org/list/87fruy2rw6.fsf@ergo
2024-05-04 14:30:25 +03:00
Ihor Radchenko
2028bb15cd
org-babel-read: Fix reading multiple quoted strings
* lisp/ob-core.el (org-babel-read): Fix naive regexp for matching
escaped quotes.  Instead, check if `read' can read the whole CELL in
one go.
* testing/lisp/test-ob.el (test-ob/org-babel-read): Add tests.

Reported-by: Max Nikulin <manikulin@gmail.com>
Link: https://orgmode.org/list/v10k4s$et9$1@ciao.gmane.io
2024-05-03 15:04:52 +03:00
Ihor Radchenko
89c68683f9
org-babel-import-elisp-from-file: Fix detecting delimiter in single-line data
* lisp/org-table.el (org-table-convert-region): When detecting
delimiter in, do not unconditionally fall back to CSV parser.  Only do
it when the line contains commas and use a simple single tab/space
split otherwise.  Add new special delimeter-detection strategy when
SEPARATOR is 'babel-auto - convert to | full line | table instead of
falling back to tab/space split when the region contains a single
line.
* lisp/ob-core.el (org-babel-import-elisp-from-file): Force special
strategy when converting data to lisp.

The commit fixes the problem with first `re-search-forward' in the
`cond' moving point to end of the region, making the third `cond'
branch never match.

A special strategy specific to babel is necessary to preserve the
historic behavior with lines like
: single line with spaces
being converted to a single table cell
: | single line with space |

Reported-by: Matt <matt@excalamus.com>
Link: https://orgmode.org/list/18f24d87b62.d55e94e24743657.3252620114689708448@excalamus.com
2024-04-29 14:42:12 +03:00
Ihor Radchenko
cab81f2428
org-babel: Improve parsing of colnames in tables with horizontal lines
* lisp/ob-core.el (org-babel-get-colnames): When table starts with
horizontal lines, consider column names to be the first non-hline row.
(org-babel-disassemble-tables): When detecting automatic column names,
do not assign colnames when the first row is an hline.
* doc/org-manual.org (Passing arguments): Update the manual, detailing
that leading hline rows are skipped for :colnames yes.

Link: https://orgmode.org/list/87wmqexjoj.fsf@localhost
2024-03-07 22:02:21 +03:00
Gerard Vermeulen
c2ea553be8
org-babel-demarcate-block: split using element API
* lisp/ob-babel.el (org-babel-demarcate-block): Modify a copy
of (org-element-at-point) to replace the old source block with 2 or 3
new modified copies by means of `org-element-interpret-data'.  The 1st
source block contains the text from the body of the old block before
point or region, the 2nd block contains the body text after point or
body text within region, and in case of region, the 3rd block contains
the text after region.  The caption and the name are deleted from the
1 or 2 blocks below the upper source block.  Indent all blocks
immediately after insertion.  Use :post-blank to control white lines
between inserted blocks.  Leave point at the last inserted block.
Trying to split when point or region is not within the body of the old
source block raises an user-error.
* lisp/ob-babel (org-get-src-block-info): add the "within blank lines
after a source block" condition to the doc-string to match it with the
doc-string of and a comment in `org-babel-demarcate-block'.
* testing/lisp/test-ob.el (test-ob/demarcate-block-split-duplication)
(test-ob/demarcate-block-split-prefix-point)
(test-ob/demarcate-block-split-prefix-region)
(test-ob/demarcate-block-split-user-errors)
(test-ob/demarcate-block-wrap-point)
(test-ob/demarcate-block-wrap-region): New tests to check test cases
that broke earlier versions of this patch.

Link: https://list.orgmode.org/7e41f9b6e9026a404e256f33371e974c@posteo.net/
2024-03-04 14:48:59 +03:00
Ihor Radchenko
5f5db3d353
org-babel-do-in-edit-buffer: Fix when opening src edit buffer fails
* lisp/ob-core.el (org-babel-do-in-edit-buffer): When opening src edit
buffer fails, do not leave point inside that buffer.

Reported-by: gerard.vermeulen@posteo.net
Link: https://orgmode.org/list/5bf6832d2485f0aa6be2e5ea2eba37d2@posteo.net
2024-03-04 13:11:21 +03:00
Ihor Radchenko
a3ebd8c669
org-babel-do-in-edit-buffer: When editing fails, do not throw an error
* lisp/ob-core.el (org-babel-do-in-edit-buffer): Avoid throwing an
error when something is not right with the code block.  We already
ignore errors when major mode fails to load and we generally don't
want this macro to fail as it is used during indentation.

Link: https://list.orgmode.org/orgmode/87wmqo3it5.fsf@localhost/
2024-02-29 15:01:00 +03:00
Ihor Radchenko
8c7313d397
org-babel: New babel backend API function org-babel-session-buffer:<lang>
* lisp/ob-core.el (org-babel-session-buffer): New API function that
return session buffer, if such buffer exists and is live.
(org-babel-execute-src-block): Use `org-babel-session-buffer'.
* lisp/ob-lua.el (org-babel-session-buffer:lua):
* lisp/ob-python.el (org-babel-session-buffer:python): Provide API to
retrieve session buffer name.
(org-babel-python-initiate-session-by-key): Use
`org-babel-session-buffer:python'.
* etc/ORG-NEWS (Org babel backends are now expected to define an
additional API function ~org-babel-session-buffer:<lang>~): Declare
the API addition.

Link: https://orgmode.org/list/87r0hr9f3b.fsf@localhost
2024-02-10 21:57:52 +01:00
Ihor Radchenko
13d0f8bf8e
org-babel-execute-src-block: Force :dir according to live session
* lisp/ob-core.el (org-babel-execute-src-block): Force eval directory
to follow live session buffer, if any.  This is consistent with what
we promise in the manual section "16.4 Environment of a Code
Block">Choosing a working directory.

Link: https://orgmode.org/list/87mssi8ht2.fsf@gmail.com
2024-02-10 21:57:08 +01:00
Kyle Meyer
72a2db86d9 Merge branch 'bugfix' 2024-01-06 16:02:02 -05:00
Po Lu
9f1d6dfd73 Backport commit 8e1c56ae4 from Emacs
; Add 2024 to copyright years
8e1c56ae46754dd7baedff49a464f078f0e9912d
Po Lu
Tue Jan 2 09:47:10 2024 +0800
2024-01-06 15:48:23 -05:00
Ihor Radchenko
e03402b931
Merge branch 'bugfix' 2023-10-24 12:28:20 +03:00
Ihor Radchenko
84fa57ad1f
org-babel-insert-result: Do not modify RESULT for side effects
* lisp/ob-core.el (org-babel-insert-result): In some scenarios, result
of evaluation is a mutable Elisp string.  Avoid modifying it for side
effects as it may affect side effects of Elisp code blocks.

Reported-by: Jeff Trull <edaskel@att.net>
Link: https://orgmode.org/list/CAF_DUeEYVMytS=V2_aGjLyhddVZaPd7FWG_5Sbys6qcB0zGnyw@mail.gmail.com
2023-10-24 12:25:12 +03:00
Ihor Radchenko
9bbc21df84
Merge branch 'bugfix' 2023-10-16 16:05:05 +03:00
hrdl
f5e41b4724
org-babel-result-names: Do not alter window configuration
* lisp/ob-core.el (org-babel-result-names): Do not change
  visibility of windows when called.

TINYCHANGE
2023-10-16 16:04:27 +03:00
Ihor Radchenko
1f88acd013
* lisp/ob-core.el (org-babel-result-cond): Document all the arguments 2023-09-07 15:05:40 +03:00
Ihor Radchenko
21654e9a44
* lisp/ob-core.el (org-babel-examplify-region): Document all the arguments 2023-09-02 12:53:08 +03:00
Ihor Radchenko
af9c063edf
* lisp/ob-core.el (org-babel-remove-result): Document function arguments 2023-09-01 14:03:39 +03:00
Ihor Radchenko
91a532b40e
org-babel-expand-noweb-references: Document all the function arguments
* lisp/ob-core.el (org-babel-expand-noweb-references): Fix the
docstring, documenting every argument.
2023-08-31 14:27:36 +03:00
Ihor Radchenko
d8af9c40e0
org-babel-remove-result-one-or-many: Document the prefix argument
* lisp/ob-core.el (org-babel-remove-result-one-or-many): Rename prefix
argument to the conventional ARG and document it in the docstring.
2023-08-30 08:24:11 +03:00
Ihor Radchenko
cd0e225e34
* lisp/ob-core.el (org-babel-import-elisp-from-file): Document all function arguments 2023-08-29 12:47:12 +03:00
Ihor Radchenko
3f6c33b7b6
* lisp/ob-core.el (org-babel-temp-stable-file): Document all function arguments 2023-08-29 12:46:58 +03:00
Ihor Radchenko
320c29c021
* lisp/ob-core.el (org-babel-remove-inline-result): Document DATUM argument 2023-08-27 14:04:25 +03:00
Ihor Radchenko
9f12a1b9e4
org-babel-map-executables: Avoid using `save-match-data'
* lisp/ob-core.el (org-babel-map-executables): Drop
`save-match-data' as it may be costly.
2023-08-27 13:10:44 +03:00
Ihor Radchenko
05064052ad
org-babel-map-call-lines: Avoid using `save-match-data'
* lisp/ob-core.el (org-babel-map-call-lines): Drop
`save-match-data' as it may be costly.
2023-08-27 13:10:26 +03:00
Ihor Radchenko
99b65bb212
org-babel-map-inline-src-blocks: Avoid using `save-match-data'
* lisp/ob-core.el (org-babel-map-inline-src-blocks): Drop
`save-match-data' as it may be costly.
2023-08-27 13:09:51 +03:00