Commit graph

25264 commits

Author SHA1 Message Date
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
Ihor Radchenko ef41f385fb
fixup! org-babel-load-file: Fix loading with non-nil COMPILE argument 2022-05-14 19:34:08 +08:00
Ihor Radchenko d6bae908f3
Fix macro indentation and re-indent code misindented by nameless
* lisp/org-fold-core.el (org-fold-core-cycle-over-indirect-buffers):
(org-fold-core-ignore-modifications):
(org-fold-core-ignore-fragility-checks):
* lisp/org-macs.el (org-element-with-disabled-cache): Fix incorrect
indentation declare statement.  Body-only macros should use (indent 0)
to avoid indenting first line differently from other body.
* lisp/org-capture.el:
* lisp/org-clock.el:
* lisp/org-fold-core.el:
* lisp/org-fold.el:
* lisp/org-id.el:
* lisp/org-list.el:
* lisp/org-macs.el:
* lisp/org.el: Reindent.

Reported in https://orgmode.org/list/CAKJdtO_Z4LBGek3SUc6-a_Z0-dDd6L26_YfMYpZTn7F92uxXJQ@mail.gmail.com
2022-05-14 16:58:35 +08:00
Ihor Radchenko e5e7ae36cf
org-element--current-element: Fix #+BEGIN$ parsed as special block
* lisp/org-element.el (org-element--current-element): Use
`org-element-dynamic-block-open-re' to match blocks.

* testing/lisp/test-org-element.el (test-org-element/paragraph-parser):
Fix test relying on previous incorrect behaviour.  Empty #+BEGIN:
should be parsed as a keyword.

Reported in https://list.orgmode.org/Ycay4s3iAdEGSwgt@tuxteam.de/T/#t
2022-05-14 13:51:56 +08:00
Ihor Radchenko 3996ea99a3
org-element-map: Refer to `org-element-parse-buffer' in the docstring
* lisp/org-element.el (org-element-map): Update docstring.  Mention
that parse tree can be obtained using `org-element-parse-buffer'.  Add
an example.
2022-05-14 13:07:01 +08:00
Ihor Radchenko c508ff41e4
Merge branch 'bugfix' 2022-05-13 18:37:04 +08:00
Ihor Radchenko 4fe59b688f
org-babel-load-file: Fix loading with non-nil COMPILE argument
* lisp/org.el (org-babel-load-file): Use correct file name to load
compiled file.

Fixes https://orgmode.org/list/t5j75h$dbo$1@ciao.gmane.io
2022-05-13 18:35:13 +08:00
TEC 5766ddd758
ox-latex: Prefix lst: to source block labels
* lisp/ox-latex.el (org-latex--label): Use the "lst:" prefix when
generating source block labels ("lst" contracted from "listing").
2022-05-13 00:43:18 +08:00
TEC 2cb62c0798
news and manual: Mention ox-latex's engraved code
* etc/ORG-NEWS: Mention the addition of the "engraved" source block
transcoding backend.

* doc/org-manual.org (Footnotes, LaTeX specific properties, Source
blocks in LaTeX export): Basic documentation on the "engraved" source
block transcoding backend.
2022-05-13 00:43:18 +08:00
TEC faa5c1887c
ox-latex: Support mathescape'd code with engraved
* lisp/ox-latex.el (org-latex-src-block--engraved,
org-latex-src--engrave-mathescape-p): Using the mathescape functionality
in engrave-faces-latex v0.3.1, we can support the mathescape option of
fvextra well.  Along the way, we fix a minor issue with the localoptions
list in `org-latex-src-block--engraved`.
2022-05-13 00:43:17 +08:00
TEC af4ca40eae
ox-latex: Fix %-captions in minted/engraved code
* lisp/ox-latex.el (org-latex-src-block--engraved,
org-latex-src-block--minted): Refactor float-env to be clearer, and
switch from `format' to `concat' to fix the bug where %-chars in
captions are interpreted as a format specifier.
2022-05-13 00:43:17 +08:00
TEC 4d5805755c
ox-latex: Support setting engraved theme per-block
* lisp/ox-latex.el (org-latex-src-block--engraved,
org-latex-src--engrave-code, org-latex-inline-src-block--engraved,
org-latex-generate-engraved-preamble): Allow for the engraved theme used
to be set on a per-src-block basis with #+attr_latex: :engraved-theme
THEME.  Extra setup code is now generated in
`org-latex-generate-engraved-preamble'.  To facilitate the application
of themes to src blocks, `org-latex-src--engrave-code' now takes on a
larger portion of the transcoding work.
2022-05-13 00:43:17 +08:00
TEC a16e208938
ox-latex: Support setting the engraved theme
* lisp/ox-latex.el (org-latex-generate-engraved-preamble,
org-latex-engraved-theme): Introduce the new export keyword
LATEX_ENGRAVED_THEME with default value given by
`org-latex-engraved-theme'.  This is used to set the engraved theme used
in org-latex-engraved-theme.

This bumps the minimum required version of engrave-faces from v0.2 to
v0.3.
2022-05-13 00:43:17 +08:00
TEC b4e4b3c502
ox-latex: Replace `org-latex-listings'
* lisp/ox-latex.el (org-latex-src-block, org-latex-keyword,
org-latex-inline-src-block, org-latex-template,
org-latex--caption/label-string, org-latex-engraved-preamble,
org-latex-listings): Replace `org-latex-listings' with
`org-latex-src-block-backend', which now can be set to listings/verbatim
and no longer advertises t/nil as valid values.

