Commit graph

17573 commits

Author SHA1 Message Date
Ihor Radchenko dc4b2772e3
org-element-cache-map: Fix an edge case with org-element-cache-continue-from
* lisp/org-element.el (org-element-cache-map): Make sure that START is
never set to -1.  It may cause infinite loops in some scenarios.
* testing/lisp/test-org.el (test-org/map-entries): Add a test catching
the reported situation.

Reported in https://list.orgmode.org/CADywB5JHAyPX99Vr02SvAqiMTD+7ss4VWVipOhKfm=iGirDPhA@mail.gmail.com/T/#t
2022-01-07 22:10:22 +08:00
Ihor Radchenko 515ce56d4e
org-element-cache: Fix transforming keywords to affiliated
* lisp/org-element.el (org-element--cache-for-removal): Consider
preceding keywords to be updated unconditionally.
(org-element-cache-map): Fix infinite loop revealed by the new test.

* testing/lisp/test-org-element.el (test-org-element/cache-affiliated):
New test.
2022-01-07 21:24:43 +08:00
Ihor Radchenko a98ae424d2
org-element-cache: Give user more control over silent modificatoin checks
* lisp/org-element.el (org-element--cache-silent-modification-check):
New variable allowing the user to suppress modification checks completely.
* lisp/org-element.el (org-element--cache-sync): Support
`org-element--cache-silent-modification-check'.

The existing heuristics for built-in non-modifying commands that
change `buffer-chars-modified-tick' is not sufficient.  At least
`capitalize-word' changes the tick regardless whether the buffer was
actually modified or not.  Yet, `capitalize-word' does not call
`after-change-functions' if the buffer is not really modified.

Reported in https://list.orgmode.org/2022-01-06T12-13-17@devnull.Karl-Voit.at/T/#mb3771758f81b31721ba2f420878a4d16081dc483
2022-01-06 20:16:00 +08:00
Kyle Meyer fe70c4d259 ox-koma-letter: Collapse space in copyright line
Match the space change made in Emacs's 19dcb237b5b (; Add 2022 to
copyright years, 2022-01-01) to avoid noise when syncing to the Emacs
repo.
2022-01-01 17:47:00 -05:00
Kyle Meyer b8656a2cef Update main-only copyright years 2022-01-01 15:25:06 -05:00
Kyle Meyer aae2ac3a68 Merge branch 'bugfix' 2022-01-01 15:21:37 -05:00
Kyle Meyer 5a229cbc44 Update copyright year to 2022 2022-01-01 15:17:08 -05:00
Ihor Radchenko 06f58e4759
org-element-cache-map: Fix when FUNC deletes current element
* lisp/org-element.el (org-element-cache-map-continue-from): New
variable forcing `org-element-cache-map' to continue from a custom
point in buffer.
(org-element-cache-map): Add support for
`org-element-cache-map-continue-from'.  Update docstring accordingly.
Also, make sure that mapping terminates correctly when FUNC deletes
all elements in buffer.
* testing/lisp/test-org.el (test-org/map-entries): Add test.

Fixes https://orgmode.org/list/CADywB5KOJ1p0NpvA=iX-ybHsO=huGA8qL3xMpUTETmS2qp7_ng@mail.gmail.com
2022-01-01 14:13:26 +08:00
Ihor Radchenko eb9f34222a
ob-gnuplot: Fix regression from 23d8d59df when ox-org is not loaded
* lisp/ob-gnuplot.el (org-babel-gnuplot-table-to-data): Require
ox-org, making sure that org export backend is available.
2021-12-27 00:46:00 +08:00
Ihor Radchenko c614234688
ob-gnuplot: Use org backend when assigning table to variable
* lisp/ob-gnuplot.el (org-babel-gnuplot-table-to-data): Switch to 'org
backend when exporting table data to plain text table.  ascii backend
incorrectly handles quote transcoders that change the column width and
sometimes throws an error.  (ascii backend simply ignores transcoded
table cells and calculates width based on the initial cell text).
2021-12-27 00:45:39 +08:00
Ihor Radchenko d012350dad
org-persist: Report read/write duration
* lisp/org-persist.el (org-persist--report-time): New variable
controlling time reporting.  The default value is to report if
read/write opeartion takes over 0.5 sec.
(org-persist-write):
(org-persist-read): Display message about read/write duration for each
variable according to `org-persist--report-time'.
2021-12-25 23:36:26 +08:00
Ihor Radchenko ecce81dace
Merge branch 'bugfix' 2021-12-25 22:26:48 +08:00
Ihor Radchenko 377d6247af
org-clock-timestamps-down: Fix typo in docstring
Reported in https://lists.gnu.org/archive/html/bug-gnu-emacs/2021-12/msg01841.html
2021-12-25 22:25:24 +08:00
Bastien fbff082f73 Update to version 9.5.2
* lisp/org.el: Update to version 9.5.2.
2021-12-24 21:01:49 +01:00
Ihor Radchenko 8f50ea2d69
org-element--parse-to: Get rid of unnecessary cache lookup
* lisp/org-element.el (org-element--parse-to): Disable cache in
`org-element--current-element'.  When calling it here, we know for
sure that element at point is not yet in cache.
2021-12-24 12:30:09 +08:00
Ihor Radchenko 410afd6f37
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-12-22 23:51:51 +08:00
Ihor Radchenko e0b1a05460
org-persist-unregister: Fix when BUFFER is not 'all
* lisp/org-persist.el (org-persist-unregister): Use `string=' instead
of `eq' to compare strings.  `eq' always returns nil here.
2021-12-22 10:22:04 +08:00
Ihor Radchenko 0b670aa8e8
org-persist: Support old Emacs without file-attribute-inode-number
* lisp/org-persist.el (org-persist--get-index): Check is
`file-attribute-inode-number' function exists.  It was not there in
Emacs 25.

Fixes https://list.orgmode.org/CAJcAo8s21R1dRrxpaHV=h68RtWctLd6giFskw1vpt9fQh81dDw@mail.gmail.com/T/#u
2021-12-20 23:00:01 +08:00
Ihor Radchenko 344b99070f
org-persist.el: Make org-persist-directory a custom variable
* lisp/org-persist.el (org-persist): Create org-persist customisation
group.
(org-persist-directory): Convert into defcustom.
2021-12-20 23:00:00 +08:00
Kyle Meyer e26b825e6e Merge branch 'bugfix' 2021-12-18 13:21:14 -05:00
Kyle Meyer a18849b786 org-babel-tangle-file: Revert recent change in return value
* lisp/ob-tangle.el (org-babel-tangle-file): Restore the recently
removed prog1 so that the return value matches the documented one.
2021-12-18 13:20:45 -05:00
Kyle Meyer f4e72ffcd4 org-babel-tangle-file: Fix void variable error from last commit
* lisp/ob-tangle.el (org-babel-tangle-file): Switch let to let* to fix
void variable error.
2021-12-18 13:16:26 -05:00
Nicolas Goaziou 2b7ea20346 Merge branch 'bugfix' 2021-12-18 15:41:13 +01:00
Nicolas Goaziou aabcf9edf2 ob-tangle: Ignore narrowing when tangling a file
* lisp/ob-tangle.el (org-babel-tangle-file): Ignore narrowing in
a buffer visiting the file being tangled.
2021-12-18 15:40:25 +01:00
Ihor Radchenko d45bd627ce
Merge branch 'bugfix' 2021-12-18 21:17:43 +08:00
Ihor Radchenko 1778eb94c5
org-habit: Preserve invisibility when inserting consistency graph
* lisp/org-habit.el (org-habit-insert-consistency-graphs): Inherit
'invisible text property of the habit line when the habit is hidden in
agenda.

Fixes https://orgmode.org/list/PAXPR06MB776069E9085C1CD606156493C6709@PAXPR06MB7760.eurprd06.prod.outlook.com
2021-12-18 21:12:22 +08:00
Ihor Radchenko ed392bc1c9
Merge branch 'bugfix' 2021-12-18 16:12:59 +08:00
Ihor Radchenko 85aaa19908
org-agenda: Make sure that time grid is aligned when hour <10
* lisp/org-agenda.el (org-agenda-format-item): Make sure that hour
part of begin time in time grid always occupy 5 chars

Fixes https://list.orgmode.org/orgmode/3afe1bba.2f48.17c350d0a41.Coremail.tumashu@163.com/
2021-12-18 16:07:58 +08:00
Ihor Radchenko 4426d8009f
org-element-cache: Fix Phase 1 when new parent overlaps future edits
* lisp/org-element.el (org-element--cache-process-request): New OFFSET
argument used to correct newly added parents during Phase 1.  The
`org-element--parse-to' call inside Phase 1 may add new elements to
cache that intersect with future edits.  Boundaries of these elements
may be shifted twice, so we have to offset the future shift.

