Commit Graph

17454 Commits

Author SHA1 Message Date
Nicolas Goaziou 14ed651db0 Merge branch 'bugfix' 2021-12-08 12:12:08 +01:00
Nicolas Goaziou a62da701b4 oc-csl: Fix location of \citeprocitem definition
* lisp/oc-csl.el (org-cite-csl-finalizer): Insert \citeprocitem before
"\begin{document}".
2021-12-08 12:09:15 +01:00
Ihor Radchenko 54534eebbb
org-element-cache: Handle some edits in top-level property drawer
* lisp/org-element.el (org-element--cache-sensitive-re): Make proprety
drawer lines sensitive.
(org-element--cache-for-removal): Make sensitive edits inside cache
gap right after org-data re-parse the org-data.  Make sensitive
top-section edits re-parse org-data.

The specific error has been reported in
https://github.com/yantar92/org/issues/40
The recepy involves loading org-contrib:
1. emacs -Q -L ~/.emacs.d/.local/straight/repos/org/lisp -L ~/.emacs.d/.local/straight/repos/org-contrib/lisp -l org
 -l org-eldoc
 2. Create a test.org file with the following content:
 :PROPERTIES:
:ID:       test
:END:

Test.
3.
(goto-char (point-min))
(org-entry-put nil "ID" "test")
(save-buffer)
(org-entry-get nil "ID")
Return value is nil, while should be "test"
2021-12-08 10:31:37 +08:00
Ihor Radchenko 7ac37478ca
org-src.el: Fix nativecomp warnings
* lisp/org-src.el: Declare `org-element--parse-paired-brackets'
function.  Declare `org-src-fontify-natively' variable.
2021-12-08 10:29:39 +08:00
Nicolas Goaziou a78d96ebc0 Merge branch 'bugfix' 2021-12-07 22:52:58 +01:00
Nicolas Goaziou 18d77ac253 oc-basic: Fix completion cache
* lisp/oc-basic.el (org-cite-basic--key-completion-table): Cache
completions per document.  Return nil when no completion is available
so insertion mechanism can properly report the problem.
2021-12-07 22:51:46 +01:00
Nicolas Goaziou a83465add3 oc-basic: Clarify prompt during key completion
* lisp/oc-basic.el (org-cite-basic--complete-key): Clarify prompt
during completion.  Format docstring.
2021-12-07 22:10:39 +01:00
Nicolas Goaziou 2dc4a4da94 Do not require `oc-basic'
Org will take care of loading it when appropriate.
2021-12-05 19:05:49 +01:00
Nicolas Goaziou eaa7817b31 org: Try loading activate processor when initializing fontification
* lisp/org.el (org-set-font-lock-defaults): Try registering activate
processor if appropriate.
2021-12-05 19:04:34 +01:00
Nicolas Goaziou e83a04b5af oc: Make `org-cite-try-load-process' public
* lisp/oc.el (org-cite-try-load-processor): New function.
(org-cite--try-load-processor): Remove function.
(org-cite-store-export-processor):
(org-cite-follow):
(org-cite-insert): Use new function.
2021-12-05 19:02:03 +01:00
Nicolas Goaziou 4f1c878d9a oc: Fix `org-cite--try-load-processor'
* lisp/oc.el (org-cite--try-load-processor): Add missing `intern'
call.
2021-12-05 18:59:24 +01:00
Kyle Meyer ad53c54645 Merge branch 'bugfix' 2021-12-04 21:40:08 -05:00
Stefan Kangas db4805c2d7 Backport commit 50b40e1d4 from Emacs
; * lisp/org/ob-julia.el: Fix Author header for authors.el.
50b40e1d4f0063ac78a53673736a2eaa3ba3287b
Stefan Kangas
Wed Dec 1 17:03:52 2021 +0100
2021-12-04 15:29:43 -05:00
Nicolas Goaziou 191552df35 oc: Fix slowdown on tests
* lisp/oc.el (org-cite--try-load-processor): New function.
(org-cite-store-export-processor):
(org-cite-follow):
(org-cite-insert): Use new function.
(org-cite-get-processor): Do not try to load unknown processor.
Loading now happens at another level.
2021-12-04 18:09:24 +01:00
Ihor Radchenko 9843670d11
org-element--cache-sync: Another take on false positive warnings
* lisp/org-element.el (org-element--cache-sync): Suppress silent edit
warnings for Emacs <28.  In older Emacs, Emacs internal functions can
modify `buffer-chars-modified-tick' and cannot be distinguished from
dangerous edits under `inhibit-modification-hooks'.  Some of the
functions even have the same footprint with the edits we want to
avoid.
2021-12-04 12:52:16 +08:00
TEC 521c534101
org-src: Refactor inline src block fontify lines
* lisp/org-src.el (org-fontify-inline-src-blocks-1): Refactor
`org-fontify-inline-src-blocks-1' to bring down the maximum line
length.  While we're at it, get rid of the debugging `message' call that
somehow made its way in, and an unused variable in the `let' statement.
2021-12-02 19:33:28 +08:00
Ihor Radchenko b59ccbf55b
org-element-at-point: Improve warning message
* lisp/org-element.el (org-element-at-point): Describe warning as
parser error when `org-element--parse-to' throws an error.  The error
may be thrown when parser encounters issue not related to cache.

Fixes confusion in https://list.orgmode.org/871r2vpblx.fsf@yandex.com/T/#u
2021-12-02 18:15:55 +08:00
Ihor Radchenko 328be6df40
org-element--parse-to: Fix skipping sibling optimisation
* lisp/org-element.el (org-element--parse-to): Fallback to normal
parsing when there are no siblings between POS and ELEM-END.

Reported in
https://github.com/yantar92/org/issues/38#issuecomment-982830497
2021-12-02 09:17:51 +08:00
Ihor Radchenko b170b23a5b
Update adadb5b55 for Emacs 26 2021-12-02 08:40:06 +08:00
Nicolas Goaziou ed5335545e lint: Reorder file
Checkers definition are last because this is the part usually expanded.
2021-12-01 16:15:08 +01:00
Nicolas Goaziou b4acde37ba lint: Allow user-defined checkers during linting
* lisp/org-lint.el (org-lint-add-checker): New function.
(org-lint--generate-reports): Checker function now must be specified.
It is not deduced anymore from the name of the checker.
* testing/lisp/test-org-lint.el (test-org-lint/add-checker): New test.
2021-12-01 16:09:13 +01:00
Nicolas Goaziou 6766c45bfd org-lint: Add checkers for citations and related
* lisp/org-lint.el (org-lint--checkers): Register new checkers.
(org-lint-non-existent-bibliography):
(org-lint-missing-print-bibliography):
(org-lint-invalid-cite-export-declaration):
(org-lint-incomplete-citation): New functions.
* testing/lisp/test-org-lint.el (test-org-lint/non-existent-bibliography):
(test-org-lint/missing-print-bibliography):
(test-org-lint/invalid-cite-export-declaration):
(test-org-lint/incomplete-citation): New tests.
2021-11-30 22:21:46 +01:00
Nicolas Goaziou 3744713b8a oc: Make `org-cite-get-processor' public
* lisp/oc.el (org-cite--get-processor): rename to...
(org-cite-get-processor): ... this.
(org-cite-unregister-processor):
(org-cite-processor-has-capability-p):
(org-cite-supported-styles):
(org-cite-activate):
(org-cite-store-export-processor):
(org-cite-export-citation):
(org-cite-export-bibliography):
(org-cite-finalize-export):
(org-cite-follow):
(org-cite-insert): Apply renaming.
2021-11-30 22:21:46 +01:00
Nicolas Goaziou 5d2e2cd1bc oc: Factor out string to cite export processor triplet conversion
* lisp/oc.el (org-cite-read-processor-declaration): New function.
(org-cite-store-export-processor): Use new function.
* testing/lisp/test-oc.el (test-org-cite/read-processor-declaration):
New test.
2021-11-30 22:21:46 +01:00
Ihor Radchenko adadb5b554
org-element--cachy-sync: Add exception for unregistered changes
* lisp/org-element.el (org-element--cache-sync): Another special case
when Emacs <28 silently changes `buffer-chars-modified-tick'.

Fixes https://list.orgmode.org/so53mm$obe$1@ciao.gmane.io/T/#mad982a75885b1eda669d8cf7decee15c3917957b
2021-11-30 20:32:28 +08:00
Ihor Radchenko 8868f0fddd
org-archive-subtree: Speed up archiving
* lisp/org-element.el (org-element--cache-avoid-synchronous-headline-re-parsing):
  New internal variable controlling latency of cache
  `after-change-functions'.

(org-element--cache-for-removal): Use
`org-element--cache-avoid-synchronous-headline-re-parsing' to decide
if we re-parse changed headlines immidiately.
* lisp/org-archive.el (org-archive-subtree): Let-bind
`org-element--cache-avoid-synchronous-headline-re-parsing' to t while
archiving for better speed.
2021-11-30 20:17:56 +08:00
Ihor Radchenko d8a1f34cf6
org-element--current-element: Use explicit regexp to match headline
* lisp/org-element.el (org-element--current-element): Do not call
`org-at-heading-p' to determine if we are at headline element.
`org-at-heading-p' calls `beginning-of-line' and may match
non-headlines as headlines.
2021-11-30 20:17:56 +08:00
Ihor Radchenko 4a2cf81dfb
org-element--cache-for-removal: Fix handling edits before first section
* lisp/org-element.el (org-element--cache-for-removal): Consider edits
within blank before first section destructive and make cache delete
the section even though the edits are technically before its
beginning.
2021-11-30 20:17:55 +08:00
TEC bb6f328847
org-src: Implement native inline src fontification
* lisp/org-src.el (org-fontify-inline-src-blocks,
org-fontify-inline-src-blocks-1): Create a function to search the buffer
up to a limit for inline src blocks.  Light fontification is applied to
matched inline src blocks.  When `org-src-fontify-natively' is
set, `org-src-font-lock-fontify-block' is applied to the content.

