Commit graph

18966 commits

Author SHA1 Message Date
Ihor Radchenko 323a669921
org-string-width: Remove unnecessary dedicated window check
* lisp/org-macs.el (org-string-width): Do not handle dedicated
selected window specially.  The bug fixed by 946abeb49 is no
longer reproducible using the release version of Emacs 29 and other
Emacs versions.  Apparently, it was caused by now-fixed Emacs bug
specific to Emacs 29.

Also, use `buffer-text-pixel-size' as in `string-pixel-width' from
Emacs master.  Using `window-text-pixel-size' requires setting buffer
to window, which is tricky when selected window is dedicated (see
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=64986).
2023-08-02 08:04:56 +03:00
Ihor Radchenko 884b84f7ad
org-string-width: Adapt Emacs commit 0c29f53ab8723
* lisp/org-macs.el (org-string-width): Make sure that default values
of `line-prefix' and `wrap-prefix' do not affect width calculation.

Link: https://git.savannah.gnu.org/cgit/emacs.git/commit/?h=emacs-29&id=0c29f53ab8723dd5a9f31ce8a6e913cc08132e56
2023-08-01 10:06:01 +03:00
Ihor Radchenko f03b839530
lisp/ob-awk.el: Fix docstrings
* lisp/ob-awk.el (org-babel-execute:awk):
* lisp/ob-awk.el (org-babel-awk-var-to-awk): Detail all the argument
in the docstring.
2023-07-31 14:17:22 +03:00
Ihor Radchenko f409cb4e52
ox: New option `org-export-expand-links'
* lisp/ox.el (org-export-options-alist): New export option toggling
environment variable expansion in link paths.
(org-export-expand-links): New customization.
(org-export--expand-links): New function expanding environment
variables all the link paths in AST.
(org-export-expand-include-keyword):
(org-export--blindly-expand-include): Add new optional arguments to
expand environment variables in INCLUDE file paths.  Update
docstrings.
(org-export--annotate-info): Call `org-export--expand-links' during
export and pass :expand-links parameter to
`org-export-expand-include-keyword'.
* doc/org-manual.org (Export Settings): Document the new option.
* etc/ORG-NEWS (New export option ~org-export-expand-links~): Announce
new option.

Link: https://list.orgmode.org/orgmode/87pm6fbnlo.fsf@localhost/
2023-07-31 11:24:40 +03:00
Ihor Radchenko 68ba286fee
org-lint-link-to-local-file: Expand environment variables in path
* lisp/org-lint.el (org-lint-link-to-local-file): Try to expand
environment variables in file paths before testing if the linked file
exists.
2023-07-31 11:20:26 +03:00
Kyle Meyer d3f587fadf org-find-open-clocks: Fix recent bug in handling of match data
* lisp/org-clock.el (org-find-open-clocks): Prevent clock match data
from being clobbered by downstream org-element-at-point call.
2023-07-30 17:56:54 -04:00
Jens Schmidt eabc9bfecf
ol-gnus.el: Fix issue when storing links from Gnus article buffers
* lisp/ol-gnus.el (org-gnus-store-link): Switch to
`gnus-summary-buffer' when calling functions that are intended to be
called only there.

Link: https://list.orgmode.org/orgmode/2fa5914d-2cbf-f41f-8be6-e79e77794140@vodafonemail.de
2023-07-30 19:31:58 +03:00
Ihor Radchenko a6f3b24a67
Merge branch 'bugfix' 2023-07-30 12:30:40 +03:00
Ihor Radchenko d1d0c30e65
org-property-value: Define face as non-nil
* lisp/org-faces.el (org-property-value): Set default value to inherit
from `font-lock-string-face' instead of using invalid face value of
nil.

Reported-by: Mauro Aranda <maurooaranda@gmail.com>
Link: https://orgmode.org/list/41956a5a-44c2-c1ea-e1e5-d018a8656e48@gmail.com
2023-07-30 12:29:17 +03:00
Ihor Radchenko dd586c5f42
* lisp/org-macs.el (org-time-convert-to-list): Provide declaration
Update obsolete declaration using the function that is used now.
This fixes native-comp warning.
2023-07-30 12:27:21 +03:00
Ihor Radchenko 01bf57488c
lisp/org.el: Define `org-rear-nonsticky-at' defsubst before its first usage
This fixes compiler warning.
2023-07-30 12:26:49 +03:00
Ihor Radchenko d5006e195a
Merge branch 'bugfix' 2023-07-30 12:22:09 +03:00
Ihor Radchenko da1bc002f2
Backport Emacs commit 670174a6d5f
* lisp/org-macs.el (org-replace-escapes): Suppress byte-compiler
warning about modifying constant string.

Unlike, 39786a8dbf, this commit does not
create merge conflicts.
2023-07-30 12:21:37 +03:00
Ihor Radchenko d38ca59230
ob-gnuplot: Fix links and verbatim when converting tables
* lisp/ob-gnuplot.el (org-babel-gnuplot-table-to-data): Use custom
backend to export table data.  The backend will export links verbatim,
without trying to resolve them and drop verbatim markers from data
fields.

Reported-by: Paul Stansell <paulstansell@gmail.com>
Link: https://orgmode.org/list/CAMJKaZzHuLxPoTg6FWUgt-U8QSHmuB3Kdqmk_E_0GH+jUZMSag@mail.gmail.com
2023-07-29 11:26:39 +03:00
Ihor Radchenko 2452f5de6d
org-export-get-all-transcoders: Fix when :parent is not symbol
* lisp/ox.el (org-export-get-all-transcoders): Handle :parent backend
not being symbol.
2023-07-29 11:26:03 +03:00
Ihor Radchenko de9f89e4be
org-babel-execute-src-block: Fix with :cache yes :results append/prepend
* lisp/ob-core.el (org-babel-execute-src-block): Do not remove
previous result when :cache is yes, but :results requests
appending/prepending the new result.
2023-07-28 12:11:31 +03:00
Evgenii Klimov 3ee10d57f1
ob-tangle.el: Avoid relative file names when grouping blocks to tangle
* lisp/ob-tangle.el (org-babel-tangle-single-block,
org-babel-tangle-collect-blocks): Make target file name attribute,
used internally to group blocks with identical language, to be
absolute.
(org-babel-effective-tangled-filename): Avoid using relative file
names that could cause one block to overwrite the others in
`org-babel-tangle-collect-blocks' if they have the same target file
but in different formats.
2023-07-28 10:16:36 +03:00
Ihor Radchenko dc78f09465
org-up-heading-safe: Fix when parent is not a heading
* lisp/org.el (org-up-heading-safe): Do not assume that
`org-element-parent' is always a heading.  Use `org-element-lineage'
to get parent heading specifically.  Move point to current heading
even when no parent heading is available, as expected by some of the
other Org routines.  Document moving point when no parent.
* testing/lisp/test-org.el (test-org/up-heading-safe): Add tests.

Reported-by: Daniel Liden <djliden91@gmail.com>
Link: https://orgmode.org/list/CAG=u__pAT9k_AsRG6cpyPPUt0__5S7o=3a8WWkAijuPPuGc7Cg@mail.gmail.com
2023-07-26 11:01:34 +03:00
Ihor Radchenko ac0042184e
org-bibtex-headline-format-function: Factor out lambda default value
* lisp/ol-bibtex.el (org-bibtex-headline-format-default): New function
to be used as the default value of
`org-bibtex-headline-format-function'.
(org-bibtex-headline-format-function): Update the default value.

Link: https://orgmode.org/list/87edl71tyu.fsf@localhost
2023-07-25 13:50:09 +03:00
Ihor Radchenko 39de4a1848
org-babel-sh-evaluate: Fix edge case when :shebang is set and :dir is remote
* lisp/ob-shell.el (org-babel-sh-evaluate): Pass remote local file
name as command when executing script with :shebang.  `org-babel-eval'
will fail when SCRIPT-FILE is TRAMP file name.