(org-element--cache-sync): New OFFSET argument providing future change
info to `org-element--cache-process-request'.

(org-element--cache-submit-request): Provide offset value in
`org-elemnt--cache-sync' call.

(org-element--cache-submit-request):
(org-element--cache-process-request):
(org-element--cache-sync): Never use %d format for region boundaries.
It may be a marker and cause error.  Use %S instead.

(org-element--cache-process-request): Use unique symbols for
catch-throw.

Fixes https://list.orgmode.org/CAFyQvY3Qv5xn-ET83L6Rzg-V1zOVu4y1gt+-_CpfaWNAdt87xA@mail.gmail.com/T/#t
2021-12-17 22:48:20 +08:00
Ihor Radchenko e2a8e95576
org-element-cache: Fix when edit extends previous element
* lisp/org-element.el (org-element--cache-after-change): Always extend
changed region to bol.
* testing/lisp/test-org-element.el (test-org-element/cache): Add test
checking the new fix.  Amend some tests around making sure that cache
is active during testing.
2021-12-17 20:23:50 +08:00
Ihor Radchenko d6e6a9a3bc
org-element.el: Silence compiler 2021-12-17 20:23:11 +08:00
Ihor Radchenko 895e0baadf
ob-gnuplot: Fix regression from 23d8d59df when ox-org is not loaded
* lisp/ob-gnuplot.el (org-babel-gnuplot-table-to-data): Require
ox-org, making sure that org export backend is available.
2021-12-17 10:17:40 +08:00
Ihor Radchenko 092e921423
org-element-cache-map: Fix when start is nil after buffer modification 2021-12-16 23:17:05 +08:00
Ihor Radchenko 3338f37061
org-element--cache-process-request: Fix format specifier allowing marker
Fixes https://list.orgmode.org/CAFyQvY2=M6-JO7k=dF74injM7kHCcGUgdCCZXM6TZPWDTGbR4A@mail.gmail.com/T/#t
2021-12-16 23:16:31 +08:00
Ihor Radchenko de022ed654
Merge branch 'bugfix' 2021-12-16 21:43:56 +08:00
Ihor Radchenko 325b06bde4
org-element-cache: Do not carry over warning after sync
* lisp/org-element.el (org-element--cache-sync): Set
`org-element--cache-warning' to nil at the end of synchronisation.
We do not need to consider that next request might be merged with
existing request in such scenario.
(org-element--cache-before-change): Add comment explaining the use of `org-element--cache-warning'.
2021-12-16 21:39:26 +08:00
Ihor Radchenko d267486002
org-element-cache: Fix some edits right after indent at :begin
* lisp/org-element.el (org-element--cache-after-change): Extend
changed region to bol when we are editing near beginning of an element
within or right after indentation.  Such edits potentially change
:post-blank value of the previous element.
* testing/lisp/test-org-element.el (test-org-element/cache): Add test
checking one of such cases.
2021-12-16 21:39:25 +08:00
Ihor Radchenko 7ec9e37117
org-tree-to-indirect-buffer: Fix when last headline is empty at point-max
* lisp/org.el (org-tree-to-indirect-buffer): Consider scenario when
`org-end-of-subtree' with 't second arg moves to `point-max' at the
end of an empty headline.  We do not need to move back the point then.

