Commit Graph

693 Commits

Author SHA1 Message Date
Ihor Radchenko 6001313b8f
Merge branch 'bugfix' 2023-01-26 12:21:17 +03:00
Arash Esbati 65ca7bc6a7
lisp/ox.el: Pacify compiler warning
* lisp/ox.el (org-export-to-buffer): Escape single quote in the
example given in docstring.
Add missing '.' after the abbreviation.
2023-01-26 12:18:49 +03:00
TEC 3e23682d37
ox: Fix non-renamed variable (f to file)
* lisp/ox.el (org-export-expand-include-keyword): In 2fecd96200 "f"
was renamed to "file", but one usage was missed, which is corrected
here.
2023-01-25 21:30:11 +08:00
TEC 6b15897a56
ox: Remove unused let binding
* lisp/ox.el (org-export-parse-include-value): The current indentation
is used for expansion in `org-export--blindly-expand-include' (and
handled there).  It is not used during #+include keyword parsing.
2023-01-23 23:11:30 +08:00
TEC 2fecd96200
ox: Regain Emacs <28 compatibility with #+include
* lisp/ox.el (org-export-expand-include-keyword): Replace the (pred (not
FUN)) `pcase' form introduced in Emacs 28 with a simple `cond' statement.
2023-01-23 23:11:30 +08:00
TEC a9ee43a124
ox: Fix parsing of example #+includes
* lisp/ox.el (org-export-parse-include-value): Since the example
environment regexp does not contain a capture group, we can not assume
we can call `replace-match' on the first capture group.  Before doing
so, check that the capture group indeed exists.
2023-01-22 20:14:23 +03:00
TEC 506989bed5
ox: Improve #+include parsing docstring
* lisp/ox.el (org-export-parse-include-value): Actually describe the
parsing behaviour of the function in the docstring.
2023-01-22 18:18:38 +03:00
TEC 7e649050c7
ox: Pass through unparsed #+include content
* lisp/ox.el (org-export-parse-include-value): Adjust the block matches
not to match keywords (i.e. ":\S-+"), and both block and env to consume
their matches in value.  Now value only contains the unmatched content,
which is given in as the results plist as :unmatched.
2023-01-22 18:18:37 +03:00
TEC 5cde90e3c8
ox: Refactor org-export-expand-include-keyword
* lisp/ox.el (org-export-expand-include-keyword): Split the parsing and
inclusion logic of the ~150 line `org-export-expand-include-keyword'
into two new functions: `org-export-parse-include-value' and
`org-export--blindly-expand-include'.
2023-01-22 18:18:36 +03:00
Ihor Radchenko 0e5de0ff64
org-export-expand-include-keyword: Fix relative links in recursive includes
* lisp/ox.el (org-export-expand-include-keyword): Add new optional
argument INCLUDER-FILE to explicitly pass the includer file path when
expanding inside a temporary buffer.  Pass the INCLUDER-FILE later
during recursive expansion.

Reported-by: Gabriel Petrini da Silveira <gpetrinidasilveira@gmail.com>
Link: https://orgmode.org/list/CAHCA-UvaqnegPYfpPcJCqiY8+dDoj0pfX0vDckUui-MCj3wq5A@mail.gmail.com
2023-01-18 11:41:03 +03:00
Ihor Radchenko 25dd206a0e
Merge branch 'bugfix' 2023-01-14 16:30:26 +03:00
Ihor Radchenko 2e22a8b827
org-export-dictionary: Fix typo
* lisp/ox.el (org-export-dictionary): Fix encoding keyword.

Reported-by: Rafael Bento <rafael.bentoe.silva@gmail.com>
Link: https://orgmode.org/list/adda99a7-b21f-a33b-571d-b7bfd6d743e2@gmail.com
2023-01-14 16:28:49 +03:00
Ihor Radchenko d0758eabfe
Merge branch 'bugfix' 2023-01-12 12:23:41 +03:00
Ihor Radchenko a52d0f0918
org-export-as: Fix subtree export when metadata ends right before heading
* lisp/ox.el (org-export-as): Only include first newline after heading
line when the metadata is non-empty.
* testing/lisp/test-ox.el (test-org-export/export-scope): Add test.

