Commit Graph

17354 Commits

Author SHA1 Message Date
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
Nicolas Goaziou ee6e4892a1 Merge branch 'bugfix' 2021-10-10 23:11:35 +02:00
Nicolas Goaziou 596ec7a167 oc-biblatex: Fix docstring
* lisp/oc-biblatex.el (org-cite-biblatex-export-citation): Fix docstring.
2021-10-10 23:11:05 +02:00
Nicolas Goaziou 2fad7be9e7 oc-biblatex: Support bare variant for noauthor style
* lisp/oc-biblatex.el (org-cite-biblatex-export-citation): Support
bare variant for noauthor style.
2021-10-10 22:18:31 +02:00
Nicolas Goaziou d872506ad3 Merge branch 'bugfix' 2021-10-10 12:12:35 +02:00
Nicolas Goaziou c4a357f192 oc-csl: Allow nbsp after locator label
* lisp/oc-csl.el (org-cite-csl--label-regexp): Allow nbsp between
locator label and value.

Reported-by: M. ‘quintus’ Gülker <post+orgmodeml@guelker.eu>
<http://lists.gnu.org/r/emacs-orgmode/2021-10/msg00423.html>
2021-10-10 12:11:26 +02:00
Nicolas Goaziou f5faffb142 Merge branch 'bugfix' 2021-10-09 23:02:41 +02:00
Nicolas Goaziou 8dfc056fcc oc: Fix failing test about `org-cite-list-citations'
* lisp/oc.el (org-cite-list-citations): Properly implement
a simplified version of `org-export-get-footnote-definition'.
2021-10-09 23:01:35 +02:00
Kyle Meyer f0c66dc4c4 Merge branch 'bugfix' 2021-10-09 16:18:17 -04:00
Nicholas Vollmer b71474ff7f lisp/org.el: (org-save-all-org-buffers): Prevent `org-mode' reload
* lisp/org.el: (org-save-all-org-buffers): Ensure `save-some-buffers' PRED returns boolean.

As of this upstream commit:

https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=a9ad3d477441feefa3bf6107d58281cb64e0e78a

