Commit Graph

25192 Commits

Author SHA1 Message Date
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
Ihor Radchenko 717f83bf75
org-fold--reveal-outline-maybe: Fix wrong side of point error
* lisp/org-fold.el (org-fold--reveal-outline-maybe): Widen the buffer
before testing headline validity.  Otherwise, `goto-char' may not move
where expected in narrowed buffer.
2022-05-09 20:39:57 +08:00
Ihor Radchenko 2a6f5cecf7
test-org: Add new test `test-org/org-find-olp'
* testing/lisp/test-org.el (test-org/org-find-olp): New test examining
`org-find-olp'.
2022-05-08 18:22:01 +08:00
Ignacio a3d9999d28
lisp/org.el: Match COMMENT in `org-complex-heading-regexp-format'
* lisp/org.el (org-set-regexps-and-options): Change
`org-complex-heading-regexp-format' initialization so that the regexp
it produces also matches a headline if it is commented.

TINYCHANGE
2022-05-08 18:22:01 +08:00
Tim Van den Langenbergh 06d08e6f30
lisp/ob-scheme.el: Use synchronous eval.
* ob-scheme.el (org-babel-scheme-execute-with-geiser): If available,
use the synchronous `geiser-eval-region/wait' function to get the
evaluation result.

Works with geiser 0.18 (before introduction of async evaluation) and
geiser 0.22 (which introduces `geiser-eval-region/wait').

Modified from a patch proposal by Felipe Lema.

TINYCHANGE
2022-05-08 17:59:59 +08:00
Ihor Radchenko 2e4ed52b19
org-fold: Revert old behaviour when handling invisible edits
* lisp/org-fold-core.el (org-fold-core-folded-p): Allow list of fold
types to be passed as argument.
* lisp/org-fold.el (org-fold-check-before-invisible-edit--overlays):
(org-fold-check-before-invisible-edit--text-properties): Make
overlay/text-property behaviour consistent.  Do not handle edits
inside folded links.  Fix inconsistencies.
* testing/lisp/test-org-fold.el:
* testing/lisp/test-org.el: Move folding-related tests to new test
file.
* testing/lisp/test-org-fold.el:
(test-org-fold/org-catch-invisible-edits): New test.

See https://orgmode.org/list/m2o809q170.fsf@gmail.com
2022-05-08 17:26:42 +08:00
Ihor Radchenko b5f0efc049
ob-plantuml: Allow setting PlantUML args for jar file
* lisp/ob-plantuml.el (org-plantuml-args): Rename
`org-plantuml-executable-args' to `org-plantuml-args'.
(org-babel-execute:plantuml): Use `org-plantuml-args' when calling
jar.
* lisp/org-compat.el (org-plantuml-executable-args): Obsolete old
variable name.
* etc/ORG-NEWS (=org-plantump-executable-args= is renamed and applies
to jar as well): Document change.

See the discussion in https://list.orgmode.org/orgmode/87y23hr045.fsf@localhost/
2022-05-08 14:44:58 +08:00
TEC 15d25644cc
org-entities: Change \minus to -
* lisp/org-entities.el: The LaTeX command \minus doesn't exist, but a
hyphen in math mode produces a minus symbol.
2022-05-04 23:49:48 +08:00
Ihor Radchenko d2a459d259
org-fold-check-before-invisible-edit: Be smart about editing at border
*
lisp/org-fold.el (org-fold-check-before-invisible-edit--text-properties):
Consider `border-and-ok-direction' value when deciding whether to
throw an error and reveal the fold.  Never throw an error when editing
at border without affecting the text inside.

Fixes https://orgmode.org/list/m2ilqle995.fsf@gmail.com
2022-05-04 22:37:29 +08:00
Ihor Radchenko ebbef7b30c
org-fold-save-outline-visibility: Make it work with 'text-properties
*
lisp/org-fold.el (org-fold-save-outline-visibility--text-properties):
Do not expand list of specs on compile time.  Simplify saving and
re-applying folds.

* lisp/org-fold.el (org-fold-save-outline-visibility): Fix typo when
-> if.
2022-05-03 14:27:25 +08:00
Ihor Radchenko 5d3173cb04
org-compile-prefix-format: Document argument
* lisp/org-agenda.el (org-compile-prefix-format): Document the KEY
argument in the docstring.

Reported in https://orgmode.org/list/CAJ1MqVGR0w93wYi7r0NNmDJxBKeY8vh2=f307u1JeGBOUC597g@mail.gmail.com
2022-05-03 11:38:10 +08:00
Ihor Radchenko 2f19fc62ab
Merge branch 'bugfix' 2022-05-02 12:04:30 +08:00
Ihor Radchenko f8bb414615
org-at-timestamp-p: Fix compatibility with Emacs 26
* lisp/org.el (org-at-timestamp-p): Do not use variables in regexp rx
form.  They are not yet supported in Emacs 26.  Expand them at runtime
instead.
2022-05-02 12:03:52 +08:00
Jacopo De Simoi 2bd34edb64
ob-tangle.el: Handle non-string arguments more gracefully
* lisp/ob-tangle.el (org-babel-tangle-single-block): If the
  argument to :tangle is nil (e.g. when parsing conditional
  tangling such as (when condition "yes") the current code
  throws an error in `file-name-directory'.  This commit
  checks if the argument is a string before calling the fun

TINYCHANGE
2022-05-01 11:36:04 +08:00
Ihor Radchenko dba46b7bc0
* doc/org-manual.org (Tracking your habits): Fix module tag habits -> habit
Reported in https://orgmode.org/list/4971b4a8-4519-ac09-a2e1-49a910e27601@fiander.info
2022-05-01 11:06:05 +08:00
Andrew Arensburger 82a09ba0ae
org-macs.el: Fix template expansion
* lisp/org-macs.el (org-fill-template): Fix a bug in template
expansion: if one key is a substring of another key (like "noweb" and
"noweb-ref", or "tangle" and "tangle-mode"), the second key wouldn't
get expanded properly.  The problem was that keys were processed in
order of increasing length; they are now sorted in order of descending
length.

TINYCHANGE
2022-04-30 17:45:33 +08:00
Andrew Arensburger 4a30e8cc0c
test-org-macs.el: Add test for template-expansion bug
* testing/lisp/test-org-macs.el (ert-deftest test-org/fill-template):
There is a bug in `org-fill-template': it sorts and processes keys in
order of increasing length, so that "noweb" is seen before
"noweb-ref", and "tangle" before "tangle-mode".  So in a template that
includes "%noweb-ref", it will substitute the value of "noweb".

This change includes a test for this bug.

TINYCHANGE
2022-04-30 17:45:32 +08:00
Ihor Radchenko 5f184b5f23
org-inlinetask.el: Fix visibility cycling for inlinetasks
* lisp/org-inlinetask.el (org-inlinetask-hide-tasks): Make sure that
we loop over inlinetasks inside current section only.
`org-inlinetask-goto-end' moves point to the end of the inlinetask
element.  If an inlinetask is followed by a heading, the function
logic will treat the heading as the beginning of another inline task.
Prevent it by moving the point at the end of the END line of the
inlinetask.

Fixes
https://list.orgmode.org/orgmode/CAP7OBx+rs-7v4jstEFYC4u0=0NZ3xJKfb3CNrWeDvjmwRTvgxw@mail.gmail.com/
2022-04-30 16:54:15 +08:00
Sébastien Miquel 2063596b90
ob-core.el: Add `:noweb-prefix` babel header argument
* lisp/ob-core.el (org-babel-expand-noweb-references): Add support for
`noweb-prefix' header argument, to not repeat the prefix characters
when expanding a noweb reference.
(org-babel-common-header-args-w-values):
(org-babel-safe-header-args): Add `noweb-prefix' value.
* doc/org-manual.org: Document `noweb-prefix' babel header argument.
* etc/ORG-NEWS: Document `:noweb-prefix'.
2022-04-30 16:13:55 +08:00
Ihor Radchenko a3dac4d20a
fixup! org-fold-show-set-visibility: Do not reveal emphasis unless DETAIL is `local'
* lisp/org-fold.el (org-fold-show-set-visibility--text-properties):
Consider nil value for REGION.
2022-04-29 10:55:42 +08:00
Ihor Radchenko 782a661921
org-fold-show-set-visibility: Do not reveal emphasis unless DETAIL is `local'
* lisp/org-fold.el (org-fold-show-set-visibility--text-properties):
Prevent revealing hidden emphasis unless requested DETAIL is `local'.
* lisp/ol.el (org-next-link): Honour `org-fold-show-context-detail'.

Reported in https://orgmode.org/list/626a0713.1c69fb81.a3583.1a07SMTPIN_ADDED_BROKEN@mx.google.com
2022-04-28 14:33:43 +08:00
Ihor Radchenko a0b8adf08a
org-fold: Reveal hidden macro markers
* lisp/org-fold.el (org-fold-show-set-visibility--text-properties):
Unfold hidden macro markers on invisible edit.
2022-04-28 14:02:32 +08:00
Ihor Radchenko 1ed9e42238
org-todo: Fix point moving after setting todo keyword in empty heading
* lisp/org.el (org-todo): Insert new todo keyword before
`save-excursion' markers.  This avoids apparent point movement when a
new keyword is inserted into an empty heading.
Before: "* <point>" -> "*<point> TODO";
After: "* <point>" -> "* TODO<point>";

Fixes https://orgmode.org/list/87mtg6265i.fsf@yandex.com
2022-04-27 19:29:36 +08:00