* lisp/ox-beamer.el (org-beamer-template): Update in the same manner as
`org-latex-template'.

* lisp/org-compat.el: Make `org-latex-listings' an obsolete alias for
`org-latex-src-block-backend'.

* testing/lisp/test-ox.el: Replace `org-latex-listings' reference with
`org-latex-src-block-backend'.

* doc/org-manual.org (Footnotes, LaTeX specific properties, Literal
Examples): Replace references to `org-latex-listings' with
`org-latex-src-block-backend'.

* etc/ORG-NEWS: Add a news entry noting this change.

The variable `org-latex-listings' originally indicated whether source
blocks should use the listings LaTeX package, or not.  This usage has
evolved over the years, and now it sets one of four different
fontification backends.  This renaming should make the variable name a
bit less misleading.
2022-05-13 00:43:17 +08:00
TEC e07b89c31c
ox-latex: Refactor source block transcode fun sigs
* lisp/ox-latex.el (org-latex-src-block--listings,
org-latex-src-block--engraved, org-latex-src-block--minted,
org-latex-src-block--custom): Refactor these --backend functions to use
cl-defun with keys instead of having an 11-argument signature.
(org-latex-src-block): Adjust for the change in signature of the
--backend functions, and refactor the `cond' statement to use `pcase'.
2022-05-13 00:43:17 +08:00
TEC bbba45a07f
ox-latex: Don't use `length' to get string width
* lisp/ox-latex.el (org-latex-src-block--listings,
org-latex-src-block--engraved, org-latex-src-block--minted): Use
`string-width' instead of `length' to gauge the displayed width of the
string in LaTeX.  This may not be a perfect match, but it should be an
improvement.
2022-05-13 00:43:17 +08:00
TEC d30738b786
ox-latex: Introduce "engraved" code highlighting
* lisp/ox-latex.el (org-latex-src-block, org-latex-src-block--engraved,
org-latex-inline-src-block, org-latex-inline-src-block--engraved,
org-latex-src--engrave-code, org-latex-template, org-latex-listings):
Make use of the engraved-faces package (available on ELPA) to provide an
alternative LaTeX code highlighting backend which functions similarly to
htmlize.el for HTML exports.

(org-latex-engraved-preamble, org-latex-engraved-options): Introduce
variables to construct the preamble for engraved code blocks.