`save-some-buffers' will call its PRED argument if it returns a function.
Since (derived-mode-p 'org-mode) returns the symbol org-mode,
and org-mode is a function, org-mode is reloaded in modified Org
buffers when calling `org-save-all-org-buffers'. Among other
undesirable behavior, this will cause the buffer's visibility to be
reset to its initial visibility.
2021-10-09 15:23:33 -04:00
Nicolas Goaziou dc154f0d18 Merge branch 'bugfix' 2021-10-09 16:10:30 +02:00
Nicolas Goaziou 11f450da80 oc-biblatex: Declare missing "nocite" style
* lisp/oc-biblatex.el (biblatex): Declare the processor provides
a "nocite" citation style.
2021-10-09 16:09:33 +02:00
Nicolas Goaziou 6717826d5a oc-bibtex: Pacify byte-compiler 2021-10-08 22:45:22 +02:00
Nicolas Goaziou 107c832642 Implement `bibtex' citation processor
* lisp/oc-bibtex.el: New file.
2021-10-08 22:03:10 +02:00
Nicolas Goaziou 93f7bf9b14 oc-biblatex: Remove unnecessary declare-function. 2021-10-08 19:12:03 +02:00
Bastien f268e7201f Merge branch 'bugfix' 2021-10-08 15:38:15 +02:00
Bastien 89968077cf lisp/ol-man.el: Add copyright header 2021-10-08 15:38:01 +02:00
Bastien d361c77285 Merge branch 'bugfix' 2021-10-07 19:37:09 +02:00
Bastien 2a4dfa7e51 lisp/ol-man.el: Add lexical-binding cookie 2021-10-07 19:36:55 +02:00
Bastien d542ef7ed6 Merge branch 'bugfix' 2021-10-07 17:47:48 +02:00
Bastien 98b34ea640 lisp/ol-man.el: Restore file
This file was mistakenly removed by db67c7e92.
2021-10-07 17:47:14 +02:00
Nicolas Goaziou c0c576b445 Merge branch 'bugfix' 2021-10-06 16:10:37 +02:00
Nicolas Goaziou 7d22dca54e oc: Fix citations in footnotes when using biblatex back-end
* lisp/oc.el (org-cite-list-citations): Do not use
`org-export-get-footnote-definition' so as to not cache footnote
definitions too early, i.e., when citations are still present in the
parse tree.
* lisp/oc-biblatex.el (org-cite-biblatex--multi-arguments): Append
"\relax" unconditionally to avoid calling `org-export-data' on next
object, when citations are still present in the parse tree.

Reported-by: Elias Bounatirou <elias.bounatirou@gmail.com>
<http://lists.gnu.org/r/emacs-orgmode/2021-09/msg00067.html>
2021-10-06 16:07:19 +02:00
Nicolas Goaziou af67fa1ebe Merge branch 'bugfix' 2021-10-06 14:42:27 +02:00
Nicolas Goaziou 94b410b32c footnote: Improve last commit
* lisp/org-footnote.el (org-footnote--allow-reference-p): Improve last
commit.
2021-10-06 14:41:50 +02:00
Nicolas Goaziou 5f6e199143 footnote: Allow footnotes at footnote definition start
* lisp/org-footnote.el (org-footnote--allow-reference-p): Allow
footnotes at footnote definition start, right after label.
* testing/lisp/test-org-footnote.el (test-org-footnote/new): Add
tests.
2021-10-06 14:34:14 +02:00
Nicolas Goaziou b07c312f28 oc: Allow citations at footnote definition start
* lisp/oc.el (org-cite--allowed-p): Allow citations at footnote
definition start.
* testing/lisp/test-oc.el (test-org-cite/insert-capability): Add tests.
2021-10-06 14:29:40 +02:00
Nicolas Goaziou 9b063251cf oc: Allow citations at footnote definition start
* lisp/oc.el (org-cite--allowed-p): Allow citations at footnote
definition start.
* testing/lisp/test-oc.el (test-org-cite/insert-capability): Add tests.
2021-10-06 14:28:04 +02:00
Kyle Meyer cc2490a706 Prune Emacs 25.1 compatibility kludges
* lisp/oc-basic.el (org-cite-basic--field-less-p):
* lisp/ol-eww.el (org-eww-store-link):
* lisp/org-agenda.el (org-agenda-check-clock-gap):
* lisp/org-clock.el (org-clock-get-clocked-time)
(org-clock-resolve-clock, org-clock-resolve)
(org-resolve-clocks, (org-resolve-clocks-if-idle)
(org-clock-in, org-clock-sum): Drop now unnecessary use of
compatibility functions.

* lisp/org-compat.el (org-string-collate-lessp, org-decode-time)
(org-format-time-string, org-link-escape-browser, org-time-add)
(org-time-subtract, org-time-since, org-time-less-p): Mark as
obsolete.

The 9.5 release declared Emacs 25.1 as the minimum version.
2021-10-04 23:43:14 -04:00
Kyle Meyer 2893eb1ae2 org.el: Drop subtract-time -> time-subtract alias
time-subtract has been available since Emacs 22.1.
2021-10-04 23:41:02 -04:00
Ihor Radchenko 0ae701f7fd
Merge branch 'bugfix' 2021-10-04 14:15:27 +08:00
Ihor Radchenko bd0493eda1
org-lint: Do not require space after : in keywords
* lisp/org-lint.el (org-lint-duplicate-name): Update regexp to conform
with org-element parsers.

Fixes https://list.orgmode.org/orgmode/87h7ee5q8u.fsf@gmail.com/
2021-10-04 14:14:16 +08:00
Nicolas Goaziou 1acacd6049 Merge branch 'bugfix' 2021-10-04 00:01:22 +02:00
Nicolas Goaziou d68d8bc1f8 oc: Pacify checkdoc
* lisp/oc.el (org-cite-export-processors):
(org-cite--move-punct-before):
(org-cite-adjust-note):
(org-cite--allowed-p): Add missing argument.
2021-10-04 00:00:33 +02:00
Nicolas Goaziou d6f0e9e105 oc: Be stricter when introducing spaces before citations
* lisp/oc.el (org-cite-process-citations): Add a space before citation
only if it is preceded by a quotation mark.
* testing/lisp/test-oc.el (test-org-cite/export-capability): Add
tests.

Reported-by: Denis Maier <denismaier@mailbox.org>
<http://lists.gnu.org/r/emacs-orgmode/2021-09/msg00085.html>
2021-10-03 23:51:43 +02:00
Nicolas Goaziou 6cb9d2ffea Merge branch 'bugfix' 2021-10-03 23:24:12 +02:00
Nicolas Goaziou 4b346e5157 oc: Fix typo in docstring
* lisp/oc.el (org-cite-adjust-note): Fix typo.
2021-10-03 23:23:37 +02:00
Bastien 8b78d482a6 Fix email addresses in some *.el headers 2021-10-03 08:54:33 +02:00
Kyle Meyer 0e6b04c856 Merge branch 'bugfix' 2021-10-02 14:22:58 -04:00
Kyle Meyer 10dc9debb9 Merge branch 'km/from-emacs-28' into bugfix 2021-10-02 14:22:37 -04:00
Glenn Morris 41e67cff0d Backport commit 4341e79a5 from Emacs
* lisp/oc.el (org-cite-global-bibliography)
(org-cite-note-rules, org-cite-punctuation-marks):
* lisp/oc-csl.el (org-cite-csl-locales-dir)
(org-cite-csl-styles-dir, org-cite-csl-no-citelinks-backends):
* lisp/oc-natbib.el (org-cite-natbib-options):
* lisp/org-keys.el (org-mouse-1-follows-link):
Remove bogus ":safe t" properties that would largely need to be
replaced by custom predicates.

Remove bogus ":safe t" custom properties
4341e79a5fad3e5e668a3eeb1b688d1986011481
Glenn Morris
Sat Oct 2 11:00:23 2021 -0700
2021-10-02 14:20:38 -04:00
Glenn Morris ec22cf0a53 Backport commit 62d6cecfc from Emacs
* lisp/oc.el (org-cite-activate-processor)
(org-cite-export-processors, org-cite-follow-processor)
(org-cite-insert-processor):
* lisp/ol.el (org-link-parameters, org-link-frame-setup)
(org-link-shell-confirm-function)
(org-link-shell-skip-confirm-regexp)
(org-link-elisp-confirm-function)
(org-link-elisp-skip-confirm-regexp):
* lisp/org-num.el (org-num-format-function):
Remove bogus ":safe nil" that do nothing but propagate a
misunderstanding of the safe-local-variable property.

Remove bogus ":safe nil" custom properties
62d6cecfcd1a67e15a436c5c2b975f327d9a8b50
Glenn Morris
Sat Oct 2 10:46:29 2021 -0700
2021-10-02 13:56:50 -04:00
Kyle Meyer 06578d7450 Merge branch 'bugfix' 2021-10-02 13:48:07 -04:00
Kyle Meyer df7b0eac13 Merge branch 'km/from-emacs-28' into bugfix 2021-10-02 13:45:37 -04:00
Glenn Morris c3e8709e2d Backport commit f9111d878 from Emacs
* lisp/oc-basic.el (org-cite-basic-sorting-field)
(org-cite-basic-author-year-separator)
(org-cite-basic-max-key-distance)
(org-cite-basic-author-column-end)
(org-cite-basic-column-separator)
(org-cite-basic-mouse-over-key-face):
* lisp/oc-biblatex.el (org-cite-biblatex-options):
* lisp/oc-csl.el (org-cite-csl-link-cites)
(org-cite-csl-html-hanging-indent)
(org-cite-csl-html-label-width-per-char)
(org-cite-csl-latex-hanging-indent):
* lisp/oc.el (org-cite-adjust-note-numbers):
* lisp/org-keys.el (org-return-follows-link):
* lisp/org.el (org-fontify-todo-headline):
* lisp/ox-html.el (org-html-equation-reference-format)
(org-html-wrap-src-lines):
* lisp/ox-latex.el (org-latex-reference-command)
(org-latex-default-quote-environment): Fix :safe property.

The safe-local-variable property is a function (bug#50944)
f9111d8784bf12263abbe127cdfcbe5f409c9b3b
Glenn Morris
Sat Oct 2 10:37:42 2021 -0700
2021-10-02 13:44:34 -04:00
Nicholas Vollmer fac96da572 org-attach.el: Fix checkdoc warnings
* org-attach.el: Fix checkdoc warnings.
2021-10-02 19:15:52 +02:00
Nicholas Vollmer aa6f8ed877 org-src.el: Fix checkdoc warnings
* org-src.el: Fix checkdoc warnings.
2021-10-02 17:10:15 +02:00
Lars Ingebrigtsen 881145f5ef Backport commit bd60fca2f from Emacs
* lisp/ox-koma-letter.el (org-koma-letter-export-block)
(org-koma-letter-export-snippet): Fix warning about two unused
parameter.

Fix ox-koma-letter compilation warnings
bd60fca2faa03034e89df68a69255656df6512ba
Lars Ingebrigtsen
Sat Oct 2 10:37:55 2021 +0200

[ km: This has already been taken care of in the bugfix branch by
  85e5540eb (lisp/ox-koma-letter.el: Use lexical-binding,
  2021-09-30). ]
2021-10-02 11:02:13 -04:00
Kyle Meyer 9e71dfd921 Merge branch 'bugfix' 2021-10-02 00:55:26 -04:00
Kyle Meyer 0f11a44e01 org-cite-csl--etc-dir: Broaden docstring description
* lisp/oc-csl.el (org-cite-csl--etc-dir): Adjust docstring to describe
purpose without tying the variable to the repository install scenario.

Since 604bfd9d7 (oc-csl: be more caution about the csl etc location,
2021-07-15), this value hasn't been limited to the repository's
etc/csl/.
2021-10-02 00:52:27 -04:00
Kyle Meyer 60b178e596 oc-csl: Locate etc/csl for system installs and Emacs repo
* lisp/oc-csl.el (org-cite-csl--etc-dir): Add `data-directory' case,
using it as the fallback.  Also, use the more specific
file-directory-p rather than file-exists-p to inspect the candidates.