Reported-by: Kaushal Modi <kaushal.modi@gmail.com>
Link: https://orgmode.org/list/CAFyQvY1d=UEJ-6ZPG1X+st=fCfBAnTfgbVNhxyxH_xKcLGG4cQ@mail.gmail.com
2023-01-12 12:23:19 +03:00
Ihor Radchenko 2f7052619b
Merge branch 'bugfix' 2023-01-07 15:15:18 +03:00
Ihor Radchenko a6523f1aa0
org-export-output-file-name: Remove redundant `cond' clause
* lisp/ox.el: Remove `cond' clause equivalent to t.
2023-01-07 15:13:52 +03:00
Kyle Meyer 96a402780c Merge branch 'bugfix' 2023-01-01 13:15:12 -05:00
Eli Zaretskii e0815d7545 Backport commit cae528457 from Emacs
; Add 2023 to copyright years.
cae528457cb862dc886a34240c9d4c73035b6659
Eli Zaretskii
Sun Jan 1 05:31:12 2023 -0500
2023-01-01 12:44:47 -05:00
TEC 0db972ad63
ox: Handle failure to localize link
* lisp/ox.el (org-export-link-localise): When no local copy of the link
resource could be fetched, produce a warning message and do nothing
instead of setting the link :path to nil.
2022-12-14 12:31:56 +03:00
Ihor Radchenko 71a5f75bbb
Merge branch 'bugfix' 2022-12-13 11:50:50 +03:00
Ihor Radchenko 7048876f6f
org-export-get-ordinal: Do not ignore ELEMENT type when TYPES is given
* lisp/ox.el (org-export-get-ordinal): Append ELEMENT type to TYPES,
when TYPES is non-nil.
2022-12-13 11:49:42 +03:00
Ihor Radchenko bdb4c4c66e
org-export-get-ordinal: Fix breakage in 0551eba40
* lisp/ox.el (org-export-get-ordinal): Do not return first cached
number.  Search the actual requested element.  Do not disregard TYPES
argument in the cache.

Reported-by: Kaushal Modi <kaushal.modi@gmail.com>
Link: https://orgmode.org/list/CAFyQvY342ee8OgWVQdv=z3V1_3rgLttb2S0v27JLjF0KiMH0qA@mail.gmail.com
2022-12-13 11:49:41 +03:00
TEC a6fc8d3f1f
ox: Handle failure to localize link
* lisp/ox.el (org-export-link-localise): When no local copy of the link
resource could be fetched, produce a warning message and do nothing
instead of setting the link :path to nil.
2022-12-11 15:47:33 +08:00
Ihor Radchenko 28dc983fff
Merge branch 'bugfix' 2022-12-10 12:45:08 +03:00
Ihor Radchenko 0616b3c375
org-export-as: Fix edge case during subtree export
* lisp/ox.el (org-export-as): Make sure that narrowing includes top
heading in a subtree when subtree export is requested.  This is needed
after 927621910 changed `org-export--get-subtree-options' behavior.

Reported-by: Alejandro Pérez Carballo <apc@umass.edu>
Link: https://orgmode.org/list/m2sfhpffui.fsf@umass.edu
2022-12-10 12:43:19 +03:00
Kyle Meyer bd5a39e60e Merge branch 'bugfix' 2022-12-09 22:55:39 -05:00
Stefan Kangas 1ce9da0048 Backport commit 8fb2afe05 from Emacs
; Fix typos
8fb2afe051168b2eac2bba0ee102039d0af90a05
Stefan Kangas
Thu Dec 8 07:17:47 2022 +0100
2022-12-09 22:49:40 -05:00
Stefan Kangas 81b083b083
Improve Swedish entry in org-export-dictionary
* lisp/ox.el (org-export-dictionary): Improve Swedish localization.
2022-12-04 16:27:33 +03:00
Ihor Radchenko 9276219103
org-export--get-subtree-options: Do not jump to parent subtree
* lisp/ox.el: Never jump to parent heading even when point is at an
existing heading.
* testing/lisp/test-ox.el (test-org-export/get-subtree-options): Fix
test assuming that current subtree may include parent.

Reported-by: Kaushal Modi <kaushal.modi@gmail.com>
Link: https://orgmode.org/list/CAFyQvY3mxi4DRTS+W-AX7bFELVujqH4DODEYPy3hyGRRuMEPSw@mail.gmail.com
2022-11-27 16:48:44 +08:00
Kyle Meyer c75aec4e6c Merge branch 'km/from-emacs-master' 2022-11-23 15:13:24 -05:00
Stefan Kangas 529c2a3df1 Backport commit beaa2e495 from Emacs
; Fix typos (misspelled symbols)
beaa2e49530b8149d2c22cb5fa15b8d48f7937b6
Stefan Kangas
Mon Nov 21 15:20:11 2022 +0100
2022-11-23 15:09:24 -05:00
Ihor Radchenko 70cee1810b
lisp/ox.el: Fix compiler warning
* lisp/ox.el (org-export--parse-option-keyword): Remove unused
variable.
2022-11-17 13:43:19 +08:00
Ihor Radchenko ad62379984
org-export: Allow "string with spaces" as #+OPTIONS: values
* lisp/ox.el (org-export--parse-option-keyword): Allow `read'ing the
option value as far as needed.  Do not restrict the value to the first
whitespace only.  This way, one can use Elisp strings with all the
escaping options as values.
* testing/lisp/test-ox.el (test-org-export/parse-option-keyword): Add
test for option value with a space inside.