* lisp/org.el (org-set-font-lock-defaults): Add
`org-fontify-inline-src-blocks' to `org-font-lock-extra-keywords', which
is locally bound inside `org-set-font-lock-defaults'.

* lisp/org-faces.el: Introduce a new face `org-inline-src-block' which
inherits from `org-block' by default.
2021-11-30 12:14:11 +08:00
Sun Lin f9dcc3d665
ob-plantuml: fix DISPLAY error with html export
* lisp/ob-plantuml.el (org-babel-execute:plantuml): Use headless mode
for Org calling plantuml for exporting to html to avoid issues with
operations that normally try to access the system graphics stack.
2021-11-30 12:14:11 +08:00
Nicolas Goaziou 0bf211a340 oc: Opportunistically load processors
* lisp/oc.el (org-cite--get-processor): Try requiring 'oc-NAME where
name is the name of the processor used.
(org-cite-register-processor): Do not use `org-cite--get-processor' to
avoid circular requires.

Suggested-by: Timothy <tecosaur@gmail.com>
<http://lists.gnu.org/r/emacs-orgmode/2021-11/msg00664.html>
2021-11-29 23:46:00 +01:00
TEC 9ce7802b79
ob-tangle: allow ls -l style suid/sgid tangle mode
* lisp/ob-tangle.el (org-babel-interpret-file-mode): Modify the regexp
for the ls -l style tangle file mode to allow for the suid/sgid bits to
be set.  While I was at it I noticed that the a= parameter should have
been o=, and so that has been fixed too.

The sticky bit is ignored, but that is not a concern as it is only
relevant to directories.
2021-11-30 02:48:03 +08:00
Nicolas Goaziou 5e35de34a6 Merge branch 'bugfix' 2021-11-28 20:44:44 +01:00
Rasmus c91271297d ox-latex: Fix asynchronous export
* lisp/ox-latex.el (org-latex-export-to-pdf): Fix "invalid-read-syntax
'#'" when exporting asynchronously with ox-latex.

See also previous bug report: https://lists.gnu.org/archive/html/emacs-orgmode/2021-06/msg00422.html
2021-11-28 20:44:22 +01:00
Stefan Kangas 36086a4f49 Backport commit 1fffe9a21 from Emacs
; * lisp/org/org.el: Fix version header.
1fffe9a210d328559da2af8facbb75286a31c74e
Stefan Kangas
Sun Nov 28 14:54:24 2021 +0100
2021-11-28 10:46:50 -05:00
Ihor Radchenko c84c71b093
org-element-at-point: Report POM when parser throws error
* lisp/org-element.el (org-element-at-point): Mention the value of POM
in warning text when `org-element--parse-to' fails with error.
2021-11-27 12:20:33 +08:00
Ihor Radchenko e1aebc1a41
org-element--cache-for-removal: Error out of irrecoverable failure
* lisp/org-element.el (org-element--cache-for-removal): Consider wrong
parent to be critical failure: reset the cache and abort current
command.
2021-11-27 12:08:45 +08:00
Ihor Radchenko 49df468849
org-element-cache-map: Report pre-process time in statistics
* lisp/org-element.el (org-element-cache-map): Calculate time elapsed
while filling the cache gaps during pre-processing.
2021-11-27 12:08:44 +08:00
Nicolas Goaziou 8ddd95e5a3 Merge branch 'bugfix' 2021-11-26 12:20:59 +01:00
Nicolas Goaziou afc5ec2187 oc-csl: "Barf" functions should actually barf
* lisp/oc-csl.el (org-cite-csl--barf-without-citeproc): Actually raise
an error, as expected from the docstring.
2021-11-26 12:20:36 +01:00
Nicolas Goaziou 25640ace0f Merge branch 'bugfix' 2021-11-26 11:44:30 +01:00
Nicolas Goaziou 2b0007a808 ox: Add autoload cookies
* lisp/ox.el (org-export-derived-backend-p):
(org-export-data):
(org-export-raw-string): Autoload function.

These functions are required at runtime by some other libraries (e.g.,
"oc-basic.el"), which cannot require `ox' because of circular
dependencies.

In particular, this fixes
<http://lists.gnu.org/r/emacs-orgmode/2021-11/msg00594.html>.
2021-11-26 11:40:28 +01:00
Ihor Radchenko 20ed794b92
org-element-parse-buffer: Avoid excessive garbage collection
* lisp/org-element.el (org-element-parse-buffer): Increase
`gc-cons-threshold' to improve performance.  In my tests on large Org
buffers, garbage collection took 50% of the time without increasing
the threshold.
2021-11-25 18:39:24 +08:00
Ihor Radchenko 08e595f312
org-agenda-get-scheduled: Fix wrong matches when WITH-HOUR is non-nil
* lisp/org-agenda.el (org-agenda-get-scheduled): Do not rely on regex
match to judge that current headline is scheduled with time when
WITH-HOUR argument is non-nil.  Limit regexp search when looking for
scheduled timestamp in current headline and intentionally signal
search error if something went wrong (headline without scheduled
timestamp in planning line must not be encountered at this point in
the code).

This commit continues 77a9932b0 and 82197761.
2021-11-25 18:39:11 +08:00
Nicolas Goaziou b3cc2f793b Merge branch 'bugfix' 2021-11-24 22:51:41 +01:00
Nicolas Goaziou 30a6126bb9 oc: Fix `org-cite-fontify-default' docstring and simplify code
* lisp/oc.el (org-cite-fontify-default): We don't need to assume
activate processor may be used on a citation reference: that will not
happen.
2021-11-24 22:50:09 +01:00
Nicolas Goaziou 308f4cb570 oc: Ensure activation returns a non-nil value
* lisp/oc.el (org-cite-activate): Return a non-nil value when
successful, even if citation processor doesn't.
2021-11-24 22:39:50 +01:00
Ihor Radchenko e76c29a586
org-element-cache-map: Update docstring 2021-11-24 20:09:56 +08:00
Ihor Radchenko cc3b468657
org-element-cache: Use 'org-element-cache warning type
* lisp/org-element.el (org-element--cache-log-message):
(org-element--cache-warn): Use special 'org-element-cache warning
type to display warnings.
2021-11-24 20:09:55 +08:00
Bastien 77a9932b03 lisp/org-agenda.el:
* lisp/org-agenda.el (org-agenda-get-scheduled): Don't throw an
error when the search for the regular expression fails.

This completes 82197761.
2021-11-24 09:02:28 +01:00
Ihor Radchenko 4b1def3c5c
org-table.el: Do not create new field when at EOL after table line
* lisp/org-table.el (org-table-justify-field-maybe): Do not treat "|$"
as unclosed table field.

Fixes https://orgmode.org/list/trinity-2561db57-1561-470b-982f-0d91ddf4f145-1629900012884@3c-app-mailcom-lxa06
2021-11-23 21:40:58 +08:00
Ihor Radchenko b5f992b678
org-table.el: Do not create new field when at EOL after table line
* lisp/org-table.el (org-table-justify-field-maybe): Do not treat "|$"
as unclosed table field.