* lisp/ox-beamer.el (org-beamer-template): Modify to add engrave-faces
preamble when applicable.
2022-05-13 00:43:17 +08:00
TEC ca91473639
ox-latex: More versitile option construction
* lisp/ox-latex.el (org-latex--make-option-string): Support a custom
option seperator string.

(org-latex--make-option-string, org-latex-minted-options,
org-latex-listings-options): The first line of the docstrings for
`org-latex-minted-options` and `org-latex-listings-options` describe the
variables as "association lists", yet `org-latex--make-option-string`
does not handle association lists and an example of two-value lists is
provided.  To make the behaviour match the docstring,
`org-latex--make-option-string` is modified to work with either a list
two-value lists or an association list, and the examples in
`org-latex-minted-options` and `org-latex-listings-options` updated
accordingly.
2022-05-13 00:43:17 +08:00
TEC 40c559ac3d
ox-latex: Refactor `org-latex-inline-src-block'
* lisp/ox-latex.el (org-latex-inline-src-block,
org-latex-inline-src-block--minted,
org-latex-inline-src-block--listings): Extract the minted and listings
specific logic out of `org-latex-inline-src-block` into the new
functions `org-latex-inline-src-block--minted` and
`org-latex-inline-src-block--listings`.
2022-05-13 00:43:17 +08:00
TEC 61d85bcdb3
ox-latex: Refactor `org-latex-src-block'
* lisp/ox-latex.el (org-latex-src-block): Extract the per-format logic
from `org-latex-src-block' into new dedicated functions:
+ `org-latex-src-block--verbatim'
+ `org-latex-src-block--custom'
+ `org-latex-src-block--minted'
+ `org-latex-src-block--listings'
This makes `org-latex-src-block' much less monolithic, taking it from
175 lines to 30, and I find also makes it easier to understand.
2022-05-13 00:43:17 +08:00
Ihor Radchenko d5a52be0a5
org-fold-core: Remove `org-fold-core-first-unfold-functions'
* lisp/org-fold-core.el (org-fold-core-first-unfold-functions):
Remove.  This is very too tricky to implement.  In particular, when we
use jit-lock, there can be a race between calls to
`org-fold-core-region' and fontification.  For example, consider that
one of the functions in the hook folds drawers and everything is
folded initially.  Then, if the user requests unfolding headlines,
drawers, and blocks, it happens before jit-lock is ran in invisible
parts of buffer (out of the display).  Those parts will be folded
despite user explicitly requested full unfold, which is wrong.  Fixing
this behaviour would involve implementing a full-fledged tracker on
top of jit-lock, which is very too complex and will likely introduce
hard-to-debug errors.

* lisp/org-fold-core.el (org-fold-core-initialize):
(org-fold-core-region):
(org-fold-core-remove-optimisation):
* lisp/org-cycle.el (org-cycle-hide-drawers):
(org-cycle-hide-archived-subtrees): Do not use
`org-fold-core-first-unfold-functions'.

Fixes https://list.orgmode.org/80k0ar1lml.fsf@felesatra.moe/T/#u
2022-05-12 21:38:01 +08:00
Daniel Fleischer aea24b3fea lisp/org.el: Fast tag selection disabled tag face
* lisp/org.el (org-fast-tag-selection): Disabled tags face

A tag can be either selected in "current", "inherited" or disabled. When
disabled, it should have the default face. Previously, if a tag was
already selected, when deselection it will still have an org-todo face.

https://lists.gnu.org/archive/html/emacs-orgmode/2021-10/msg00350.html
2022-05-10 08:33:15 +03:00
Ihor Radchenko 0b07b30dea
orgtbl-toggle-comment: Fix when table is at point-min' or point-max'
* lisp/org-table.el (orgtbl-toggle-comment): Avoid infinite loop when
begin/end line of the table is at `point-min' or `point-max'.

Fixes https://orgmode.org/list/874k20v7sj.fsf@gmail.com
2022-05-09 21:31:54 +08:00