Link: https://www.reddit.com/r/orgmode/comments/14zh2yi/orgbabel_shebang_not_working_on_with_tramp_dir/
2023-07-23 17:38:09 +03:00
Ihor Radchenko ef391c882c
org-babel--shell-command-on-region: Remove obsolete workaround
* lisp/ob-eval.el (org-babel--shell-command-on-region): Remove
workaround for ancient Emacs version < minimal supported Emacs 26.
2023-07-23 17:35:44 +03:00
Ihor Radchenko 36c254ae30
org-lint: Add checkers for square brackets inside link description
* lisp/org-lint.el (org-lint-confusing-brackets):
(org-lint-brackets-inside-description):
(trailing-bracket-after-link):
(unclosed-brackets-in-link-description): New checkers testing for
trailing extra "]" after links and for unmatched opening "[" inside
link description.
2023-07-21 12:36:47 +03:00
Ihor Radchenko 6a2d84e501
ob-lilypond: Resolve FIXME
* lisp/ob-lilypond.el: Use `org-src-lang-modes' to inform Org babel
about non-standard mode name instead of using `defalias'.
* testing/lisp/test-ob-lilypond.el (ob-lilypond/check-lilypond-alias):
Remove test.
2023-07-20 10:02:07 +03:00
Ihor Radchenko 724135ddaf
fixup! org-do-emphasis-faces: Make sure that 'invisible property is not sticky 2023-07-19 10:05:30 +03:00
Ihor Radchenko 3e3b873d3f
org-do-emphasis-faces: Make sure that 'invisible property is not sticky
* lisp/org.el (org-do-emphasis-faces): Mark invisible text property in
emphasis markers non-sticky.  This is usually not a problem as we
manage invisible text property via font-lock.  However subtle bugs may
exist with non-interactive calls to Elisp primitives that inherit text
properties (like `indent-to').

Reported-by: Jens Schmidt <jschmidt4gnu@vodafonemail.de>
Link: https://orgmode.org/list/8b691a7f-6b62-d573-e5a8-80fac3dc9bc6@vodafonemail.de
2023-07-18 11:10:46 +03:00
Ihor Radchenko 5b6268c29e
org-columns--truncate-below-width: Fix Emacs 27 compatibility
* lisp/org-colview.el (org-columns--truncate-below-width): Do not use
extra optional arguments that are only available since Emacs 28.
2023-07-17 12:57:35 +03:00
Ihor Radchenko 3007511f3f
org-string-width: Reuse buffer when calculating string width
* lisp/org-macs.el (org-string-width): Use dedicated buffer instead of
creating a new one every time.  The idea is from `string-pixel-width'.
2023-07-17 12:33:03 +03:00
Ihor Radchenko c730caf512
org-babel-result-to-file: Fix when in indirect buffer
* lisp/ob-core.el (org-babel-result-to-file): Consider file name in
base buffer when calculating base directory.

Reported-by: 赵一宇 <zhyznd@163.com>
Link: https://list.orgmode.org/orgmode/3d69c850.69db.18953ae45da.Coremail.zhyznd@163.com/
2023-07-17 12:04:05 +03:00
Ruijie Yu 8739a95782
Let org-columns correctly detect string-widths in code
TODO: maybe I should also make a test directly on
`org-columns-add-ellipses'.  Will do in next iteration unless
objections.

* lisp/org-colview.el (org-columns--truncate-below-width): add a
helper function that will trim off just enough data from string to
fit into expected width.
(org-columns-add-ellipses): make sure to do truncation correctly
even in CJK locales (where an ellipsis character takes two
spaces).

* testing/lisp/test-org-colview.el
(test-org-colview/substring-below-width): add test to make sure
helper function is correct.
(test-org-colview/columns-width): fix incorrect expectations for
CJK locales about ellipses.
2023-07-17 11:06:32 +03:00
Ihor Radchenko c0dbcf361e
org-store-link: Move already stored link to front by default
* lisp/ol.el (org-link-store-existing): New customization controlling
how to deal with already stored links.
(org-store-link): Respect the new customization, allowing duplicates
to (1) be added anyway; (2) be ignored; (3) be moved to front of
`org-stored-links'.  The default is (3).
* etc/ORG-NEWS (~org-store-link~ now moves an already stored link to
front of the ~org-stored-links~): Document the breaking change.

Reported-by: Samuel Wales <samologist@gmail.com>
Link: https://list.orgmode.org/orgmode/CAJcAo8sjD3_FX5pFQ4git9wRDNM3bMqTgP-R5mM8zcf1B3mjPg@mail.gmail.com/
2023-07-15 15:31:41 +03:00
Liu Hui 5e31dcdd9a ob-python: Fix async evaluation
* lisp/ob-python.el (org-babel-python-async-evaluate-session): Bind
`python-shell-buffer-name' inside the temp buffer.
* testing/lisp/test-ob-python.el (test-ob-python/async-local-python-shell):
Add test.
2023-07-13 17:24:41 -07:00
Ihor Radchenko c9b80f06d4
org-fold-core-next-folding-state-change: Optimize performance
* lisp/org-fold-core.el (org-fold-core-next-folding-state-change):
Avoid repetitive searches all to way to LIMIT.  Instead, limit the
next searches by the limit computer by previous.
2023-07-13 19:32:49 +03:00
Ihor Radchenko 17096b3f4c
Refactor `org-src--contents-for-write-back'
* lisp/org-src.el (org-src--contents-for-write-back-1): New function
that is passed indentation parameters and contents explicitly, without
relying on buffer-local variables in current buffer.  The function
extracts variable-independent code and removes unused MARKER.
(org-src--contents-for-write-back): Use the new function, passing the
parameters according to buffer-local values in src edit buffer.
2023-07-13 12:28:13 +03:00
Ihor Radchenko 1967aa43e5
org-src-preserve-indentation: Refactor handling src block flags
* lisp/org-src.el (org-src-preserve-indentation-p): New function
checking whether block should preserve indentation.  This function
abstracts away the check for block type, indentation flag, and
customized `org-src-preserve-indentation' value.
(org-src--edit-element):
* lisp/ob-core.el (org-babel--normalize-body):
(org-babel-read-element):
(org-babel-update-block-body):
* lisp/ob-exp.el (org-babel-exp-process-buffer):
* lisp/org-element.el (org-element-example-block-interpreter):
(org-element-src-block-interpreter):
* lisp/org.el (org-fixup-indentation):
(org-indent-region):
* lisp/ox.el (org-export-unravel-code): Use the new function instead
of duplicating code.

* lisp/ob-haskell.el (org-babel-haskell-export-to-lhs): Add FIXME.  We
do not have access to the block element here and cannot easily check
the flag.

* lisp/ob-tangle.el (org-babel-tangle-single-block):
* lisp/org-src.el (org-src-font-lock-fontify-block):
* lisp/org.el (org-indent-line): Check block flag in addition to `org-src-preserve-indentation'.

This commit unifies logic deciding whether to preserve block
indentation into a single place to avoid confusion.
2023-07-13 11:51:15 +03:00
Ilya Chernyshov c74c4ab18d
lisp/org-element.el: Add new timestamp property :range-type
The new property is needed to reduce ambiguity when interpreting the
parsed data.

* lisp/org-element.el (org-element-timestamp-interpreter): Preserve old
behavior when :range-type is `nil'.  Take into account :range-type
value when interpreting ranges.  When :range-type is `timerange',
return a timerange (<YYYY-mm-DD HH:MM-HH:MM>).  If :range-type is
`daterange' return a daterange (<...>--<...>).  When :range-type is
nil, return a daterange (as it was before).  When :range-type is
`daterange' or `timerange' and :type is `active'/`inactive', throw an
error.
(org-element-timestamp-parser): Add :range-type property.

* lisp/org.el (org-timestamp-split-range): Make sure that :range-type
is nil for a split timestamp.

* testing/lisp/test-org-element.el
(test-org-element/timestamp-interpreter): Add new tests.
(test-org-element/timestamp-parser): Add tests for :range-type
property.

* etc/ORG-NEWS (Major changes and additions to Org API): Add news about this property.

Link: https://list.orgmode.org/orgmode/87y1ot6dqz.fsf@gmail.com/
2023-07-12 11:12:46 +03:00
Ihor Radchenko 0b6f9f8677
Fix typo in `org-todo-log-states' variable name
* doc/org-manual.org (Priorities):
* lisp/org.el (org-update-parent-todo-statistics): Fix incorrect
spelling of `org-todo-log-states' variable.

Reported-by: Evgenii Klimov <eugene.dev@lipklim.org>
Reported-by: Max Nikulin <manikulin@gmail.com>
Link: https://list.orgmode.org/orgmode/e900a08d-11af-9106-423e-28a2befe813d@gmail.com/
2023-07-11 12:06:52 +03:00
Akira Kyle 8fa7f0279e
org-html-link: Fix relative links with :html-link-use-abs-url
* lisp/ox-html.el (org-html-link): When publishing relative links with
both :html-link-use-abs-url and :html-link-home, ensure the correct
link is constructed.  Never append `home' to absolute paths.

TINYCHANGE
2023-07-10 11:16:32 +03:00
Max Nikulin 879ba22ef6
org-compat.el: `org--flatten-tree' for Emacs-26 compatibility
* lisp/org-compat.el (org--flatten-tree): New internal compatibility
alias or function based on `flatten-tree' added to Emacs-27.1.
* lisp/org-protocol.el (org-protocol-flatten): Convert to an obsolete
function alias.
(org-protocol-flatten-greedy): Use the `org--flatten-tree' new
compatibility alias or function instead of `org-protocol-flatten'.
* lisp/org-src.el (org-src--get-known-shells): Make the function
compatible with Emacs-26 by using `org--flatten-tree' instead of
`flatten-tree'.

Reported as: Justin to emacs-orgmode. [PATCH] org-src: flatten-tree is
Emacs 27.1; require compat. Tue, 4 Jul 2023 19:21:05 -0400.
https://list.orgmode.org/0288575b-fde8-0e7d-ac74-1f0ac93ce56f@vallon.homeip.net
2023-07-08 12:09:25 +03:00
Max Nikulin caa27be102
org-element.el: Fix Emacs-26 compatibility
* org-element.el (org-element--current-element-re): Use `rx-to-string'
instead of `rx' to expand variables.
(org-element--cache-setup-change-functions): Avoid multiple variables in
`setq-local'.

Reported as: Justin to emacs-orgmode. [BUG] org-element loading fails
with "regexp" argument not "stringp" Tue, 4 Jul 2023 19:51:44 -0400.
https://list.orgmode.org/2ff109c7-b3ec-27ac-e75d-ae5ddac14746@vallon.homeip.net
2023-07-08 12:09:24 +03:00
Sébastien Miquel 2e2ed40553
org-src.el: Use native value of `indent-tabs-mode' for indentation
* lisp/org.el (org-indent-line): Simplify native indentation inside
src block.  Ensure we add the org indentation if the line is empty.
* lisp/org-macs.el (org-do-remove-indentation): Preserve
indentation (spaces vs tabs) past the common indentation to remove.
Do not empty blank lines.
* lisp/org-src.el (org-src--contents-for-write-back): Preserve the
native indentation (spaces vs tabs).  If necessary, add a common org
indentation to the block according to org's `indent-tabs-mode'.
(org-src-font-lock-fontify-block): Display the native indentation tab
characters with a fixed width, according to the native tab width
value, to preserve vertical alignement in the org buffer.
* testing/lisp/test-org-src.el (test-org-src/indented-blocks): Update
tests.  Indentation no longer obeys `indent-tabs-mode' from the org
buffer, but is separated in an eventual org part, and the native part.

Link: https://list.orgmode.org/87a5wcez7e.fsf@localhost/T/#t
2023-07-07 11:58:43 +03:00
Ihor Radchenko 7c6302e203
org-agenda-show-new-time: Fix when window is very narrow
* lisp/org-agenda.el (org-agenda-show-new-time): When window is
narrower than timestamp, do not try to display timestamps starting at
negative column.

Reported-by: Nick Römer <nick.romer@skynet.be>
Link: https://orgmode.org/list/4196e86e.19136.1891ceef131.Webtop.154@skynet.be
2023-07-05 16:12:19 +03:00
Evgenii Klimov 402f72ad4f
lisp/org.el: Add final hooks to S-/M-/S-M-cursor commands
* lisp/org.el (org-metaleft-final-hook, org-metaright-final-hook,
org-metaup-final-hook, org-metadown-final-hook): Define final hooks
for S-cursor commands.
(org-metaleft, org-metaright, org-metaup, org-metadown): Add final
hooks to M-commands and document them in the docstring.

* lisp/org.el (org-shiftup, org-shiftdown, org-shiftright,
org-shiftleft): Document hooks for S-cursor commands in the docstring.

* lisp/org.el (org-shiftmetaleft-final-hook,
org-shiftmetaright-final-hook, org-shiftmetaup-final-hook,
org-shiftmetadown-final-hook): Define final hooks for the S-M-cursor
commands.
(org-shiftmetaleft, org-shiftmetaright, org-shiftmetaup,
org-shiftmetadown): Add final hooks to the S-M-cursor commands and
document hooks in the docstring.

* etc/ORG-NEWS (New final hooks for Modifier-Cursor keys): Document
new hooks.

TINYCHANGE
2023-07-05 13:40:19 +03:00
Justin Vallon f18fad60b6
org-id-uuid: Use compat org-time-convert-to-list for emacs <27.1
* lisp/org-macs.el (org-id-uuid): Use `org-time-convert-to-list'
instead of `time-convert', which is not yet available in Emacs 26.
2023-07-05 13:28:38 +03:00
Evgenii Klimov 48fffa5dac
org-insert-link: Keep the link in `org-stored-links' if it was not inserted
* lisp/ol.el (org-insert-link): Keep the link in `org-stored-links' if
the command was interrupted by the user during the reading of a
description from the minibuffer.

TINYCHANGE
2023-07-04 13:43:21 +03:00
Ihor Radchenko e34b72eec6
org-make-tags-matcher: Do not try collecting tags from non-Org buffers
* lisp/org.el (org-make-tags-matcher): When building tag completion
table, do not attempt to call `org-get-buffer-tags' when current
buffer is not an Org buffer.

Reported-by: Colin Baxter <m43cap@yandex.com>
Link: https://orgmode.org/list/87ilb1fakk.fsf@yandex.com
2023-07-03 15:28:08 +03:00
Ihor Radchenko 38f87aa30a
Update Ihor Radchenko's email address
* lisp/ob-gnuplot.el:
* lisp/org-cycle.el:
* lisp/org-element-ast.el:
* lisp/org-fold-core.el:
* lisp/org-fold.el:
* lisp/org-persist.el: Update contact email of the maintainer/author.
2023-07-03 11:08:49 +03:00
Ihor Radchenko 02ad2a114f
lisp/org-element-ast.el: Fix copyright notice
Make copyright consistent with the rest of Org.
2023-07-03 11:06:55 +03:00
Ihor Radchenko 948c896448
Rename org-element-property-1' to org-element-property-raw'
The new name is more readable.

Link: https://orgmode.org/list/87sfail69e.fsf@localhost
2023-07-01 14:36:32 +03:00
Ihor Radchenko 66c8e94732
lisp/org-element-ast.el: Fix typo in commentary 2023-07-01 14:36:31 +03:00
Ihor Radchenko f97aeaa243
org-fold-core--isearch-setup: Use `add-function'
* lisp/org-fold-core.el (org-fold-core--isearch-setup): Use
add-function, respecting the value of `isearch-filter-predicate'.
(org-fold-core--isearch-filter-predicate-overlays): Remove.

Link: https://yhetil.org/emacs-devel/87o7lxpip9.fsf@web.de
2023-07-01 14:36:31 +03:00
Ihor Radchenko 7f337a2b95
org-fold-core: Fix isearch with `org-fold-core-isearch-open-function'
* lisp/org-fold-core.el (org-fold-core--with-isearch-active): New
macro, signaling `org-fold-core-region' to store newly created folds
in `org-fold-core--isearch-overlays'.
(org-fold-core-region): Respect the new macro.  Respect fold priority
for overlays.
(org-fold-core--isearch-setup): Do not run
`org-fold-core--clear-isearch-overlays' twice.
(org-fold-core--isearch-show): Fix when point is not on the match.
(org-fold-core--isearch-show-temporary): Rewrite, limiting to overlays
only and simplifying the code.
(org-fold-core--create-isearch-overlays): Extend link folds to full
link.
(org-fold-core--clear-isearch-overlay): Do not expect to be called in `isearch-mode-end-hook'.
* lisp/org-fold.el (org-fold--isearch-reveal): Respect argument.
2023-07-01 14:36:30 +03:00
Ihor Radchenko afbbebff3f
org-fold-core-get-folding-spec: Respect `org-fold-core-style'
* lisp/org-fold-core.el (org-fold-core-get-folding-spec): Only
consider folding using a single (currently selected) folding style.

Multiple fold styles may be present during isearch - we do not want to
mix them.
2023-07-01 14:36:29 +03:00
Ihor Radchenko 383d5dacb7
org-fold-show-set-visibility: Fix lineage visibility
* lisp/org-fold.el (org-fold-show-set-visibility): Do not reveal
everything, including drawers under heading when point is outside
drawers.  Reveal individual folding specs one by one, within their
folding bounds.
2023-07-01 14:36:28 +03:00
Ihor Radchenko 52c63f5cce
org-lint-export-option-keywords: Small refactoring
* lisp/org-lint.el (org-lint-export-option-keywords): Use
`org-element-post-affiliated'.
2023-07-01 14:36:28 +03:00
Ihor Radchenko 37a58cc6ee
org-agenda-skip: Do not alter match data
* lisp/org-agenda.el (org-agenda-skip): Never alter match-data.  The
callers often use `re-search-forward' and do not expect the match data
to be altered.
2023-07-01 14:36:27 +03:00
Ihor Radchenko f2dd1eea41
org-find-open-clocks: Fix false positives
* lisp/org-clock.el (org-find-open-clocks): Ensure that we only match
actual clock elements, not everything matching `org-clock-re',
including clocks inside verbatim environments.
2023-07-01 14:36:26 +03:00
Ihor Radchenko 759676b308
org-fold-core--isearch-show: Do not fully rely on `point'
* lisp/org-fold-core.el (org-fold-core--isearch-show): Make use of the
passed argument.  Do not just rely on `point' being at the isearch
match.

This partially fixes edge case with point being moved to the end of
the folded region during isearch.
2023-07-01 14:36:25 +03:00
Ihor Radchenko e18263fceb
org-element--substring: Fix when buffer is narrowed
* lisp/org-element.el (org-element--substring): Ignore narrowing.
2023-07-01 14:36:25 +03:00
Ihor Radchenko 81e85bda2b
Fix Emacs 27 compatibility
* lisp/org-element-ast.el (org-element-create): Do not use `length='
that is not yet available.
(org-element-property-inherited): Do not use `ensure-list' that is not
yet available.
2023-07-01 14:36:22 +03:00
Ihor Radchenko 21d3b888c6
org-element-create: Fix Emacs 28 compatibility
* lisp/org-element-ast.el (org-element-create): Do not use `plistp'
that is not yet available in older Emacs.
2023-07-01 14:36:22 +03:00
Ihor Radchenko f895be1ad9
org-element--properties-mapc: Small refactoring
* lisp/org-element-ast.el (org-element--properties-mapc): Do not use
`pcase' - we are not testing for complex patterns here.
2023-07-01 14:36:21 +03:00
Ihor Radchenko ea401fb1f4
org-agenda-ignore-properties: Bump :package-version
* lisp/org.el (org-agenda-ignore-properties): Remove :version keyword
and bump :package-version after changing the allowed values.
2023-07-01 14:36:19 +03:00
Ihor Radchenko 96b754c105
org-get-category, org-get-tags: Clarify that match data is modified
* lisp/org.el (org-get-category):
(org-get-tags): Update docstrings, documenting that these functions
may modify match data.
2023-07-01 14:36:19 +03:00
Ihor Radchenko a04e16bd11
lisp/org-macs.el: Restructure file outline, fixing compiler warning
Add new section "Misc", moving all the functions that do not belong to
other sections below.  This also fixes defun order for
`org-compile-file' that needs `org-trim' to be defined.
2023-07-01 14:36:18 +03:00
Ihor Radchenko 5ed3e1dfc3
org-refresh-category-properties: Do not check element cache
* lisp/org.el (org-refresh-category-properties): Do not check if
org-element-cache is active.  This function is now obsolete and can
only be called on purpose by third-party code that probably expects
the text properties to be assigned regardless whether the cache is
active.

This commit also fixes compiler warning as
`org-element--cache-active-p' is not declared anymore in lisp/org.el.
2023-07-01 14:36:17 +03:00
Ihor Radchenko 9ed7956afd
org-element: Use constant values for fixed deferred properties
* lisp/org-element.el (org-element--headline-archivedp):
(org-element--headline-footnote-section-p):
(org-element--headline-raw-value):
(org-element--headline-parse-title-raw):
(org-element--headline-parse-title-parse):
(org-element--headline-deferred):
(org-element--get-global-node-properties):
(org-element--headline-parent-deferred): New internal constants
holding deferred values used by parser.  These values are not a
subject of modification and thus can be re-used instead of
re-allocating a new instance for every new parsed element.
(org-element--headline-parse-title):
(org-element-headline-parser):
(org-element-org-data-parser):
(org-element-inlinetask-parser):
(org-element--parse-to): Use the new constants.

This patch aims for smaller memory footprint of Org AST and cache.
2023-07-01 14:36:16 +03:00
Ihor Radchenko 48e4a76b99
org-element: Avoid computing static regexps dynamically
* lisp/org-element.el (org-element--headline-comment-re):
(org-element--timestamp-raw-value-regexp): New internal regexp
constants.
(org-element--headline-parse-title):
(org-element-timestamp-parser): Use the new constants.
2023-07-01 14:36:15 +03:00
Ihor Radchenko 5a1dd94309
org-element: Avoid slow `end-of-line'
Link: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=63225#98
2023-07-01 14:36:15 +03:00
Ihor Radchenko f93d855c51
Prefer forward-line' over beginning-of-line'
The latter is much slower.

Link: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=63225#98
2023-07-01 14:36:14 +03:00
Ihor Radchenko 1c7c67b3c6
org-indent-drawer, org-indent-block: Remove unnecessary checks
* lisp/org.el:
(org-indent-block):
(org-indent-drawer): Do not try to check drawer/block twice.
2023-07-01 14:36:13 +03:00
Ihor Radchenko f63000cca8
org-element--current-element: Use "nogroup" versions of regexps
* lisp/org-element.el (org-element-dynamic-block-open-re-nogroup):
(org-element--latex-begin-environment-nogroup): New constants for
internal regexps.
(org-element-comment-parser):
(org-element--current-element-re):
(org-element--current-element): Prefer string constants instead of
repeated plain strings that may be considered different by Emacs
regexp compiler.  Also, avoid groups in these regexps as creating
groups makes Emacs regexp matches allocate extra memory.  Finally,
avoid using \{N\} constructs in regexps as they are slightly more
costly for regexp engine.
2023-07-01 14:36:12 +03:00
Ihor Radchenko 110601ce74
org-element--current-element: Add FIXME 2023-07-01 14:36:12 +03:00
Ihor Radchenko b0a2deaec6
org-element--current-element: Faster property drawer check
* lisp/org-element.el (org-element--current-element): Slight
optimization of checking for property drawer at point.  `forward-line'
is significantly faster compared to `beginning-of-line'.
`skip-chars-forward' also provides a bit of improvement compared to
`looking-at-p'.

Reported-by: Mattias Engdegård <mattias.engdegard@gmail.com>
Link: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=63225#80
2023-07-01 14:36:11 +03:00
Ihor Radchenko a80efaf460
org-element-node-property-parser: Remove unnecessary regexp search
* lisp/org-element.el (org-element-node-property-parser): Remove
unnecessary `re-search-forward'.  It always triggers as long as
`org-property-drawer-re' only allow node properties inside property
drawer.  Also, remove unnecessary `case-fold-search' setting that has
no meaning since we do not match against specific letters.
2023-07-01 14:36:10 +03:00
Ihor Radchenko 3ce57e17a0
org-item-re: Convert into defsubst
* lisp/org-list.el (org-item-re): Use faster `defsubst'.  This
function is called very frequently when parsing Org buffers by
`org-element--current-element'.
2023-07-01 14:36:09 +03:00
Ihor Radchenko 01351f3eab
Restructure file organization 2023-07-01 14:36:06 +03:00
Ihor Radchenko 2b96501070
org-element: Simplify drawer and property drawer regexps
* lisp/org-element.el (org-element-drawer-re-nogroup): New constant
regexp matching drawer line without creating regexp groups.
(org-element--current-element): Use the new constant.
* lisp/org.el (org-drawer-regexp): Ensure that it is the same with
org-element version and mark for removal/alias.
(org-property-drawer-re): Simplify, removing unnecessary matching of
node property structures.

Link: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=63225#62
2023-07-01 14:36:05 +03:00
Ihor Radchenko 39466ecf47
org-element-cache: Do not check for deferred :parent unnecessarily
* lisp/org-element.el (org-element--cache-remove):
(org-element--cache-interrupt-p):
(org-element--cache-sync):
(org-element--cache-process-request):
(org-element--parse-to):
(org-element--cache-submit-request):
(org-element--cache-for-removal): use `org-element-property-1' to
retrieve parent without checking if it is deferred.  All the cached
elements have proper parent.
2023-07-01 14:36:05 +03:00
Ihor Radchenko e1a2ea65ef
Allow syntax nodes to be supplied in place of POM in API functions
* lisp/org-agenda.el (org-agenda-entry-get-agenda-timestamp):
* lisp/org-element.el (org-element-context):
* lisp/org-habit.el (org-is-habit-p):
* lisp/org-id.el (org-id-get):
* lisp/org-macs.el (org-with-point-at):
* lisp/org.el (org-fast-tag-selection):
(org-get-tags):
(org-entry-properties):
(org--property-local-values):
(org-entry-get):
(org-entry-delete):
(org-entry-remove-from-multivalued-property):
(org-entry-member-in-multivalued-property):
(org-entry-put-multivalued-property):
(org-entry-get-with-inheritance):
(org-entry-put):
(org-read-property-value):
(org-read-property-value):
(org-property-get-allowed-values): Allow POM to be a cached Org syntax
node.
2023-07-01 14:36:04 +03:00
Ihor Radchenko 7dee228569
org-element-at-point-no-context: Update docstring 2023-07-01 14:36:03 +03:00
Ihor Radchenko 598d7bbcf2
Remove APPT_WARNTIME text property cache
* lisp/org.el (org-agenda-ignore-properties):
(org-agenda-prepare-buffers): Remove APPT_WARNTIME cache.
* lisp/org-agenda.el (org-agenda-get-timestamps):
(org-agenda-get-sexps):
(org-agenda-get-deadlines):
(org-agenda-get-scheduled): Use `org-entry-get' to retrieve
APPT_WARNTIME.
2023-07-01 14:36:02 +03:00
Ihor Radchenko 5898fcf269
Remove unused declares 2023-07-01 14:36:01 +03:00
Ihor Radchenko 7c549f4841
org-babel-tangle-collect-blocks: Switch to org-element API 2023-07-01 14:36:01 +03:00
Ihor Radchenko ebbdd67a2a
Remove effort property cache
* lisp/org-compat.el (org-refresh-effort-properties): Obsolete.
* lisp/org-clock.el (org-clock-in):
* lisp/org.el (org-default-properties):
(org-edit-agenda-file-list)
(org-set-property-and-value): Remove unnecessary calls to
`org-refresh-effort-properties'.
(org-agenda-ignore-properties): Update the allowed values.
2023-07-01 14:36:00 +03:00
Ihor Radchenko 2efc7fcfdc
org-agenda-get-scheduled: Switch to org-element API 2023-07-01 14:35:59 +03:00
Ihor Radchenko 06aba04f75
org-agenda-get-deadlines: Switch to org-element API 2023-07-01 14:35:58 +03:00
Ihor Radchenko 31d53cb015
org-end-of-subtree: Use org-element API
* lisp/org.el (org-end-of-subtree): Skip all the blank lines before,
not just the last empty.  Update the docstring.
2023-07-01 14:35:58 +03:00
Ihor Radchenko def4bfa9c1
org-scan-tag: Switch to pure use of `org-element-cache-map' 2023-07-01 14:35:57 +03:00
Ihor Radchenko e3d690edf8
org-element-cache-map: Allow when cache is disabled
* lisp/org-element.el (org-element--cache-variables): New constant
holding variables involved in cache state.
(org-element-cache-reset): Fix modification hooks when cache is reset
and buffer already have indirect child buffers.
(org-element-with-enabled-cache): New macro, to enable cache around
body.
(org-element-cache-map): Enable cache when executing.
2023-07-01 14:35:56 +03:00
Ihor Radchenko 3024e933c0
org-get-buffer-tags: Switch to org-element API 2023-07-01 14:35:55 +03:00
Ihor Radchenko 6938857369
org-goto-first-child: Switch to org-element API 2023-07-01 14:35:54 +03:00
Ihor Radchenko 6266197bbd
org-at-item-p: Use org-element API 2023-07-01 14:35:54 +03:00
Ihor Radchenko fefaadc2d5
org-element: Optimize working with match data and Emacs regexps
* lisp/org-element.el: Add commentary explaining some regexp-related
optimizations useful for the parser.

Link: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=63225
(org-element--headline-deferred):
(org-element-item-parser):
(org-element-item-interpreter):
(org-element--list-struct):
(org-element-plain-list-parser):
(org-element-example-block-parser):
(org-element-fixed-width-interpreter):
(org-element-paragraph-parser):
(org-element-src-block-parser):
(org-element-table-parser):
(org-element--parse-generic-emphasis):
(org-element-export-snippet-interpreter):
(org-element-link-parser):
(org-element--current-element):
(org-element--collect-affiliated-keywords):
(org-element-parse-buffer):
(org-element-normalize-string):
(org-element-normalize-contents):
(org-element--parse-to):
(org-element--cache-before-change):
(org-element--cache-for-removal):
(org-element-context): Avoid storing match data unless strictly
necessary.  Explain the necessity in places where we have to use
`save-match-data'.  Prefer `looking-at-p' (does not alter match data)
to `looking-at'.  Simplify regexps.  Update docstrings clearly
indicating when match data might be modified.
* lisp/org.el:
(org-offer-links-in-entry):
* lisp/ob-exp.el (org-babel-exp-process-buffer):
* lisp/org-agenda.el: Fix places where we need to protect match data.
2023-07-01 14:35:53 +03:00
Ihor Radchenko dfd36d1969
org-up-heading-safe: Use element API 2023-07-01 14:35:52 +03:00
Ihor Radchenko eb0a293a02
Remove 'org-category text property cache
* lisp/org.el (org-get-category): Update useing
`org-entry-get-with-inheritance'.
(org-agenda-ignore-properties): Update docstring.
(org-refresh-category-properties):
(org-check-agenda-file): Do not call
`org-refresh-category-properties'.
* lisp/org-compat.el (org-refresh-category-properties): Obsolete.
* doc/org-manual.org (Speeding Up Your Agendas): Update the manual.
* testing/lisp/test-org.el (test-org/get-category): Update tests, not
calling the obsolete function.
2023-07-01 14:35:51 +03:00
Ihor Radchenko 771074ba5e
org-in-archived-heading-p: Use org-element API 2023-07-01 14:35:50 +03:00
Ihor Radchenko ec8f359bd6
org-in-commented-heading-p: Use org-element API 2023-07-01 14:35:50 +03:00
Ihor Radchenko 13ae9b95f8
org-narrow-to-subtree: Use org-element API 2023-07-01 14:35:49 +03:00
Ihor Radchenko 7cbc441915
org-entry-get-with-inheritance: Use org-element API
* lisp/org.el (org--property-local-values):
(org-entry-get-with-inheritance): Switch to pure org-element API.
2023-07-01 14:35:48 +03:00
Ihor Radchenko 3b1693c461
org-back-to-heading: Use org-element API 2023-07-01 14:35:47 +03:00
Ihor Radchenko 4d63e571e0
org-get-tags: Use org-element API
* lisp/org.el (org--get-local-tags):
(org-get-tags): Switch to pure org-element API instead of regexp
matching.
2023-07-01 14:35:47 +03:00
Ihor Radchenko 607c230d74
org-with-point-at: Accept syntax node as POM 2023-07-01 14:35:46 +03:00
Ihor Radchenko f225e24869
org-element--current-element: Make defsubst 2023-07-01 14:35:45 +03:00
Ihor Radchenko b00c2d0e1d
org-element--parse-to: Provide deferred :parent when cache is inactive
* lisp/org-element.el (org-element--headline-parent-deferred): New
function to calculate :parent of a heading on demand.
(org-element--parse-to): Assign deferred :parent when cache is
inactive.
2023-07-01 14:35:44 +03:00
Ihor Radchenko bc29f5de41
org-element: New `org-element-*property*' functions
* lisp/org-element.el (org-element-begin):
(org-element-end):
(org-element-contents-begin):
(org-element-contents-end):
(org-element-post-affiliated):
(org-element-post-blank): New functions for fast access to frequently
used element properties.  The functions are `setf'-able.

Update all the relevant code in Org to use the new functions instead
of genetic property queries.
2023-07-01 14:35:43 +03:00
Ihor Radchenko 81a7e8c836
org-element-lineage: Allow TYPES to be a symbol
* lisp/org-element-ast.el (org-element-lineage): Allow TYPES argument
to be a symbol.
* lisp/ox-ascii.el (org-ascii--current-text-width):
(org-ascii-format-inlinetask-default):
(org-ascii-section):
* lisp/ox-beamer.el (org-beamer--format-block):
* lisp/ox-html.el (org-html-section):
(org-html-table-cell):
(org-html-table-row):
* lisp/ox-latex.el (org-latex-table-cell):
(org-latex-table-row):
* lisp/ox-odt.el (org-odt-headline):
(org-odt-table-style-spec):
(org-odt-get-table-cell-styles):
(org-odt-table-cell):
(org-odt-table-row):
* lisp/ox-org.el (org-org-section):
* lisp/ox-publish.el (org-publish-collect-index):
* lisp/ox-texinfo.el (org-texinfo--get-node):
(org-texinfo-section):
(org-texinfo-table-row):
* lisp/ox.el (org-export--skip-p):
(org-export-get-node-property):
(org-export-table-cell-borders):
(org-export-table-row-in-header-p):
(org-export-table-row-number):
(org-export-collect-headlines): Update all the callers.
2023-07-01 14:35:43 +03:00
Ihor Radchenko 2d22d7f515
ox.el: Rename `org-element-get-parent-element' and move to org-element
* lisp/org-element.el: Rename `org-element-get-parent-element' to
`org-element-parent-element'.
* lisp/org-compat.el (org-export-get-parent-element):
* lisp/ox.el (org-export-get-parent-element): Remove, adding obsolete
alias.
(org-export--skip-p):
* lisp/org-table.el:
* lisp/ox-beamer.el (org-beamer-link):
* lisp/ox-html.el (org-html-link):
* lisp/ox-latex.el (org-latex-footnote-reference):
* lisp/ox-md.el (org-md-link):
* lisp/ox-odt.el (org-odt-format-label):
(org-odt-link--inline-image):
(org-odt-link--inline-formula):
* lisp/ox-texinfo.el (org-texinfo--inline-image): Update all the
callers.
2023-07-01 14:35:42 +03:00
Ihor Radchenko ea4f4fdf58
Rename org-export-get-parent' to org-element-parent' 2023-07-01 14:35:41 +03:00
Ihor Radchenko 6a7aee2c35
org-texinfo--normalize-headlines: Use `org-element-create' 2023-07-01 14:35:40 +03:00
Ihor Radchenko a43cc8c9aa
org-export-get-node-property: Use `org-element-property-inherited' 2023-07-01 14:35:40 +03:00
Ihor Radchenko a2730b47fa
org-odt--paragraph-style: Use `org-element-lineage' 2023-07-01 14:35:39 +03:00
Ihor Radchenko 69383dfc24
org-ascii--current-justification: Use `org-element-lineage-map' 2023-07-01 14:35:38 +03:00
Ihor Radchenko 44baf8f2b8
org-element-parse-buffer: New optional argument to not force undefer
* lisp/org-element.el (org-element-parse-buffer): Do not force-undefer
when new optional argument is provided.
* lisp/org-lint.el (org-lint--generate-reports):
* lisp/org.el (org-unindent-buffer):
* lisp/ox.el (org-export--missing-definitions):
(org-export--annotate-info): Do not undefer when unnecessary.

Adjust all the declare forms.
2023-07-01 14:35:37 +03:00
Ihor Radchenko 244cc7d560
org-element-org-data-parser: Defer parsing
* lisp/org-element.el (org-element--get-category): New function
calculating buffer category, excluding top-level property drawer.
(org-element--get-global-node-properties): Set category as well,
calling `org-element--get-category'.
(org-element-org-data-parser): Defer category and top-level drawer
property parsing.
2023-07-01 14:35:37 +03:00
Ihor Radchenko a06dc07cc0
org-element: Defer more when parsing headings and inlinetasks
* lisp/org-element.el (org-element-headline-parser--deferred):
(org-element--headline-deferred): Rename.
(org-element--headline-archivedp):
(org-element--headline-footnote-section-p):
(org-element--headline-parse-title): New internal helpers.
(org-element-headline-parser):
(org-element-inlinetask-parser): Defer parsing headline components.
*
testing/lisp/test-org-attach.el (test-org-attach/dired-attach-to-next-best-subtree/1):
Use property API instead of relying upon internal syntax node representation.
2023-07-01 14:35:36 +03:00
Ihor Radchenko a7d1dfa171
Use `org-element-type-p'
Use `org-element-type-p' across Org source, except some tests, where `eq' can
produce more meaningful failure explanations.
2023-07-01 14:35:35 +03:00
Ihor Radchenko 5e94d5cef6
org-element-map: Allow FUN to be a lisp form
* lisp/org-element-ast.el (org-element-ast-map):
* lisp/org-element.el (org-element-map): Allow FUN to be a lisp form,
wrapping it into lambda.
2023-07-01 14:35:34 +03:00
Ihor Radchenko 71e2ea5698
org-element: Update docstrings using new syntax node terminology 2023-07-01 14:35:34 +03:00
Ihor Radchenko 23f9347d1a
org-element-map: Allow TYPES t and add new arg NO-UNDEFER
* lisp/org-element-ast.el (org-element-ast-map):
* lisp/org-element.el (org-element-map): Treat TYPES t as all possible
types.  Add new optional parameter to no resolve deferred while
traversing the AST.
2023-07-01 14:35:33 +03:00
Ihor Radchenko c22697f472
Use new function names org-element-extract' and org-element-set' 2023-07-01 14:35:32 +03:00
Ihor Radchenko 29cb0b370b
org-element-headline-parser: Defer property drawer values
* lisp/org-element.el (org-element--get-node-properties): Defer the
property values.
2023-07-01 14:35:31 +03:00
Ihor Radchenko 4fcdcb456d
org-element: Defer large buffer substrings when parsing
* lisp/org-element.el (org-element--substring):
(org-element--unescape-substring): New functions to be used for
deferred buffer substring calculation.
(org-element--headline-raw-value):
(org-element-comment-block-parser):
(org-element-example-block-parser):
(org-element-export-block-parser):
(org-element-latex-environment-parser):
(org-element-src-block-parser):
(org-element-table-parser):
(org-element--parse-generic-emphasis):
(org-element-inline-babel-call-parser):
(org-element-latex-fragment-parser):
(org-element-export-snippet-parser): Defer large buffer substrings.
2023-07-01 14:35:30 +03:00
Ihor Radchenko daebeb6446
org-element-inlinetask-parser: Use deferred properties 2023-07-01 14:35:30 +03:00
Ihor Radchenko 932c49c7bb
org-element-headline-parser: Use deferred properties
* lisp/org-element.el (org-element--headline-raw-value): New function
calculating :raw-value property dynamically.
(org-element-headline-parser): Use the new function, deferring
:raw-value to reduce memory footprint of the cache.
2023-07-01 14:35:29 +03:00
Ihor Radchenko 55ba9f05a7
org-element-map: Refactor using `org-element-ast-map'
* lisp/org-element.el (org-element-map): Use `org-element-ast-map' to
traverse the AST.  Update the docstring adding new features from
`org-element-ast-map' - FUN can now throw `:org-element-skip' signal
to skip current node and its child nodes.  Clarify the structure of
INFO argument.  Reverse the traverse order for dual keywords -
secondary value is now traversed after the main value.
* testing/lisp/test-org-element.el (test-org-element/map): Update the test
reflecting the change in dual keyword traversal order.
2023-07-01 14:35:28 +03:00
Ihor Radchenko 5f37f77fc6
org-element--cache-shift-positions: Make use of inliner
* lisp/org-element.el: Allow `org-element-property' inliner to expand
into `aref'.
2023-07-01 14:35:27 +03:00
Ihor Radchenko ad75fd2bae
org-element: Use `org-element-create' when parsing 2023-07-01 14:35:27 +03:00
Ihor Radchenko a8286a5a9e
org-element: Record origin buffer when parsing
* lisp/org-element.el (org-element-parse-buffer): Resolve all the
deferred values in the string.  If not, we might leave pointers to
killed buffer.
(org-element--parse-elements): Resolve deferred in objects.
(org-element--object-lex): Store :buffer property.
* lisp/org-macro.el (org-macro--find-date): Do not try to print
:buffer property.
* lisp/org-element.el (org-element--cache-persist-before-write):
(org-element--cache-persist-after-read): Clear and restore
non-printable buffer objects in :buffer property.
2023-07-01 14:35:26 +03:00
Ihor Radchenko f4aa3747e1
org-element: Preserve order of multiple affiliated keywords
* lisp/org-element.el: Do not reverse affiliated keyword order.
(org-element-map): Remove special arrangement to restore keyword
ordering.
(org-element--interpret-affiliated-keywords): Obey the new keyword order.
* lisp/ox.el (org-export-get-caption):
* testing/lisp/test-org-element.el (test-org-element/affiliated-keywords-parser):
* testing/lisp/test-org-element.el (test-org-element/interpret-data):
Do not assume reverse order.

This is one of the undocumented conventions that is inconsistent with
other aspects of the parser.
2023-07-01 14:35:25 +03:00
Ihor Radchenko 924a64da39
org-element: Use the new org-element-ast library
* lisp/org-element.el (org-element-class):
(org-element-interpret-data): Explicitly consider anonymous syntax
node type.
* lisp/org-element.el (org-element-put-property):
(org-element-set-contents):
(org-element-secondary-p):
(org-element-adopt-elements):
(org-element-extract-element):
(org-element-insert-before):
(org-element-set-element):
(org-element-create):
(org-element-copy):
(org-element-lineage): Remove from org-element.el, using
org-element-ast function versions.
* lisp/org-element.el (org-element-headline-parser):
(org-element-inlinetask-parser):
(org-element-item-parser):
(org-element-citation-parser):
(org-element-citation-reference-parser): Assign :secondary property.
(org-element-parse-buffer):
(org-element-parse-secondary-string): Resolve deferred properties.
(org-element--cache-shift-positions): Use the new AST API.
(org-element--cache-for-removal): Use optional argument for
`org-element-set-element' to keep the needed property values.
(org-element--cache-gapless): Bump element cache version when persisting.
* testing/lisp/test-org-element.el (test-org-element/class): Update
test using the new :secondary property convention.
* lisp/ox-man.el (org-man-paragraph): Use the new AST API.
2023-07-01 14:35:24 +03:00
Ihor Radchenko ea9d5b45db
org-element-create: Allow single &rest argument as a list
* lisp/org-element-ast.el (org-element-create): Add special case when
CHILDREN contains a single list of Org notes:

  (let ((children (list a b c ...)))
    (org-element-create 'type nil children))

This will simplify creating new elements when children are stored in a
list.
2023-07-01 14:35:24 +03:00
Ihor Radchenko 6333a20aa5
org-element-ast: New function `org-element-lineage-map' 2023-07-01 14:35:23 +03:00
Ihor Radchenko 6b20a23065
org-element-ast: New function `org-element-type-p' 2023-07-01 14:35:22 +03:00
Ihor Radchenko ae49451364
org-element-ast: New function `org-element-put-property-2'
* lisp/org-element-ast.el (org-element-put-property-2): New function
allowing to pass NODE as the last argument.
2023-07-01 14:35:21 +03:00
Ihor Radchenko 80122a1204
org-element-ast: New function `org-element-property-2' 2023-07-01 14:35:21 +03:00
Ihor Radchenko f611f131ee
org-element-ast: New function `org-element-ast-map'
* lisp/org-element-ast.el (org-element-ast-map): New function
equivalent to `org-element-map', but more low-level.  Unlike
`org-element-map', `org-element-ast' does not consider the details of
Org syntax - just syntax tree structure.
2023-07-01 14:35:20 +03:00
Ihor Radchenko 669e8d8824
org-element-ast: New function `org-element-property-inherited' 2023-07-01 14:35:19 +03:00
Ihor Radchenko 4a8849340d
org-element-ast: New functions to map and resolve property values
* lisp/org-element-ast.el (org-element--properties-mapc): New internal
helper.
(org-element-properties-resolve): New function used to resolve
deferred property values by side effect.
(org-element-properties-mapc):
(org-element-properties-map): New function to map over properties and
their values.
(org-element-resolve-deferred): New alias to resolve all the deferred
values in syntax nodes.
2023-07-01 14:35:18 +03:00
Ihor Radchenko 2d2656f6a7
org-element-ast: Add setters for org-element-property' and org-element-property-1' 2023-07-01 14:35:18 +03:00
Ihor Radchenko 1260f61830
Refactor org-element API for abstract syntax tree
Major changes:
1. Property values can now deferred and computed next time when the
   value is requested.
2. Some properties are stored in an array instead of plist.  The
   functions are inlined to turn the propery queries into direct
   `aref' and `aset' calls to the plist, when applicable.
3. Secondary strings are now considered of `anonymous' type, in
   backwards-compatible way.
4. New functions to map over and/or resolve deferred values of element
   properties.
5. Docstrings and code consistently use "node" for generic syntax tree
   elements, to not confuse the element/object terminology we use in
   the parser.

* lisp/org-element-ast.el (org-element-deferred): New type user to
store deferred values.
(org-element--deferred-resolve-once):
(org-element--deferred-resolve):
(org-element--deferred-resolve-force):
(org-element--deferred-resolve-list): Helper functions used to resolve
the deferred values.
(org-element--standard-properties):
(org-element--standard-properties-idxs):
(org-element--property-idx):
(org-element--parray):
(org-element--plist-property): Store most commonly used properties in
vector for faster access.  Implement inliner helpers to transform
property keywords into array indices.
(org-element-property-1): New function to retrieve property without
resolving deferred value.
(org-element--put-parray):
(org-element-put-property): Refactor, using the new property vector
when applicable.
(org-element--property): New helper function.
(org-element-property): Refactor, using the new property vector and
deferred value resolution.  Add new optional arguments DFLT and
FORCE-UNDEFER.  Define setters.
(org-element-set-contents): Handle anonymous nodes.
(org-element-set):
(org-element-adopt):
(org-element-extract): Rename from `org-element-set-elements',
`org-element-adopt-elements', and `org-element-extract-elements' and
keep backward-compatible alias.  This is to reduce the confusion about
"node" vs. "element" vs. "object".
(org-element-create): Initialize property array correctly.
(org-element-copy): Allow copying secondary strings.  Add new optional
argument KEEP-CONTENTS.
(org-element-lineage): Clarify the limitation when cache is disabled.
(org-element-type): New optional argument to identify anonymous nodes
instead of returning nil for both anonymous nodes and everything not
matching other element types.
2023-07-01 14:35:17 +03:00
Ihor Radchenko d5198e39fb
org-element-ast: Add commentary describing the basics of AST structure
Clarify some of the undocumented concept assumptions about Org syntax
tree that are used in Org code base.  In particular, clarify that
syntax nodes are not necessarily limited by the specific Org syntax -
exporters can define new "pseudo" elements and objects.

Introduce a new concept of deferred values.

Add a new convention to keep secondary property names in a special
:secondary property.

Introduce `anonymous' element type, which was previously
indistinguishable from values that are not Org syntax elements.
2023-07-01 14:35:16 +03:00
Ihor Radchenko f750f46c9d
Factor out pure syntax tree API to org-element-ast.el (copy old functions)
The functions to be modified are copied here for better diffs with
subsequent commits.
2023-07-01 14:35:15 +03:00
Ihor Radchenko 184b735323
Merge branch 'bugfix' 2023-07-01 13:26:08 +03:00
Gerard Vermeulen a4586f0d71
org: fix symbol names and grammar in docstrings
* lisp/org.el (org-outline-level):
* lisp/org.el (org-current-level): change undefined symbol names
  to `org-odd-levels-only' and change "Unlike to" to "Unlike".
2023-07-01 13:25:21 +03:00
Ihor Radchenko 64a0a624d2
org-insert-structure-template: Err on empty TYPE
* lisp/org.el (org-insert-structure-template): Throw a user error on
empty TYPE input.  Throw an error when TYPE is not a string or an
empty string.

Reported-by: pva-outdoor@yandex.ru
Link: https://orgmode.org/list/87a5wij05o.fsf@yandex.ru
2023-07-01 13:22:46 +03:00
Ihor Radchenko 85aa3c1850
org-narrow-to-block: Use element API and handle all the block types
* lisp/org.el (org-narrow-to-block): Narrow to any block type,
including dynamic blocks.  Use org-element API.

Reported-by: pva-outdoor@yandex.ru
Link: https://orgmode.org/list/87a5wij05o.fsf@yandex.ru
2023-07-01 13:18:38 +03:00
Ihor Radchenko dc70878fc0
org-lint: Add new linter for ambiguous literal $
* lisp/org-lint.el (org-lint-LaTeX-$-ambiguous): New linter that
matches "$.12" and similar that match right LaTeX fragment boundary,
but are likely indented for literal use.

Reported-by: Paul Rubin <paulr@hackyon.net>
Link: https://orgmode.org/list/49c5dcf6-26fa-5fe1-1778-c932d056eadb@hackyon.net
2023-07-01 13:03:11 +03:00
Ihor Radchenko c33ea8f9e2
org-refile: Fix typo in 94c2c8d92
* lisp/org-refile.el (org-refile): Fix typo in variable name.
2023-06-30 15:49:57 +03:00
Ihor Radchenko a19654583c
Refactor `org-fast-tag-selection'
* lisp/org.el (org-fast-tag-selection): Refactor the function, adding
commentary and renaming variables to more readable names.
2023-06-30 15:46:51 +03:00
Ihor Radchenko f5001c0da6
Refactor `org-fast-todo-selection'
* lisp/org.el (org-fast-todo-selection): Refactor the function, adding
commentary and renaming variables to more readable names.
2023-06-30 15:46:51 +03:00
Matthew Trzcinski 88c572de25 Create aliases for export region functions
lisp/ox-ascii.el: Create alias `org-export-region-to-ascii` for
`org-ascii-convert-region-to-ascii`.
lisp/ox-html.el: Create alias `org-export-region-to-html` for
`org-html-convert-region-to-html`.
lisp/ox-latex.el: Create alias `org-export-region-to-latex` for
`org-latex-convert-region-to-latex`.
lisp/ox-md.el: Create alias `org-export-region-to-md` for
`org-md-convert-region-to-md`.
lisp/ox-texinfo.el: Create alias `org-export-region-to-texinfo` for
`org-texinfo-convert-region-to-texinfo`.
doc/org-manual.org: Change commands from "*-convert-region-*" form to
the "org-export-region-to-*" aliases.  Add function index for aliases.
2023-06-29 21:18:01 +02:00
Ihor Radchenko 5df1ee36ae
org-refile: Fix typo in 94c2c8d92
* lisp/org-refile.el (org-refile): Fix typo in variable name.
2023-06-28 12:34:53 +03:00
Ihor Radchenko 7da765e459
Revert "org-replace-escapes: Fix compiler warning"
This reverts commit 39786a8dbf.

In favor of an equivalent upstream Emacs commit 670174a6d5f.
2023-06-26 13:43:44 +03:00
Ihor Radchenko ca873f7fe4
Update version number for the 9.6.7 release 2023-06-25 14:06:19 +03:00
Ihor Radchenko 39786a8dbf
org-replace-escapes: Fix compiler warning
* lisp/org-macs.el (org-replace-escapes): Do not modify constant
string.
2023-06-25 14:05:36 +03:00
Ihor Radchenko f8b0b2babf
org-edit-special: Fix docstring
* lisp/org.el (org-edit-special): Document missing contexts in the docstring.
2023-06-25 13:45:18 +03:00
Ihor Radchenko 18f003a164
Merge branch 'bugfix' 2023-06-24 15:36:34 +03:00
Ihor Radchenko 421b443483
org-babel-tangle-single-block: Fix compiler warning
* lisp/ob-tangle.el (org-outline-regexp): Declare variable.
2023-06-24 15:34:22 +03:00
Ihor Radchenko 0a842cc94b
org-forward-heading-same-level: Do not rely on match-data from `org-back-to-heading'
* lisp/org.el (org-forward-heading-same-level): Use
`org-current-level' instead of relying upon `org-back-to-heading' to
set match data.

Reported-by: Nick Dokos <ndokos@gmail.com>
Link: https://orgmode.org/list/87352hk0nt.fsf@alphaville.usersys.redhat.com
2023-06-24 15:33:59 +03:00
Ihor Radchenko 57bb9cada3
org-mouse-transform-to-outline: Do not rely on match-data from `org-back-to-heading'
* lisp/org-mouse.el (org-mouse-transform-to-outline): Use
`org-current-level' instead of relying upon `org-back-to-heading' to
set match data.

Reported-by: Nick Dokos <ndokos@gmail.com>
Link: https://orgmode.org/list/87352hk0nt.fsf@alphaville.usersys.redhat.com
2023-06-24 15:33:13 +03:00
Ihor Radchenko f56ca5009e
fixup! org-babel-tangle-single-block: Do not rely on match-data from `org-back-to-heading' 2023-06-24 15:32:40 +03:00
Ihor Radchenko 94c2c8d929
Inhibit error when saving bookmarks with `debug-on-error' set to non-nil
* lisp/org-capture.el (org-capture-store-last-position):
* lisp/org-refile.el (org-refile): Use `condition-case' instead of
`with-demoted-errors' when saving bookmarks.  We intent to suppress
errors completely here (116c09053), even when `debug-on-error' is set.
`with-demoted-errors' does trigger error in such scenario, unlike
explicit `condition-case' clause.

Reported-by: No Wayman <iarchivedmywholelife@gmail.com>
Link: https://orgmode.org/list/875y7d7jlr.fsf@gmail.com
2023-06-24 15:05:12 +03:00
Dmitry Logvinenko 5b3a1a634c
lisp/org-habit.el: Inherit habit style property
* lisp/org-habit.el (org-is-habit-p):  Use `org-entry-get' with
'selective option to optionally find habit subheadings.
* etc/ORG-NEWS: Describe a breaking change.

TINYCHANGE
2023-06-23 13:47:51 +03:00
Tim Visher bea9fca183
org-capture.el: Allow `(here)' as a template target
* lisp/org-capture.el (org-capture-set-target-location): Allow
`(here)' as a template target in addition to `here'.
(org-capture-templates): Update the docstring, describing the new
target.
* doc/org-manual.org (Template elements): Add `(here)' target
documentation
* etc/ORG-NEWS (Capture templates now support ~(here)~ as a target):
Document the new feature.

Templates had no user accessible way to target the current location
directly from a capture template. Attempting to directly utilize the
behavior accessible through a 0 prefix arg exposed the inconsistent
treatment of the `:target` property in
`org-capture`. `org-capture-set-target-location` understood that it
could be both a symbol and a list, while `org-capture` itself required
it to be a list through its use of `car`.

This change opts to make `org-capture-set-target-location` more
liberal in what it accepts rather than making `org-capture` agree that
targets can be lists. This is because the manual implies, especially
in the `(clock)' entry, that targets are expected to be lists even if
they are meant as specific points.

TINYCHANGE
2023-06-22 13:14:12 +03:00
Ihor Radchenko 200d168275
Merge branch 'bugfix' 2023-06-22 12:54:51 +03:00
Ihor Radchenko 79ec91584c
org-babel-tangle-single-block: Do not rely on match-data from `org-back-to-heading'
* lisp/ob-tangle.el (org-babel-tangle-single-block): Explicitly move
to the beginning of title instead of assuming that
`org-back-to-heading' sets match data appropriately (it is not
documented to do so).
* testing/lisp/test-ob-tangle.el (ob-tangle/comment-org): Add test.

Reported-by: Nick Dokos <ndokos@redhat.com>
Link: https://orgmode.org/list/87bkh8k3at.fsf@alphaville.usersys.redhat.com
2023-06-22 12:54:23 +03:00
Ihor Radchenko c8c8e3326d
org-priority-show: Fix the docstring after changes in "priority" for agenda
* lisp/org.el (org-priority-show): Do not wrongly assert that the
priority is affected by scheduled and deadline values.  This was not
true in the past for Org mode buffers, and it is no longer true after
8fab6eeef renamed composite agenda rank from priority to urgency.

* etc/ORG-NEWS (~org-priority=show~ command no longer adjusts for
scheduled/deadline): Document the change, right before the NEWS item
describing changes in the agenda.
2023-06-21 20:22:43 +03:00
Jack Kamm 294a4d2fe2 ox-icalendar: Add support for unscheduled and repeating TODOs
* lisp/ox-icalendar.el (org-icalendar-todo-unscheduled-start): New
customization to control the exported start time of unscheduled tasks.
(org-icalendar--rrule): Helper function for RRULE export.
(org-icalendar--vevent): Use the new helper function for RRULE.
(org-icalendar--repeater-type): Helper function to get the repeater
type, and display warning if not supported.
(org-icalendar--vtodo): Change how unscheduled TODOs are handled using
the new customization option.  Export SCHEDULED and DEADLINE
repeaters.  In case of SCHEDULED repeater and a DEADLINE without
repeater, treat DEADLINE as RRULE UNTIL.  Emit a warning for tricky
edge cases that are not yet implemented.
* testing/lisp/test-ox-icalendar.el
(test-ox-icalendar/todo-repeater-shared): Test for exporting shared
SCHEDULED/DEADLINE repeater.
(test-ox-icalendar/todo-repeating-deadline-warndays): Test using
warning days as DTSTART of repeating deadline.
(test-ox-icalendar/todo-repeater-until): Test using DEADLINE as RRULE
UNTIL.
(test-ox-icalendar/todo-repeater-until-utc): Test RRULE UNTIL is in
UTC format when DTSTART is not in local time format.
(test-ox-icalendar/warn-unsupported-repeater): Unit test to warn for
unsupported repeater types.
* lisp/org-lint.el (org-lint-mismatched-planning-repeaters): Add lint
for mismatched SCHEDULED and DEADLINE repeaters.
* testing/lisp/test-org-lint.el
(test-org-lint/mismatched-planning-repeaters): Add test for linting of
mismatched SCHEDULED and DEADLINE repeaters.
* doc/org-manual.org (iCalendar Export): Add link to new variable
`org-icalendar-todo-unscheduled-start'.
2023-06-18 06:51:47 -07:00
Ihor Radchenko 1ec3a43c58
org-lint: Add checker for misspelled export options in properties
* lisp/org-lint.el (org-lint-export-option-keywords): New linter
checking export properties without EXPORT_.

Link: https://orgmode.org/list/87ttv7kp2j.fsf@k-7.ch
2023-06-17 15:09:03 +03:00
Ihor Radchenko 739c8989a7
Merge branch 'bugfix' 2023-06-15 12:39:12 +03:00
Ihor Radchenko 7b3b7b92e7
org-fold-core: Try harder to reduce overheads
* lisp/org-fold-core.el (org-fold-core-cycle-over-indirect-buffers):
Clear folds from killed indirect buffers once only.  Avoid calling
`remove-text-properties' when there is nothing to remove.
* lisp/org-fold-core.el (org-fold-core--fix-folded-region): Ignore
deletions more aggressively, avoiding the calls to
`org-fold-core-cycle-over-indirect-buffers'.
2023-06-15 12:36:32 +03:00
Ihor Radchenko a072608567
org-set-font-lock-defaults: Fix checkbox fontification
* lisp/org.el (org-set-font-lock-defaults): Use full
`org-list-full-item-re' that accounts for alphabetical bullets as
well.

Reported-by: pondersson <pondersson@gmail.com>
Link: https://orgmode.org/list/CAHewz5N5vNMiWFuG3t=bZoyVmsYswyerZ6VsLC88DGTXR+AhOA@mail.gmail.com
2023-06-14 13:49:09 +03:00
Ihor Radchenko 2f7b35ac89
org-element-cache: Reduce memory footprint in indirect buffers
* lisp/org-element.el (org-element--cache-setup-change-functions): Set
buffer-local cache values to nil in indirect buffers.

Reported-by: Sebastian Wålinder <s.walinder@gmail.com>
Link: https://orgmode.org/list/87v8funovi.fsf@localhost
2023-06-13 13:08:48 +03:00
Ihor Radchenko 34082ff184
org-indent-line: Fix with line is within blank lines after heading
* lisp/org.el (org-indent-line): Fix when we are within blank lines
after heading.  ELEMENT is then `heading' and looking at :begin - 1
does not make sense.
* testing/lisp/test-org.el (test-org/indent-region): Add test.

Reported-by: Jens Schmidt <jschmidt4gnu@vodafonemail.de>
Link: https://orgmode.org/list/d7129804-1f42-ea2b-85e8-18ea1ee32d73@vodafonemail.de
2023-06-11 13:16:31 +03:00
Ihor Radchenko 9082fa8892
Merge branch 'bugfix' 2023-06-08 16:14:13 +03:00
Ihor Radchenko 84e5a4da54
org-element-cache-map: Fix edge case when FUNC removes DATA
* lisp/org-element.el (org-element-cache-map): Fix when DATA is
obsolete after buffer modification.
* testing/lisp/test-org.el (test-org/map-entries): Add test.

Reported-by: Victor A. Stoichita <victor@svictor.net>
Link: https://orgmode.org/list/87v8fzxbfo.fsf@svictor.net
2023-06-08 16:11:38 +03:00
Ihor Radchenko c9f3de6e8f
Merge branch 'bugfix' 2023-06-07 20:34:23 +03:00
Steven Allen f2e71ee726
org.el: inline display of attached images in link descriptions
* lisp/org.el (org-display-inline-images): inline display of attached
images in link descriptions.

Previously, `org-display-inline-images' only inlined images in link
descriptions when they were explicit "file:" links. This change adds
support for "attachment:" links. E.g.:

    [[https://orgmode.org][attachment:emacs-screenshot.png]]
2023-06-07 20:32:26 +03:00
Ihor Radchenko ba8c468634
org-insert-todo-heading-respect-content: Fix regression in b4e41b
* lisp/org.el (org-insert-todo-heading-respect-content): Do not force
first TODO keyword in the inserted heading.  Instead, accept prefix
arguments and pass them directly to `org-insert-todo-heading'.
* etc/ORG-NEWS (~org-insert-todo-heading-respect-content~ now accepts
prefix arguments): Document the change.
*
testing/lisp/test-org.el (test-org/insert-todo-heading-respect-content):
Add tests.

Reported-by: Xuan Wang <xuan.public@gmail.com>
Link: https://orgmode.org/list/CALjN2yehOVYZuU+tURes+mJ5XyTrRY1O0UG1ijH-6TjJ=W0ibw@mail.gmail.com
2023-06-07 15:18:16 +03:00
Ihor Radchenko 661a98f891
org-insert-todo-heading: Update docstring
* lisp/org.el (org-insert-todo-heading): Use docstring construct when
talking about prefix argument.
2023-06-07 15:12:04 +03:00
Ihor Radchenko e83d4e94d8
fixup! org-fold-core: Fix folding for `isearch-filter-prediacate' outside isearch
* lisp/org-fold-core.el (org-fold-core--isearch-show-temporary): Fix
edge case when `org-fold-core--isearch-local-regions' contains empty
region.
2023-06-03 11:09:52 +03:00
Ihor Radchenko 07521331c3
org-image-max-width: Allow floating point value as fraction of window width
* lisp/org.el (org--create-inline-image): Allow `org-image-max-width'
to be a floating point value - fraction of window width.
(org-image-max-width): Update the docstring and type specification.
2023-06-02 14:55:36 +03:00
Ihor Radchenko 1cb5de6211
org-eval: Use `condition-case-unless-debug' for better backtraces 2023-06-02 10:52:12 +03:00
Leo Butler d55a112149
lisp/ob-C.el: replace %f with %s to prevent unneeded rounding
* lisp/ob-C.el (org-babel-C-val-to-C-type): Floats should be printed
as string literals to prevent rounding introduced by %f format.

* testing/lisp/test-ob-C.el (ob-C/float-var): Test that floats are not
rounded when passed as an org :var.
2023-06-02 10:23:58 +03:00
Ihor Radchenko 2c77551a68
org-texinfo-export-to-info: Fix docstring
* lisp/ox-texinfo.el (org-texinfo-export-to-info): Remove description
of a removed argument from the docstring.  The PUB-DIR argument has
been removed in 496ed832d.

Reported-by: Niall Dooley <dooleyn@gmail.com>
Link: https://list.orgmode.org/orgmode/CADS3Lq7W=LZYd3F3aA0p1RaDWdHSmwahvs8oyJfx_Hw0WF9K9Q@mail.gmail.com/
2023-06-02 10:23:57 +03:00
Leo Butler c50b03d99e
lisp/ob-C.el: replace %f with %s to prevent unneeded rounding
* lisp/ob-C.el (org-babel-C-val-to-C-type): Floats should be printed
as string literals to prevent rounding introduced by %f format.

* testing/lisp/test-ob-C.el (ob-C/float-var): Test that floats are not
rounded when passed as an org :var.
2023-06-02 10:21:28 +03:00
Ihor Radchenko 5b4eebfabd
Prefer `condition-case-unless-debug' where possible
* lisp/org-clock.el (org-clock-play-sound):
* lisp/org-element.el (org-element-at-point):
* lisp/org-src.el (org-src--edit-element):
(org-fontify-inline-src-blocks):
* lisp/org.el (ox):
(org-fontify-meta-lines-and-blocks):
(org-map-dblocks):
* lisp/ox-odt.el (org-odt--export-wrap): Use
`condition-case-unless-debug' to allow more descriptive backtraces
when `debug-on-error' is non-nil.

Link: https://orgmode.org/list/878rdnq1iy.fsf@web.de
2023-06-01 15:05:22 +03:00
Ihor Radchenko 7dee2c07f4
org-fold-core: Fix folding for `isearch-filter-prediacate' outside isearch
* lisp/org-fold-core.el (org-fold-core--keep-overlays): New internal
macro, signaling `org-fold-core-region' to keep overlays in place and
store new overlays for later use in isearch.
(org-fold-core-region): Never remove overlays and store newly created
ones in `org-fold-core--isearch-overlays' when
`org-fold-core--keep-overlays' is non-nil.  Remove resolved FIXME.
(org-fold-core--isearch-setup): Advice `isearch-clean-overlays' as
more reliable way to clear all the temporary overlays created for
isearch.  `query-replace' and EVIL packages use
`isearch-filter-predicate' separately as thus `isearch-mode-end-hook'
is not sufficient to ensure that isearch overlays are converted back
to text properties.
(org-fold-core--isearch-show-temporary): Do not alter match data, as
isearch expects the match data to stay unchanged.  Arrange the
overlays to be kept for isearch consumption (otherwise, isearch will
signal an error; see
https://list.orgmode.org/orgmode/87pmc4smdg.fsf@fastmail.fm/).
(org-fold-core--create-isearch-overlays): Call `org-fold-core-region'
with let-bound `org-fold-core-style' instead of repeating the code
from `org-fold-core-region'.

Reported-by: Michael Dauer <mick.dauer@gmail.com>
Link:
https://list.orgmode.org/orgmode/CAP7OBx+L11ck3Ni6rv94HGU3otdj6C4rG-rMDzkwR1LTj=BWiw@mail.gmail.com/
Link+: https://list.orgmode.org/orgmode/87pmc4smdg.fsf@fastmail.fm/
Link+: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=60399
Link+: https://yhetil.org/emacs-devel/87fs7c10cq.fsf@web.de/
2023-06-01 14:24:33 +03:00
Ihor Radchenko 873b0d22fd
org-fold-core--isearch-reveal: Fix typo
* lisp/org-fold-core.el (org-fold-core--isearch-setup): Fix arguments
in the `org-fold-core-get-region-at-point' call.
2023-06-01 14:22:59 +03:00
Ihor Radchenko 74198ac49c
org-lint: Add linter for unknown babel language
* lisp/org-lint.el (org-lint-suspicious-language-in-src-block): New
linter checking for unknown src block languages.
2023-05-31 11:40:47 +03:00
Ihor Radchenko 3123caa8e9
org-display-inline-images: Expand environment variables in image path
* lisp/org.el (org-display-inline-images): Expand environment
variables in the link path, just like `org-open-file' does.

Reported-by: Pan Xie <xiepan@skyguard.com.cn>
Link: https://orgmode.org/list/7a012430-6084-e693-1a86-f14d0512bebc@skyguard.com.cn
2023-05-31 11:20:02 +03:00
Ihor Radchenko 24ed8b204e
org-mode-tags-syntax-table: Make the value available outside Org buffers
* lisp/org.el (org-mode-syntax-table): New explicitly defined variable
for Org mode syntax table.
(org-mode-tags-syntax-table): Define value in advance, available even
before Org mode is loaded.
(org-mode): Use the new `org-mode-syntax-table' variable.

Reported-by: Daniel Clemente <n142857@gmail.com>
Link: https://orgmode.org/list/CAJKAhPCcMwZS6aYK9MRKsjds9uTivOdfC9nzMok70Df8vR3tPA@mail.gmail.com
2023-05-29 11:30:58 +03:00
Ihor Radchenko 513534f2a7
lisp/org.el: allow org-return to call org-open-at-point on citations
* lisp/org.el (org-return): When `org-return-follows-link' is non-nil
and point is over an org-cite citation or citation reference, call `org-open-at-point'.

TINYCHANGE
2023-05-25 14:21:20 +02:00
Ihor Radchenko 93492b8619
org-compile-file: Ensure whitespace before ERR-MSG
* lisp/org-macs.el (org-compile-file): Make sure that ERR-MSG has
lading whitespace and no trailing whitepace when displaying error.

Reported-by: Niall Dooley <dooleyn@gmail.com>
Link:
https://orgmode.org/list/CADS3Lq5Uv4gK0U93H2EX9r=g43BbhzHT33oXbWVg7bAURmFvFw@mail.gmail.com
2023-05-25 13:56:32 +02:00
Ihor Radchenko 8037aab493
org-texinfo-export-to-info: Fix docstring
* lisp/ox-texinfo.el (org-texinfo-export-to-info): Remove description
of a removed argument from the docstring.  The PUB-DIR argument has
been removed in 496ed832d.

Reported-by: Niall Dooley <dooleyn@gmail.com>
Link: https://list.orgmode.org/orgmode/CADS3Lq7W=LZYd3F3aA0p1RaDWdHSmwahvs8oyJfx_Hw0WF9K9Q@mail.gmail.com/
2023-05-24 16:56:24 +02:00
Ihor Radchenko 6d9f3af774
org-element--parse-to: Micro optimizations
* lisp/org-element.el (org-element-headline-parser): Store :true-level
property.
(org-element--parse-to): Call `org-get-limited-outline-regexp'
directly rather than via `org-with-limited-levels'.  Avoid moving
point unnecessarily.  Prefer `org-headline-re' to generate regexps.
* lisp/org-macs.el (org-headline-re):
(org-skip-whitespace): Inline.
2023-05-18 15:22:49 +02:00
Ihor Radchenko 64e15ea0b0
Optimize org-element--cache-compare
* lisp/org-element.el (org-element--cache-key): Reduce property and
type queries.
(org-element--cache-compare): Convert into `defsubst'.
2023-05-18 15:22:49 +02:00
Ihor Radchenko 534045979d
org-element--current-element: Do not try to query cache
* lisp/org-element.el (org-element--current-element): Do not try to
search cache.  This is rarely useful and forces an awkward
`org-element-copy' workaround what parsing buffer.
(org-element--parse-elements): Do not use `org-element-copy' for
element at point - it is now safe to assume that
`org-element--current-element' does not return cached.
(org-element--parse-to): Do not force disabled cache when calling
`org-element--current-element'.  It is no longer needed.
2023-05-18 15:22:48 +02:00
Ihor Radchenko bc4ee1c72a
org-element--current-element: Micro optimizations
* lisp/org-element.el (org-element--current-element): Try hard
spending minimal amount of time in testing which parser to call.
Prefer `look-at-p' that does not modify match data and thus save us
significant amount of time.  Do not call `org-with-limited-levels' and
instead use the simplest possible tests with all unnecessary branches
removed.  Add commentary explaining the importance of writing fast
core when adding new elements.
(org-inlinetask-min-level): Declare variable.

* lisp/org-list.el (org--item-re-cache):
(org-item-re): Cache results rather than calculating regexp every time
the parser is invoked.
* lisp/org-macs.el:
(org--headline-re-cache):
(org--headline-re-cache-no-bol):
(org--headline-re-cache-bol):
(org-headline-re): Prefer plists to store headline regexp cache - the
number of items tends to be within 10-20 and hence hash table is an
overkill and will be slower.
2023-05-18 15:22:44 +02:00
Ihor Radchenko 3a4f9604f1
Cache <N>-level headline regexps instead of calculating dynamically
* lisp/org-macs.el (org-headline-re): New function to retrieve cached
or get a new regexp for headline of level TRUE-LEVEL.
(org-get-limited-outline-regexp): Use `org-headline-re'.  Add new
optional argument WITH-BOL.
2023-05-18 15:07:24 +02:00