When using Org from the system installation, the CSL files will be
available in the etc/org/csl/ subdirectory underneath
`data-directory'.  (This requires the etc/csl/ files to be synced to
the Emacs repo under etc/org/csl.)

Give the Org repository and package cases precedence because they are
anchored to a specific oc.el location while, for Emacs releases with
Org 9.5 or later, the data-directory files will typically always be
present.
2021-10-02 00:52:27 -04:00
Kyle Meyer d0f774b0b4 Merge branch 'km/from-emacs-28' into bugfix 2021-10-02 00:51:56 -04:00
Ihor Radchenko fa315986a1
org-do-emphasis-faces: Never treat closing marker as next opening marker
* lisp/org.el (org-do-emphasis-faces): Make sure that we never match
ending marker of an emphasis as a beginning marker of another
emphasis.  For example, in "(~-~) test (~+~)" "~) test (~" is a valid
code match unless we move point to the end the first code emphasis
completely during parsing.

Fixes https://orgmode.org/list/87fsujp7mc.fsf@web.de
2021-10-02 12:47:42 +08:00
Glenn Morris e83ee601f2 Backport commit d50597189 from Emacs
; Standardize some license headers
d505971894d83e04e8d206be1dcee1cee5e8bb93
Glenn Morris
Fri Oct 1 18:07:45 2021 -0700
2021-10-01 21:57:10 -04:00
Glenn Morris 7dcdf98f1d Backport commit f1f57a541 from Emacs
* lisp/oc-csl.el (org-cite-csl-locales-dir)
(org-cite-csl-styles-dir):
* lisp/org-plot.el (org-plot/preset-plot-types): Fix :type.

Fix some custom types
f1f57a541e4c74eec68a27c47c7416ed6c7d75dd
Glenn Morris
Fri Oct 1 08:33:32 2021 -0700
2021-10-01 21:57:09 -04:00
Ihor Radchenko 60365a1641
orgtbl-to-generic: Mention that :fmt is ignored for empty cells
* lisp/org-table.el (orgtbl-to-generic): Amend docstring mentioning
that :fmt is ignored for empty table cells.
2021-10-01 11:56:30 +08:00
Ihor Radchenko d19660b05b
ob-gnuplot: Honour :missing argument
* lisp/ob-gnuplot.el (org-babel-gnuplot-table-to-data): Force applying
`org-babel-gnuplot-quote-tsv-field' to empty table cells when
converting org tables to gnuplot input.  By default,
`orgtbl-to-generic' ignores :fmt for empty table cells.  We need to
set :raw to non-nil AND :backend to non-nil to force custom formatting
of empty table cells.

Fixes https://orgmode.org/list/20210617211347.59e4de56@happy.intern.roklein.de
2021-10-01 11:44:52 +08:00
Ihor Radchenko ddee7b617c
ob-gnuplot: Honour :missing argument
* lisp/ob-gnuplot.el (org-babel-gnuplot-table-to-data): Force applying
`org-babel-gnuplot-quote-tsv-field' to empty table cells when
converting org tables to gnuplot input.  By default,
`orgtbl-to-generic' ignores :fmt for empty table cells.  We need to
set :raw to non-nil AND :backend to non-nil to force custom formatting
of empty table cells.

Fixes https://orgmode.org/list/20210617211347.59e4de56@happy.intern.roklein.de
2021-10-01 11:43:22 +08:00
Kyle Meyer d97223b244 Merge branch 'bugfix' 2021-09-30 21:27:57 -04:00
Kyle Meyer 8bc222bce6 org-src: Silence byte-compiler under 'make single'
This warning shows up when compiling in the Emacs repo, too.
2021-09-30 21:27:41 -04:00
Kyle Meyer 1c1614e9b7 Merge branch 'km/from-emacs-28' into bugfix 2021-09-30 21:18:30 -04:00
Mattias Engdegård 7de3d3cb32 Backport commit 2075411ed from Emacs
* lisp/org-element.el (org-element-citation-key-re):
* lisp/ox-org.el (org-org-identity):
Remove repeated chars in alternatives.
* lisp/ob-java.el (org-babel-execute:java):
Remove superfluous backslash.
* lisp/ob-java.el (org-babel-java--main-re)
(org-babel-java--any-method-re): Remove (0+ space) expressions
subsumed by adjacent expressions.

Fix regexp snags in org
2075411edbad954c0fdf2aa141757d834a6708b7
Mattias Engdegård
Thu Sep 30 17:16:41 2021 +0200
2021-09-30 21:18:08 -04:00
Mattias Engdegård c763b9ae61 Backport commit 58102466e from Emacs
* lisp/org-element.el (org-element-headline-parser):
Pretty sure this one should be `skip-chars-backward`, not
`skip-syntax-backward`, since \t isn't a valid syntax code.

org-element: use correct function
58102466e32d4dd9c7d816cdc3f4595a2145f332
Mattias Engdegård
Thu Sep 30 17:16:25 2021 +0200
2021-09-30 21:18:08 -04:00
Stefan Monnier 7325cf186a Backport commit b5e3cc3bc from Emacs
* lisp/ob-julia.el: Use lexical-binding.
(ess-eval-visibly-p): Declare.
(org-babel-julia-assign-elisp): Remove unused vars `header` and
`row-names` and corespondingly remove now unused args `colnames-p` and
`rownames-p`.
(org-babel-variable-assignments:julia): Adjust call to
`org-babel-julia-assign-elisp` accordingly.
(org-babel-julia-initiate-session): Use `bound-and-true-p`.
(org-babel-julia-evaluate-external-process)
(org-babel-julia-evaluate-session, org-babel-julia-evaluate):
Remove unused arg `row-names-p`.
(org-babel-execute:julia): Adjust call to
`org-babel-julia-evaluate` accordingly.

* lisp/org/ob-julia.el: Use lexical-binding
b5e3cc3bc597d56dfe09ee500717344649ea0354
Stefan Monnier
Thu Sep 30 10:02:29 2021 -0400

[ km: This was independently applied covered on the bugfix branch with
  the combination of a3b6728f9 and efa498b67.  I'm applying it here
  too for bookkeeping/traceability purposes, and to bring in one
  missing piece (see merge). ]
2021-09-30 21:17:02 -04:00
Stefan Monnier 15b09c1680 Backport commit a5b761ec3 from Emacs
* lisp/org/ox-koma-letter.el: Use lexical-binding
a5b761ec334cded8252e81c3887142a46752ec6a
Stefan Monnier
Thu Sep 30 09:58:04 2021 -0400

[ km: This was independently applied covered on the bugfix branch with
  the combination of 85e5540eb and f5b297292, but I'm applying it here
  too for bookkeeping/traceability purposes. ]
2021-09-30 21:16:41 -04:00
Bastien 6c8f8f6225 Merge branch 'bugfix' 2021-09-30 23:20:04 +02:00
Bastien f5b297292e lisp/ox-koma-letter.el: Backport Emacs commit a5b761ec
* lisp/org/ox-koma-letter.el: Remove redundant `:group` args.
2021-09-30 23:19:30 +02:00
Bastien efa498b679 lisp/ob-julia.el: Backport modifications from Emacs b5e3cc3
* (org-babel-julia-initiate-session): Use `bound-and-true-p`.
2021-09-30 23:15:24 +02:00
Bastien 2cdd930a7b Merge branch 'bugfix' 2021-09-30 19:33:27 +02:00
Bastien a3b6728f9a lisp/ob-julia.el: Use lexical-binding
* lisp/ob-julia.el: Use lexical-binding.
(ess-eval-visibly-p): Declare as dynamically scoped.
(org-babel-execute:julia, org-babel-julia-assign-elisp)
(org-babel-julia-evaluate, org-babel-julia-evaluate-session):
Remove unused references to `colnames-p' and `rownames-p'.

