Commit Graph

25186 Commits

Author SHA1 Message Date
TEC e3bf83fe82
ox: Support #+include-ing URLs
* lisp/ox.el (org-export--prepare-file-contents,
org-export--inclusion-absolute-lines): Replace instances of
`(insert-file-contents FILE)' with `(insert (org-file-contents FILE))',
as in `org--collect-keywords-1'.
(org-export-expand-include-keyword): Tweak to accept a URL as FILE, and
not perform the standard "file exists and is readable" check.

* etc/ORG-NEWS: Mention this change in behaviour.
2022-06-12 18:02:25 +08:00
Ihor Radchenko f5c9ce8f06
org-babel-exp-process-buffer: Disable edit control while processing
* lisp/ob-exp.el (org-babel-exp-process-buffer): Do not track buffer
changes in element cache and org-fold after-change hooks while
updating src blocks.  `org-babel-exp-process-buffer' makes a large
number of changes, which would overload the element cache and degrade
performance.
2022-06-12 14:11:11 +08:00
Ihor Radchenko 84c89ea7cb
org-export-resolve-id-link: Pre-cache all the ids in the parse tree
* lisp/ox.el (org-export-resolve-id-link): Pre-cache all the ids in
the parse tree for faster lookup.
2022-06-12 13:32:35 +08:00
Ihor Radchenko 792cd4b0a6
org-export-resolve-fuzyy-link: Pre-cache all possible search cells
* lisp/ox.el (org-export-resolve-fuzzy-link): Before matching LINK,
pre-process and cache all the non-nil search cells in the parse tree.
When matching, use the pre-processed info.  Fix the :test function for
the cache hash table.
2022-06-12 13:06:47 +08:00
Ihor Radchenko f51c286716
org-export-get-footnote-definition: Pre-cache references in parse tree
* lisp/ox.el (org-export-get-footnote-definition): Pre-process parse
tree once to filter out all non-footnote elements.  This speeds up
subsequent footnote definition searches.
2022-06-12 13:05:16 +08:00
Ihor Radchenko 147ca39750
org-in-commented-heading-p: Do not parse section unless already cached
* lisp/org.el (org-in-commented-heading-p): When element at point is
not yet in cache, parse the parent headline instead of also parsing
section up to point.
2022-06-12 13:04:25 +08:00
Ihor Radchenko 2f8e688516
org-back-to-heading-or-point-min: Rely less on cache
* lisp/org.el (org-before-first-heading-p): Do not try to parse the
whole section when there is no cached element at point.
2022-06-12 13:03:30 +08:00
Ihor Radchenko 8a0b03fb3b
org-element-headline-parser: Fix headings like * COMMENTnospace
* lisp/org-element.el (org-element-headline-parser): Do not parse
headings like * COMMENTnospace as commented.
2022-06-12 13:02:39 +08:00
Ihor Radchenko ed6f8dc67f
org-list: Do not move point and change space when promoting/demoting items
* lisp/org-list.el (org-list-struct-apply-struct): Make sure the
origin marker is not moved to bol when promoting/demoting item in
special case:
 - item
 - <point> ::
Do not remove the trailing space after point as well.
(org-insert-item): Do not expect point to remain at bol after writing
list struct.

* testing/lisp/test-org-list.el (test-org-list/indent-item): Add tests.

Fixes https://orgmode.org/list/87o88hlkvv.fsf@gmail.com
2022-06-11 20:17:29 +08:00
Robert Pluim a8b32247d9
doc/org-manual.org: Reference org-cyclic and org-block
* doc/org-manual.org (Footnotes): Add `org-cyclic' and `org-block' to
note about org diary functions.  Add function indices for `org-date',
`org-anniversary', `org-cyclic', and `org-block'.
2022-06-11 12:48:48 +08:00
Ihor Radchenko 3825ca6ccb
Fix make doc failure introduced by 93821b431
* lisp/org-element.el (org-element--cache-for-removal): Parse
secondary :title value required by exporter.

See https://list.orgmode.org/87mtek1t63.fsf_-_@gmail.com/T/#md63481c471181c96dfb6248c1551fba219b11f30
2022-06-10 23:01:08 +08:00
Sébastien Miquel 1425a86ae7 org.el: With an active region, act with latex-preview
* lisp/org.el (org-latex-preview): With an active region, display
images for all fragments in the region. With universal prefix
argument, remove all images in the region.
2022-06-10 17:30:44 +03:00
Ihor Radchenko 57d64cf78c
Date/time prompt: Allow input of relative time in hours (e.g. +1h)
* lisp/org.el (org-read-date-analyze): Match relative hour specifier.

Fixes https://orgmode.org/list/C9A76EFA-1D76-4C5D-941D-AFA288A64CD0@icloud.com
2022-06-09 21:36:15 +08:00
Rudolf Adamkovič d9963c58dc
lisp/ol.el: Fix shadowed radio targets
* lisp/ol.el (org-update-radio-target-regexp): Sort radio targets
before building the regexp that matches them.
* testing/lisp/test-org.el: Test shadowed radio targets.  The bug
occurs when two targets share the same prefix and when and the longer
target appears first.
2022-06-09 16:22:44 +08:00
Ihor Radchenko 0e7033e0ca
org-capture: Expand sexps in template with Org mode being active
* lisp/org-capture.el (org-capture-fill-template): Enable `org-mode'
in the temporary template expansion buffer.  Update docstring
accordingly.
(org-capture-templates): Clarify that %(sexp) expansion happens in a
temporary Org mode buffer.