Reported-by: Pierre Balayé <pierrebalaye@gmail.com>
Link: https://list.orgmode.org/orgmode/CANpQAF-n+4xhNvL8aaP8j2gJ70vbu80wmh9a4Oj0BxNHA5-yDA@mail.gmail.com/
2022-11-17 12:49:29 +08:00
Ihor Radchenko e3a7c01874
Refactor `org-time-stamp-custom-formats' and `org-time-stamp-formats'
* lisp/org.el (org-time-stamp-formats):
* lisp/org.el (org-time-stamp-custom-formats): Change the default
values stripping leading "<" and trailing ">".  Update the docstring
explaining the format and that leading and trailing brackets are now
ignored.  Update the :type specification to more precise.
(org-time-stamp-format): Update the argument list and docstring
allowing to use the function more flexibly to find the time stamp
format for both `org-time-stamp-formats' and
`org-time-stamp-custom-formats'.  Rename `long' argument to more
accurate `with-time'.  Ignore brackets in the `org-time-stamp-formats'
and `org-time-stamp-custom-formats'.  Allow `inactive' argument to be
`no-brackets'
(org-format-timestamp):
(org-read-date-display):
(org-insert-time-stamp):
(org-display-custom-time):
(org-timestamp-translate):
* lisp/org-compat.el (org-timestamp-format): Rename
`org-timestamp-format' to `org-format-timestamp'.  The old variant is
too similar with other `org-time-stamp-format' function.  Also, use
`org-time-stamp-format' to determine the timestamp format instead of
using `org-time-stamp-formats' directly.
* lisp/ol.el (org-store-link):
* lisp/org-agenda.el (org-agenda-get-timestamps):
(org-agenda-get-progress):
* lisp/org-archive.el (org-archive-subtree):
(org-archive-to-archive-sibling):
* lisp/org-clock.el (org-clock-special-range):
* lisp/org-colview.el (org-colview-construct-allowed-dates):
* lisp/org-element.el (org-element-timestamp-interpreter):
* lisp/org-macro.el (org-macro--find-date):
* lisp/org-pcomplete.el (pcomplete/org-mode/file-option/date):
* lisp/ox-odt.el (org-odt--format-timestamp):
(org-odt-template):
* lisp/ox.el (org-export-get-date):
* testing/lisp/test-org.el (test-org/timestamp-format): Use
`org-time-stamp-format' instead of directly examining
`org-time-stamp-custom-formats' and `org-time-stamp-formats'.  Use the
new function name `org-format-timestamp'.
* etc/ORG-NEWS (Default values and interpretations of ~org-time-stamp-formats~ and ~org-time-stamp-custom-formats~ are changed):
(~org-timestamp-format~ is renamed to ~org-format-timestamp~):
(Updated argument list in ~org-time-stamp-format~): Document the
user-facing changes.

This commit documents and unifies previously undocumented assumptions
about the values of `org-time-stamp-formats' and
`org-time-stamp-custom-formats'.  Instead of fiddling with
leading/trailing brackets in the values, expedite the time format
calculation to `org-time-stamp-format'.  The undocumented assumption
about brackets in user option `org-time-stamp-custom-formats' is not
relaxed making the docstring correct.

Reported-by: Uwe Brauer <oub@mat.ucm.es>
Link: https://orgmode.org/list/87k04ppp1t.fsf@localhost
2022-11-07 15:05:37 +08:00
Ihor Radchenko 192742c9c5
org-export-with-buffer-copy: Allow safe reusable buffer copy
* lisp/ox.el (org-export--generate-copy-script):
(org-export-copy-buffer):  Accept cl-style key arguments.
* lisp/ox.el (org-export-with-buffer-copy): Allow optional cl-style
key arguments for fine-grained control on what to copy from the target
buffer and which buffer to use as a target.  Do not kill the target
buffer upon finished, when the target is provided.  Make sure that
remaining buffer copy does not preserve `buffer-file-name' from the
original buffer and that it never overwrites the file associated with
the original buffer.
* lisp/ox-html.el (org-html-format-latex): Use the new version of
`org-export-with-buffer-copy' instead of managing edge cases by
itself.

Reported-by: Rudolf Adamkovič <salutis@me.com>
Link: https://orgmode.org/list/87zge8j5iu.fsf@localhost
2022-10-10 17:36:10 +08:00
Rudolf Adamkovič e7feeb2225
org-export: Propertize keybindings in Org Export dispatch UI
* lisp/ox.el (org-export--dispatch-ui): Propertize the navigational
keybindings.
2022-10-09 15:46:14 +08:00
Ihor Radchenko 233ad88651
org-export: Do not use `always' not available in Emacs <28
* lisp/ox.el (org-export--generate-copy-script): Use explicit `lambda'
instead of `always', which is not yet available in all the supported
Emacs versions.