Fixes https://orgmode.org/list/trinity-2561db57-1561-470b-982f-0d91ddf4f145-1629900012884@3c-app-mailcom-lxa06
2021-11-23 21:14:44 +08:00
Ihor Radchenko dd173bf451
org-get-buffer-tags: Use cache 2021-11-23 21:14:43 +08:00
Matt Huszagh 912cf21494
org.el: Fix missing arg in string-match-p call
* lisp/org.el (org-display-inline-image--width): `string-match-p'
requires two arguments, but the second one was missing.
2021-11-23 13:40:40 +08:00
Kyle Meyer 27f26f7829 org-display-inline-image--width: Fix syntax error from last commit
* lisp/org.el (org-display-inline-image--width): Fix unbalanced
parentheses and reference to free variable introduced in last commit.
2021-11-22 23:44:15 -05:00
TEC 4514a324c8
org: More carefully interpret image width attrs
* lisp/org.el (org-display-inline-image--width): Before attempting to
interpret a :width attribute numerically, check that it indeed starts
with a digit and use the default value given by `org-image-actual-width'
if not.  However, if a value of "t" is given, treat this as if
`org-image-actual-width' were "t" and just use the image's pixel width.

This change fixes a strange behaviour where a non-numeric width would
previously display the image with zero width.
2021-11-23 01:52:19 +08:00
Ihor Radchenko 17d4b31a84
org-element--cache-before-change: Make sure that rx expr is always valid
* lisp/org-element.el (org-element--cache-before-change): Make sure
that we never construct (repeat 1 0 "*") rx expr.

Hopefully fixes https://list.orgmode.org/d8749145-29b9-39d6-5bbe-4b7e765792e5@ctpowe.net/T/#u
2021-11-22 19:38:36 +08:00
Ihor Radchenko 7a14d6035c
Fix element property queries for inlinetasks
* lisp/org.el (org-get-tags): Do not ignore local tags in inlinetasks.
(org-in-commented-heading-p): Do not ignore commented inlinetasks.
* testing/lisp/test-org.el (test-org/get-tags): Add tests for
inlinetasks.

Fixes https://list.orgmode.org/CAKJdtO8-KkVvhcviTqhi+DMZmSK=o37jn1jJPM9qxcuXZPnGgw@mail.gmail.com/T/#u
2021-11-22 19:34:21 +08:00
Matt Huszagh cd3e138ee5
org.el: Improve inline image width calculation
* lisp/org.el (org-display-inline-image--width): When
display-line-numbers-width is nil, the width is computed dynamically.
This does not mean that the line number width is necessarily 0.
2021-11-22 03:13:04 +08:00
Ihor Radchenko 54da1d6d7b
org-element--cache-process-request: Fix phase 2 with nil parent field
* lisp/org-element.el (org-element--cache-process-request): Fix
potential error raised when merging phase 2 requests with current
request having nil parent field.

Should help with https://list.orgmode.org/PAXPR08MB664034C85DDC73D21AD1CB0FA39E9@PAXPR08MB6640.eurprd08.prod.outlook.com/T/#t
2021-11-21 17:52:40 +08:00
Ihor Radchenko 28d47cfb82
org-element--cache-sync: Do not show warning on known safe modifications
* lisp/org-element.el (org-element--cache-sync): Do not raise warning
when `buffer-chars-modified-tick' changes safely outside
org-element-cache visibility.  Safe modifications are detected
according to heuristics based on `buffer-chars-modified-tick' and
`buffer-modified-tick'.  Their difference contains footprint for some
known [1,2,3] modifications triggered by Emacs internals.  However,
still reset cache to avoid false-positives for all but one [1] type of
modification.

[1] https://lists.gnu.org/archive/html/bug-gnu-emacs/2021-11/msg01069.html
[2] https://list.orgmode.org/YYy9Hx8mNQN08U7e@smoon.bkoty.ru/T/#t
[3] https://list.orgmode.org/87ee7jdv70.fsf@localhost/T/#t
2021-11-21 16:26:00 +08:00
Clément Pit-Claudel ebd06c15b5
org-src: Reset buffer-modified-p after fontifying
* lisp/org-src.el (org-src-font-lock-fontify-block): Reset the
modification flag of the temporary fontification buffer after
fontifying.

Without this some modes cause Emacs to prompt about unsaved buffers
when exiting: "Save buffer *org-src-fontification:...-mode*?".
2021-11-21 14:59:43 +08:00
Kyle Meyer 27edae8ced tangle: Fix :version keyword of org-babel-tangle-default-file-mode
* lisp/ob-tangle.el (org-babel-tangle-default-file-mode): Prefer
":package-version" to ":version".

The :version keyword should correspond to the Emacs version.  Using
the Org version leads to an incorrect help message:

  This variable was introduced, or its default value was changed, in
  version 9.6 of Emacs.

Instead go through :package-version so that the displayed message is

  This variable was introduced, or its default value was changed, in
  version 9.6 of the Org package that is part of Emacs 29.1.
2021-11-20 14:36:21 -05:00
Kyle Meyer 58cc9efd7d Update customize-package-emacs-version-alist
* lisp/org.el (customize-package-emacs-version-alist): Map Org 9.6 to
Emacs 29.1.

Emacs 28.1 is nearing release.  The earliest Emacs version that Org
9.6 would be synced with is 29.1.
2021-11-20 14:36:10 -05:00
TEC e6ae351f96
ob-tangle: Rename org-babel-tangle-default-mode
* lisp/ob-tangle.el (org-babel-tangle-default-mode,
org-babel-interpret-file-mode): Rename `org-babel-tangle-default-mode`
to the slightly more apt `org-babel-tangle-default-file-mode`, and
update `org-babel-interpret-file-mode` accordingly.
2021-11-21 03:06:19 +08:00
Nicolas Goaziou 1db301a758 element: Drop `org-end-of-subtree' use
* lisp/org-element.el (org-element-headline-parser): Implement
a simple end of subtree search instead of relying on
`org-end-of-subtree'.
2021-11-20 19:54:41 +01:00
Kyle Meyer 69dbe86625 org-element: Silence byte-compiler
* lisp/org-element.el (org-element--cache-gapless): Move definition
before first use to remove byte-compiler warning about assignment to
free variable.
2021-11-20 13:52:48 -05:00
Bruce D'Arcus 9b398ba626 oc-basic: Add function to shorten names
* lisp/oc-basic.el (org-cite-basic--shorten-names): new function to
shorten author names

* lisp/oc-basic.el (org-cite-basic--print-entry): shorten author name
list for the "plain" output style
2021-11-20 19:40:36 +01:00
TEC 048f478799
ob-tangle: Make ls-style file mode regex stricter
* lisp/ob-tangle (org-babel-interpret-file-mode): Instead of allowing 9
characters from [rwx-], require [r-][w-][x-] repeated thrice.  This no
longer allows invalid ls-style file modes.
2021-11-20 22:57:20 +08:00
TEC ff6fd93876
ob-tangle: Check that integer file modes are valid
* lisp/ob-tangle.el (org-babel-interpret-file-mode): Check that the
integer as an octal represents a valid file mode, and complain
otherwise.
2021-11-20 22:57:20 +08:00
TEC 3a6686010e
ob-tangle: Use oXXX as file mode octal shorthand
* lisp/ob-tangle (org-babel-interpret-file-mode): Accept "o755" and
similar as octal shorthand. A non-digit character must be included as
otherwise `org-babel-parse-header-arguments' will convert it to a
base-10 integer.
2021-11-20 22:57:20 +08:00
Nicolas Goaziou 26e68816bd element: Integrate some syntax constants
* lisp/org-element.el (org-element-archive-tag):
(org-element-clock-line-re):
(org-element-comment-string):
(org-element-closed-keyword):
(org-element-deadline-keyword):
(org-element-scheduled-keyword):
(org-element-planning-keywords-re):
(org-element-planning-line-re):
(org-element-drawer-re):
(org-element-dynamic-block-open-re):
(org-element-headline-re): New constants.
(org-element-drawer-parser):
(org-element-dynamic-block-parser):
(org-element--footnote-separator):
(org-element--get-node-properties):
(org-element--get-time-properties):
(org-element-headline-parser):
(org-element-headline-interpreter):
(org-element-inlinetask-parser):
(org-element--list-struct):
(org-element-paragraph-parser):
(org-element-planning-parser):
(org-element-planning-interpreter):
(org-element--current-element):
(org-element--cache-for-removal):
(org-element-cache-map):
(org-element-context): Use new constants so as to not use org.el's.
* testing/lisp/test-org-element.el (test-org-element/headline-comment-keyword):
(test-org-element/headline-archive-tag):
* testing/lisp/test-ox.el (test-org-export/handle-options): Fix tests.
2021-11-20 11:37:52 +01:00
Nicolas Goaziou 652e8db821 Merge branch 'bugfix' 2021-11-19 09:53:56 +01:00
Nicolas Goaziou a51e4dc710 ox-icalendar: Fix error dangling footnotes
* lisp/ox-icalendar.el (icalendar): Add an inner-template function so
as to not use "ox-ascii"'s.
(org-icalendar-inner-template): New function.

This fixes <https://lists.gnu.org/archive/html/emacs-orgmode/2013-04/msg01478.html>
and <http://lists.gnu.org/r/emacs-orgmode/2021-11/msg00395.html>.

Footnote definition is lost, but references are already removed from
the description anyway, so the problem is not worse.
2021-11-19 09:53:13 +01:00
Jeremie Juste 58db28db04
ob-R: Tidy up bits of the async implementation
* ob-R.el (ob-session-async-org-babel-R-evaluate-session): Use
defvaralias for `ess-eval-visibly-p' instead of modifying user-defined
variable.  Remove temporary declaration that silences the byte-compiler.