Fixes https://orgmode.org/list/CABUh-776V-_+_JAZwcKQm9ATcs0WUV9SmGwjooGFbt=CtwQj8g@mail.gmail.com
2022-06-09 16:12:38 +08:00
Ihor Radchenko 4487acc630
org-element-cache: Do not compare buffer positions with cache keys
* lisp/org-element.el (org-element--cache-key-less-p): Clarify that
comparison between buffer points and cache keys is not reliable.
(org-element--cache-find): Do not compare POS with cache keys.
(org-element-at-point): Use cache BEG field to determine the cached
buffer portion.
2022-06-09 15:10:18 +08:00
Ihor Radchenko 819409baab
org-get-buffer-tags: Improve performance
* lisp/org.el (org-get-buffer-tags): Use hash table to accumulate
unique tags only.  The old approach also used hash tables under the
hood of `delete-dups', but required extra memory allocation to store
the full tag list.
2022-06-09 15:07:49 +08:00
Ihor Radchenko 93821b431c
org-element--cache-for-removal: Improve performance
* lisp/org-element.el (org-element--cache-for-removal): Directly check
for headline at point instead of running full
`org-element--current-element' that is matching a large number of
regexps.
2022-06-09 15:07:38 +08:00
Ihor Radchenko 46df681336
org.el: Improve performance of deletion commands
* lisp/org.el (org-delete-char):
(org-delete-backward-char): Wrap into
`org-fold-core-ignore-modifications'.  These commands are for
interactive use anyway and they have no risk of not inheriting folding
properties.
2022-06-09 15:07:29 +08:00
Ihor Radchenko 96746438c0
org-element--cache-find: Do not hash section/org-data/table elements
* lisp/org-element.el (org-element--cache-find): Never use hashed
elements with children that can have the same :begin property.
2022-06-09 15:07:04 +08:00
Ihor Radchenko c02c0d660d
org-do-emphasis-faces: Remove link folds if any
* lisp/org.el (org-do-emphasis-faces): Reveal hidden parts of links
fontified by `org-activate-link', if any.

Partially fixes
https://list.orgmode.org/t7np1d$vu8$1@ciao.gmane.io/T/#u
The proper fix should also involve `org-activate-link' not hitting
false-positives inside verbatim.
2022-06-08 21:39:19 +08:00
Nick Dokos 9fd5349d0a
org-lint: Fix invocation with C-u prefix argument
* lisp/org-lint.el (org-lint): Fix the order of the arguments in
the `assoc-string' call when calculating the list of checkers to
invoke.

`C-u M-x org-lint' was failing to run any checkers, no matter what
category of checkers was chosen, because the calculation of the list
of checkers always returned `nil'.
2022-06-08 21:26:31 +08:00
Daniel Fleischer 1105da80a7 doc/org-manual.org: variable rename
* doc/org-manual.org: (invisible edits) org-fold-catch-invisible-edits

Suggested-by: Yury Kholodkov <marleng@disroot.org>
2022-06-06 09:34:30 +03:00
Leo Vivier cde5c5d78f
lisp/org-persist.el (org-persist-gc): Fix pcase pattern
* lisp/org-persist.el (org-persist-gc): Fix pcase pattern.