Fixes https://orgmode.org/list/CA+AFVDUF3RzA-mnoAp8yFv-bppoYJfJo=Wa8qmNQhV-tfHHB+w@mail.gmail.com
2021-12-16 21:39:24 +08:00
Ihor Radchenko 5840e4d61a
org-element-cache Do not make headline non-robust after changes at :end
* lisp/org-element.el (org-element--cache-for-removal): When changes
involve :end of a headline, allow it to be re-parsed synchronously.
2021-12-16 11:39:23 +08:00
Ihor Radchenko 69985367cd
org-element-cache: Consider non-PROPERTIES drawers robust
* lisp/org-element.el (org-element--cache-for-removal): Drawers are
generally robust elements (they cannot be changed if a non-sensitive
change is made inside their contents).  The only exception is
PROPERTIES drawer that may switch back and forth between ordinary
drawer and properties drawer depending on its contents.  The old code
treated all possible drawer as non-robust for this reason, degrading
performance on large LOGBOOK drawers that are now processed much
faster since they do not need to be removed and re-parsed on every
single change.
2021-12-16 11:26:54 +08:00
Ihor Radchenko 6339c622f8
org-element-cache: Do not consider BEGIN lines of elements sensitive
* lisp/org-element.el (org-element--cache-sensitive-re): Remove
 #+begin_ and \begin{ lines from sensitive regexp.  Such changes can
 be handled without a need to re-parse from earlier position.  If a
 change introduces a new element, the new element will be recognised
 and the unupdated elements not intersecting with the new element will
 be handled during Phase 1.