* ob-R.el (org-babel-R-evaluate,
ob-session-async-org-babel-R-evaluate-session, org-babel-R-evaluate):
Remove mentions of unused argument `result-params'.
2021-11-18 18:42:38 +08:00
TEC fa97f9a395
ob-tangle: Accept more :tangle-mode forms
* lisp/ob-tangle.el (org-babel-tangle): Accept many more forms for
:tangle-mode, including octal strings (#o755, 0755, 755), ls forms (rwx,
rw-r--r--), and chmod forms (a=rw,u+x).  The interpretation of the input
is now handled by the new function `org-babel-interpret-file-mode' which
references the new variable `org-babel-tangle-default-mode' when
considering relative mode forms.
2021-11-18 18:18:00 +08:00
Ihor Radchenko faf8ce7dee
org-element--cache-sync: Ignore some more silent changes
* lisp/org-element.el (org-element--cache-sync): Add heuristics
skipping silent buffer changes made by quail.el when inserting "S-\"
using computer-russian input method.

Reported in https://list.orgmode.org/smre9o$hn1$1@ciao.gmane.io/
2021-11-15 19:39:29 +08:00
Ihor Radchenko bc3f385c97
org-element--cache-diagnostics-modifications: Fix docstring width 2021-11-15 19:39:28 +08:00
Ihor Radchenko fefb867d91
org-persist-write-all: Fix when BUFFER is nil 2021-11-15 19:39:17 +08:00
Nicolas Goaziou 2bbac432a8 org-element: Remove dependency on ’org-emph-re’
* lisp/org-element.el (org-element--parse-generic-emphasis): New fuction.
(org-element-bold-parser):
(org-element-code-parser):
(org-element-italic-parser):
(org-element-strike-through-parser):
(org-element-underline-parser):
(org-element-verbatim-parser): Use new function.

The consequence of this patch is that the syntax does not inherit from
unrelated limitations from ‘org-emph-re’, i.e., the number of lines
allowed in the markup.
2021-11-15 10:47:03 +01:00
Nicolas Goaziou c47b535bbd org-element: Remove dependency on ‘org-emphasis-regexp-components’
* lisp/org-element.el (org-element--set-regexps): Hard-code syntax,
since this is not configurable.
2021-11-14 15:13:41 +01:00
Ihor Radchenko 577b987972
org-element-cache: Honour org-odd-levels-only
* lisp/org-element.el (org-element--parse-to): Fix incorrect heading
regexps when `org-odd-levels-only' is non-nil.
(org-element--cache-before-change): Use reduced level for
`org-element--cache-change-warning' when headlines are modified.
2021-11-14 15:09:47 +08:00
Ihor Radchenko c3f4573758
org-element--cache-sync: Fix warning about unregistered modifications
* lisp/org-element.el (org-element--cache-diagnostics-modifications):
New variable to enable/disable warnings when unregistered
modifications are detected in Org buffers.
* lisp/org-element.el (org-element--cache-sync): Only show
"Unregistered modification" warning when
`org-element--cache-diagnostics-modifications' is non-nil or during
Org tests.  Add special handling for unregistered changes by
`replace-match' in Emacs <28.

Fixes https://list.orgmode.org/87pmr6lu1y.fsf@localhost/T/#t
2021-11-14 14:48:43 +08:00
Ihor Radchenko d8606c316e
org-element--cache-sync: Handle silent changes for non-latin input methods
* lisp/org-element.el (org-element--cache-sync): Detect silent changes
in buffer made by quail.el when non-latin input methods are active.
These silent changes do not modify the buffer, but only change
`buffer-chars-modified-tick' and do no affect element cache.  Note
that the detection uses heuristics.

Fixes https://list.orgmode.org/87sfw2luhj.fsf@localhost/T/#you
2021-11-13 22:43:44 +08:00
Ihor Radchenko 494c203639
org-element-at-point: Fix breakage when called at the end of section
* lisp/org-element.el (org-element-at-point): Do no unconditionally
return first matching cached element when point is within blank lines
after section element and CACHED-ONLY is non-nil.

Fixes https://list.orgmode.org/smbl59$qjm$1@ciao.gmane.io/T/#u
2021-11-10 21:23:08 +08:00
Nicolas Goaziou e961125768 oc: Fix docstring typos
* lisp/oc.el (org-cite-make-insert-processor): Fix typos in docstring.
Fill mostly under 60 characters.
2021-11-10 11:47:22 +01:00
Ihor Radchenko 876e813334
org-persist.el: Fix Emacs versions where xdg.el is not available
* lisp/org-persist.el (org-persist-directory): Make `xdg-cache-home'
call optional.  Prefer cache directory in `user-emacs-directory' when
the cache already exists there.

Fixes https://list.orgmode.org/CAFqubHf+WpuNEEapKcG94WjHFcRxVSF+j-7Ut3b_roMfKQchhg@mail.gmail.com/T/#m99c63439a745c07fd7c30cde0b49b3d5bd1757f0
2021-11-10 09:45:16 +08:00
Ihor Radchenko ded97b7672
org-element.el: Fix regression from d3836c1a1
* lisp/org-element.el: Do not require `backtrace'.  It is not
available in Emacs 26.
(org-element--cache-sync, org-element-at-point): Do not try to show
backtrace in warning when `backtrace' library is not available.

Reported in https://list.orgmode.org/d20a8753-8d0a-b4bf-c3fc-bce2f0a22392@gmail.com/T/#u
2021-11-09 08:39:20 +08:00
Marco Wahl 35e21b6161
org-goto: Fix UI
* lisp/org-goto.el (org-goto-location): Drop the wrap by
`org-no-popups'.  This restores the expected functionality of org-goto
with interface type 'outline.

See ml: https://list.orgmode.org/87mtnovv7f.fsf@alphapapa.net/.
2021-11-09 00:14:10 +08:00
Ihor Radchenko d3836c1a13
org-element.el: Add missing require for `backtrace' 2021-11-08 22:11:27 +08:00
Ihor Radchenko 343e228d6d
org-element-at-point: Provide more helpful warning in case of error
* lisp/org-element.el (org-element-at-point): Print current backtrace
when `org-element--parse-to' throws error.
2021-11-07 12:36:53 +08:00
Juan Manuel Macías 85998490d9 ox-latex: add `options' latex attribute to tables
* lisp/ox-latex.el (org-latex--org-table): The `:options' LaTeX
attribute allows adding an optional argument (`\begin{env}[opt]'),
since certain tabular environments, such as `longtblr', accept optional
arguments.
* doc/org-manual.org (Tables in LaTeX export): this feature in the manual.
* etc/ORG-NEWS (New :options attribute when exporting tables to
LaTeX): this feature in `ORG-NEWS'.
2021-11-06 14:50:27 +01:00
Ihor Radchenko 1492fc5857
org-element--cache-persist-before-write: Avoid saving in non-org buffers
* lisp/org-element.el (org-element--cache-persist-before-write): Do
not try to save cache when buffer is not in Org mode and when cache is
not initialised.

Fixes https://list.orgmode.org/CAFyQvY1rEbL8LJWSR-q6sNgwS1_+Assyd=Jmv1YgeeQ_R3Yn5g@mail.gmail.com/T/#u
2021-11-05 22:21:33 +08:00
Ihor Radchenko ced2b33357
org-element--parse-to: Fix return value at the and of first section
* lisp/org-element.el (org-element--parse-to): Fix edge case when
calling `org-element--parse-to' at contents end point of first
section.  We need to return outermost element ending before point in
such scenario.

Fixes https://list.orgmode.org/01bc6137-200d-8e2d-fdd7-6aad8382c619@posteo.eu/T/#u
2021-11-04 23:04:57 +08:00
Nicolas Goaziou e4ee04eeae Merge branch 'bugfix' 2021-11-03 17:50:13 +01:00
Nicolas Goaziou 4e185becbf oc-basic: Use `org-cite-main-affixes' when appropriate
* lisp/oc-basic.el (org-cite-basic-export-citation): Use
`org-cite-main-affixes' when appropriate.
2021-11-03 17:49:41 +01:00
Sébastien Miquel 975462e653 Small fix to image width computation
org.el (org-display-inline-image--width): The variable
display-line-numbers-width is nil by default.
2021-11-03 17:23:56 +01:00
Nicolas Goaziou 74b1eefa5e Merge branch 'bugfix' 2021-11-03 16:54:04 +01:00
Nicolas Goaziou d0201d5801 oc-csl: Fix global affixes
* lisp/oc-csl.el (org-cite-csl--create-structure): Properly
concatenate global affixes to the first or last cite, as intended.
2021-11-03 16:50:07 +01:00
Nicolas Goaziou e0bbfe63a4 oc-bibtex: Use `org-cite-main-affixes'
* lisp/oc-bibtex.el (org-cite-bibtex-export-citation): Call
`org-cite-main-affixes'.
2021-11-03 16:30:09 +01:00
Nicolas Goaziou 498a76857b Merge branch 'bugfix' 2021-11-03 16:29:59 +01:00
Nicolas Goaziou ad40282860 oc: Refactor affixes extraction
* lisp/oc.el (org-cite-main-affixes): New function.
* lisp/oc-natbib.el (org-cite-natbib--build-optional-arguments): Use
new function.
* testing/lisp/test-oc.el (test-org-cite/main-affixes): New test.
2021-11-03 16:27:53 +01:00
Nicolas Goaziou 073d9c6b6b Merge branch 'bugfix' 2021-11-03 16:14:27 +01:00
Nicolas Goaziou 37c99e0874 oc-basic: Also extract year from "date" field
* lisp/oc-basic.el (org-cite-basic--get-year): Try extracting year
from "date" field when "year" field is empty.  Add optional argument
to prevent disambiguation mechanism.
(org-cite-basic--print-entry):
(org-cite-basic--key-completion-table): Use `org-cite-basic--get-year'
instead of `org-cite-basic--get-field'.
2021-11-03 16:12:42 +01:00
Ihor Radchenko dc0c60f123
org-element-parse-buffer: Avoid interference with element cache
* lisp/org-element.el (org-element-copy): Make sure that element
properties containing secondary objects are also copied.
(org-element--parse-elements): Avoid modifying cached elements.

Fixes https://list.orgmode.org/CAHyO48yS2EAJnhiYoK7syjb1_Fbfxcv2A0fk4t5RFzTLj1hSGA@mail.gmail.com/
In the backtrace provided in the email, org-roam calls to
`org-element-parse-buffer' add uncached `org-data' element as cached
element `:parent' property.  Uncached elements in `:parent' property
break the cache code.
2021-11-03 19:36:41 +08:00
Nicolas Goaziou 2e99997830 Merge branch 'bugfix' 2021-11-02 18:40:04 +01:00
Nicolas Goaziou 95ad5a954b oc-csl: Small refactoring
* lisp/oc.el (org-cite-wrap-citation): Mention return value.
* lisp/oc-csl.el (org-cite-csl--create-structure): Use return value
from `org-cite-wrap-citation' instead of using `org-element-lineage'.
2021-11-02 18:39:09 +01:00
Nicolas Goaziou 7d769615fd Merge branch 'bugfix' 2021-11-02 18:34:43 +01:00
András Simonyi 16dcfdfa80 oc-csl: Fix footnote status reporting for wrapped citations
* lisp/oc-csl.el (org-cite-csl--create-structure): Update footnote information
when citation is wrapped in a footnote.
2021-11-02 18:34:28 +01:00
Nicolas Goaziou 266a151d08 Merge branch 'bugfix' 2021-11-02 15:08:37 +01:00
Vinicius f135889ca1 macro: Fix keyword macro with multiple keywords
* lisp/org-macro.el (org-macro-initialize-templates): Properly collect
multiple keywords' values with "keyword" macro.
2021-11-02 15:07:53 +01:00
Ihor Radchenko 7a6f48ab4a
org-persist-read: Do not raise warning on known read error 2021-11-01 20:47:11 +08:00
Ihor Radchenko 6621ee32e4
org-persist.el: Do not try to follow XDG on Windows
* lisp/org-persist.el (org-persist-directory): `xdg-cache-home'
apparently returns "~/.cache" even on Windows.  Fallback to
`user-emacs-directory' when the directory returned by `xdg-cache-home'
does not exist.