Otherwise, `(pred #'numberp)' expands to `(function numberp foo)'
where foo is the first arg of pcase.
2022-06-04 19:13:58 +08:00
Ihor Radchenko e156e54251
org-clone-local-variables: Prevent carrying over cache data
* lisp/org-macs.el (org-unique-local-variables): Add newly added cache
variables.  They must not be copied by `org-clone-local-variables'.
Otherwise, random failure may happen when cache does not correspond to
the buffer text.
2022-06-04 11:51:00 +08:00
Ihor Radchenko 548632a15e
fixup! org-element: Implement tree search caching 2022-06-03 22:09:07 +08:00
Bastien 7c5132938f Merge branch 'bugfix' 2022-06-03 08:38:29 +02:00
Bastien e0b05b0752 lisp/org.el: Bump version to 9.5.4 2022-06-03 08:37:30 +02:00
Ihor Radchenko 962b796900
org-element: Implement tree search caching
* lisp/org-element.el (org-element--cache-hash-size):
(org-element--cache-hash-statistics):
(org-element--cache-hash-nocache):
(org-element--cache-hash-size):
(org-element--cache-hash-left):
(org-element--cache-hash-right): Implement recent search cache for
`org-element--cache-find'.  The cache stores recent cache tree queries
as a vector with O(1) access time.

(org-element--cache-find): Make use of `org-element--cache-hash-left'
and `org-element--cache-hash-right' when cached query element starts
at POS and SIDE is nil.  Record statistics.

(org-element-cache-reset): Reset search cache on init.

(org-element-cache-hash-show-statistics): Provide a command reporting
the new caching efficiency.  Can be used for debugging/survey
purposes.

* lisp/org-macs.el (org-knuth-hash): Implement multiplicative hash
function.

Preliminary testing reveals that this simple strategy can reduce query
time from O(Log N) down to O(1) for ~30%-50% cache queries.
2022-06-03 09:59:58 +08:00
Ihor Radchenko b18635f745
org-persist: Disable when Emacs is called with -Q arg
* lisp/org-persist.el (org-persist-disable-when-emacs-Q): New
variable.
(org-persist-gc):
(org-persist-read):
(org-persist-write): Do nothing when
`org-persist-disable-when-emacs-Q' is non-nil and
`emacs-user-directory' is nil.
2022-06-02 11:06:53 +08:00
TEC 4197fcc641
org-plot: Run `org-plot/gnuplot-script' in org buf
* lisp/org-plot.el (org-plot/gnuplot): Instead of running
`org-plot/gnuplot-script' in a temp buffer, run it in the original Org
buffer to preserve file-local variables in the event the user has
configured `org-plot/gnuplot-term-extra' or
`org-plot/gnuplot-script-preamble' to functions that reply on local
variables.
2022-06-01 23:48:25 +08:00
Ihor Radchenko 4dda0d7a8d
org-element: Fix org-element-timestamp-parser for incomplete ranges
* lisp/org-element.el (org-element-timestamp-parser): Use more strict
regexp to match second timestamp in timestamp--timestamp range.

Fixes https://list.orgmode.org/orgmode/87tuh88kjv.fsf@localhost/
2022-05-30 19:42:34 +08:00
Ihor Radchenko 1525a5a64e
org-babel-load-file: Do not rely on `org-babel-tangle-file' making changes
* lisp/org.el (org-babel-load-file): Update modification time even
when `org-babel-tangle-file' does not actually modify the tangled
file.  This makes sure that modify-time comparison logic does not make
Org re-tangle Org file that had been changed but the changes did not
affect the tangled code.

See https://orgmode.org/list/t5j75h$dbo$1@ciao.gmane.io
2022-05-30 11:02:08 +08:00
Ihor Radchenko f6f26d4ce4
org-babel-tangle: Do not overwrite when contents does not change
* lisp/ob-tangle.el (org-babel-tangle): Do not overwrite existing
tangled files if their contents is exactly the same as we are going to
write during tangle process.  This avoids unneeded disk writes and can
speed up tangling significantly when many small files are tangled from
a single .org source.