Reported-by: Kyle Meyer <kyle@kyleam.com>
2022-10-08 13:30:36 +08:00
Ihor Radchenko 17708ab3fa
org-export-copy-buffer: Document the caveats
* lisp/ox.el (org-export-copy-buffer): Mention that `buffer-file-name'
is copied around and explain the consequences.  Document why
`buffer-file-name' is copied.
2022-10-07 18:06:12 +08:00
Ihor Radchenko 3de74bbeff
fixup! org-export-copy-buffer: Prevent saving to disk
* lisp/ox.el (org-export--generate-copy-script): Set
`write-contents-functions' after running `major-mode'.
* testing/lisp/test-ox.el (test-org-export/org-export-copy-buffer):
Add test.
2022-10-07 17:46:15 +08:00
Ihor Radchenko 514e3a9cd2
org-export: Suppress cache persistence in buffer copies during export
* lisp/org-element.el (org-element-cache-reset): Add new optional
argument that suppresses all persistence-related calculations.
* lisp/org-table.el (org-element-cache-reset):
* lisp/org.el (org-element-cache-reset): Update function signature.
* lisp/ox.el (org-export--generate-copy-script): Do not try to use
cache persistence in throwaway buffer copies.

Reported-by: Rudolf Adamkovič <salutis@me.com>
Link: https://list.orgmode.org/m2zgef774u.fsf@me.com/T/#t
2022-10-07 13:15:17 +08:00
Ihor Radchenko 09fd5f886a
org-html-format-latex: Avoid unnecessary string allocation
* lisp/ox.el (org-export--generate-copy-script): Add new optional
arguments to limit what is being copied.
(org-export-copy-buffer): Allow copying into provided buffer and copy
selectively passing the new optional arguments to
`org-export--generate-copy-script'.  Do not try to check if all the
local variable values are `read'able - it is only needed during async
export.
* lisp/ox-html.el (org-html-format-latex): Re-use the same hidden
buffer during export.  Only copy local variables into that buffer.