Reported in https://list.orgmode.org/CAPY3P0RWTkUv_5q0aJjgmpaDGzxYYrs0z4vyEF2Sxpua7BtztA@mail.gmail.com/T/#u
2021-11-01 19:28:16 +08:00
Ihor Radchenko d4e1925147
org-element--cache-warn: Provide command backtrace 2021-10-31 10:39:40 +08:00
Ihor Radchenko 49e2f6c1ab
org-element-cache-map: Check if `native-comp-available-p' is defined
Fixes https://list.orgmode.org/87tugzinxz.fsf@gmail.com/T/#u
2021-10-30 10:05:17 +08:00
Ihor Radchenko 9f87b1cc33
org-element.el: Handle cache requests inside `combine-change-calls'
* lisp/org-element.el (org-element--cache-active-p): Prevent cache
queries when `org-element--cache-after-change' is not in
`after-change-functions'.  `after-change-functions' can be temporalily
set to nil by i.e. `combine-change-calls'.  We should not try to get
information from cache in such scenarios because cache may not yet be
up-to-date.  The modifications will only be registered upon exiting
the `combine-change-calls' macro.

Fixes https://list.orgmode.org/875ytggcuk.fsf@yandex.com/T/#t
2021-10-29 22:23:18 +08:00
Ihor Radchenko 1b2d06880f
org-persist.el: Do not write global variables on buffer kill
* lisp/org-persist.el (org-persist-write-all): Prevent writing global
variables when BUFFER arg is provided.
(org-persist-gc): Handle case when :persist-file is set to nil in the
index.