Thanks to Pedro Bruel for reviewing this patch.
2021-09-30 19:32:53 +02:00
Bastien 85e5540eb5 lisp/ox-koma-letter.el: Use lexical-binding
* lisp/ox-koma-letter.el (org-koma-letter-export-block)
(org-koma-letter-export-snippet): Silence the compiler.
Use lexical-binding.
2021-09-30 19:29:47 +02:00
Bastien 59cb39f53d Merge branch 'bugfix' 2021-09-30 16:17:02 +02:00
Sébastien Miquel e1c49af76d org-src.el: Fix special editing of LaTeX fragments
* lisp/org-macs.el (org-do-remove-indentation): Add optional argument
to skip the first line.
* lisp/org-src.el (org-src--coordinates): Fix coordinates for inline
LaTeX fragments.
(org-src--contents-for-write-back): Do not indent first line for LaTeX
fragments.
(org-src--edit-element): Compute block-indentation according to parent
for LaTeX fragments.  Skip first line when removing common indentation
for LaTeX fragments.
2021-09-30 16:16:52 +02:00
Bastien 35928a6d09 lisp/org.el: Update the Version header to 9.6-dev 2021-09-30 06:46:53 +02:00
Sébastien Miquel 10139c86bc org.el (org-create-formula-image): Fix ignored background color
* lisp/org.el (org-preview-latex-process-alist): add a
`:transparent-image-converter' property for `dvipng'.
(org-create-formula-image): If available, use
`:transparent-image-converter' when no background color is set.
2021-09-30 06:46:31 +02:00
TEC 55cf527375
org: Image display, account for line number width
* lisp/org.el (org-display-inline-image--width): To be slightly more
accurate when calculating image widths that are proportional to the text
width in the current buffer, subtract the width taken up by line numbers.
2021-09-29 21:40:35 +08:00
Bastien 0a86adc127 lisp/org.el: Set version header to 9.5 2021-09-29 14:24:53 +02:00
Bastien 80b2aa41e1 Fix 1d5e41d41 2021-09-29 14:17:04 +02:00
Bastien 1344911585 lisp/ob-R.el: Fix compiler warnings 2021-09-29 14:16:47 +02:00
Bastien 1d5e41d41b lisp/ob-core.el (org-babel-eval-headers): Fix elements ordering
* lisp/ob-core.el (org-babel-eval-headers): Fix elements ordering.
(org-babel-merge-params): Tiny refactoring.

This fixes the test `test-ob-lob/call-with-header-arguments' that
fails after 9f1507bdd.
2021-09-29 14:05:10 +02:00
Ihor Radchenko 32b9251886 Parse titleless headlines with a tag correctly
* lisp/org-element.el (org-element-headline-parser): Do not treat tag
as headline title in headlines like "* :tag:".
2021-09-29 13:25:44 +02:00
Bastien 31929f539c Merge branch 'bugfix' 2021-09-29 13:19:55 +02:00
Jonathan Gregory e4c0281d23 Set the MIDI file extension conditionally
* lisp/ob-lilypond.el (org-babel-lilypond-attempt-to-play-midi): By
default, LilyPond outputs .mid files for Windows and .midi for
everything else.