2021-12-16 11:23:33 +08:00
Ihor Radchenko fd93ad698a
org-element-cache: Do not treat inserting newline at :begin sensitive
* lisp/org-element.el (org-element--cache-before-change): Do not match
`org-element--cache-sensitive-re' against an element starting at END
when END is at bol.  Such changes never break an element structure (as
opposed to inserting non-newline right at :begin of an element).
2021-12-16 11:20:32 +08:00
Ihor Radchenko cfe4b17d96
org-element-cache: Optimise changed property drawer detection
* lisp/org-element.el (org-element--cache-for-removal): Only force
re-parsing headlines when the changed region falls within the headline
before property drawer end position.
2021-12-16 11:18:00 +08:00
Ihor Radchenko 23d8d59df8
ob-gnuplot: Use org backend when assigning table to variable
* lisp/ob-gnuplot.el (org-babel-gnuplot-table-to-data): Switch to 'org
backend when exporting table data to plain text table.  ascii backend
incorrectly handles quote transcoders that change the column width and
sometimes throws an error.  (ascii backend simply ignores transcoded
table cells and calculates width based on the initial cell text).
2021-12-16 11:14:59 +08:00
Nicolas Goaziou 8908fba113 compat: Silence byte-compiler 2021-12-12 16:21:04 +01:00
Nicolas Goaziou f8cd8a6645 oc-biblatex: Generate cite styles dynamically
* lisp/oc-biblatex.el (org-cite-biblatex-list-styles): New function.
Use it when registering `biblatex' citation processor.
2021-12-12 16:17:56 +01:00
Nicolas Goaziou cfffdf5e1a oc-biblatex: Add missing shortcut
* lisp/oc-biblatex.el (org-cite-biblatex-style-shortcuts): Add missing shortcut.
2021-12-12 16:09:24 +01:00
Nicolas Goaziou e995e069ca oc-biblatex: Allow style customization
* lisp/oc-biblatex.el (org-cite-biblatex-styles):
(org-cite-biblatex-style-shortcuts): New defcustoms.
(org-cite-biblatex--expand-shortcuts): New function.
(org-cite-biblatex-export-citation): Extract adequate style from
defcustoms above instead of hard-coding all styles.
2021-12-12 15:42:29 +01:00
Nicolas Goaziou 82bb04be22 oc-biblatex: Spell out multicite commands instead of guessing them
* lisp/oc-biblatex.el (org-cite-biblatex-export-citation): Provide
full multicite command name.
(org-cite-biblatex--command): Use name instead of guessing it from
base name.
2021-12-12 15:42:29 +01:00
Nicolas Goaziou 7e2d9091d0 oc: Allow declaring cite styles as a function
* lisp/oc.el (org-cite-register-processor): Allow a function
as :cite-styles value.
(org-cite-supported-styles): Propagate change above.
* testing/lisp/test-oc.el (test-org-cite/supported-styles): Add test.
2021-12-12 15:42:29 +01:00
Ihor Radchenko 798435be85
org-element-cache: Fix merging intersecting Phase 0 requests
* lisp/org-element.el (org-element--cache-submit-request): Extend
calculation of affected parent elements to the full changed region.
The previous behaviour could miss some outer elements to be removed.
2021-12-12 16:13:16 +08:00
Ihor Radchenko 9c7acaa02d
Re-implement 54534eebb more efficiently
* lisp/org-element.el (org-element--cache-sensitive-re): Do not treat
properties inside property drawers as global sensitive change. It can
cause cache drop on large logbook drawers where a new clock entry is
inserted.
(org-element--cache-for-removal): Use the same technique used for
detecting property drawer <-> ordinary drawer changes under headlines
for org-data.
2021-12-12 12:51:56 +08:00
Kyle Meyer 0c9b30e961 Merge branch 'bugfix' 2021-12-11 12:40:39 -05:00
Stefan Kangas 9ca3bc3730 Backport commit 26fb4168b from Emacs
; Prefer HTTPS in more URLs
26fb4168b884eeb910580c42e87efb73399019c9
Stefan Kangas
Thu Dec 9 16:26:04 2021 +0100
2021-12-11 12:26:28 -05:00
Nicolas Goaziou e6c7ea3a36 Merge branch 'bugfix' 2021-12-11 17:21:45 +01:00
TAKAHASHI Yoshio 888689f2ba org-macro: Adjust for compatibility with latest vc (bug#51365)
* lisp/org-macro.el (org-macro--vc-modified-time): Wrap file in a list
when passing to vc-call to avoid a type error starting with Emacs 28.

Before Emacs's 3572613550f (Fix vc-git-state for filenames with
wildcards, 2021-08-15), a string could be given to vc-git-print-log as
the FILES argument because the argument was passed directly as
vc-git-command's FILE-OR-LIST, which as the name suggests, accepts
either a string or a list.  After 3572613550f, passing a string leads
to a type error.