An example of performance improvement when tangling an .org file into
~200 files:
(benchmark-run 10 (org-babel-tangle))
Before the commit (on SSD): (76.33826743 8 11.551725374)
After the commit:           (43.628606052 4 5.751274237)
2022-05-30 11:02:07 +08:00
Ihor Radchenko a407a89c5f
org-footnote.el:org-footnote-section: Fix typo in docstring
Reported in https://list.orgmode.org/c43cc980-108a-176b-accc-e5649264ba53@gmail.com/T/#u
2022-05-29 20:55:01 +08:00
Ihor Radchenko d37e4dc0f2
ox-latex: Scale inlinetasks according to column width
* lisp/ox-latex.el (org-latex-format-inlinetask-default-function): Set
inlinetask box width relative to \linewidth in current column.  Using
\textwidth scales the box wider than column in multi-column documents.
2022-05-29 18:06:12 +08:00
Ihor Radchenko 66528468a1
org-src-font-lock-fontify-block: Do not transfer non-existing properties
* lisp/org-src.el (org-src-font-lock-fontify-block): Never set
font-lock properties when `get-text-property' returns nil.  This
usually means that the property is not present in the position
property list.  The old behavior could, for example, set 'invisible
property to nil explicitly and prevent folding completely.

Fixes https://list.orgmode.org/CA+G3_PN6RvcRcvN2fM=vfK1K6UsT=nNPJ7SUucmA1Ypc=Emorg@mail.gmail.com/T/#u
2022-05-28 09:35:32 +08:00
Ihor Radchenko 5e0afb669b
org-cycle-hide-block-startup: Fix docstring
* lisp/org-cycle.el (org-cycle-hide-block-startup): #+STARTUP:
showblocks does not work, according to `org-startup-options'.  Users
need to use nohideblocks instead.
2022-05-27 15:11:17 +08:00
Matt Lundin 292116b627
manual: Fix function name and key index reference
* doc/org-manual.org: Change name to `org-cycle-force-archived` to
avoid obsolete name and fix key index reference.
2022-05-26 12:36:58 +08:00
Aaron L. Zeng 713c15d852
org-todo-yesterday: Fix interactive arg when in agenda buffer
* lisp/org.el (org-todo-yesterday): Fix an incorrect use of apply when
`org-todo-yesterday' intends to call `org-agenda-todo-yesterday' with
the same interactive arg.  Before this change, the command incorrectly
set the todo state of the task to blank when called with C-u C-u C-u
in an agenda buffer (supposed to bypass any blocked
checkboxes/subtasks).

TINYCHANGE
2022-05-26 12:32:58 +08:00
Bastien 8e69adabe2 Merge branch 'bugfix' 2022-05-22 22:02:12 +02:00
Bastien 4aaa2683b6 lisp/org-clock.el: Fix `read-number' prompt
* lisp/org-clock.el (org-clock-resolve): Fix `read-number' prompt.
2022-05-22 22:01:19 +02:00
Ihor Radchenko 2cb4f46fec
org-latex-compile: Add commentary on fallback compiler command
* lisp/ox-latex.el (org-latex-compile): Clarify when "pdflatex"
constant is used as a fallback.
2022-05-22 11:43:38 +08:00
Tyler Grinn e268e47971
lisp/org.el: Add org-property-separators option
* lisp/org.el (org-property-separators, org-property-get-separator):
Created.
(org-entry-get, org-entry-get-with-inheritance): Use new
`org-property-get-separator' function.

* testing/lisp/test-org.el (test-org/entry-get): Added tests for
combining properties with custom separators

`org-property-separators' is a customization option that allows for
properties to be combined using a separator other than the default (a
single space).  It is an alist with the car of each element being a
list of property names or regular expression and the cdr being the
separator string, like '((("EXPORT_FILE_NAME") . "/")).
2022-05-20 15:56:11 +08:00
Marco Wahl 4f0f244477 Revert "org-src: Add RET to go from overlay to edit buffer"
This reverts commit 0d39ea6ef3.
2022-05-19 12:20:31 +02:00
Marco Wahl 0d39ea6ef3 org-src: Add RET to go from overlay to edit buffer
* lisp/org-src.el (org-edit-src-goto): org-edit-src-goto factors out
the functionality from org-edit-src-continue.  The latter needs an event.

The return key is bound to org-edit-src-goto for the overlay.
2022-05-18 22:50:33 +02:00
Ihor Radchenko 2778972509
org-fold--reveal-outline-maybe: Prevent wrong-side-of-point error
* lisp/org-fold.el (org-fold--reveal-outline-maybe): Fix scenario when
point is moved beyond REGION.
2022-05-17 13:24:21 +08:00
Ihor Radchenko cdbb1c9633
org--deadline-or-schedule: Allow warning period in TIME argument
* lisp/org.el (org--deadline-or-schedule): Match warning period if
provided in TIME arg.
* testing/lisp/test-org.el (test-org/deadline): Add relevant tests.

Fixes https://orgmode.org/list/87o85bl582.fsf@localhost
2022-05-15 14:49:10 +08:00
Ihor Radchenko 5c14a17344
org-clock.el: Consider clocking-in in an empty narrowed buffer
* lisp/org-clock.el (org-clock-in): Fix wrong calculation of
TARGET-POS when we are inside an empty narrowing.

Fixes https://orgmode.org/list/87tufktz5z.fsf@posteo.de
2022-05-15 14:15:15 +08:00
Ihor Radchenko 513ab7c48c
Merge branch 'bugfix' 2022-05-14 19:34:41 +08:00