See: <https://lists.gnu.org/r/emacs-orgmode/2021-08/msg00379.html>

TINYCHANGE
2021-09-29 13:19:44 +02:00
Bastien 806ac1b7f6 *el: Fix indentation 2021-09-29 09:22:47 +02:00
Matt Huszagh 9f1507bdd1 ob-core.el: Add ability to use closures as default header arguments
* lisp/ob-core.el (org-babel-default-header-args): Document ability to
use closures.
(org-babel-eval-headers): New function to generate header arguments,
which adds the ability to evaluate closures during source block
execution or export.
(org-babel-merge-params): Only evaluate closures when we have our
final list of headers.
2021-09-29 09:19:05 +02:00
Bastien a5e8dfaf5b Revert "ob-core.el: Add ability to use closures as default header arguments"
This reverts commit 78783f4e47.
2021-09-29 09:18:48 +02:00
Yasushi SHOJI 3a291b0f0e ox-publish.el: Add `org-html-publish-to-html' as the default publishing function
* lisp/org-macs.el (org-plist-delete-all): New function.

* lisp/ox-publish.el (org-publish-file): Add
`org-html-publish-to-html' as the default publishing function.

* testing/lisp/test-ox-publish.el (org-test-publish): Use
`org-plist-delete-all' to remove properties from the plist.

Reported-by: Christopher W. Ryan
See <https://list.orgmode.org/CAELBRWLgV-s6SGX=cevtN7iW8htwiLezR469T-cGMWE_6iX1+A@mail.gmail.com>
2021-09-29 09:14:43 +02:00
Bastien 7e1745d744 lisp/ob-julia.el: Fix copyright header 2021-09-29 09:02:44 +02:00
Bastien 519947e508 * lisp/org.el: Require Emacs 25.1.
lisp/org.el: Require Emacs 25.1

See https://orgmode.org/worg/org-maintenance.html#emacs-compatibility
2021-09-29 08:52:04 +02:00
Nicholas Vollmer b41f2971ab org-id: Fix checkdoc warnings
* org-id: Fix checkdoc warnings.
2021-09-29 08:50:06 +02:00
Kyle Meyer 1292d89c37 Clean up spacing to pass Emacs's pre-commit check
* lisp/org-agenda.el (org-agenda-highlight-todo):
(org-agenda-set-mode-name):
* lisp/org-table.el (org-table-eval-formula): Avoid space before tab in
indent.

This is in preparation for syncing with the Emacs repo.
2021-09-29 00:37:30 -04:00
András Simonyi b96aae4684 oc-csl: Refactor code to help byte-compilation
* lisp/oc-csl.el (org-cite-csl--create-structure-params): Refactor pcase pattern
to avoid slow or in some cases non-terminating byte compilation.
2021-09-28 18:55:01 +02:00
Jeremie Juste 72a48c306f ob-R.el: Patch async evaluation when :results output
* lisp/ob-R.el (ob-session-async-org-babel-R-evaluate-session):
Make sure that `ess-inject-source' is set to the default
'function-and-buffer before running `ess-eval-buffer'.  Return
`ess-inject-source' to its user-specified state afterwards.
2021-09-28 18:22:18 +02:00
Jeremie Juste 01557eef57 ob-R.el: Patch async evaluation when :results output
* lisp/ob-R.el (ob-session-async-org-babel-R-evaluate-session): Make
sure that `ess-eval-visibly' is nil before evaluating the temporary
buffer, but return ess-eval-visibly to it's original state afterwards.
2021-09-28 18:22:15 +02:00
Jeremie Juste 51a60cd53f lisp/ob-R: Async evaluation in R
* lisp/ob-R.el (ob-session-async-R-indicator): Add constant
representing a prefix R to identity session.
(ob-session-async-org-babel-R-evaluate-session): New function to
evaluate R src block asynchrously.
(ob-session-async-R-value-callback): New function that calls back
the result of the asynchronous evaluation.
(org-babel-R-evaluate): Add `async' parameter and call
`ob-session-async-org-babel-R-evaluate-session' if `async'
parameter is present.
(org-babel-execute:R): Call `org-babel-comint-use-async' to check
if async is among `params' and add async parameter to
`org-babel-R-evaluate'.

* testing/lisp/test-ob-R.el: Add 7 more tests for async
evaluations, also taken from the `ob-session-async' package.