This commit avoids excessive calls to `org-mode' and copying the
exported buffer contents for every single latex fragment.  The result
is lower impact on GC and better overall performance.

Reported-by: Rudolf Adamkovič <salutis@me.com>
Link: https://list.orgmode.org/m2zgef774u.fsf@me.com/T/#t
2022-10-07 13:15:16 +08:00
Ihor Radchenko b45911d41e
org-export-copy-buffer: Prevent saving to disk
* lisp/ox.el (org-export--generate-copy-script): Prevent Emacs from
ever saving copied buffer contents to disk despite `buffer-file-name'
being set to the original value.
2022-10-07 13:15:15 +08:00
Ihor Radchenko 0551eba40c
org-export-get-ordinal: Cache results
* lisp/ox.el (org-export-get-ordinal): Cache results while counting to
avoid quadratic scaling.

Reported-by: Rudolf Adamkovič <salutis@me.com>
Link: https://list.orgmode.org/m2zgef774u.fsf@me.com/T/#t
2022-10-07 13:15:14 +08:00
Ihor Radchenko 4cb1b8ebd0
org-export-ignored-local-variables: Do not copy cache
* lisp/ox.el (org-export-ignored-local-variables): Do not copy buffer
cache.  It is large by size (and, thus, slow to `read') and may be
changed destructively by reference, interfering with the original
buffer when calling `org-export-copy-buffer'.

Reported-by: Rudolf Adamkovič <salutis@me.com>
Link: https://list.orgmode.org/m2zgef774u.fsf@me.com/T/#t
2022-10-07 13:15:14 +08:00
Ihor Radchenko aa90e5b59c
org-export-with-buffer-copy: Avoid all the hooks, not just `org-mode-hook'
* lisp/ox.el (org-export--generate-copy-script): Use
`delay-mode-hooks' to disable all the hooks to be executed instead of
only `org-mode-hook'.

Reported-by: Rudolf Adamkovič <salutis@me.com>
Link: https://list.orgmode.org/m2zgef774u.fsf@me.com/T/#t
2022-10-07 13:15:13 +08:00
Kyle Meyer 07b6a0e044 compat: Use org- wrapper for string-equal-ignore-case compatibility
* lisp/org-compat.el (org-string-equal-ignore-case): New compatibility
function.
(org-mode-flyspell-verify):
* lisp/ob-core.el (org-babel-results-keyword):
(org-babel-insert-result):
* lisp/org-lint.el (org-lint-duplicate-custom-id):
* lisp/ox.el (org-export-resolve-radio-link):
Use org-string-equal-ignore-case.

Prefer an explicit org- wrapper to isolate the kludge and avoid any
confusion about where it is defined.

This is a follow-up to the port of Emacs's 70341cab3.
2022-10-04 18:38:25 -04:00
Kyle Meyer 98e168b489 compat: Add compatibility wrapper for string-clean-whitespace
* lisp/org-compat.el (org-string-clean-whitespace): New compatibility
function.
* lisp/ox.el (org-export-resolve-radio-link): Use
org-string-clean-whitespace.

This is a follow-up to the port of Emacs's 70341cab3.
2022-10-04 18:38:25 -04:00
Kyle Meyer 42c418693f Merge branch 'km/from-emacs-master' 2022-10-04 18:37:42 -04:00
Kyle Meyer aeb934b598 Merge branch 'km/from-emacs-28' 2022-10-04 18:36:31 -04:00
Lars Ingebrigtsen e9df837d8a Backport commit 0a6e2b3bf from Emacs
* lisp/ox.el (org-export-to-file): Fix quoting of #' in doc strings.

Fix quoting of #' in some doc strings
0a6e2b3bfce8b5ae9e713e0668cb3cf5609073e2
Lars Ingebrigtsen
Wed Aug 3 13:14:32 2022 +0200
2022-10-04 17:18:04 -04:00