TINYCHANGE
2021-12-11 11:14:03 -05:00
Nicolas Goaziou 41f412f0bc Merge branch 'bugfix' 2021-12-11 14:21:54 +01:00
Nicolas Goaziou 957feb2df4 oc: Fix typo in docstring
* lisp/oc.el (org-cite-make-insert-processor): Fix typo.
2021-12-11 14:21:10 +01:00
Ihor Radchenko edddc7d149
org-element-cache-map: Reduce memory allocation and time re-search
* lisp/org-element.el (org-element-cache-map): Move all possible
let-bindings outside the loop to avoid remory re-allocation on every
iteration.  Track statistics for `re-search-forward' calls.
2021-12-11 10:08:40 +08:00
Ihor Radchenko 0350c7dd71
org.el: Avoid excessive memory usage by effort text properties
* lisp/org.el (org-set-effort):
(org-property-next-allowed-value): Do not use text properties cache
for `effort' and `effort-minutes' when org-element-cache is active.
These text properties are superceded by element cache and their only
effect (when cache is active) is extra load on Emacs garbage collector
leading to overall Emacs slowdown.
* lisp/org-clock.el (org-clock-in): Use `org-element-use-cache'
instead of `org-element--cache-active-p' to check if element cache is
active. The latter is too precise and may trigger
`org-refresh-effort-properties' when cache is temporarily disabled by
internal calls.
2021-12-11 10:08:39 +08:00
Ihor Radchenko 67fb7a4892
org-agenda-get-deadline: Use org-element-cache 2021-12-11 10:08:39 +08:00
Nicolas Goaziou 04f9fa314c Merge branch 'bugfix' 2021-12-10 10:34:43 +01:00
Nicolas Goaziou a957a4c19d keys: Don't bind illegal C-TAB
* lisp/org-keys.el (org-mode-map): Bind `org-force-cycle-archived' to
C-c C-<tab> instead of C-c C-TAB.

Reported-by: Ingo Lohmar <ingo.lohmar@posteo.net>
<http://lists.gnu.org/r/emacs-orgmode/2021-10/msg00048.html>
2021-12-10 10:33:01 +01:00
Nicolas Goaziou 96e022bbe0 Merge branch 'bugfix' 2021-12-10 10:29:41 +01:00
Nicolas Goaziou f0d8041f0c ox: Clarify `org-export-to-(buffer|file)' docstrings
* lisp/ox.el (org-export-to-buffer):
(org-export-to-file): Fix example and add precision about the need for
quoting lambda sexps.
2021-12-10 10:28:58 +01:00
Sébastien Miquel 8d189720b2 ox: Fix async export with native compilation
* lisp/ox-beamer.el (org-beamer-export-to-pdf):
* lisp/ox-icalendar.el (org-icalendar-export-to-ics):
* lisp/ox-koma-letter.el (org-koma-letter-export-to-pdf):
* lisp/ox-man.el (org-man-export-to-pdf):
* lisp/ox-texinfo.el (org-texinfo-export-to-info): Quote lambda.

Quote or name lambdas to prevent their compilation into anonymous
functions which cannot be passed to the external async emacs process.
2021-12-10 10:22:53 +01:00
Emmanuel Charpentier c6186be3fd oc-csl: Also look for style files in default directory
* lisp/oc-csl.el (org-cite-csl--style-file): When file name is
relative, look for it in default directory before expanding it against
`org-cite-csl-styles-dir'.
(org-cite-csl-styles-dir): Document change.
2021-12-10 10:17:00 +01:00
Kyle Meyer f1929afc66 Merge branch 'bugfix' 2021-12-09 22:45:02 -05:00
Kyle Meyer 4aca51fcbe org-priority: Fix SPC handling for numeric priorities (bug#52341)
* lisp/org.el (org-priority): When reading numeric priorities, provide
special handling of SPC so that it clears the priority, as advertised.

If the user has configured numeric priorities and tries to clear a
priority by inputting SPC at the prompt, org-priority feeds " " to
string-to-number and ends up with 0 instead of the ?\s (32) that's
used downstream to signal "remove".  Explicitly check for " " and
translate it to ?\s.

Reported-by: "Bruce E. Robertson" <brucer42@gmail.com>
Link: https://list.orgmode.org/877dch89s1.fsf@kyleam.com/
2021-12-09 22:42:56 -05:00
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