This is almost a carbon copy of Jack Kamm's `ob-session-async'.
The original source code can be found
https://github.com/jackkamm/ob-session-async.

Please refer to the following thread to trace back the discussion
on async evaluation in R:

https://list.orgmode.org/87eed9g9p6.fsf@gmail.com/
2021-09-28 18:22:12 +02:00
Bastien 93d7825d55 lisp/org.el (visual-fill-column-width): Silence compiler warning
* lisp/org.el (visual-fill-column-width): Silence compiler warning.
2021-09-28 17:31:18 +02:00
TEC 8130147958 ox-org: Use lower case keywords
* lisp/ox-org.el (org-org-identity, org-org-template): As it has
previously been clarified on the mailing list that upper-case keywords
are only intended for the manual[1], an Org export of an Org file should
use lower-case keywords.

[1]: https://list.orgmode.org/87tuuw3n15.fsf@nicolasgoaziou.fr/
2021-09-28 17:27:55 +02:00
András Simonyi 9e2341bc65 oc-csl: Add support for the text and year citation styles
* lisp/oc-csl.el (org-cite-csl--create-structure-params): Introduce this new
function to map the extended list of supported citation styles and variants to
the corresponding citeproc-el citation structure creation parameters.
(org-cite-csl--no-affixes-p, org-cite-csl--capitalize-p,
org-cite-csl--no-author-p): Remove them since their functionality is provided
now by `org-cite-csl--create-structure-params'.
(org-cite-csl--parse-reference): Don't generate `suppress-author' cite
information as that is treated now by citeproc-el as a citation style.
(org-cite-csl--create-structure): Use `org-cite-csl--create-structure-params' to
generate style-dependent citation structure parameters.
2021-09-28 16:39:10 +02:00
Nicholas Vollmer 3f1bf8c1f6 org-capture: Fix checkdoc warnings
* org-capture: Fix checkdoc warnings.
2021-09-28 07:36:28 +02:00
Bastien 8d4a88b8d9 lisp/ob-stan.el: Delete
* lisp/ob-stan.el: Delete.

ob-stan.el has been move to https://git.sr.ht/~bzg/org-contrib and
will be maintained on https://git.kyleam.com/ob-stan in the future.
2021-09-28 07:03:53 +02:00
TEC 663255e25e org: Remove obsolete default LaTeX packages
* lisp/org.el (org-latex-default-packages-alist): Remove grffile and
textcomp from the list of default LaTeX packages to load, as they've
been obsolete for quite a few years now.

* etc/ORG-NEWS: Announce the removal of grffile and textcomp from
`org-latex-default-packages-alist'.
2021-09-27 18:40:08 +02:00