* lisp/org-element.el (org-element--next-mode): Reorder two patterns
to sidestep an error on Emacs 24.
The valid pattern introduced in 4a27b67fd (org-element: Fix property
drawers parsing, 2020-04-22) makes entering Org mode in Emacs 24.5
fail with "Eager macro-expansion failure: (wrong-type-argument listp
:pcase--succeed)". This seems to be due to a bug fixed in Emacs 25.
Reported-by: Jens Lechtenboerger <lechten@wi.uni-muenster.de>
Ref: https://orgmode.org/list/87pn6n5u13.fsf@wi.uni-muenster.de
* lisp/org.el (org-fontify-meta-lines-and-blocks-1): Fix meta lines
regexp to work correctly for lines with only a #.
Replace blank in regexp by (any " \t").
TINYCHANGE
* lisp/ob-core.el (org-babel-expand-noweb-references): Don't anchor
noweb regexp at start of line to allow multiple matches per line.
* testing/lisp/test-ob-tangle.el (ob-tangle/multiple-noweb-in-line):
Add test.
This fixes a regression introduced by c1aed9f80 (ob-core: Refactor
`org-babel-expand-noweb-references', 2020-01-12), which was part of
the 9.4 release.
Reported-by: Tom Gillespie <tgbugs@gmail.com>
Ref: https://orgmode.org/list/CA+G3_PO2yO1jMMpdrkc39BGQQ2eU5X4FzTEJVotjDJo-50dsqQ@mail.gmail.com
* lisp/org.el (org-cycle): Use `beginning-of-line' instead of
`move-beginning-of-line' to move point to the beginning of
line (including any invisible characters) such that org-outline-regexp
matches headlines with hidden stars (such as those produced by
[[https://github.com/TonCherAmi/org-starless][org-starless-mode]]).
TINYCHANGE
* lisp/org.el (org-end-of-meta-data): Allow to skip only standard
drawers, i.e. properties and logbook drawers.
* lisp/org-crypt.el (org-at-encrypted-entry-p)
(org-encrypt-entry): Use `org-end-of-meta-data' so that standard
drawers are all skipped, including logbook drawers.
Reported-by: Nicolas Goaziou <mail@nicolasgoaziou.fr>
See https://orgmode.org/list/87d02qgj6u.fsf@nicolasgoaziou.fr
and https://debbugs.gnu.org/cgi/bugreport.cgi?bug=43094 for the reason
of the previous fix c93983613d.
* lisp/org-faces.el (org-block): Enhance docstring.
* lisp/org.el (org-fontify-meta-lines-and-blocks-1): Clean up some
comments.
See 7769518f3, which was wrong.
* lisp/ob-python.el (org-babel-python-eoe-indicator): Add back
variable for end-of-expression indicator.
(org-babel-python--shift-right): New function to indent source body.
(org-babel-python-evaluate-external-process): Call new function org-babel-python--shift-right.
(org-babel-python--send-string): Wrap body in try-except-finally,
print indicator token, and find end of output via the token.
cf https://orgmode.org/list/871rjcan53.fsf@kyleam.com/
* lisp/org.el (org-add-planning-info): * lisp/org.el
(org-add-planning-info): Use `org-time-was-given' and
`org-end-time-was-given' if the variables are bound from an
outside call.
This allows e.g. programmatically passing a time of day to
`org-schedule'.
TINYCHANGE
* lisp/ol-gnus.el (org-gnus-store-link): Use nnselect when available.
In the master branch of the Emacs repository, f103e89c1d (Add aliases
for recent Gnus nnselect changes, 2020-09-07) switched
org-gnus-store-link over to using nnselect, but that can't be ported
as is because it isn't backward compatible. Make a similar change
that includes compatibility kludges.
* lisp/ox-texinfo.el (org-texinfo-link): Use
`org-texinfo--sanitize-content'.
(cherry picked from commit 8fd24c0a53)
[km]: This fixes a double-escaping regression introduced by 706970efb
(ox-texinfo.el: Fix escaping special chars in raw-path,
2020-06-05).
* lisp/ob-python.el (org-babel-python--eval-ast): Removed.
(org-babel-python-format-session-value): New function that returns
Python code to evaluate for sessions with value results.
(org-babel-python-evaluate-session): Replace
org-babel-python--eval-ast with org-babel-python-format-session-value.
Motivation is that the new function is more flexible than the old
format string. We can pass in the full result-params, which can be
used to add more formatting options in future. We could also add more
optional arguments in the future to extend this functionality.
This function will be particularly helpful for a couple patches after
9.4:
- ob-reticulate
- https://orgmode.org/list/875z98gj4f.fsf@gmail.com/
- Improved formatting
- https://orgmode.org/list/87eenpfe77.fsf@gmail.com/
However, I add this function in now 9.4, so those future patches can
rely on it in 9.4. In particular, ob-reticulate will probably be
packaged separately from org-mode, and I want to provide a stable
interface to it so that it can be released after 9.4.
* lisp/org-faces.el (org-block): Tiny docstring enhancement.
* lisp/org.el (org-fontify-meta-lines-and-blocks-1): Use the
`org-block' face for every true blocks.
Reported-by: Sébastien Miquel <sebastien.miquel@posteo.eu>
https://orgmode.org/list/42749c98-ddfe-bad4-43a5-1119e24972bd@posteo.eu
* lisp/org.el (org-in-archived-heading-p): New function.
* lisp/ob-exp.el (org-babel-exp-process-buffer):
* lisp/ob-tangle.el (org-babel-tangle-collect-blocks): Use
`org-in-archived-heading-p' to skip archived headings when tangling
and exporting.
* testing/lisp/test-org.el (test-org/in-archived-heading-p): Add
test for `org-in-archived-heading-p'.
Reported-by: flare <gabrielxaviersmith@gmail.com>
See https://orgmode.org/list/877dt9ey2c.fsf@gmail.com/
* lisp/ob-python.el (py-send-string-no-output): Remove external function.
(py-shell-send-string): Add external function.
(org-babel-python--eval-ast): Remove blank lines.
(org-babel-python--send-string): New function to send string to Python
process and return output.
(org-babel-python-evaluate-session): Call
org-babel-python--send-string to evaluate code.
New function to send code to Python session. It has the following
desirable properties:
- Wait for evaluation to finish before returning.
- Input can have arbitrary spaces/newlines.
- Avoid echoing input to the session.
- Echo all output to the session.
- Output is also captured and returned separately.
- Avoid adding extra prompts to the session.
- Work well with both Python and IPython repls.
The implementation borrows from `python-shell-send-string-no-output'
and `org-babel-comint-with-output'. This commit is related to
632ceabb1, which tried to implement the same thing, but also
introduced bugs, and had to be partially reverted in b5709ddc9.
* lisp/ob-python.el (org-babel-python-initiate-session-by-key): Remove
workaround for emacs<24.1. Sleep after starting Python, to prevent
startup messages leaking into output results.
* testing/lisp/test-ob-python.el (test-ob-python/session-multiline):
Remove workaround for startup message leaking into results.
* lisp/ob-shell.el (org-babel-execute:shell)
(org-babel-sh-evaluate): Use the exit code as the value and,
consequently, as the result when no :results header is set.
See this thread:
https://orgmode.org/list/CA+A2iZaziAfMeGpBqL6qGrzrWEVvLvC0DUw++T4gCF3NGuW-DQ@mail.gmail.com/
And Tim's useful summary here:
https://orgmode.org/list/87sgiszqc1.fsf@gmail.com/
This commit resolves the issue by deciding not to make an exception
for ob-shell.el:
- the "value" of executing a shell/bash script is the exit code
- when no :results header is set, use the value as the result
- use :results output to use the stdout
* lisp/ob-core.el (org-babel--expand-body): New function.
(org-babel-check-confirm-evaluate):
(org-babel-execute-src-block): Use org-babel--expand-body.
As of 727c6d7fe (lisp/ob-core.el: org-babel-check-confirm-evaluate
strip coderefs, 2020-09-04), org-babel-check-confirm-evaluate and
org-babel-execute-src-block use the same logic to expand the body and
strip coderefs. Move that code to a helper function.
This patch is functionally equivalent to the patch originally proposed
by Tom Gillespie at
https://orgmode.org/list/CA+G3_PNi3uMvBiWgBdKuC3C6VJt1T1j-RKH43LRqYbr+4NS8ZA@mail.gmail.com
* lisp/ob-core.el (org-babel-check-confirm-evaluate): strip coderefs
before passing the body of the block to org-confirm-babel-evaluate
using the same let block as is used in org-babel-execute-src-block.
* lisp/org.el (org-read-date-display-live): Document that live
display is only available when `org-read-date-popup-calendar' is
non-nil.
See <https://orgmod.org/list/20200630180259.zj3krk57x5iqmbsj@orion>
Reported-by: Edmund Christian Herenz <eherenz@eso.org>
* lisp/ob-core.el (org-babel-result-to-file): Use
`buffer-base-buffer' so that `buffer-file-name' returns correct
results in indirect buffers too.
See <https://orgmode.org/list/87eeos3w7v.fsf@localhost>
TINYCHANGE
* lisp/org-capture.el (org-capture-finalize): Update
`org-capture-plist' with local-value before finalizing.
We use the global-variable `org-capture-plist' to populate the
local-variable `org-capture-current-plist' on the init of the
`org-capture' buffer. However, we do not do the opposite (i.e. update
the global-variable with the local-variable) on
`org-capture-finalize'.
This is fine for the majority of `org-capture-finalize', since we’re
using the LOCAL arg of `org-capture-get' to read
`org-capture-current-plist' instead of `org-capture-list', but this
trick does not work for `org-capture-after-finalize', since the hook
is run after the `org-capture-buffer' has been closed.
This causes problem with `:kill-buffer t', and it limits what can be
done with cleanup functions in `org-capture-after-finalize'.
See <https://orgmode.org/list/87h7tv9pkm.fsf@hidden/> for details.
* lisp/org.el (org-make-tags-matcher): Add a parameter to make it
optional to include non-buffer tags.
(org-match-sparse-tree): Use the new parameter.
TINYCHANGE
* lisp/ox-odt.el (org-odt--translate-latex-fragments):
* lisp/ox-html.el (org-html--format-image): Use
`org-preview-latex-image-directory' instead of hardcoding the
directory name.
See <https://orgmode.org/list/87a70v9jan.fsf@ucl.ac.uk>
Reported-by: Eric S Fraga <e.fraga@ucl.ac.uk>
* lisp/org-goto.el (org-goto-location): Call make-indirect-buffer with
a non-nil CLONE to preserve the base buffer's state, avoiding a more
expensive call to org-mode.
Reported-by: Vladimir Nikishkin <lockywolf@gmail.com>
Suggested-by: Ihor Radchenko <yantar92@gmail.com>
* lisp/ob-python.el (py-shell-send-string): Remove unneeded
declare-function.
(org-babel-python-eoe-indicator): Add back this const.
(org-babel-python--eval-ast): Fix spacing so the block can be entered
line by line into the interpreter.
(org-babel-python-evaluate-session): Revert previous changes to
evaluation for value results.
* testing/lisp/test-ob-python.el (test-ob-python/session-value-sleep):
New test for session blocks that don't return immediately.
632ceabb1 introduced a bug where session blocks don't wait for value
results if not returned immediately. This reverts part of that
commit, specifically for evaluation of session blocks with value
results. It leaves other parts of that commit alone, for example the
changes to session output results, which is more robust handling
prompts from ipython interpreter.
A downside of reverting the session value implementation is that the
ugly code from org-babel-python--eval-ast is again printed in the
console, but this is less bad than the new bug that was introduced by
the change, hence reverted.
* lisp/ol.el (org-store-link): Store link with CUSTOM_ID anchor
in indirect buffer.
(org-insert-link): Do not add file name to search and CUSTOM_ID
links pointed to the same file when called from indirect buffer.
When a subtree was open in an indirect buffer, wrong argument
of `abbreviate-file-name' prevented storing link to a CUSTOM_ID
anchor. Internal link to a header line or to a CUSTOM_ID anchor
was created with file name instead of concise form.
This is a follow up of 784e5f1488.
TINYCHANGE
* lisp/ob-plantuml (org-babel-variable-assignments:plantuml): Support
using plantuml executable instead of jar.
Some systems come with an executable for plantuml instead of a specific
JAR file. This adds support for two different modes:
- jar :: using java together with a JAR (previous behavior)
- plantuml :: using a PlantUML executable
The PlantUML executable can be configured via
`org-plantuml-executable-path` and also the arguments that will be given
via `org-plantuml-executable-args`.
* lisp/ob-J.el (org-babel-execute:J, org-babel-J-eval-string): Add
customizability.
(org-babel-execute:J): Lookup optional parameter `:sit' to allow one
to wait for a specified amount of time before grabbing the output of
the J subprocess. Pass this specified value or the previous default
of .1 to `org-babel-J-eval-string'.
(org-babel-eval-string): Pass new argument `sit-time' to `sit-for'
before grabbing output.
The problem is that we read the contents of the output after 0.1
seconds, which, for expensive computations, results in the mangling of
output. Output from expensive computations gets propagated down to
subsequent code-blocks' outputs, producing a horrible mess.
TINYCHANGE
* lisp/ob-core.el (org-babel-import-elisp-from-file): Don't try to
convert empty file to a table.
* testing/lisp/test-ob.el (test-ob/import-elisp-from-file): Add tests.
If org-babel-import-elisp-from-file is called with an empty file
(which many ob- libraries do when there are no results), feeding that
to org-table-import leads to a beginning-of-buffer error. Before
14878f3f9 (ob-core: Display warning on failure to read results,
2020-05-21), this error was hard to notice because, after catching it,
it was reported as a quickly buried message. After that commit, it is
displayed as a warning, which is not appropriate for the common and
unproblematic case of empty results.
Avoid the warning by only doing the table conversion if the file has
content. Another option would be to do the table conversion but add a
beginning-of-buffer arm to the surrounding condition-case. However,
that risks swallowing other sources of that error.
Reported-by: Colin Baxter <m43cap@yandex.com>
<https://orgmode.org/list/878se3nhbj.fsf@yandex.com>
* lisp/ob-python.el: Require python.el at top-level.
(org-babel-python-eoe-indicator): Remove unused variable.
(org-babel-python-initiate-session-by-key): Rename
python-buffer to avoid obsolete warning.
(org-babel-python-evaluate-external-process): Remove unnecessary
require.
(org-babel-python--exec-tmpfile): Simplify this template.
(org-babel-python--eval-ast): Add printing of results to this
template, requiring additional string escapes.
(org-babel-python-evaluate-session): Simplify to use adjusted
templates, and call out to functionality in python.el or
python-mode.el.
(org-babel-python-evaluate-session): Simplified to use adjusted templates.
This commit refactors and cleans up code related to session
evaluation. python.el is now required at the top-level. Python
templates for wrapping code are simplified. Instead of directly
pasting code to the REPL, functionality from python.el and
python-mode.el are used; this fixes issues with code being echoed to
the REPL, and should be generally more robust. Finally, in the
:results value case, special handling of exceptions is removed, and we
no longer print None when the last statement isn't an expression.
* lisp/ob-python.el (org-babel-python-evaluate-session): Fix
discrepancy between how single-line and multiline code blocks return
output.
For example, before this commit, the 2 blocks behaved differently:
+begin_src python :session :results output
pass
"foo"
+end_src
+RESULTS:
+begin_src python :session :results output
"foo"
+end_src
+RESULTS:
: 'foo'
But now, they both behave as the former.
* lisp/org-num.el (org-num--skip-value): Handle empty headlines.
This happens when org-num-skip-commented is non-nil. When creating
a new headline, often org-num--skip-value is invoked before any
headline text is created. This means that ‘title‘ is nil and the
string-match check breaks. Checking if title is non-nil fixes this.
TINYCHANGE