Fixes https://list.orgmode.org/DB9PR08MB66336CDF0F43DE3DB1D08649A3869@DB9PR08MB6633.eurprd08.prod.outlook.com/T/#m40fcc5ea8ba0ef52518a58713cf9ad3d1fffa33d
2021-10-28 22:32:50 +08:00
Ihor Radchenko 5abd149cf1
org-persist-write: Do not try to write cache when killing indirect buffer 2021-10-28 09:11:14 +08:00
Ihor Radchenko 91523479fb
org-scan-tags: Fix `org-agenda-change-all-lines' when prefix has effort
* lisp/org.el (org-scan-tags): Add `effort' and `effort-minutes' to
full agenda line, not just its heading string part.
`org-agenda-change-all-lines' expects the properties to be at BOL.
2021-10-27 23:44:41 +08:00
Ihor Radchenko b135b8c7ae
org-element-cache: Rename `interrupt' `org-element--cache-interrupt'
* lisp/org-element.el (org-element--cache-sync,
org-element--cache-process-request, org-element--parse-to): Some other
code (at least, `org-indent-mode') is using `interrupt' signal in
`after-change-functions'.  Rename `interrupt' signal used in
org-element-cache to unique `org-element--cache-interrupt'.

Reported in https://list.orgmode.org/PAXPR08MB66400699DACEB31F4F0650F1A3849@PAXPR08MB6640.eurprd08.prod.outlook.com/T/#u
2021-10-27 23:12:04 +08:00
Ihor Radchenko cc3df3af2a
org--backward-paragraph-once: Fix infinite loop at first element in section
* lisp/org.el (org--backward-paragraph-once): Do not consider section
parent as greater element.  section elements starts at the same point
with its first child and we do not want to "move" from beginning of
child to the beginning of the section.

Fixes https://list.orgmode.org/87cznsnql6.fsf@localhost/T/#t
2021-10-27 23:09:02 +08:00
Ihor Radchenko 5ca866d08a
org-persist.el: Detect buffer-locals vars for moved files
* lisp/org-persist.el (org-persist--get-index): Match buffer inode and
hash if path does not match.
(org-persist-read-all): Do not require file path match before trying
to read local variables.
(org-persist-read): Do not try to read non-existing data.
2021-10-27 22:51:43 +08:00
Ihor Radchenko 994cad9fed
org-element.el/org-element--cache-self-verify: Update docstring
* lisp/org-element.el (org-element--cache-self-verify): Mention
`org-element--cache-self-verify-frequency' in the docstring.
2021-10-27 17:43:36 +08:00
Ihor Radchenko 52cdf53328
Revert "org-do-emphasis-faces: Never treat closing marker as next opening marker"
This reverts commit fa315986a1.

The commit broke fontification of nested emphasis like
/italic *bold* more italic/.
2021-10-27 14:51:29 +08:00
Ihor Radchenko f2b52f411c
org.el/org-scan-tags: Fix effort in tags agenda views
* lisp/org.el (org-scan-tags): Manually add effort and effort-minutes
properties to be used by agenda.
2021-10-27 11:11:03 +08:00
Ihor Radchenko 801be9dcd0
org-element-cache-map: Reduce regexp search overheads
* lisp/org-element.el (org-element--cache-gapless): New variable
tracking when cache does not contain gaps.
(org-element-cache-reset): Initialise `org-element--cache-gapless'.
(org-element-cache-map): Fill the cache gaps before running FUNC
query.  When multiple calls to `org-element-cache-map' are done on
unchanged buffer, pre-processing only requires a single regexp search
pass across i.e. headlines.  Subsequent `org-element-cache-map' calls
can then be reduced to a simple cache tree walk.
2021-10-27 11:11:03 +08:00
Ihor Radchenko 244bc7d174
org-element-cache-map: Improve compiled function check
* lisp/org-element.el (org-element-cache-map): Do not try to
byte-compile subroutines and natively compiled functions.
2021-10-27 11:11:02 +08:00
Ihor Radchenko cf8906eee0
org-agenda-get-todos: Fix effort-up sorting in todo agenda
* lisp/org-agenda.el (org-agenda-get-todos): Calculate effort-minutes
before adding it as text property in agenda line.

Reported in https://old.reddit.com/r/emacs/comments/qfqcip/sorting_by_effort_doesnt_work_on_latest_org/
2021-10-26 09:47:58 +08:00
TEC 9dc08c9093
org: Don't change image size based on font size
* lisp/org.el (org--create-inline-image): Set :scale parameter to 1 to
prevent font-size based rescaling.

When `create-image' is called without the :scale parameter, the image
size is expanded based on the default font size (if it is larger than
10px).  When displaying images with a specified width in Org buffers,
either in pixels or proportional to the text width, this width should
not be modified according the to font size.  Giving a :scale parameter
of 1 prevents this font-size based rescaling.
2021-10-25 21:48:04 +08:00
TEC 76f33fea31
oc-csl: Support bare author citations
* lisp/oc-csl.el (org-cite-csl--create-structure-params): Add support
for bare (b), bare-caps (bc), bare-full (bf), and bare-caps-full (bcf)
author citation styles.
2021-10-25 21:46:26 +08:00
Ihor Radchenko 4c6595d2b4
org-in-archived-heading-p: Use ELEMENT arg more optimally
* lisp/org.el (org-in-archived-heading-p): Do not check for point
position when ELEMENT is provided and use ELEMENT when checking
archive status of ancestors.
2021-10-25 19:15:14 +08:00
Ihor Radchenko 30f1f187d1
org-element-cache-map: Improve speed
* lisp/org-element.el (org-element-cache-map): Remove unnecessary
expensive let binding.
2021-10-25 19:13:23 +08:00
Ihor Radchenko 5f4fd0880a
org--get-expected-indentation: Consider section parent type
* lisp/org.el (org--get-expected-indentation): Consider new :parent
structure when `org-element-at-point' returns parent section and
headline elements.

* testing/lisp/test-org.el (test-org/indent-region): Add test.

Fixes https://list.orgmode.org/87pmrupu0s.fsf@gmail.com/T/#t
2021-10-24 19:46:00 +08:00
Ihor Radchenko e2fa3c4c40
org-element-cache-map: Increase minimal Emacs version in 717a847d6
* lisp/org-element.el (org-element-cache-map): Do not byte-compile
FUNC in Emacs 28 as well.  Some variants of Emacs 28 do not
byte-compile the lambda correctly [1].

[1] https://list.orgmode.org/87tuha62rq.fsf@localhost/T/#ma9f23ef9e96de01c53451f40d097e4ce2fd51571
2021-10-24 16:38:52 +08:00
Nicolas Goaziou d2f4d4b457 Merge branch 'bugfix' 2021-10-23 14:33:18 +02:00
Nicolas Goaziou 52e6f1cf57 macro: Properly collect multiple authors
* lisp/org-macro.el (org-macro--collect-macros): Multiple lines are
allowed for AUTHOR keyword (per `org-export-options-alist') so make
sure we collect all of them.
* testing/lisp/test-org-macro.el (test-org-macro/author): Add test.

Reported-by: Vinicius Vinicius <vinicius.vin@yandex.com>
<http://lists.gnu.org/r/emacs-orgmode/2021-10/msg00727.html>
2021-10-23 14:32:00 +02:00
Ihor Radchenko 717a847d64
org-element-cache-map: Do not byte-compile FUNC in older Emacs
* lisp/org-element.el (org-element-cache-map): Fix reported bug [1]
when some agenda items are missing when `org-element-cache-map' is
called from `org-agenda-get-scheduled'.  Byte compilation of FUNC
matcher somehow fails to produce equivalent function in Emacs <28.

[1] https://list.orgmode.org/87tuha62rq.fsf@localhost/T/#t
2021-10-23 19:34:35 +08:00
Nicolas Goaziou d3143feaf7 Fix sloppiness when collecting keywords
* lisp/org.el (org--collect-keywords-1): Use an accurate
function instead of an approximation. Accuracy trumps speed when parsing.
* testing/lisp/test-org.el (test-org/collect-keywords): New test.
2021-10-23 11:18:10 +02:00
Ihor Radchenko 6ca685c3c5
org-element.el: Encourage bug reports in case of cache issues
* lisp/org-element.el (org-element--cache-remove,
org-element--cache-sync, org-element--cache-process-request,
org-element--parse-to, org-element--cache-for-removal,
org-element--cache-verify-element, org-element-at-point): Update
warning messages.
2021-10-23 14:09:15 +08:00
Ihor Radchenko 0a92b2db19
org-element.el: Allow user to interrupt cache sync by default
* lisp/org-element.el (org-element--cache-interrupt-C-g,
org-element--cache-interrupt-C-g-max-count,
org-element--cache-interrupt-C-g-count): Add docstring and change
default value of `org-element--cache-interrupt-C-g' to t.
(org-element--parse-to): Show informative message when user tries to
interrupt in the middle of cache sync.
2021-10-23 14:02:44 +08:00
Ihor Radchenko 5315773e8a
Fix "Variable binding depth exceeds max-specpdl-size"
* lisp/org-persist.el (org-persist-register): Fix `add-hook' args.

Reported in:
https://list.orgmode.org/8735ouxz6y.fsf@yandex.com/
https://list.orgmode.org/1012598.1634829727@apollo2.minshall.org/T/#u
2021-10-21 23:58:03 +08:00
Ihor Radchenko 79971b748d
org-element.el: Prevent cache key collisions
* lisp/org-element.el (org-element--cache-sync,
org-element-cache-reset): Do not use `buffer-chars-modified-tick' as
`org-element--cache-sync-keys-value'.  Instead, make sure that
`org-element--cache-sync-keys-value' is always changed upon completing
cache request sequence.  Using `buffer-chars-modified-tick' can
trigger using obsolete sync keys after we add elements to cache via
`org-element--parse-to' after cache sync is completed, but no other
changes were made in the buffer.  The newly added elements are then
not comparable with the obsolete sync keys.

(org-element--cache-persist-before-write): Cleanup
`:org-element--cache-sync-key' from elements before saving element
cache to file.  If we do not do it, obsolete keys may be reused
inintentionally during next Emacs session.
2021-10-21 23:38:42 +08:00
Ihor Radchenko 4eab5bd3f0
org-element: Allow force-quitting during cache sync
* lisp/org-element.el (org-element--cache-interrupt-C-g,
org-element--cache-interrupt-C-g-max-count,
org-element--cache-interrupt-C-g-count): New variables controlling
force-quitting cache sync process.  If
`org-element--cache-interrupt-C-g' is non-nil, user can force
terminating syncronisation request even in the middle of sync process
by invoking `keyboard-quit'
`org-element--cache-interrupt-C-g-max-count' times.
`org-element--cache-interrupt-C-g-count' stores the number of
invokations during current sync process.

(org-element--cache-sync): Initialise
`org-element--cache-interrupt-C-g-count' before processing sync
request.
(org-element--parse-to): Handle interruption in potentially infinite
loop.
2021-10-21 20:05:05 +08:00
Ihor Radchenko a149fdd569
org-agenda-get-scheduled: Fix deadline value when using cache
* lisp/org-agenda.el (org-agenda-get-scheduled): First `deadline'
let-binding when element cache is enabled should not be timestamp
element, but a string.  Make it so.

Reprted in https://list.orgmode.org/87tuhazs36.fsf@localhost/T/#t
2021-10-21 16:50:10 +08:00
Ihor Radchenko f7403e56eb
org-element--cache-submit-request: Re-enable future-change
* lisp/org-element.el (org-element--cache-submit-request): Re-enable
FUTURE-CHANGE argument in `org-element--cache-sync' call.  Without
this argument, cache can be processed incorrectly because elements
within changed region may be shifted and not deleted in subsequent
phase 0 request.
2021-10-21 14:58:40 +08:00
Ihor Radchenko a78282746d
org-persist.el/org-persist--read-index: Provide warning if reader fails
* lisp/org-persist.el (org-persist--read-index): Inform user when
reader fails to read existing index file.
2021-10-21 14:57:42 +08:00
Ihor Radchenko 849dd68b27
org-persist.el/org-persist--read-index: Handle reader errors
* lisp/org-persist.el (org-persist--read-index): Do not emit
unrecoverable error if index file is corrupted (i.e. empty).
2021-10-20 20:33:55 +08:00
Ihor Radchenko b9d0d06ca5
org-persist.el: Do not use hook depth unnecessarily
* lisp/org-persist.el: Do not use hook depth to define the order of
`org-persist-gc' and `org-persist-write-all'.  Rely on default
behaviour of `add-hook' instead.
(org-persist-register): Use default hook depth.
2021-10-20 14:17:44 +08:00
Ihor Radchenko 350fa065b4
org-persist.el/org-persist--get-index: Do not show warning
* lisp/org-persist.el (org-persist--read-index): Disable warning when
`org-persist-index-file' does not exist.  The warning would spam the
users with disabled cache persistance unnecessarily.

Link: https://list.orgmode.org/87o87kb64s.fsf@yandex.com/T/#u
2021-10-20 14:14:46 +08:00
Ihor Radchenko ccb0271e1a
org-persist.el: Do not add write hooks when there is no write access 2021-10-19 20:17:27 +08:00
Ihor Radchenko 2b33ef3c97
org-persist.el/org-persist-write: Do not write when no write access 2021-10-19 20:10:27 +08:00
Ihor Radchenko 46da64c4cf
org-persist.el: Fix `add-hook' priority argument 2021-10-19 20:07:31 +08:00
Ihor Radchenko c130f71036
org-persist.el: Fix typo 2021-10-19 20:07:18 +08:00
Ihor Radchenko bad854d5fa
org-persist.el: Catch write errors
* lisp/org-persist.el (org-persist--get-index): Check index file.
(org-persist--read-index): Warn when index file is missing.
(org-persist-write): Report write access errors.
2021-10-19 20:06:08 +08:00
Ihor Radchenko 3b48224994
org-persist.el: Rename `org-persist-path' to `org-persist-directory' 2021-10-19 20:05:30 +08:00
Ihor Radchenko 821977611c
org-agenda-get-scheduled: Make sure that 'org-marker is at timestamp
* lisp/org-agenda.el (org-agenda-get-scheduled): Use beginning
position of the timestamp as 'org-marker.

Fixes https://list.orgmode.org/87sfwyrcyj.fsf@gnu.org/T/#meeca619b0abd3c3b30fe5057b51c891e8de705b8
2021-10-18 16:07:40 +08:00
Ihor Radchenko d18beb7c6f
Fix effort calculation in agenda
* lisp/org-agenda.el (org-agenda-get-scheduled): Fix property symbol
in `org-element-property' call.

(org-agenda-get-todos, org-agenda-get-scheduled,
org-agenda-get-timestamps, org-agenda-get-sexps,
org-agenda-get-progress, org-agenda-get-deadlines,
org-agenda-get-blocks, org-agenda-change-all-lines): Pass effort
properties to `org-agenda-format-item'
2021-10-18 13:40:06 +08:00
Ihor Radchenko 0e912bd288
org-persist.el: Make sure that org-persist-path is absolute 2021-10-18 13:37:02 +08:00
Ihor Radchenko 7a04f3b1cd
Fix 'org-hd-marker position changed in 0ef88e2d9
* lisp/org-agenda.el (org-agenda-get-scheduled): Move to correct point
before calculating the marker position.
2021-10-17 18:48:33 +08:00
Ihor Radchenko 0ef88e2d91
org-agenda.el/org-agenda-get-scheduled: Use cache
* lisp/org-agenda.el (org-agenda-get-scheduled): Use
`org-element-cache-map' for faster agenda generation.
2021-10-17 18:29:35 +08:00
Ihor Radchenko f4bcc0cc56
Merge branch 'main' into feature/org-element-cache-new 2021-10-17 14:49:59 +08:00
Ihor Radchenko 004ac14a5b
Fix compatibility with Emacs 26
* lisp/org-compat.el (org-file-name-concat): Do not use
`string-empty-p'.
(combine-change-calls): Create a stub when `combine-change-calls' were
not yet available.
(org-replace-buffer-contents): Add compatibility function for
`replace-buffer-contents'.

* lisp/org-element.el (org-element--current-element): Do not use
`if-let'.
* lisp/org-persist.el (org-persist-gc): Do not use `when-let'.
* lisp/org-plot.el (org-plot/gnuplot): Do not use `if-let'.
* lisp/org-src.el (org-edit-src-save, org-edit-src-exit): Use
`org-replace-buffer-contents'.

* lisp/org.el (org-narrow-to-subtree, org--property-local-values,
org-entry-get-with-inheritance, org-in-commented-heading-p,
org-up-heading-safe, org-goto-first-child): Do not use
`if-let'/`when-let'.

* testing/org-test.el (org-test-at-time): Fallback to old
`decode-time' specification in older Emacs.
2021-10-17 14:34:10 +08:00
Ihor Radchenko eeb04504ef
Use XDG cache dir as default dir for cache persistance
* lisp/org-persist.el (org-persist-path): Change default dir to XDG
cache dir and fall back to `user-emacs-directory' as the last resort.
2021-10-17 12:24:32 +08:00
Ihor Radchenko 85712d6456
Add comments documenting cache diagnostics 2021-10-17 12:23:58 +08:00
Ihor Radchenko 07ca988bb4
Fix compatibility with Emacs 27
* lisp/org-compat.el: Remove `length>' alias
* lisp/org-element.el (org-element-cache-map): Suppress compiler
warning.
* lisp/org-persist.el (org-persist-register): Do not `push' into
`plist-get'.  Not supported yet in Emacs 27.
(org-persist-unregister): Do not use `length>'.  Use
`org-directory-empty-p'.
(org-persist-gc): Use `org-directory-empty-p'.
2021-10-17 11:44:33 +08:00
Ihor Radchenko abe7222ed8
Add declares to suppress compiler warnings 2021-10-17 00:01:56 +08:00
Ihor Radchenko 3c4290e668
org.el/org-scan-tags: Make use of fast `org-element-cache-map' 2021-10-17 00:00:01 +08:00
Ihor Radchenko 85e0a69567
Avoid frequent cache updates in some functions
* lisp/org.el (org-promote-subtree, org-demote-subtree,
org-paste-subtree, org--align-node-property): Group buffer changes
together and call after-change-functions once to avoid performance
degradation during cache updates.
2021-10-16 23:58:40 +08:00
Ihor Radchenko 5aeeb4f739
Use `org-element-at-point-no-context' in performance-critical places
* lisp/org-compat.el (org-mode-flyspell-verify, org-indent-line,
org-indent-region, org-indent-drawer, org-indent-block): Use
`org-element-at-point-no-context' in place of `org-element-at-point'
when we are doing changes.
* lisp/org.el (org-collect-keywords): Use direct parsing in place of
`org-elemnt-at-point'
2021-10-16 23:56:29 +08:00
Ihor Radchenko e70a8aac59
Use org-element-cache in place of text property cache in agenda
* lisp/org-agenda.el (org-agenda-skip): Use
`org-in-archived-heading-p' and `org-in-commented-heading-p' in place
of text property cache.

(org-agenda-get-todos, org-agenda-get-timestamps,
org-agenda-get-sexps, org-agenda-get-progress,
org-agenda-get-deadlines, org-agenda-get-scheduled,
org-agenda-get-blocks): Do not use text property cache in favour of
Org API functions.  The API functions use cache now.

* lisp/org-clock.el (org-element--cache-active-p): Declare function to
suppress compiler warning.

(org-clock-in): Do not use text property cache when element cache is
active.

* lisp/org-duration.el (org-duration-to-minutes): Do not change match
data.  It is needed to not break agenda---agenda relies on match data
not being altered.

* lisp/org.el (org-run-like-in-org-mode): Use element cache.
(org-refresh-category-properties): Use element cache.
(org-make-tags-matcher, org-agenda-prepare-buffers): Do not rely on
text property cache.

* testing/lisp/test-org.el (test-org/refresh-category-properties): Do
not use text property cache.
2021-10-16 23:50:21 +08:00
Ihor Radchenko fe6cefdaaf
ox.el: Support cache during export
* lisp/ox.el (org-export-ignored-local-variables): Preserve cache
state in export buffer.
(org-export--generate-copy-script): Fix cache confusion about buffer
change tic.
2021-10-16 23:41:00 +08:00
Ihor Radchenko fede2588e4
org.el/org-in-archived-heading-p: Support cache and passing element arg 2021-10-16 23:40:28 +08:00
Ihor Radchenko 86345df9ab
org.el/org-in-commented-heading-p: Support cache and passing element arg 2021-10-16 23:40:14 +08:00
Ihor Radchenko 399a29c4f4
org.el/org-up-heading-safe: Add cache support 2021-10-16 23:39:43 +08:00
Ihor Radchenko ec737554d0
org.el/org-end-of-subtree: Support cache and passing element arg 2021-10-16 23:39:11 +08:00
Ihor Radchenko d43781707b
org.el/org-goto-first-child: Support cache and passing element arg 2021-10-16 23:38:46 +08:00
Ihor Radchenko 5d162b7bcf
org.el/org-back-to-heading: Handle inlinetasks correctly
* lisp/org.el(org-back-to-heading): Rewrite `outline-back-to-heading'
considering inlinetasks.
2021-10-16 23:37:15 +08:00
Ihor Radchenko 5bf5fdbc28
org.el/org-entry-get-with-inheritance: Support cache and passing element arg
* lisp/org.el (org-entry-get-with-inheritance): Add cache support.
Add new optional argument---an element to get properties from.  Fix
getting top-level properties when a headline is located at BOB.
2021-10-16 23:33:10 +08:00
Ihor Radchenko 7b83168295
org.el/org--property-local-values: Support cache and passing element arg 2021-10-16 23:32:39 +08:00
Ihor Radchenko 78abbcd052
org.el/org-get-tags: Support cache and passing element arg
* lisp/org.el (org-fast-tag-selection): Allowing passing an element or
position as first argument.  Add cache support.
2021-10-16 23:31:15 +08:00
Ihor Radchenko 38b632d2ea
org.el/org--get-local-tags: Add cache support 2021-10-16 23:30:52 +08:00
Ihor Radchenko 7159ec0be0
org.el/org-at-planning-p: Add cache support 2021-10-16 23:30:13 +08:00
Ihor Radchenko 68a44eadac
org.el/org-narrow-to-subtree: Support cache and passing element arg 2021-10-16 23:29:11 +08:00
Ihor Radchenko bc52c4d9ab
Fix compatibility for older Emacs versions
* lisp/org-compat.el (org-length>, org-file-name-concat): Add backward
compatibility for `length>' and `org-file-name-concat'.
2021-10-16 23:26:43 +08:00
Ihor Radchenko fc80d052db
Re-implement org-element-cache and add headline support
* lisp/org-element.el (org-element-with-disabled-cache): New macro.

(org-element-greater-elements): Add new org-data element.  It
functions like a virtual headline containing the whole buffer.  The
org-data properties are like headlie properties, but according to the
top-level drawer.  org-data's category is the buffer's category as
defined by top-level property drawer, #+CATEGORY keyworsd, and the
buffer file name.

(org-element--cache-element-properties, org-element-set-element): New
variable containing properties to be transferred when updating changed
element in cache in `org-element-set-element'.

(org-element--get-node-properties): Allow parsing node propreties in
top-level drawer when new optional argument is passed.  Respect
PROPERTY+ syntax.

(org-element--get-global-node-properties): New function.  It returns
node properties for top-level property drawer.

(org-element-org-data-parser, org-element-org-data-interpreter):
Implement the new org-data element.

(org-element-headline-parser, org-element-section-parser): Add new
:robust-begin and :robust-end
properties delimiting safe changes that do not modify headline
element.

(org-element--list-struct): Fix cache update when adding a headline
inside list.

(org-element--current-element): Implement cache support.  Record
parsing mode (:mode) and parsing granularity (:granularity) in the
element properties.

(org-element-parse-buffer, org-element--next-mode): Support new
org-data element.

(org-element--parse-elements): Record parsing granularity in the
returned tree

(org-element-use-cache): Enable cache by default.

(org-element-cache-persistent): New variable controlling cache
persistance across sessions.  Enabled by default.

(org-element--cache-self-verify,
org-element--cache-self-verify-frequency,
org-element--cache-diagnostics, org-element--cache-map-statistics,
org-element--cache-map-statistics-threshold,
org-element--cache-diagnostics-level,
org-element--cache-diagnostics-ring,
org-element--cache-diagnostics-ring-size): New variables controlling
cache diagnostics and self-diagnostics.  Greatly simplifies cache
debugging.

(org-element--cache, org-element--cache-sync-requests,
org-element--cache-sync-timer): Make cache buffer-local by default.

(org-element--headline-cache): Implement separate cache storing only
headlines and inlinetasks.

(org-element--cache-size, org-element--headline-cache-size): New
variables containing cache sizes.  This is much faster than
`avl-tree-size'.

(org-element--cache-sync-requests): Update docstring explaning the
request list structure.

(org-element--cache-sync-keys-value): New variable replacing
`org-element--cache-sync-keys' hash table.  The hash table was not
reliable because it was using elements as keys.  Upon any cached
element update/shift, the keys were invalidated making cache ordering
incorrect and breaking the cache badly.  Now, the cache keys are
stored as :org-element--cache-sync-key element property and the new
variable stores marker value indicating the current sync request
cycle.  See `org-element--cache-key' for more details.

(org-element--cache-change-tic): New variable controlling buffer
modification count that is registered in cache.  This variable allows
catching "stealth" edits.

(org-element--cache-non-modifying-commands): New variable listing
commands that will not be slown down if we fill cache on the fly.

(org-element--request-key, org-element--request-beg,
org-element--request-end, org-element--request-offset,
org-element--request-parent, org-element--request-phase): New macros.
They improve code readability (especially when using nameless-mode).

(org-element--format-element, org-element--cache-log-message,
org-element--cache-warn): New macros implementing generic logging
functionality.

(org-element--cache-key): Add section and org-data element support.
Change cache key storage from hash map to :org-element--cache-sync-key
element property + `org-element--cache-sync-keys-value'.  We use the
latter to group all the cache keys during a single cache request
sequence.  Once sync request is fully complete, the
`org-element--cache-sync-keys-value' is updated making all the old
sync keys obsolete (they will still be store as element properties).

(org-element--headline-cache-root): New function returning headline
cache root.

(org-element--cache-active-p): Prevent cache updates when
`inhibit-modification-hooks' is non-nil, unless non-nil optional
argument is provided.

(org-element--cache-find): Share cache between indirect buffers and
the base buffer.  We have to do it because after-change hooks for
indirect buffer are not called in the base buffer and vice versa.  Add
support for section and org-data elements.

(org-element--cache-put): Implement new approach for cache key
storage.  Add diagnostics.  Indicate cached elements using :cached
element property.  Support cache size calculation.

(org-element--cache-remove): Invalidate parent contents when removing
element.  Support cache size calculation.  Detect cache corruption due
to misordered elements.

(org-element--cache-shift-positions): Support :robust-begin and
:robust-end element properties.

(org-element--cache-sync): Add diagnostics.  Add detailed comments.
Prevent slowdown when large cache chunks need to be deleted forcing
O(N) complexity cutoff.  In phase 2, fix cases when next request
contains deleted cache key.  In phase 2, fix scenario when newly
inserted element intersects with existing elements in cache.  In phase
2, detect obsolete parents removed from cache.

(org-element--open-end-p): New function checking if an element can
have blank lines right after its :contents-end.

(org-element--parse-to): Do not alter match data.  Process complex
parsing mode changes correctly.  Support headlines in cache.  Support
org-data parsing.  Add detailed comments.  Add diagnostics.

(org-element--cache-sensitive-re): Make list lines sensitive.

(org-element--cache-change-warning): Update docstring.  Now, the
variable can have t, nil, and number values.  Numbers are used to
provide more details about changed headlines.

(org-element--cache-before-change, org-element--cache-after-change):
Handle headline hierarchy.  Properly handle cache in indirect
buffers.

(org-element--cache-after-change): Update docstring clarifying the
return values.  Add special handling for headline and org-data
elements updating them in-place instead of removing together with the
whole contents when possible.  Use :robust-begin/:robust-end element
properties to detect robust changes.

(org-element--cache-submit-request): Add detailed comments.  Correctly
handle cache in indirect buffers.  Delegate element modifications to
`org-element--cache-for-removal'.

(org-element--cache-verify-element): New function for cache
self-verification.

(org-element--cache-persist-before-write,
org-element--cache-persist-before-read,
org-element--cache-persist-after-read): Implement cache persistance.

(org-element-cache-reset): Correctly handle cache in indirect
buffers.  Support cache persistance.  Support new cache size
calculation and new cache key schema.

(org-element-cache-map): New function analagous to `org-element-map',
but much faster.  The function overperforms org-ql written by Adam
Porter aka alphapapa [1] and reuses some ideas from there (namely,
fast element skipping via regexps).

[1] https://github.com/alphapapa/org-ql/

(org-element-at-point): The returned elements are now guaranteed to
have correct parents up to org-data.  New optional argument
CACHED-ONLY limits element search to current cache---if element is not
in cache and current command is not in cache
`org-element--cache-non-modifying-commands', the cache is not updated
and the function returns nil.  Also, support cache verification.

(org-element-at-point-no-context): New function.  It is analogous of
older `org-element-at-point' with no guarantee that :parent properties
are correct beyond direct parent heading.  This function does not
update cache and can be useful when cache updates should be avoided
for performance reasons.

* lisp/ob-core.el (org-babel-where-is-src-block-result): Support
section and org-data elements in cache.

* lisp/org-macro.el (org-macro-replace-all,
org-macro--find-keyword-value): Support org-element-cache.

* lisp/org-table.el (orgtbl-to-generic): Support org-element-cache.

* lisp/org.el (org-mode): Add cache persistance.

(org-up-element): Preserve old behaviour when error is returned for
section and org-data element.

*
testing/lisp/test-org-archive.el (test-org-archive/update-status-cookie):
Fix test when cache is active.

* testing/lisp/test-org-colview.el (test-org-colview/columns-update):
Fix test.

* testing/lisp/test-org-element.el (test-org-element/extract-element):
Add suport for new org-data element.

* testing/lisp/test-org-element.el (test-org-element/parent-property):
Fix equality check.  Parents returned by cache and `org-element-map'
may not be `eq' now.  Just `equal'.

* testing/lisp/test-org-element.el (test-org-element/context): Support
section and headline parents.
2021-10-16 23:22:18 +08:00
Ihor Radchenko 6933c1ad78
lisp/org-persist.el: New library to store data across sessions 2021-10-16 21:16:11 +08:00
Nicolas Goaziou ad224f5b8e Merge branch 'bugfix' 2021-10-15 19:45:44 +02:00
Nicolas Goaziou 745f0913fc oc-basic: Load unconditionally
oc-basic is used for opening links and for fontifying them out of the
box.
2021-10-15 19:41:11 +02:00
Marco Wahl 93132c2390 org-goto: Fix UI
* lisp/org-goto.el (org-goto-location): Drop the wrap by
`org-no-popups'.  This restores the expected functionality of org-goto
with interface type 'outline.

See ml: https://list.orgmode.org/87mtnovv7f.fsf@alphapapa.net/.
2021-10-14 12:07:49 +02:00
Nicolas Goaziou 8799422a32 Merge branch 'bugfix' 2021-10-13 22:23:03 +02:00
Nicolas Goaziou 009900d7fa oc: Add autoload cookie for `org-cite-insert'
* lisp/oc.el (org-cite-insert): Autoload function.
2021-10-13 22:22:22 +02:00
Nicolas Goaziou c83fe001c7 oc: Fix error message
* lisp/oc.el (org-cite-insert): Fix copy-pasta in error message.
2021-10-13 22:20:11 +02:00
Nicolas Goaziou 2b1fc6ba72 Merge branch 'bugfix' 2021-10-11 23:59:00 +02:00
Nicolas Goaziou 17e25c3f14 oc-csl: Map § and §§ o section locators
* lisp/oc-csl.el (org-cite-csl--label-alist): Map § and §§ o section
locators.
2021-10-11 23:58:17 +02:00
Marco Wahl d0b55739c0 org: Fix: Respect TAB in property drawer as separator
* lisp/org.el (org-property-drawer-re): Allow TAB as first
character after the property name's colon.
2021-10-11 14:08:01 +02:00
Nicolas Goaziou b5713f4f1b Merge branch 'bugfix' 2021-10-11 11:39:22 +02:00
Nicolas Goaziou 18dca3478a oc: Upon inserting citations, add a space between keys
* lisp/oc.el (org-cite-make-insert-processor): Add a space in addition
to the semicolon.
2021-10-11 11:38:18 +02:00
Nicolas Goaziou 880d4fada6 Merge branch 'bugfix' 2021-10-11 11:21:48 +02:00
Nicolas Goaziou eb40091929 oc-csl: Improve an error message
* lisp/oc-csl.el (org-cite-csl--style-file): Add missing placeholder
for format string.
2021-10-11 11:21:00 +02:00
Nicolas Goaziou 3bb0cb9398 oc: Fix § locator name
* lisp/oc-csl.el (org-cite-csl--label-regexp): § is not a word start,
so adjust regexp accordingly.  Also fix mistake introduced in
c4a357f192.
(org-cite-csl--parse-reference): Ignore any space after locator name.
2021-10-11 11:18:40 +02:00