Compare commits

..

303 Commits

Author SHA1 Message Date
TEC 8dac1e25f5
---END PERSONAL NOPUSH DIVIDER---
--
2.42.0
2024-02-20 16:50:45 +08:00
TEC 32b0a20060
NOPUSH org: Don't fill displayed equations in text
* list/org.el (org-fill-element): If a displayed equation (\[ ... \])
starts on its own line, it should not be filled into the rest of the
text. I.e.,

some nice text
\[
  1+1=2
\]
more text.

should not become,

some nice text \[ 1+1=3 \] more text.

While the above example may not look bad, with non-trivial equations
this can become quite messy.
2024-02-20 16:50:45 +08:00
TEC 8c5456b66e
NOPUSH org-src: Prettify inline results
* lisp/org.el (org-inline-src-prettify-results):

* lisp/org-src.el (org-fontify-inline-src-blocks-1):
2024-02-20 16:50:45 +08:00
TEC 6a587f5577
---NOPUSH PERSONAL DIVIDER---
--
2.42.0
2024-02-20 16:50:45 +08:00
TEC 12cee84433
org-latex-preview: Take advantage of dvisvgm3.2
* lisp/org-latex-preview.el (org-latex-preview--tex-styled,
org-latex-preview--dvisvgm-filter,
org-latex-preview--dvisvgm-version>=3.1,
org-latex-preview-process-alist,
org-latex-preview--dvisvgm3-minor-version): Take advantage of the new
--message flag of dvisvgm 3.2 to produce a more concise output.
2024-02-20 16:50:45 +08:00
TEC 177ba504a7
ox-html: Allow inlining svg tex as <svg> elements
* lisp/ox-html.el (org-html-latex-image--data, org-html-latex-image):
Add support for inlining dvisvgm-exported svgs as <svg> elements,
preserving the effect of the currentColor attribute.  While making this
change, we improve a few other aspects of the html LaTeX fragment export
system, namely refactoring/code style improvements and the recognition
of \[...\] and $$...$$ fragments as blocks not inline fragments.
2024-02-20 16:50:45 +08:00
TEC 318460f369
org-latex-preview: Skip blank fragments
* lisp/org-latex-preview.el (org-latex-preview--construct-entries,
org-latex-preview-auto--regenerate-overlay): Blank fragments produce
invisible previews, which is at best silly and at worst confusing.  It's
much better to simply not produce a preview image of blank fragments.
We also now avoid exessive re-numbering calculations when repeatadly
generating live previews.
2024-02-20 16:50:45 +08:00
TEC 2f2a12d50b
org-latex-preview: Accommodate a flaky cache
* lisp/org-latex-preview.el (org-latex-preview--get-cached): When using
persist, occasionally we need to be more careful about assuming that
cache entries exist.
2024-02-20 16:50:45 +08:00
Karthik Chikmagalur cd5fbb92eb
org-latex-preview: Handle html export preview fail
* lisp/org-latex-preview.el (org-latex-preview--check-all-fragments-produced):
This function assumes that previews are being generated for placement in
the buffer.  Handle the case of preview generation for HTML exports.
2024-02-20 16:50:45 +08:00
TEC 020291fe43
org-latex-preview: Fix face selection Emacs 28 bug
* lisp/org-latex-preview.el (org-latex-preview--face-around): On Emacs
28 (and presumably below), should a face with :extend set be identified
as appropriate, the overlay may cast a pall (background colour) over the
rest of the line.  This can be addressed by replacing the use of the
default face to normalise display with an anonymous face that inherits
from default and has the :extend attribute set.

Reported-by: Roshan Shariff <roshan.shariff@gmail.com>
Link: https://list.orgmode.org/CAG8iPGxoAD7qmKzDXQ_SRFbmxD7jdM96piCa-dCSCpzae4rCsw@mail.gmail.com
2024-02-20 16:50:45 +08:00
TEC aaf233d664
ox-html: Support for customised latex image dir
* lisp/ox-html.el (org-html-latex-image, org-html-prepare-latex-images,
org-html-latex-image-options): Allow for customising the LaTex image
directory in `org-html-latex-image-options'.
2024-02-20 16:50:45 +08:00
TEC 5c93e3745d
org-latex-preview: Rework general cache variable
* lisp/org-latex-preview.el (org-latex-preview--get-cached,
org-latex-preview--table, org-latex-preview-persist,
org-latex-preview-cache): Rename and tweak `org-latex-preview-persist'
to also allow for caching to a custom directory, and (in the near
future) unify behaviour with HTML export.

* testing/lisp/test-org-latex-preview.el: Accommodate for the cache variable
change.

* etc/ORG-NEWS: Accommodate for the cache variable change.
2024-02-20 16:50:45 +08:00
TEC 8c01ec6703
org-latex-preview: Add ignored auto environments
* lisp/org-latex-preview.el (org-latex-preview-live--src-buffer-setup,
org-latex-preview-auto--maybe-track-element-here,
org-latex-preview-auto-ignored-environments): Introduce a new
customisation variable `org-latex-preview-auto-ignored-environments',
for specifying environments that should not be automatically previewed.
2024-02-20 16:50:45 +08:00
Karthik Chikmagalur d21a944473
org-latex-preview: Dynamic throttle for live previews
* lisp/org-latex-preview.el (org-latex-preview-live--throttle,
org-latex-preview-live-throttle,
org-latex-preview-live--preview-times,
org-latex-preview-live--update-times,
org-latex-preview-live--record-hook,
org-latex-preview-live--regenerate,
org-latex-preview-live--update-props,
org-latex-preview-live--src-buffer-setup,
org-latex-preview-live--setup, org-latex-preview-live--teardown,
org-latex-preview--create-image-async): Find the optimal throttle
time for live preview updates dynamically.  The variable
`org-latex-preview-live--preview-times' records the last three
process run times, and `org-latex-preview-live-throttle' is set to
the average of these.  This ensures that there are never more than
two concurrent processes live-previewing a single fragment.  Start
another preview run process the end of the throttle period if the
preview image is out of date to ensure that the state of the
preview is eventually consistent with the contents of the
fragment.
2024-02-20 16:50:45 +08:00
TEC e9751ede2c
org-latex-preview: Adjust customisation scheme
* lisp/org-latex-preview.el (org-latex-preview-live--teardown,
org-latex-preview-live--setup, org-latex-preview-live--src-buffer-setup,
org-latex-preview-live--ensure-overlay, org-latex-preview-throttle,
org-latex-preview-debounce, org-latex-preview-live-preview-inline,
org-latex-preview-auto--open-this-overlay,
org-latex-preview-auto--detect-fragments-in-change,
org-latex-preview-auto--handle-post-cursor,
org-latex-preview--face-around, org-latex-preview-auto-generate,
org-latex-preview-auto-blacklist, org-latex-preview-clear-cache,
org-latex-preview--latex-preview-filter,
org-latex-preview--create-tex-file,
org-latex-preview--create-image-async, org-latex-preview--hash,
org-latex-preview--auto-aware-toggle, org-latex-preview--preview-region,
org-latex-preview-live--teardown, org-latex-preview-live--setup,
org-latex-preview-live--src-buffer-setup,
org-latex-preview-live--ensure-overlay,
org-latex-preview-auto--regenerate-overlay,
org-latex-preview-auto--close-previous-overlay,
org-latex-preview-auto--open-this-overlay,
org-latex-preview-auto--detect-fragments-in-change,
org-latex-preview--update-overlay,
org-latex-preview--indicate-processing, org-latex-preview-precompile,
org-latex-preview-open-functions, org-latex-preview-close-functions,
org-latex-preview-update-overlay-functions,
org-latex-preview-auto-command-blacklist,
org-latex-preview-processing-indicator,
org-latex-preview-default-process): Change the customisation naming
scheme to be more consistent.

* testing/lisp/test-org-latex-preview.el: Change the LaTeX preview
customisation naming scheme to be more consistent.

* lisp/org-compat.el: Change the LaTeX preview customisation naming
scheme to be more consistent.

* etc/ORG-NEWS: Change the LaTeX preview customisation naming scheme to
be more consistent.

* doc/org-manual.org (Footnotes, Previewing LaTeX fragments): Change the
LaTeX preview customisation naming scheme to be more consistent.
2024-02-20 16:50:45 +08:00
TEC b600b3c814
ox-latex: Introduce \codefont command
* lisp/ox-latex.el (org-latex-engraved-preamble): Make it easier to
customise the font used in engraved Code environments with a \codefont
command (defaulting to \footnotesize).
2024-02-20 16:50:45 +08:00
TEC c6e437b38e
ox-latex: Use more robust engraved theme grouping
* lisp/ox-latex.el (org-latex-src--engrave-code): Use of curly brackets
for grouping has a few edge-cases which \begingroup-\endgroup should not
suffer from.
2024-02-20 16:50:45 +08:00
TEC fd8c3f5593
ox-latex: Better handle multiple engraved themes
* lisp/ox-latex.el (org-latex-generate-engraved-preamble): Improve the
generated LaTeX code in the multiple-themes case. Using "\long\def"
instead of "\newcommand" mixed with "\renewcommand" is needed without
without duplicating the default theme.  The "\efstrut" command also
needs to be extracted out of the theme-generated commands, which was
previously overlooked.
2024-02-20 16:50:45 +08:00
TEC 9735905fb3
ox-latex: Fix engraved-theme propagation
* lisp/ox-latex.el (org-latex-src-block--engraved,
org-latex-src--engrave-code, org-latex-inline-src-block--engraved):
Actually propagate the ":latex-engraved-theme" property through to the
`org-latex-src--engrave-code` call.  To account for whether the theme is
the default theme, or whether it will need to be explicitly switched to,
a new indicator argument ("explicit-theme-p") has been added to
`org-latex-src--engrave-code`.
2024-02-20 16:50:45 +08:00
TEC 9e783262d4
ol: more versatile #+link replacement forms (WIP)
* lisp/ol.el (org-link-expand-abbrev, org-link--abbrev-functions): Allow
link abbreviations to use %s and %h as format-specs, as well as allowing
an anonymous function form with %(sexpr using tag).
2024-02-20 16:50:45 +08:00
TEC e24a13764a
org: Introduce semantic seperator fontification
* lisp/org.el (org-fontify-semantic-seperator,
org-set-font-lock-defaults): TODO
2024-02-20 16:50:45 +08:00
TEC a4c782d686
ox-html: Fix C++ label CSS
* lisp/ox-html.el (org-html-style-default): The "C++" pre-label works if
the "+" characters are backslash-escaped.
2024-02-20 16:50:45 +08:00
TEC d47fdb7da2
---PATCH SET DIVIDER---
--
2.42.0
2024-02-20 16:50:45 +08:00
TEC 4ed6bb632d
org-latex-preview: Formatting and spacing tweaks
* lisp/org-latex-preview.el (org-latex-preview--dvipng-filter,
org-latex-preview--latex-preview-filter,
org-latex-preview--create-tex-file,
org-latex-preview--create-image-async,
org-latex-preview--get-numbered-environments,
org-latex-preview-live--setup,
org-latex-preview-live--update-overlay-run,
org-latex-preview-auto--detect-fragments-in-change,
org-latex-preview--update-overlay): Adjust formatting/spacing.
2024-02-20 16:50:45 +08:00
Karthik Chikmagalur cd57cafea4
org-latex-preview: Live previews in org-src bufs
* lisp/org-latex-preview.el (org-latex-preview-live--src-buffer-setup):
When live previews are enabled in an Org buffer and using org-src
buffers to edit LaTeX fragments (via `org-edit-special'), show
continuously updated previews in the source Org buffer if it is
visible.  If it is not visible, show continuously updated previews
in the org-src buffer.
2024-02-20 16:50:45 +08:00
Karthik Chikmagalur b3c5251f02
org-latex-preview: Eldoc support for live previews
* lisp/org-latex-preview.el (org-latex-preview-live-display-type,
org-latex-preview-live--display-in-eldoc,
org-latex-preview-live--update-eldoc,
org-latex-preview-live--setup, org-latex-preview-live--teardown):
Add Eldoc support for live previews.  The user option
`org-latex-preview-live-display-type' now accepts the symbols
buffer and eldoc as values.  When it is set to eldoc and live
previews are enabled, display of the continuously updated previews is
handled by Eldoc.  Note that previewing larger images with Eldoc may
require `eldoc-echo-area-use-multiline-p' and `max-mini-window-height'
to be set appropriately.
2024-02-20 16:50:45 +08:00
Karthik Chikmagalur 0c64cb39ef
org-latex-preview: Add support for live previews
* lisp/org-latex-preview.el (org-latex-preview-auto-generate,
org-latex-preview-live-preview-inline, org-latex-preview-throttle,
org-latex-preview-debounce, org-latex-preview-live-display-type,
org-latex-preview-live--debounce,
org-latex-preview-live--throttle,
org-latex-preview-live--clearout,
org-latex-preview-live--regenerate,
org-latex-preview-live--update-props,
org-latex-preview-live--ensure-overlay,
org-latex-preview-live--update-overlay,
org-latex-preview-live--setup, org-latex-preview-live--teardown,
org-latex-preview-live--docstring,
org-latex-preview-live--element-type,
org-latex-preview-live--generator,
org-latex-preview--ensure-overlay,
org-latex-preview--failure-callback,
org-latex-preview--svg-make-fg-currentColor): Add support for
live-previewing LaTeX fragments.  When
`org-latex-preview-auto-generate' is set to the symbol live and
`org-latex-preview-auto-mode' is turned on, LaTeX previews are
continuously updated when editing a LaTeX fragment.  These
previews are shown to the right of or below the fragment.  The
preview generation timing can be controlled using the options
`org-latex-preview-debounce' and `org-latex-preview-throttle'.
2024-02-20 16:50:45 +08:00
TEC 4a7f68b63f
---LIVE PREVIEW DIVIDER--- 2024-02-20 16:50:45 +08:00
TEC 2a9b650443
org-latex-preview: Update copyright years 2024-02-20 16:50:45 +08:00
TEC beed6c970f
org-latex-preview: Put :page-width in opt plist
* lisp/org-latex-preview.el (org-latex-preview-options,
org-latex-preview-appearance-options): Rename
`org-latex-preview-options' to `org-latex-preview-appearance-options',
as it better reflects the purpose of the variable.

(org-latex-preview--tex-styled, org-latex-preview--image-extract-async,
org-latex-preview--create-tex-file,
org-latex-preview--create-image-async, org-latex-preview--hash,
org-latex-preview-place, org-latex-preview--update-overlay): Put the
page width specification in `org-latex-preview-appearance-options', and
adjust existing code to handle this new structuring.

* lisp/ox-html.el (org-html-prepare-latex-images,
org-html-latex-image-options): Adjust for the
`org-latex-preview-appearance-options' rename, and put :page-width in
the options plist, just with a raised value of 1.0 as the HTML default.

* lisp/org.el (org-do-latex-and-related, org-latex-preview-options),
org-compute-latex-and-related-regexp): Adjust for the
`org-latex-preview-appearance-options' rename.

* lisp/org-compat.el: Adjust for the
`org-latex-preview-appearance-options' rename.

* lisp/ob-latex.el (org-babel-execute:latex, org-latex-preview-header)):
Adjust for the `org-latex-preview-appearance-options' rename.

* etc/ORG-NEWS: Adjust for the `org-latex-preview-appearance-options'
rename.

* doc/org-manual.org (Previewing LaTeX fragments): Adjust for the
`org-latex-preview-appearance-options' rename.
2024-02-20 16:50:45 +08:00
Karthik Chikmagalur bbf569140e
org-latex-preview: Fix preview help-echo property
* lisp/org-latex-preview.el (org-latex-preview--update-overlay):
Add LaTeX compilation errors to the help-echo property when the
cursor is inside the fragment that is being previewed.  This
primarily affects the use of `org-latex-preview-auto-mode`.
2024-02-20 16:50:45 +08:00
TEC 8efc1c8f1d
org-latex-preview: Improved face heuristics
* lisp/org-latex-preview.el (org-latex-preview--face-around): To work
around issues where syntax highlighting of the underlying LaTeX fragment
interferers with the foreground colour of the preview, we append default
to the face list regardless.

(org-latex-preview--ignored-faces): While we're improving face
heuristics, it's also come to my attention that whitespace-mode can
interferer with face selection, and whitespace-mode should also be
ignored.  Perhaps this should become part of the API?
2024-02-20 16:50:45 +08:00
TEC da7605a95e
org-latex-preview: Support symbol entrypoint args
* lisp/org-latex-preview.el (org-latex-preview): Refactor to support a
symbol-value "mode" argument as well as prefix arguments.  This stops
forcing programmatic invocations from having to use uninformative
values, and actually makes the implementation slightly nicer to read I
think.

* lisp/org.el: Change the argument in the preview startup invocation to 'buffer.
2024-02-20 16:50:45 +08:00
TEC fe1d9228c4
org-latex-preview: Robustify DPI calculation
* lisp/org-latex-preview.el (org-latex-preview--get-display-dpi): It was
reported that on a WSLg system using pgtk that
`org-latex-preview--get-display-dpi' produced an arithmetic overflow
error.  Inspecting the calculation performed and docstrings of functions
involved, it seems we need to be more careful of the `display-mm-height'
output.  We now guard against it being zero or nil, which should make
the DPI calculation more robust.

Simply falling back to a guessed DPI of 140 is non-ideal, but probably
the best we can reasonably do here.
2024-02-20 16:50:45 +08:00
TEC 7ef969acb9
org-latex-preview: Guard against deleted buf/ov
* lisp/org-latex-preview.el (org-latex-preview--place-images): Since the
image generation and placement is asynchronous, it is possible that in
the meantime the target overlay or even buffer could be deleted.  To
avoid errors, we simple check that this is not the case before
attempting to place preview images.
2024-02-20 16:50:45 +08:00
TEC 96e319f5f4
org-latex-preview: Still show errs with no tooltip
* lisp/org-latex-preview.el (org-latex-preview--update-overlay): When
`tooltip-mode' is not active, still show the error, just remove multiple
spaces to be economic with the horizontal room available.  This isn't
good as showing the tooltip, but it's better than not showing anything.
2024-02-20 16:50:45 +08:00
TEC 3c836f0bf3
org-macs: Set some process variables in org-async
* lisp/org-macs.el (org-async-call): When eking out maximum performance
from external commands, there are a few potentially important process
variables. `org-async-call' is extended to support setting these, with
default values that differ from Emacs' defaults but should enable better
performance in general.
2024-02-20 16:50:45 +08:00
TEC bdc438f4ed
org-latex-preview: Mention latex buffer if no dvi
* lisp/org-latex-preview.el (org-latex-preview--failure-callback,
org-latex-preview--create-image-async): When the image conversion step
fails due to a missing input file, point the user to the LaTeX output
buffer instead of the image conversion output buffer.
2024-02-20 16:50:45 +08:00
TEC 252133b597
org-latex-preview: Include running command in bufs
* lisp/org-latex-preview.el (org-latex-preview--image-extract-async,
org-latex-preview--tex-compile-async): Add a comment at the start of the
process output buffers mentioning what the command being run is.
2024-02-20 16:50:45 +08:00
TEC 9fc512bc6e
org-latex-preview: Simplify color formatting
* lisp/org-latex-preview.el (org-latex-preview--format-color,
org-latex-preview--normalize-color): Use three decimal places, and
remove the now-obsolete `org-latex-preview--normalize-color'.

* lisp/org-compat.el (org-normalize-color): With the removal of the
`org-latex-preview--normalize-color' alias, mark `org-normalize-color'
as obsolete.
2024-02-20 16:50:45 +08:00
TEC 7295bf6b0f
org-latex-preview: Use dvisvgm 3.1+ currentcolor
* lisp/org-latex-preview.el (org-latex-preview--tex-styled,
org-latex-preview--svg-make-fg-currentColor,
org-latex-preview--dvisvgm-filter,
org-latex-preview--dvisvgm-version>=3.1): With dvisvgm 3.1+, it can
replace the foreground color with "currentColor" itself, and so we can
skip `org-latex-preview--svg-make-fg-currentColor' when we are using a
new enough dvisvgm.

(org-latex-preview--await-fragment-existance): Just in case the
asyncronicity in file writing causes issues, we keep the file existence
check (for now).
2024-02-20 16:50:45 +08:00
TEC 540690c02a
org-latex-preview: Improve env numbering calc
* lisp/org-latex-preview.el (org-latex-preview--get-numbered-environments,
org-latex-preview--environment-numbering-table): Make numbering
calculations more accurate, at the expense of a ~10x increase in the
time to calculate numbering in a document, mitigated by the use of
caching — resulting in a ~2x improvement compared to the simpler method
in subsequent runs.

(org-latex-preview--numbered-environments,
org-latex-preview--numbered-environments-single,
org-latex-preview--numbered-environments-multi,
org-latex-preview--numbered-environments-all): Split
`org-latex-preview--numbered-environments' into
`org-latex-preview--numbered-environments-single' and
`org-latex-preview--numbered-environments-multi', then rename
`org-latex-preview--numbered-environments' to
`org-latex-preview--numbered-environments-all' for the sake of clarity.

Determining the count of numbered equations in a LaTeX environment is
non-trivial.  Previously, a simple heuristic was used that counted the
number of lines ending with "\\" in particular environments, then
subtracted the number of "\nonumber" and "\tag{...}" instances.

However, lines can end with "\\" without contributing to the number of
equations in the environment, consider the "cases" and "bmatrix"
environments.  To improve the heuristic, we (with some care) remove
/all/ inner environments from the LaTeX maths environment before
processing.  Since this takes more effort, we split the numbered
environments into those we know will contain exactly one numbered
equation where we can avoid the extra processing, and those that require
the more sophisticated heuristics.

The new org-element caching API is very helpful for recovering the
performance cost of this extra computation in the long run.
2024-02-20 16:50:45 +08:00
Karthik Chikmagalur c67992527d
org-latex-preview: Fix process filter timing errs
* lisp/org-latex-preview.el (org-latex-preview--create-image-async,
org-latex-preview--latex-preview-filter,
org-latex-preview--dvipng-filter, org-latex-preview--dvisvgm-filter,
org-latex-preview--place-images): The dvipng and latex-preview filters
run concurrently (interleaved), and both contribute image metadata.
So caching/placing images cannot be associated with the dvipng filter,
this leads to non-deterministic errors where preview images can have
incomplete metadata.  To fix this, check if we are using dvipng when
running the LaTeX filter, and place images from whichever of the two
filters processes each fragment second.

Refactor: Move the image placement/caching logic fully to
`org-latex-preview--place-images' instead of duplicating code in all
three (latex-filter, dvipng and dvisvgm) previews.
2024-02-20 16:50:45 +08:00
Karthik Chikmagalur cb2906ea13
org-latex-preview: Fix LaTeX header on fails + reruns
*
lisp/org-latex-preview.el (org-latex-preview--check-all-fragments-produced):
When rerunning a preview run (because of catastrophic failures), pass
the LaTeX header used to the new process.  The current behavior passes
an empty header, which causes the process to fail again.
2024-02-20 16:50:45 +08:00
Karthik Chikmagalur 7e537b93d0
org-latex-preview: Fix xelatex preview image sizes
*
lisp/org-latex-preview.el (org-latex-preview--include-preview-string,
org-latex-preview--latex-preview-filter):  when xetex is used,
preview.sty assumes PDF output by default and does not write any
postscript data to the output XDV file.  This makes dvisvgm unable to
correctly determine the preview geometry.  Fix by specifying the
`dvips' option to preview, which adds (apparently as a side effect)
this geometry information to the XDV file.

Remove a conditional in `org-latex-preview--latex-preview-filter' that
was previously used to attempt to work around this issue.
2024-02-20 16:50:45 +08:00
Karthik Chikmagalur 73a7f69642
ox-latex: Disable precompile for xelatex/lualatex
* lisp/ox-latex.el (org-latex-make-preamble): If xelatex or
lualatex are used for LaTeX export, disable LaTeX header
precompilation (via the CTAN package mylatexformat) locally in the
buffer and issue a warning.  Xelatex does not support
precompilation, and while Lualatex supports it in some cases, it
is best left unsupported by the Org LaTeX export process until
precompilation support for them improves upstream.

* lisp/org-latex-preview.el (org-latex-preview--create-tex-file):
Make the same changes as above when precompiling LaTeX headers
for LaTeX preview purposes.
2024-02-20 16:50:45 +08:00
Karthik Chikmagalur 47f848b154
org-latex-preview: Rename precompilation vars
* lisp/org-latex-preview.el (org-latex-preview-precompile,
org-latex-preview--latex-preview-filter,
org-latex-preview--create-tex-file,
org-latex-preview-use-precompilation, org-latex-preview--precompile):
Rename (i) the user option that controls precompilation for LaTeX
previews, and (ii) the function that precompiles headres for LaTeX
previews.  This makes the names shorter and consistent with their
corresponding equivalents in `ox-latex'.

Rename
`org-latex-preview-use-precompilation' -> `org-latex-preview-precompile'
`org-latex-preview-precompile' -> `org-latex-preview--precompile'

The new names have equivalents `org-latex-precompile' and
`org-latex--precompile' in `ox-latex'.

* testing/lisp/test-org-latex-preview.el: Update tests that set this
user option.

* etc/ORG-NEWS: Update the NEWS file.
2024-02-20 16:50:45 +08:00
Karthik Chikmagalur e5e5c968cb
org-latex-preview: Fix bug clearing precompile cache
* lisp/org-latex-preview.el (org-latex-preview-clear-cache,
org-latex-preview--create-tex-file,
org-latex-preview--include-preview-string): LaTeX headers that are
precompiled include additional strings that set the
textwidth (according to `org-latex-preview-width') and include
preview.sty.  These strings are not appended to the header when
trying to clear the precompile cache for the present buffer.  Fix
by (i) removing the textwidth declaration from the precompiled
text, and (ii) including the preview.sty inclusion string with the
header we look for when trying to remove the corresponding fmt
file in the org-persist cache.

org-latex-preview--include-preview-string: Introduce string that
holds the text to include preview.sty in the document header.
2024-02-20 16:50:44 +08:00
Karthik Chikmagalur de2e0a8117
org-latex-preview: Reduce delay when re-rendering
*
lisp/org-latex-preview.el (org-latex-preview-auto--close-previous-overlay):
Reduce the delay when re-rendering fragments (with `org-latex-preview-auto-mode' turned
on) from 50 ms to 10 ms. This delay is a heuristic number for
perceived smoothness, and this change represents a tuning effort.
2024-02-20 16:50:44 +08:00
Karthik Chikmagalur 9e0e12320f
org-latex-preview: Change preview hashing parameters
* lisp/org-latex-preview.el (org-latex-preview--hash): Use only the
`:scale' parameter from `org-latex-preview-options' when hashing
fragments.  Other parameters like `:zoom' do not affect the content of
the image, so this helps avoid building up garbage in the org-persist
cache.  `org-latex-preview' is also faster since re-rendering images
is required less often.
2024-02-20 16:50:44 +08:00
Karthik Chikmagalur 453029dfb0
org-latex-preview: Change hooks to abnormal hooks
*
lisp/org-latex-preview.el (org-latex-preview-auto--close-previous-overlay,
org-latex-preview-auto--open-this-overlay,
org-latex-preview-close-hook, org-latex-preview-open-hook): Change
`org-latex-preview-open-hook' and `org-latex-preview-close-hook' to
abnormal hooks that accept an overlay as the argument.  This makes it
easier to apply overlay-specific changes -- which is what these hooks
are primarily for -- without having to find the overlay by probing the
buffer first.

Rename:
`org-latex-preview-open-hook' to `org-latex-preview-open-functions'
`org-latex-preview-close-hook' to `org-latex-preview-close-functions'
2024-02-20 16:50:44 +08:00
Karthik Chikmagalur cbfc622810
org-latex-preview: Fix clear-cache command
* lisp/org-latex-preview.el (org-latex-preview-clear-cache): When
clearing the preview cache, clear the cached preamble after clearing
the image cache, since the preamble is used to compute the image
hashes.
2024-02-20 16:50:44 +08:00
Karthik Chikmagalur a56c582473
test-org-latex-preview: Add preliminary tests
* testing/lisp/test-org-latex-preview.el: Tests for
org-latex-preview.el.

* testing/examples/org-latex-preview-test.org: Short but
full-featured document with LaTeX fragments to run tests on.
2024-02-20 16:50:44 +08:00
Karthik Chikmagalur 45bcff54a7
org-latex-preview: Don't fully reset overlay state
* lisp/org-latex-preview.el (org-latex-preview--ensure-overlay,
org-latex-preview--update-overlay): When ensuring a preview overlay
exists, do not fully reset the state of the overlay, such as the
stored image spec, the flag that checks if the preview is open, etc.
Persisting prior state is required for the "live" preview
feature (introduced in the following commits) to function.  Similarly,
if "live" previewing a LaTeX element that has an overlay attached, do
not set the overlay face or error display indicator(s).
2024-02-20 16:50:44 +08:00
Karthik Chikmagalur 4dd6672b6a
org-latex-preview: Add hooks for customization
* lisp/org-latex-preview.el (org-latex-preview-process-finish-functions,
org-latex-preview-update-overlay-hook, org-latex-preview-close-hook,
org-latex-preview-open-hook, org-latex-preview--create-image-async,
org-latex-preview-auto--handle-post-cursor,
org-latex-preview--run-finish-functions): Add four hooks for better
control of the LaTeX preview process.

`org-latex-preview-process-finish-functions': Runs after the image
conversion process. This is an abnormal hook: each hook function
accepts the same arguments as other `org-async' callbacks for this
process.

`org-latex-preview-close-hook' and `org-latex-preview-open-hook':
Run after a preview is closed (text hidden to reveal image) or
opened (image hidden to reveal text) respectively.

`org-latex-preview-update-overlay-functions': Run after a LaTeX
preview overlay is updated with a new image.  This is an abnormal
hook: each hook function accepts one argument, the overlay that was
updated.

The "live" preview system introduced in the following commits uses
these hooks, along with the facilities provided by
`org-latex-preview-auto-mode'.  In addition, these hooks will
prove useful when writing code that reuse the API afforded by
`org-latex-preview-place' to provide LaTeX previews for other
major modes.
2024-02-20 16:50:44 +08:00
TEC 3ae13a43f9
org-latex-preview: Ignored cmds list for auto mode
* lisp/org-latex-preview.el (org-latex-preview-auto-blacklist): Add a
blacklist for commands that should not cause LaTeX preview overlays to
be "opened", i.e. for preview images to be hidden and text revealed when
using `org-latex-preview-auto-mode'.  A common use case would be cursor
navigation commands like `next-line' or `scroll-up-command' that are
often intended to move the view of the buffer, where opening preview
overlays can be distracting.
2024-02-20 16:50:44 +08:00
Karthik Chikmagalur b4f883861f
org-latex-preview: Fix overlay boundary deletion bug
*
lisp/org-latex-preview.el (org-latex-preview-auto--regenerate-overlay):
When `org-latex-preview-auto-mode' is active and a LaTeX fragment
or environment boundary is deleted,
`org-latex-preview-auto--regenerate-overlay' generates a new
preview for the new org-element at point, which is no longer a
LaTeX fragment or environment.  This results in paragraph text or
other syntax being captured into the preview.  Fix by adding a
check to ensure that the element post-change is still a LaTeX
fragment or environment.
2024-02-20 16:50:44 +08:00
Karthik Chikmagalur 49d0c446a4
org-latex-preview: non-buffer-local auto-marker bug
* lisp/org-latex-preview.el (org-latex-preview-auto--marker,
org-latex-preview-auto-mode): `org-latex-preview-auto--marker' is
initialized to a marker, which can cause it to not be
buffer-local.  Instead, initialize it to nil and explicitly set it
to a marker when running `org-latex-preview-auto-mode'.
2024-02-20 16:50:44 +08:00
Karthik Chikmagalur ab38d6c974
org-latex-preview: Fix startup preamble generation
* lisp/org-latex-preview.el (org-latex-preview--get-preamble):
When `org-startup-with-latex-preview' (or the `#+startup:
latexpreview') option is set, preamble generation and
precompilation fail as latex previews are generated in the clone
of the current buffer created by `org-export-with-buffer-copy'.
This is because org-mode is turned on in the cloned buffer, which
requires creating LaTeX previews there.  Not only is this
unnecessary, it causes a flurry of errors since the cloned buffer
is killed before the previews can be placed.  Explicitly avoid
org-startup-* tasks in the cloned buffer when generating the LaTeX
preamble for our main Org buffer.
2024-02-20 16:50:44 +08:00
Karthik Chikmagalur 772b0e5dba
org-latex-preview: Ensure fmt file cache is cleared
* lisp/org-latex-preview.el (org-latex-preview-clear-cache): When
running `org-latex-preview-clear-cache', the precompiled format
file is only removed from the `org-persist' cache if the preamble
has been cached in the current buffer.  We require the format file
to always be unregistered from the cache, so generate the preamble
if necessary so it can be hashed and used as the key to find the
corresponding format file in the cache.
2024-02-20 16:50:44 +08:00
Karthik Chikmagalur 52f27790e2
org-latex-preview: Optimize overlay-modify hook
*
lisp/org-latex-preview.el (org-latex-preview-auto--mark-overlay-modified):
Reduce slightly the number of checks needed to run each time text
inside a LaTeX fragment overlay is modified.
2024-02-20 16:50:44 +08:00
Karthik Chikmagalur ce02811869
Update ORG-NEWS
* etc/ORG-NEWS: Add summary of `org-latex-preview' changes.
2024-02-20 16:50:44 +08:00
Karthik Chikmagalur a9f69fc4ef
org-manual: Update LaTeX preview section
* doc/org-manual.org (Previewing LaTeX fragments): Mention newly
added user options and `org-latex-preview-auto-mode'.
2024-02-20 16:50:44 +08:00
TEC 9226f38879
ox-html: Allow inlining of LaTeX images
* lisp/ox-html.el (org-html-latex-image, org-html-latex-image-options):
Add a new `org-html-latex-image-options' keyword, ":inline", which
controls image inlining in `org-html-latex-image'.
2024-02-20 16:50:44 +08:00
TEC d485fceb7c
org-latex-preview: Emit warning when hyperref seen
* lisp/org-latex-preview.el (org-latex-preview--latex-preview-filter):
If during LaTeX compilation hyperref seems to be present, emit a warning
mentioning the sizing issue it is known to cause.
2024-02-20 16:50:44 +08:00
TEC 70d6b3c24e
org-latex-preview: Add preview-order eqn numbering
* lisp/org-latex-preview.el (org-latex-preview--tex-styled,
org-latex-preview-numbered): Allow for preview-order based equation
numbering, by setting `org-latex-preview-numbered' to the symbol
"preview".
2024-02-20 16:50:44 +08:00
TEC 3afd1d0c9f
org-latex-preview: Use icon for non-numbered eqns
* lisp/org-latex-preview.el (org-latex-preview--get-preamble,
org-latex-preview--single-eqn-format): When numbering is turned off (via
`org-latex-preview-numbered'), instead of always showing "(1)" as the
equation number, use a diamond symbol, and in multiline environments
show +offset.  The LaTeX setup for this is stored in the new const
`org-latex-preview--single-eqn-format'.
2024-02-20 16:50:44 +08:00
TEC f7af98999c
org-latex-preview: Fix snippet preamble hash
* lisp/org-latex-preview.el (org-latex-preview--create-tex-file,
org-latex-preview--hash, org-latex-preview-place,
org-latex-preview-clear-cache): The only the default preamble was being
hashed, which led to incorrect results across documents.  To correctly
hash the preamble, it is now determined at the start of
`org-latex-preview-place', and used in `org-latex-preview--hash',
`org-latex-preview--create-tex-file', and
`org-latex-preview-clear-cache'.
2024-02-20 16:50:44 +08:00
TEC d8dd2c7222
org-latex-preview: Set overlay priority to -80
* lisp/org-latex-preview.el (org-latex-preview--ensure-overlay): Setting
the overlay priority to -80 ensures that the background colour of
hl-line-mode's overlays takes priority, improving the visual consistency
of previews in the buffer.
2024-02-20 16:50:44 +08:00
TEC 8111a28e77
ox-html: Update LaTeX export for images and mathml
* lisp/ox-html.el (org-html-latex-environment, org-html-format-latex,
org-latex-to-html-convert-command, org-format-latex-as-html,
org-html-latex-image-options): Introduce new functions and variables to
work directly with the new org-latex-preview and ox-mathml API.

* lisp/org-latex-preview.el (org-format-latex-as-html,
org-latex-preview--tex-styled, org-latex-preview-replace-fragments,
org-latex-to-html-convert-command, org-latex-preview-options,
org-latex-preview-place-image-link): Move all of the HTML-specific
processing out of org-latex-preview.el, and into ox-html.el, and remove
now-obsolete code.

* lisp/org-compat.el (org-place-formula-image, org-html-format-latex):
Relocate a copy of `org-place-formula-image' and `org-html-format-latex'
here, and mark them as obsolete.
2024-02-20 16:50:43 +08:00
TEC 65cdc3ad83
ox-mathml: Refactor mathml export
* lisp/ox-mathml.el: Introduce a new library for managing mathml conversion.

* lisp/org-latex-preview.el (org-create-math-formula,
org-format-latex-mathml-available-p, org-latex-to-mathml-jar-file): Move
the various mathml functions into ox-mathml.

* lisp/org-compat.el: Add compat entries for the various mathml
conversion functions that have now been brought under ox-mathml.

* lisp/ox-odt.el (org-odt-export-as-odf,
org-odt--translate-latex-fragments): Use the new org-mathml functions.
2024-02-20 16:49:01 +08:00
TEC f4b9b891c5
org: Update LaTeX overlay during fontification
* lisp/org.el (org-do-latex-and-related, org-latex-preview-options): To
ensure that LaTeX preview overlays update as the face changes (for
instance, when in a heading that changes level), the face used is
updated during fontification when applicable.  This also ensures that
the correct face is used when JIT fontification is active.
2024-02-20 16:49:01 +08:00
TEC 16ce57134d
org-latex-preview: Improved face adaptation
* lisp/org-latex-preview.el (org-latex-preview--face-around): Instead of
only examining the face immediately before the LaTeX snippet, also look
at the face immediately after before determining the appropriate face to
use.  This is relevant when the prior face is
uninformative (e.g. org-indent) but the latter face contains the
applicable face (e.g. org-list-dt).  Determination of the applicable
face is now performed in the new function
`org-latex-preview--face-around'.
(org-latex-preview--colors-at, org-latex-preview--update-overlay):
Rename `org-latex-preview--colors-at' to
`org-latex-preview--colors-around', and use
`org-latex-preview--face-around' for better face determination.
(org-latex-preview-place, org-latex-preview-clear-cache): Update to
provide an "end" value to `org-latex-preview--colors-around'.
2024-02-20 16:49:01 +08:00
TEC fe2d28ad33
org-latex-preview: Better handle temp/remote files
* lisp/org-latex-preview.el (org-latex-preview-precompile,
org-latex-preview--create-tex-file): Before obtaining the (compiled)
preamble, check for the temp-ness and remote-ness of the file, and act
accordingly.  Non-temp remote files are not currently supported, and an
error will now be thrown in such cases.  The temporary file status is
now passed on to `org-latex-preview-precompile' and through to
`org-latex--precompile'.
2024-02-20 16:49:01 +08:00
TEC bd16d37976
ox-latex: Handle preamble temp-ness explicitly
* lisp/ox-latex.el (org-latex--precompile, org-latex-make-preamble):
Instead of detecting relative file includes within
`org-latex--precompile', have an optional argument to signal a file can
be safely compile in the tempdir.  Move the check to
`org-latex-make-preamble' when calling `org-latex--precompile'.
2024-02-20 16:49:01 +08:00
Karthik Chikmagalur 4709ce1003
org-latex-preview: Clean up tex file on failure
*
lisp/org-latex-preview.el (org-latex-preview--create-image-async):
Ensure that the latex-preview cleanup callback runs when the
preview image extraction process fails.  This is to avoid
littering the default-directory with temporary tex files.
2024-02-20 16:49:01 +08:00
TEC cca2b007ed
org-latex-preview: Work around XeTeX misbehaviour
* lisp/org-latex-preview.el (org-latex-preview--latex-preview-filter):
Since XeLaTeX seems to misbehave with tightpage, we special-case the
tightpage processing to account for it.
2024-02-20 16:49:01 +08:00
TEC 386316e5c1
org-latex-preview: Improved error messages
* lisp/org-latex-preview.el (org-latex-preview--image-extract-async,
org-latex-preview--tex-compile-async,
org-latex-preview--create-image-async): Edit the error messages for
LaTeX compilation and image generation failure to be slightly more informative.
2024-02-20 16:49:01 +08:00
TEC 8da34d836e
org-latex-preview: Disable buf precompile on error
* lisp/org-latex-preview.el (org-latex-preview--create-tex-file): When
an error occurs during LaTeX precompilation, disable it using
`setq-local' and emit an informative warning message.
2024-02-20 16:49:01 +08:00
TEC 4d9b64ace0
org-latex-preview: Use stand-in color for SVG fg
* lisp/org-latex-preview.el (org-latex-preview--svg-make-fg-currentColor,
org-latex-preview-place): Instead of guessing the SVG foreground to be
the first color seen, set a static stand-in color that is unlikely to
occur organically.
2024-02-20 16:49:01 +08:00
TEC a28f487e6c
org-latex-preview: Guard against caching nil-files
* lisp/org-latex-preview.el (org-latex-preview--cache-image): When
caching an image with `org-latex-preview--cache-image', check that the
image path is non-nil.  Should this not be true, a warning message is
emitted suggesting this is a bug that should be reported to the Org
mailing list.
2024-02-20 16:49:01 +08:00
TEC 127016cff1
org-latex-preview: Get a list of all started tasks
* lisp/org-latex-preview.el (org-latex-preview--create-image-async):
Instead of just returning the main tex-compile task, return a list of
all async tasks created (i.e. the dvipng task, when used).  This will
allow for `org-async-wait-for' to be used on the list to wait until all
processing has completed.
2024-02-20 16:49:01 +08:00
TEC c465870516
org-latex-preview: Split out entry construction
* lisp/org-latex-preview.el (org-latex-preview--place-from-elements,
org-latex-preview--construct-entries): Split the entry construction code
into its own function `org-latex-preview--construct-entries'.

This change will make it easier to generate previews during export.
2024-02-20 16:49:01 +08:00
TEC 48aab53799
org-latex-preview: Construct numbering from tree
* lisp/org-latex-preview.el (org-latex-preview--get-numbered-environments,
org-latex-preview--environment-numbering-table): Extend
`org-latex-preview--get-numbered-environments' and
`org-latex-preview--environment-numbering-table' to accept a parse tree
to operate on as an optional argument.

This will be useful when trying to integrate numbering with exports.
2024-02-20 16:49:01 +08:00
TEC f55d9d544f
org-latex-preview: Wait for SVGs more robustly
* lisp/org-latex-preview.el (org-latex-preview--svg-make-fg-currentColor,
org-latex-preview--dvisvgm-filter): Instead of waiting 0.01s and hoping
that an SVG exists by that point, we can wait and check for the
existance of an SVG within
`org-latex-preview--svg-make-fg-currentColor', and that should reduce
the chance of edge cases where the delay is insufficient.
(org-latex-preview--svg-make-fg-currentColor): Adjust the
`buffer-substring' call to not error when the buffer is empty.
2024-02-20 16:49:01 +08:00
TEC fd4a5a2f1d
org-latex-preview: Move org-format-latex to compat
* lisp/org-latex-preview.el (org-latex-preview-create-image,
org-format-latex): It has become apparent that it is not reasonably
possible to maintain the behaviour of `org-format-latex' and
`org-create-formula-image' using the new image, so instead put the
original implementations in org-compat.
(org-preview-latex-image-directory): Move and mark as obsolete in
org-compat as it has not be used.

* lisp/org-compat.el: Introduce the original `org-format-latex' and
`org-create-formula-image' definitions.  Also move
`org-preview-latex-image-directory' here and mark as obsolete, since it
has ended up being completely unused.
2024-02-20 16:49:01 +08:00
Karthik Chikmagalur aab33d6872
org-latex-preview: Get geometry from preview.sty
* lisp/org-latex-preview.el (org-latex-preview--latex-preview-filter,
org-latex-preview--tex-scale-divisor,
org-latex-preview--dvipng-dpi-pt-factor): Fetch image geometry and
alignment information from the LaTeX compilation output instead of
dvisvgm or dvipng.  This calculation is simpler and should work for all
image converters (including imagemagick) and with all latex
processors (including xelatex and lualatex).

(org-latex-preview--shameful-magic-tex-scaling-factor): New
variable to match image geometry reported by preview.sty and that
computed by dvisvgm.

(org-latex-preview--dvipng-filter, org-latex-preview--dvisvgm-filter,
org-latex-preview--latex-preview-filter,
org-latex-preview--display-info): Adjust to no longer use the old sizing
information.

* lisp/org-latex-preview.el (org-latex-preview-process-alist,
org-latex-preview-create-image, org-latex-preview--display-info,
org-latex-preview--image-extract-async): Remove the :image-size-adjust
keyword, as with the new geometry detection system it is redundant.

We tried also switching dvisgm from "--bbox=preview" to "--exact-bbox",
as it should no longer be needed, but testing found "--exact-bbox" to
cause sizing issues in practice.
2024-02-20 16:49:01 +08:00
TEC 768fbc9afc
org-latex-preview: Introduce a place-preview arg
* lisp/org-latex-preview.el (org-latex-preview--dvipng-filter,
org-latex-preview--dvisvgm-filter,
org-latex-preview--check-all-fragments-produced,
org-latex-preview--generic-callback,
org-latex-preview--create-image-async, org-latex-preview-place):
Refactor the preview pipeline to use a "place-preview" argument to
indicate that LaTeX previews should be placed after generation.

This change will pave the way for use with export, where the LaTeX
preview should be generated but not previewed.
2024-02-20 16:49:01 +08:00
TEC 2aa6c8b81e
ox-latex: Precompile preamble for export
* lisp/ox-latex.el (org-latex-precompile, org-latex-make-preamble): Make
use of "mylatexformat" to precompile the LaTeX preamble, for faster
exports.
(org-latex--remove-cached-preamble): Add a function to clear a cached
preamble.

* lisp/org-latex-preview.el (org-latex-preview-precompile,
org-latex-preview--get-preamble): Relocate the precompilation
functionality to ox-latex.el, and use the new ox-latex preamble
precompilation API.
(org-latex-preview-clear-cache): Use the new preamble cache clearing
functionality in ox-latex.
2024-02-20 16:49:01 +08:00
TEC fcb98fa2bb
org-latex-preview: Use org-persist for .fmt cache
* lisp/org-latex-preview.el (org-latex-preview-precompile,
org-latex-preview--create-tex-file): Cache compiled ".fmt" format dump
files with org-persist, instead of using predictably named tempfiles.
`org-latex-preview--precompile-preamble' is introduced to seperate out
the compilation process from the org-persist interaction.  As a result
of the new changes, the ".fmt" extension is also returned now, and so it
must be stripped in `org-latex-preview--create-tex-file'.
2024-02-20 16:49:01 +08:00
TEC ea6e996fa0
org-latex-preview: Rework auto toggle behaviour
* lisp/org-latex-preview.el (org-latex-preview--auto-aware-toggle):
Adjust the toggle behaviour to hopefully behave more intuitively.
2024-02-20 16:49:01 +08:00
TEC de22f5e4aa
org-latex-preview: org-latex-conditional-features
* lisp/org-latex-preview.el (org-latex-preview--get-preamble):
2024-02-20 16:49:01 +08:00
Karthik Chikmagalur 5802eaa2ac
org-latex-preview: Reduce verbosity of messaging
* lisp/org-latex-preview.el (org-latex-preview--cleanup-callback,
org-latex-preview--create-image-async, org-latex-preview-place,
org-latex-preview--auto-aware-toggle, org-latex-preview,
org-latex-preview-auto--regenerate-overlay): Do not emit a message
when previewing is successful.  This reduces how "busy" the echo area
is, especially when `org-latex-preview-auto-mode' is on.  When
previewing fails, display a message as before (behaviour unchanged).
2024-02-20 16:49:01 +08:00
TEC 0ee6e1f44d
org-latex-preview: Lazy-load, with autoloads
* lisp/org.el: No longer require org-latex-preview.

* lisp/org-latex-preview.el: Require the relevant files, and add
autoload tokens to `org-latex-preview-options',
`org-latex-preview-process-alist' (for backwards compatibility),
`org-latex-preview-auto-mode', `org-latex-preview' (the major likely
entry points), and `org-latex-preview-place` (potential external entry
point).
2024-02-20 16:49:01 +08:00
TEC 329b6e9eba
org-latex-preview: Use the conditional preamble
* lisp/org-latex-preview.el (org-latex-preview--create-tex-file,
org-latex-preview--clear-preamble-cache): Instead using a minimal info
export plist, populate it with buffer-specific values so that the
conditional preamble can be appropriately generated, and cache the
result.
2024-02-20 16:49:01 +08:00
Karthik Chikmagalur fcb1b6137f
org-latex-preview: Speed up texfile creation time
* lisp/org-latex-preview.el (org-latex-preview--create-tex-file):
Speed up texfile creation time by inhibiting fsync and setting the
`coding-system-for-write' explicitly.  Times are reduced by about
40-50%.
2024-02-20 16:49:01 +08:00
TEC 70d07ed4e5
org-latex-preview: Fix spacing before LaTeX envs
* lisp/org-latex-preview.el (org-latex-preview--create-tex-file): Set
the \abovedisplayskip length to zero to remove the default padding.
2024-02-20 16:49:01 +08:00
Karthik Chikmagalur 2a84a0d712
org-latex-preview: Fix element start positions
* lisp/org-latex-preview.el (org-latex-preview--place-from-elements,
org-latex-preview-auto--maybe-track-element-here): The org-element
property `:begin' includes any Org keyword text associated with the
element, such as "#+RESULTS:" or "#+ATTR_LATEX:" and these are swallowed
up in the created preview overlays.  Fix by using the `:post-affiliated'
property over `:begin' when it is available.  Note that some
calculations, such as equation numbering, still use the `:begin'
keyword.  These calculations don't involve creating overlays and thus
this is not (expected to be) an issue.
2024-02-20 16:49:01 +08:00
TEC d533b6f0ff
org-macs: Support blocking on async tasks
* lisp/org-macs.el (org-async--blocking-tasks, org-async-wait-for,
org-async--cleanup-process, org-async--execute-callback): Add support
for waiting for a set of async tasks to complete via the new function
`org-async-wait-for'.
2024-02-20 16:49:01 +08:00
TEC a4648bbeb4
org-latex-preview: Redesign preview creation API
* lisp/org-latex-preview.el (org-latex-preview--check-all-fragments-produced,
org-latex-preview--create, org-latex-preview-fragments,
org-latex-preview-auto--regenerate-overlay,
org-latex-preview-auto--detect-fragments-in-change): Split the
org-element processing and the preview creation components of
`org-latex-preview--create` into two new functions, `
org-latex-preview--place-from-elements' and `org-latex-preview-place'.
The latter of these can serve as a convenient public API for creating
fragments.
(org-latex-preview-place, org-latex-preview-create-image-async): To make
`org-latex-preview-place' this easier to use, we also allow the LaTeX
preamble to be provided as an optional argument, and adjust
`org-latex-preview-create-image-async' to add this as the :latex-header
to the processing-info plist.
2024-02-20 16:49:01 +08:00
Karthik Chikmagalur cf4e72ac1a
org-latex-preview: Better imagemagick cleanup
* lisp/org-latex-preview.el (org-latex-preview--generic-callback,
org-latex-preview-create-image-async,
org-latex-preview-process-alist): Reuse
`org-latex-preview--cleanup-callback' for imagemagick-based previews.
Additionally, check produced fragments and regenerate them if
necessary.
2024-02-20 16:49:01 +08:00
Karthik Chikmagalur 18ab7bc22c
org-latex-preview: Fix auto-gen at end of overlay
* lisp/org-latex-preview.el (org-latex-preview-auto--maybe-track-element-here):
`overlays-at' does not include overlays that end at the position it is
called on.  This caused auto-generation to not trigger immediately
when manually typing the closing delimiters of a LaTeX fragment. Fix
this by recording the position just before the end of a newly created overlay.
2024-02-20 16:49:01 +08:00
Karthik Chikmagalur 613b873891
org-latex-preview: Respect auto-generate option
* lisp/org-latex-preview.el (org-latex-preview-auto--detect-fragments-in-change):
Respect the user option `org-latex-preview-auto-generate' when
`org-latex-preview-auto-mode' is active.  (This was lost when the
auto-generation code was rewritten.)
2024-02-20 16:49:01 +08:00
TEC 3b9d33bbf2
org-latex-preview: Use appropriate TeX compiler
* lisp/org-latex-preview.el (org-latex-preview--tex-compile-async,
org-latex-preview-process-alist): Introduce %l and %L placeholders for
the LaTeX compiler.
(org-latex-preview-precompile): Record the LaTeX compiler in the
preamble hash, and add %l/%L to the `org-compile-file' format spec.
(org-latex-preview-compiler-command-map): Introduce a new variable to
map each LaTeX compiler name to the command and arguments needed.

Note that due to idiosyncrasies in how the various TeX compilers behave,
pdfLaTeX will likely continue to provide a smoother experience.  In the
future, some work can be done to improve this situation.
2024-02-20 16:49:01 +08:00
TEC b48745fa11
org-latex-preview: Allow setting persist expiry
* lisp/org-latex-preview.el (org-latex-preview--cache-image,
org-latex-preview-persist-expiry): Introduce a new variable
`org-latex-preview-persist-expiry' which is used within
`org-latex-preview--cache-image' as the expiry value when calling
`org-persist-register' on preview data.
2024-02-20 16:49:01 +08:00
TEC 0b674082e7
org-latex-preview: Customisable preview width
* lisp/org-latex-preview.el (org-latex-preview--create-tex-file,
org-latex-preview-width ): Introduce a new variable
`org-latex-preview-width' for convenient setting of the preview width,
and use it in the preamble generation.
(org-latex-preview-header): Remove now-redundant content (thanks to the
use of preview.sty).
2024-02-20 16:49:01 +08:00
TEC f3c0add85a
org-latex-preview: Wait for complete SVG file
* lisp/org-latex-preview.el (org-latex-preview--svg-make-fg-currentColor):
Wait until the SVG file is complete before processing it.
2024-02-20 16:49:01 +08:00
Karthik Chikmagalur c8ab31a72d
org-latex-preview: Custom processing indicator
* lisp/org-latex-preview.el (org-latex-preview-create-image-async,
org-latex-preview--update-overlay, org-latex-preview--ensure-overlay):
These functions are modified to incorporate customizable visual
indication of preview processing.
(org-latex-preview-processing-indicator): User option to customize how
preview processing is indicated visually.  The current options are:
no indication, show a fringe marker, or apply the
face `org-latex-preview-processing-face'.  The fringe marker is
currently set as the default.
(org-latex-preview--indicate-processing): Add function to handle
applying the appropriate processing indicator.
2024-02-20 16:49:01 +08:00
Karthik Chikmagalur 65c6b8334f
org-latex-preview: Compile previews in default-dir
* lisp/org-latex-preview.el (org-latex-preview--generic-callback,
org-latex-preview--tex-compile-async,
org-latex-preview--create-tex-file): Compile latex fragments in
`default-directory', with output placed in `temporary-file-directory'.
This is to ensure that relative paths in fragments (such as paths to
figures) are parsed correctly.  Note that relative paths in the header
are handled during precompilation instead.
2024-02-20 16:49:01 +08:00
Karthik Chikmagalur 4c9396b622
org-latex-preview: Rename filename parts uniformly
* lisp/org-latex-preview.el (org-latex-preview-create-image,
org-latex-preview--dvipng-filter, org-latex-preview--generic-callback,
org-latex-preview--do-cleanup,
org-latex-preview--image-extract-async): Adopt the following
convention for parts of file names used in the latex and image
processing: For file with path 'foo', foo-base refers to its base
name (no directory, no extension) and foo-no-ext refers to its full
path but without a file extension.  The third option (no directory
component but with file extension) is not used in org-latex-preview.
2024-02-20 16:49:01 +08:00
Karthik Chikmagalur c0ff434a0f
org-latex-preview: Precompile with relative paths
* lisp/org-latex-preview.el (org-latex-preview-precompile,
org-latex-preview-process-alist): Change the precompilation parameters
so the created format file includes all files included/input in the
header with paths relative to the original Org buffer.  The
precompilation is carried out by calling latex from the
`default-directory', with the source tex file and destination format
dump file both placed in `temporary-file-directory'.  Additionally the
source tex file for precompilation is deleted if the precompilation is
successful.
2024-02-20 16:49:01 +08:00
TEC fa33184c53
org-persist: Add situational write inhibition
* lisp/org-persist.el (org-persist-write, org-persist--inhibit-write): TODO
2024-02-20 16:49:01 +08:00
Karthik Chikmagalur ad8bc4201c
org-latex-preview: Compile latex in default-dir
* lisp/org-latex-preview.el (org-latex-preview-precompile,
org-latex-preview--do-cleanup, org-latex-preview--image-extract-async,
org-latex-preview--tex-compile-async,
org-latex-preview--create-tex-file): Format dump-files can be referred
to by their full paths in latex file preambles by adding a space after the "%&"
token.  Using this, we can compile the tex file containing the
previews in the same directory as the org file and handle relative
file references.  The above functions now do the following:
- format dump-file: Compiled and placed in
temporary-file-directory (no change)
- preview tex file: Refers to the format dump file in
temporary-file-directory. Compiled in default-directory, with output to
default-directory.
- image processors: Input (from tex output) in and output to
temporary-file-directory.
2024-02-20 16:49:01 +08:00
Karthik Chikmagalur ea0b32dadd
org-latex-preview: Indicate errors when using pngs
* lisp/org-latex-preview.el (org-latex-preview--update-overlay,
org-latex-preview--ensure-overlay): When using dvipng, latex errors
cannot be indicated using an error face, and if a preview is generated
it is indistinguishable from a correct one.  Fall back to a fringe
marker in this situation.
2024-02-20 16:49:01 +08:00
TEC f9fe58dc04
org-latex-preview: Introduce auto-aware toggling
* lisp/org-latex-preview.el (org-latex-preview--auto-aware-toggle,
org-latex-preview): Toggling of fragments with auto-mode active needs a
bit of work to function as most people would likely expect.  To provide
this more nuanced behaviour a new function
`org-latex-preview--auto-aware-toggle' is created and replaces the prior
"toggle this element" implementation in `org-latex-preview'.
2024-02-20 16:49:01 +08:00
TEC bd4497deae
org-latex-preview: Document async image logic
* lisp/org-latex-preview.el (org-latex-preview-create-image-async):
Explain the async call structure/logic with a large code comment.
2024-02-20 16:49:01 +08:00
Karthik Chikmagalur 03624d0124
org-latex-preview: Add error reporting via tooltip
* lisp/org-latex-preview.el (org-latex-preview--update-overlay): Add a
rudimentary interface for viewing compile errors (via tooltip).
2024-02-20 16:49:01 +08:00
TEC e8bccb2e96
org-persist: Fallback to associated files in write
* lisp/org-persist.el (org-persist-write:file): If the path given in a
file container does not exist, instead of returning nothing return the
associated path if possible.  This fixes an issue where should the
original file be deleted and `org-persist-write-all' be run, then the
file container's association will be set to nil and so when
`org-persist-gc' is run the nil path will cause
org-persist-associated-files:file to produce an error.
2024-02-20 16:49:01 +08:00
TEC d7beb5c495
org-latex-preview: Fix face checking
* lisp/org-latex-preview.el (org-latex-preview--resolved-faces-attr,
org-latex-preview--update-overlay): Handle more of the complexity of the
forms of face specifications, and avoid inheriting information from the
`org-indent' face, which is never useful.
2024-02-20 16:49:01 +08:00
TEC 164df5b2a3
org-latex-preview: Wait for dvisvgm to write
* lisp/org-latex-preview.el (org-latex-preview--dvisvgm-filter): As
mentioned in the code comment, dvisvgm seems to sometimes lie about when
file content has been written, so we need to work around that by waiting
a little bit.
(org-latex-preview--cleanup-callback): Now that the svg processing is on
a timer, we must be careful not to run the callback to soon.  This isn't
desperately urgent, so we can use a relatively generous timer for this.
2024-02-20 16:49:01 +08:00
TEC 26fb9d79de
org-latex-preview: Adjust defaults
* lisp/org-latex-preview.el (org-latex-preview,
org-latex-to-html-convert-command, org-latex-preview-process-alist):
Adjust the default LaTeX preview parameters to better suit the reworked
preview system.
2024-02-20 16:49:01 +08:00
TEC a0b9e17f82
org-latex-preview: Equation numbering
* lisp/org-latex-preview.el (org-latex-preview-numbered): Introduce a
new variable to signal whether equations numbering should be calculated
to be correct throughout the document, or not.
(org-latex-preview--numbered-environments): Create a list of known
numbered environments.
(org-latex-preview--environment-numbering-table,
org-latex-preview--get-numbered-environments): Introduce functions which
create a numbering hash table from the buffer.
(org-latex-preview--tex-styled): When an initial equation number is
provided, add LaTeX code to set the counter to apply the numbering.
(org-latex-preview--create,
org-latex-preview-auto--detect-fragments-in-change,
org-latex-preview--create): Make use of the new equation numbering
facilities.
(org-latex-preview--hash): Include first equation number (if applicable)
in the hash.
(org-latex-preview-clear-cache): Use numbering information.
2024-02-20 16:49:01 +08:00
Karthik Chikmagalur c4823b5314
org-latex-preview: Simplify overlay regeneration
* lisp/org-latex-preview.el (org-latex-preview--close-previous-overlay,
org-latex-preview--regenerate-overlay): Overlays carry information
about the buffer they belong to, so it is unnecessary to pass this
information explicitly when passing an overlay argument to a function.
2024-02-20 16:49:01 +08:00
TEC 942e4dc9db
org-latex-preview: Reuse overlays more
* lisp/org-latex-preview.el (org-latex-preview--create,
org-latex-preview--maybe-track-element-here,
org-latex-preview--make-overlay): Instead of always deleting and
re-creating overlays in a region when wanting to ensure a suitable
overlay exists, we can look at the scanned overlays, check if a suitable
overlay already exists, and re-use it.  To indicate the change in
behaviour, as well as documentation updates
`org-latex-preview--make-overlay' is renamed to
`org-latex-preview--ensure-overlay'.  While we're at it, the
"front-advance" argument is now set when calling `make-overlay', to make
sure that text typed at the beginning of the fragment is not absorbed
into the overlay.
(org-latex-preview--failure-callback): It's possible the overlay
provided could be nil when something goes wrong, in which case do
nothing.
(org-latex-preview--mark-overlay-modified): Move to a separate function
for neatness.
2024-02-20 16:49:01 +08:00
TEC 34e7495b59
org-latex-preview: Better fragment insertion check
* lisp/org-latex-preview.el (org-latex-preview--handle-insert,
org-latex-preview--detect-fragments-in-change, ): Replace the old
checker `org-latex-preview--handle-insert' that was called as a
`post-insert-hook' with a new method of checking for newly created
fragments based on buffer modifications as a `after-change-functions'
hook.  This has a number of benefits, including generally improved
robustness, and the removal of a reliance on font-lock information.
2024-02-20 16:49:01 +08:00
Karthik Chikmagalur 606a18c66f
org-latex-preview: Previews stored in /tmp
* lisp/org-latex-preview.el (org-latex-preview--get-cached,
org-latex-preview--remove-cached, org-latex-preview--cache-image):
These functions are modified to search in, remove from or add to a
session cache instead of org-persist's cache.
(org-latex-preview-persist-p): User option to turn off or on
persistent caching.
(org-latex-preview--table): Hash table used to hold preview image
metadata when using a session cache instead of org-persist.
2024-02-20 16:49:01 +08:00
Karthik Chikmagalur a1da3ed93b
org-latex-preview: Fix precomp when backend switch
* lisp/org-latex-preview: (org-latex-preview-process-alist,
org-latex-preview-precompile): Update programs required for
imagemagick conversion to include pdflatex.  Precompilation now
generates a new format file when switching
`org-latex-preview-default-process' to or from imagemagick.
2024-02-20 16:49:01 +08:00
TEC ef62c0bbaf
org-macs: Ensure that filter run before callbacks
* lisp/org-macs.el (org-async--cleanup-process): Run
`accept-process-output` until no further output is fetched on process
exit, so we can assume that the callbacks are run after all filter
invocations.
2024-02-20 16:49:01 +08:00
TEC a10c6199c0
org-macs: Add :coding kwarg to org-async-call
* lisp/org-macs.el (org-async-call): It is recommended in
(info "(elisp) Decoding Output") that the process coding system be set.
To allow for this we add a new keyword argument, :coding, and set the
default value to utf-8.
2024-02-20 16:49:01 +08:00
Karthik Chikmagalur 86a99c773e
org-latex-preview: Improve preview creation msg
* lisp/org-latex-preview.el: (org-latex-preview,
org-latex-preview-create-image-async): `org-latex-preview' starts an
async process, and so it can only inform the user of the start of the
process. Information about the completion (to success or failure) is
provided by the relevant process sentinels instead.
(org-latex-preview--latex-log, org-latex-preview--image-log,
org-latex-preview--precompile-log): Log buffer names for preview latex
processing.
(org-latex-preview--tex-compile-async,
org-latex-preview--image-extract-async, org-latex-preview-precompile,
org-latex-preview-create-image): Use the newly created log buffer name
variables.
2024-02-20 16:49:01 +08:00
Karthik Chikmagalur 4fed12c45c
org-latex-preview: Clear failed preview overlays
* lisp/org-latex-preview.el: (org-latex-preview-create-image-async): If
preview images fail to generate for some or all LaTeX fragments, the
overlays placed on the fragments during processing need to be cleared.
This is done by adding a (failure) callback function to the image
generation process.
(org-latex-preview--failure-callback): Add callback that clears overlays
for previews that fail to generate.  Other behaviours are possible here
but not implemented yet.  This includes signalling failure by changing
how the overlays are displayed, such as by adding a face or fringe
marker.
2024-02-20 16:49:01 +08:00
Karthik Chikmagalur d3ffd0b82c
org-latex-preview: Make clear-cache user-friendly
* lisp/org-latex-preview.el (org-latex-preview-clear-cache): Ask for
confirmation before wiping the entire LaTeX preview cache, and confirm
cache clearing at the end when clearing the buffer cache.
2024-02-20 16:49:01 +08:00
Karthik Chikmagalur 974b6e1bc3
org-latex-preview: Add cache clearing function
* lisp/org-latex-preview.el (org-latex-preview-clear-cache): Clears the
latex preview cache for LaTeX fragments in a region.  This can be called
as a command by itself, but is primarily required when previewing
fragments by force-regenerating their preview images.  This might be
necessary when the output image corresponding to a fragment is malformed
in some way, for instance.
2024-02-20 16:49:01 +08:00
TEC 747480ec89
org-latex-preview: More robust face resolving
* lisp/org-latex-preview.el (org-latex-preview--colors-at,
org-latex-preview--resolved-faces-attr): Just using `face-attribute' on
the first face spec given when the face text property is a list is too
naive.  To do this correctly, a new function
`org-latex-preview--resolved-faces-attr' is introduced which takes care
of the annoying semantics, and used in `org-latex-preview--colors-at' to
better resolve the face attribute.
2024-02-20 16:49:01 +08:00
Karthik Chikmagalur 9de526b642
org-latex-preview: Split org-latex-preview--create
* lisp/org-latex-preview.el (org-latex-preview--create): This function
does many tasks, including computing face colors and hashes for
fragments.  Split this function into three to reuse the parts for other
planned purposes, such as clearing cached images.
(org-latex-preview--colors-at): Finds appropriate foreground and
background colors at a position for the preview image of a LaTeX
fragment.  Also improve the code to handle multiple faces.
(org-latex-preview--hash): Computes the hash key for a LaTeX fragment
combined with relevant processing metadata.  This key is used to
identify the fragment when caching and placing images.
2024-02-20 16:49:01 +08:00
TEC 911b52b9a3
org-latex-preview: Graceful precompile failure
* lisp/org-latex-preview.el (org-latex-preview-precompile,
org-latex-preview--create-tex-file): Fall back to compiling without
using a preamble format file if the preamble could not be precompiled
without error.  In such an event, alert the user that preamble
precompilation failed, and in particular let them know if mylatexformat
could not be found.
2024-02-20 16:49:01 +08:00
TEC 1dbd8103b5
org-latex-preview: Check all fragments produced
* lisp/org-latex-preview.el (org-latex-preview--check-all-fragments-produced):
Create a new callback that checks that each fragment has indeed been
produced not, and if not guesses the last produced fragment caused a
problem.  The last produced fragment is then marked as erroneous,
its cache entry updated (replaced and re-inserted), and the remaining
fragments are regenerated.
(org-latex-preview-create-image-async): Run
`org-latex-preview--check-all-fragments-produced' after successfully
extracting images.
(org-latex-preview--cache-name, org-latex-preview--cache-image,
org-latex-preview--get-cached): Use a defconst instead of hardcoding the
cache container string in `org-latex-preview--cache-image' and
`org-latex-preview--get-cached'.
(org-latex-preview--remove-cached): Easy removal of an item from the
org-persist cache, as a counterpart to `org-latex-preview--cache-image'.
2024-02-20 16:49:01 +08:00
TEC f44d9ee651
org-latex-preview: Strip redundant color switching
* lisp/org-latex-preview.el (org-latex-preview--create,
org-latex-preview--create-tex-file): Keep track of the last fragment's
foreground/background color, and only include LaTeX color specifications
as needed.
(org-latex-preview-create-image-async): Provide the processing type so
`org-latex-preview--create-tex-file' can change the style of color
setting as appropriate.  This allows the dvipng route to use postscript
special statements instead of regular color declarations.
2024-02-20 16:49:01 +08:00
TEC 20d341f30b
org-latex-preview: Do not show empty SVG fragments
* lisp/org-latex-preview.el (org-latex-preview--svg-make-fg-currentColor):
When an SVG is empty, delete it.  This will cause
`org-latex-preview--cache-image' to give nil as the path.  When the
provided path is nil, do nothing.
(org-latex-preview--update-overlay): If the image path is nil, do
attempt to place an image.  If an error is recorded and there is no
image this causes the text to be shown with the error face.
(org-latex-preview--cleanup-callback): If the image path is nil, do not
try to delete it.
2024-02-20 16:49:01 +08:00
TEC b2cf025ec4
org-persist: Allow inhibiting of normalisation
* lisp/org-persist.el (org-persist-register,
org-persist--normalize-container,
org-persist--inhibit-container-normalization): Since container
normalisation is applied frequently (via
`org-persist--normalize-container'), when registering many new
containers the cost can quickly add up.  To avoid redundant overhead,
after normalising the container initially in `org-persist-register' we
bind a new variable `org-persist--inhibit-container-normalization' to t
and adjust `org-persist--normalize-container' to do nothing when this
new variable is non-nil.
2024-02-20 16:49:01 +08:00
TEC 4492e665dd
org-latex-preview: Cache formatted color strings
* lisp/org-latex-preview.el (org-latex-preview--format-color,
org-latex-preview--format-color-cache): Introduce a color cache alist, and use
it.
2024-02-20 16:49:01 +08:00
TEC e9261c8da6
org-latex-preview: Reduce overhead in SVG editing
* lisp/org-latex-preview.el (org-latex-preview--svg-make-fg-currentColor):
By setting the coding system and avoiding triggering any file
handlers (such as the `image-file-handler'), memory usage is nearly
halved, reducing GC pressure.
2024-02-20 16:49:01 +08:00
TEC f2137e3e8e
org-latex-preview: Tweak baseline alignment
* lisp/org-latex-preview.el (org-latex-preview--update-overlay): After
doing quite a bit of testing, tweak the ascent formula to introduce a
slight correction to visually improve the final result.
2024-02-20 16:49:00 +08:00
TEC c2d9c88316
org-latex-preview: Introduce dvipng filter
* lisp/org-latex-preview.el (org-latex-preview--dvipng-filter,
org-latex-preview-create-image-async): Introduce a dvipng filter
function to capture information from the dvipng stdout, and place images
as they are generated.
(org-latex-preview-process-alist): Update default dvipng process to emit
depth and height information.
2024-02-20 16:49:00 +08:00
TEC ba12d0d668
org-latex-preview: Eagerly make fragment overlays
* lisp/org-latex-preview.el (org-create-latex-export,
org-latex-preview--place-images, org-latex-preview--generic-callback,
org-latex-preview--create-tex-file,
org-latex-preview-create-image-async, org-latex-preview--create,
org-latex-preview--close-previous-overlay,
org-latex-preview--make-overlay, org-latex-preview--update-overlay,
org-latex-preview-processing-face): Instead of saving buffer locations
and creating an overlay after the fragment image has been generated,
create an overlay initially and then update it when the image has been
created.  This is done by splitting the image-related code of
`org-latex-preview--make-overlay' into a new function,
`org-latex-preview--update-overlay'.  This provides a number of
advantages, primarily robustness to buffer edits during image
generation.  It also allows us to create a face to indicate
in-progress (`org-latex-preview-processing-face'), which is a nice
visual indicator.
2024-02-20 16:49:00 +08:00
Karthik Chikmagalur f045db7abd
org-latex-preview: Avoid duplicating cached images
* lisp/org-latex-preview.el (org-latex-preview--cache-image): When
caching an image, check if there is already an entry in the
`org-persist--index' with the same hash as this one.  This avoids
missing preview images for fragments with duplicates in a buffer, or
across org-persist's cache.  Without this measure, when we try to
register two fragments identified by the same hash,
`org-persist-register' returns a structure with the correct metadata
for both, but with the cached image path field missing for the second
fragment.
2024-02-20 16:49:00 +08:00
Karthik Chikmagalur ab1d88477d
org-latex-preview: Prioritise near latex previews
* lisp/org-latex-preview.el (org-latex-preview-fragments): Reorder
gathered latex fragments so that they are processed starting at the
window start position.  When previewing a large file, this makes a
significant difference to the perceived speed of the processing.
Remove references to `org-preview-latex-image-directory' from this
function, as it is no longer used to cache images.
2024-02-20 16:49:00 +08:00
Karthik Chikmagalur 38b7621a9c
org-latex-preview: Avoid duplicate latex fragments
* lisp/org-latex-preview.el (org-latex-preview-collect-fragments): This
function was collecting duplicate org-elements when handling nested
latex environments (For instance, a matrix env inside an equation env).
Fix by comparing the current element with the previously collected one.
2024-02-20 16:49:00 +08:00
TEC 4e1559fc50
org-latex-preview: Inhibit fsync when editing SVGs
* lisp/org-latex-preview.el (org-latex-preview--svg-make-fg-currentColor):
The value of fsync appears questionable at best on modern hardware, and
makes little sense for small files where the performance overhead is
significant.  Thus, it makes sense to inhibit fsync when editing the
generated SVGs.
2024-02-20 16:49:00 +08:00
Karthik Chikmagalur c4246c6a97
org-latex-preview: Add org-preview-latex-auto-mode
* lisp/org-latex-preview.el (org-latex-preview--make-overlay): Add
overlay hooks that correct for any edits made inside the overlay, and
store a copy of the image specification in the "preview-image" slot.
Also return the created overlay, so it can be used in other functions.
(org-latex-preview--from-overlay-p, org-latex-preview--marker,
org-latex-preview--inhibit): New variables to keep track of overlay
state when using auto-mode.
(org-latex-preview--handle-pre-cursor,
org-latex-preview--handle-post-cursor, org-latex-preview--move-into):
Detect when the cursor is entering or leaving a preview overlay, and
trigger the appropriate action.
(org-latex-preview--open-this-overlay,
org-latex-preview--close-previous-overlay): When cursor has entered/left
a preview overlay, show the text/image as appropriate.
(org-latex-preview--handle-insert): Create a dummy preview overlay when
a new LaTeX fragment is created.
(org-latex-preview--insert-front-handler,
org-preview--insert-behind-handler): Extend preview overlay boundaries
when their content changes.
(org-latex-preview-auto-mode): A new minor mode for automatic
opening/closing of preview overlays, and regeneration.
(org-latex-preview-auto-generate-p): Variable which affects the
regeneration behaviour of `org-latex-preview-auto-mode'.
2024-02-20 16:49:00 +08:00
TEC b817e59f8d
org-latex-preview: Use prefix more consistently
* lisp/ox-odt.el (org-odt--translate-latex-fragments): Use renamed
org-latex-preview-* functions/variables.

* lisp/ox-html.el (org-html-latex-fragment, org-html-latex-environment,
org-html-format-latex, org-html-with-latex): Use renamed
org-latex-preview-* functions/variables.

* lisp/org.el (org-compute-latex-and-related-regexp,
org-latex-packages-alist): Use renamed org-latex-preview-*
functions/variables.

* lisp/org-latex-preview.el (org-dvipng-color, org-create-formula-image,
org--get-display-dpi, org-create-latex-export,
org-preview-latex--tex-styled, org-preview-precompile,
org-latex-preview--place-images, org-latex-preview--generic-callback,
org-latex-preview--image-extract-async,
org-preview-latex--create-tex-file, org-create-formula-image-async,
org-create-latex-preview, org-format-latex, org-latex-preview-fragments,
org-latex-replace-fragments, org-latex-preview,
org--latex-preview-region, org-clear-latex-preview,
org-latex-preview--handle-insert,
org-latex-preview--close-previous-overlay,
org-latex-preview--handle-post-cursor, org--make-preview-overlay,
org-latex-preview-auto-generate-p, org-preview-use-precompilation,
org-format-latex-header, org-preview-latex-process-alist,
org-preview-latex-default-process, org-format-latex-signal-error,
org-format-latex-options): Use renamed org-latex-preview-*
functions/variables.  Use the org-latex-preview group instead of
org-latex for preview-related variables.

* lisp/org-compat.el: Add entries for renamed and obsoleted
org-latex-preview-* functions/variables.

* lisp/ob-latex.el (org-babel-execute:latex, org-format-latex-header)):
Use renamed org-latex-preview-* functions/variables.

* doc/org-manual.org (Footnotes, Previewing LaTeX fragments, LaTeX
fragments): Use renamed org-latex-preview-* functions/variables.

org-latex-preview: clear overlays name

* lisp/org-latex-preview.el (org-clear-latex-preview):
2024-02-20 16:49:00 +08:00
TEC 50ce38e6cc
org-latex-preview: Basic error indication
* lisp/org-latex-preview.el (org-latex-preview--tex-compile-async,
org-latex-preview--latex-preview-filter): Search the latex compilation
stdout for fragment error messages via a process filter, and record any
found.
(org-latex-preview--display-info): Save the :error field of fragments.
(org--make-preview-overlay): When showing an SVG that has an error, use
the error face.
(org-preview-latex--tex-styled): Make any generated styling directives
take up exactly one line in all situations, so the fragment-relative
line numbers can easily be worked out in
`org-latex-preview--latex-preview-filter'.
2024-02-20 16:49:00 +08:00
TEC 0f1a04878d
org-latex-preview: Filter dvisvgm process for info
* lisp/org-latex-preview.el (org-latex-preview--display-info,
org-latex-preview--cleanup-callback, org-create-formula-image-async,
org--make-preview-overlay): Apply a filter to the dvisvgm process in
order to place overlays as images are produced, and along the way
extract size and baseline information that is used to more accurately
position the overlay image.  Because `org-latex-preview--place-images'
is now run within a filter and hence the stdout buffer, we need to
record the org buffer and switch to it before placing overlays.
(org-latex-preview--image-extract-async): Record the DPI-based scaling
factor so it can be accounted for when calculating the pt-scale fragment
height/width/depth.
(org-latex-format-options): Introduce a new parameter :zoom for
affecting the display scaling of images with associated height
resolution, but unlike :scale not the resolution/size of the images
files themselves.  This is then used in `org--make-preview-overlay'.
2024-02-20 16:49:00 +08:00
TEC ae5a053c5a
org-latex-preview: Use a fragment info plists
* lisp/org-latex-preview.el (org-latex-preview--cleanup-callback,
org-create-formula-image-async, org-create-latex-preview): Instead of
using lists of the same length for fragment information, use a single
list of fragment information plists.  This allows for more information
to be stored/used without ending up with half a dozen disparate lists
that we rely on lining up.
2024-02-20 16:49:00 +08:00
TEC b28b749952
org-latex-preview: Use org-persist for caching
* lisp/org-latex-preview.el
(org-latex-preview--cache-image, org-latex-preview--get-cached):
Implement image data save/retrieve functions using org-persist.
(org-place-latex-image, org-create-latex-export,
org-latex-preview--cleanup-callback, org-create-formula-image-async,
org-create-latex-preview, org--make-preview-overlay): Use the new model
of image data caching relying on org-persist.
2024-02-20 16:49:00 +08:00
Karthik Chikmagalur 11b003c8b9
org-latex-preview: Make image optional in overlay
* lisp/org-latex-preview.el (org-make--preview-overlay): Supplying an
image file when creating a latex preview overlay is now optional.
This change is in preparation for fully-automatic preview generation,
which requires "dummy" overlays to be placed on latex fragments that
have not yet been fully inserted or previewed.
2024-02-20 16:49:00 +08:00
Karthik Chikmagalur 9a1a4b79f5
org-latex-preview: Add imagemagick support
* lisp/org-latex-preview.el (org-preview-latex-process-alist,
org-preview-latex--create-tex-file, org-preview-precompile):
Add a new entry `:latex-precompiler' to
`org-preview-latex-process-alist', and tweak imagemagick-specific
`:image-converter' entries.  The function `org-preview-precompile' now
accepts two arguments.  Extra processing info is used to find the
right precompilation command.
2024-02-20 16:49:00 +08:00
TEC 9faf5e25ec
org-macs: Rework async filter
* lisp/org-macs.el (org-async--filter, org-async-call): Expose :info to
the async filter function, and make the obvious modifications to the
process buffer content.
2024-02-20 16:49:00 +08:00
TEC 32e0665c3c
org-macs: Accept nested org-async callbacks
* lisp/org-macs.el (org-async--execute-callback, org-async-call): Change
the org-async call arguments callback form to start with the symbol
org-async-task.  This allows for a list of callbacks to be
differentiated from a single callback.  `org-async-call' is also
extended to accept a a callback of this form as its sole argument.

* lisp/org-latex-preview.el (org-latex-preview--image-extract-async,
org-latex-preview--tex-compile-async, org-create-formula-image-async):
Use the new async callback form.
2024-02-20 16:49:00 +08:00
TEC 0fc1851c94
org-latex-preview: use currentColor in SVGs
* lisp/org-latex-preview.el (org-place-latex-image,
org-create-formula-image-async, org--make-preview-overlay,
org-latex-preview--dvisvgm-callback): Edit the dvisvgm generated SVGs to
use "currentColor" instead of a hardcoded foreground color.  To then set
the color of the displayed images, set the overlay face as appropriate.
(org-create-latex-preview): Now that the foreground is generalised, when
producing the sha1 hash for an SVG image, the current foreground value
should not affect it.
2024-02-20 16:49:00 +08:00
TEC 1a7cafe87a
org-latex-preview: Run dvipng concurrently
* lisp/org-latex-preview.el (org-create-formula-image-async): When using
dvipng with the "--follow" flag, image processing can occur
concurrently, so we may as well check for this case and start it
concurrently when this occurs.
2024-02-20 16:49:00 +08:00
TEC 1a26162c1b
org-latex-preview: Refactor async formula function
* lisp/org-latex-preview.el (org-create-preview-string,
org-create-latex-preview, org-latex-replace-fragments,
org-create-formula-image-async): Refactor
`org-create-formula-image-async', specifically by splitting up the
texfile creation, texfile compilation, image extraction, and cleanup
phases into individual functions (`org-preview-latex--create-tex-file',
`org-latex-preview--tex-compile-async',
`org-latex-preview--image-extract-async',
`org-latex-preview--cleanup-callback') and use `org-async-call' for
managing async.  Along the way a few other minor tweaks have crept in.
2024-02-20 16:49:00 +08:00
Karthik Chikmagalur 0de6a605c3
org-latex-preview: Add preamble precompilation
* lisp/org-latex-preview.el (org-create-formula-image-async): Change
how the latex header is computed to account for precompiled headers.
(org-preview-use-precompilation): Boolean to control if
header/preamble precompilation is enabled when generating latex
previews.  If enabled, previewing will be much faster at the expense
of a slower first run.
(org-preview-precompile): This function creates precompiled dumps of
latex preambles/headers, and is intended for use with
`org-create-formula-image-async'.
2024-02-20 16:49:00 +08:00
Karthik Chikmagalur 2bb8cd7959
org-latex-preview: Change default latex command
* lisp/org-latex-preview.el (org-preview-latex-process-alist,
org-create-formula-image-async): Change the default latex command to
include the input file name.  Previously the input file was introduced
via process input for compatibility with preview.sty directives.  But
it appears that it's possible to simply set \RequirePackage{preview}
in the latex header without issues.
2024-02-20 16:49:00 +08:00
TEC 912c0734d4
org-latex-preview: Get face from char before latex
* lisp/org-latex-preview.el (org-create-latex-preview): Instead of
getting the face using `face-at-point' use `get-text-property' on the
position one before the start of the LaTeX fragment.  This ensures that
the face is that of the parent element rather than the LaTeX fragment.
2024-02-20 16:49:00 +08:00
Karthik Chikmagalur 2f7646fa3c
org-latex-preview: Add async image previews
* lisp/org-latex-preview.el (org-latex-preview-fragments): Collect and
send all fragments to be processed in a single pass.

(org-create-latex-preview): Apply cached previews and send the
other fragments to be generated asynchronously.

(org-create-formula-image-async): Generate latex preview
images asynchronously and apply them to the buffer.

(org-create-preview-string): Helper function that accepts a math
fragment and returns a latex snippet suitable for use with
preview.sty. Respects color preferences.
2024-02-20 16:49:00 +08:00
TEC bf16883d07
org-latex-preview: Collect math fragments in fun
* lisp/org-latex-preview.el (org-latex-preview-fragments,
org-latex-replace-fragments, org-latex-collect-fragments): Introduce a
new function to collect all LaTeX math fragments in a
region (`org-latex-collect-fragments') and use it in
`org-latex-preview-fragments' and `org-latex-replace-fragments'.
2024-02-20 16:49:00 +08:00
TEC bf9ae8b46c
org-latex-preview: Split org-create-latex-preview
* lisp/org-latex-preview.el (org-create-latex-preview,
org-create-latex-export): Split the export and preview functionality of
`org-create-latex-preview' into two functions: a rewritten
`org-create-latex-preview' that now /only/ deals with previews, and
`org-create-latex-export' for exports.
(org-latex-preview-fragments): Use the new `org-create-latex-preview`.
(org-latex-replace-fragments): Use the new `org-create-latex-export`.
2024-02-20 16:49:00 +08:00
TEC 2b3cab47e8
org-latex-preview: Split org-format-latex into two
* lisp/org-latex-preview.el (org-format-latex, org-create-latex-preview,
org-latex-replace-fragments): The rather large `org-format-latex'
function mixed the preview and export code paths together in rather
confusing way.  This has now been split into
`org-latex-replace-fragments' for export, and
`org-latex-preview-fragments' for in-buffer previews.
(org--latex-preview-region): Replace `org-format-latex' with the more
specific `org-latex-preview-fragments'.
(org-latex-tentative-math-re): Instead of let-binding the math regexp,
use a const and explain its usage.

* lisp/ox-odt.el (org-odt--translate-latex-fragments): Replace
`org-format-latex' with the more specific `org-latex-replace-fragments`.

* lisp/ox-html.el (org-html-format-latex): Replace `org-format-latex'
with the more specific `org-latex-replace-fragments`.
2024-02-20 16:49:00 +08:00
TEC cfe471f4da
org-latex-preview: Split org-place-formula-image
* lisp/org-latex-preview.el (org-create-latex-preview,
org-place-formula-image, org-place-latex-image,
org-place-latex-image-link): Replace `org-place-formula-image' with two
functions, one for overlays (`org-place-latex-image') and another for
links (`org-place-latex-image-link').
2024-02-20 16:49:00 +08:00
TEC 8b000cac24
org-latex-preview: Split org-format-latex into two
* lisp/org-latex-preview.el (org-create-latex-preview,
org-format-latex): Split `org-format-latex' into two, creating a new
function for the `cond' branch that deals with
`org-preview-latex-process-alist'.
2024-02-20 16:49:00 +08:00
TEC 7a6ae07b2c
org.el: Relocate LaTeX preview code to new file
* lisp/org.el (org-format-latex-options, org-format-latex-signal-error,
org-latex-to-mathml-jar-file, org-latex-to-mathml-convert-command,
org-latex-to-html-convert-command, org-preview-latex-default-process,
org-preview-latex-process-alist, org-preview-latex-image-directory,
org-format-latex-header, org-format-latex-mathml-available-p,
org--make-preview-overlay, org-clear-latex-preview,
org--latex-preview-region, org-latex-preview, org-format-latex,
org-place-formula-image, org-create-math-formula,
org-format-latex-as-mathml, org-format-latex-as-html,
org--get-display-dpi, org-create-formula-image, org-dvipng-color,
org-dvipng-color-format, org-latex-color, org-latex-color-format,
org-normalize-color): Move to org-latex-preview.el.

* lisp/org-latex-preview.el: A new home for code related to the
generated of in-buffer previews of LaTeX fragments.
2024-02-20 16:48:58 +08:00
TEC f941e1bc4d
ox-latex: Call compilation commands asynchronously
* lisp/ox-latex.el (org-latex-compile): Make use of the new
`org-async-call' to call compilation commands asynchronously.

When running ox-export via the command line, the expectation is the
Emacs process will not exit until the export has completed.  This
assumption is violated with async export, so when the current Emacs
session is `noninteractive' we go back to the previous (synchronously)
method of compiling.
2024-02-20 16:42:22 +08:00
TEC 50826a1ab1
org-macs: Add an async command execution system
* lisp/org-macs.el (org-async--stack, org-async--wait-queue,
org-async-process-limit, org-async-timeout,
org-async-check-timeout-interval, org-async--counter, org-async-call,
org-async--sentinel, org-async--cleanup-process,
org-async--execute-callback, org-async--monitor-scheduled,
org-async--monitor): Introduce an asynchronous command execution system.
2024-02-20 16:42:22 +08:00
TEC 24b75f8302
---PATCH SET DIVIDER--- 2024-02-20 16:42:22 +08:00
TEC a06e33a165
org-manual: Document export features
* doc/org-manual.org (+*** Export features): Initial manual entry on
export features.
2024-02-20 16:42:22 +08:00
TEC 32c965e7a6
test-ox: Add tests for export feature resolution
* testing/lisp/test-ox.el: Add a set of tests for
`org-export-resolve-feature-implementations'.
2024-02-20 16:42:22 +08:00
TEC bc1decc2e8
oc-*: Make use of conditional preamble for export
* lisp/oc-natbib.el (org-cite-natbib-use-package): Refactor to make use
of the conditional/generated preamble.

* lisp/oc-csl.el (org-cite-csl-finalizer): Refactor to make use of
the conditional/generated preamble.

* lisp/oc-biblatex.el (org-cite-biblatex-prepare-preamble): Refactor to
make use of the conditional/generated preamble.
2024-02-20 16:42:22 +08:00
TEC 9aa4d667cf
ox: Introduce conditional/generated preamble
* lisp/ox.el (org-export-detect-features, org-export-expand-features,
org-export-generate-features-preamble): New functions for detecting
features and generating content based on them.
(org-export-conditional-features): Customisation for feature detection.
(org-export-as): Add detected to features to info in the slot :features.
(org-export-update-features): Add a convenience function for users to
edit the feature condition/implementation lists.
(org-export--annotate-info, org-export-detect-features,
org-export-define-derived-backend, org-export-define-backend,
org-export-conditional-features): Refactor backend feature
conditions/implementations into a struct field.  This allows for parent
inheritance to be properly managed, and leads into future work making
features more widely used in the export process.
(org-export-expand-features, org-export-resolve-feature-implementations,
org-export-generate-features-preamble,
org-export-expand-feature-snippets): The main functions for working with
export features.
(org-export-process-features, org-export-update-features): Introduce
`org-export-process-features' to simplify the application of features to
INFO.
2024-02-20 16:42:22 +08:00
TEC b97014ece2
org-compat: Add ensure-list as org-ensure-list
* lisp/org-compat.el (org-ensure-list): Add `ensure-list' from Emacs 28,
as `org-ensure-list'.
2024-02-20 16:42:22 +08:00
Ihor Radchenko 0dd2c5ea39
Merge branch 'bugfix' 2024-02-19 13:20:47 +03:00
Ihor Radchenko d5b98bcfb5
org-dynamic-block-define: Clarify that FUNC must accept zero arguments
* lisp/org.el (org-dynamic-block-define): Update the docstring.

Reported-by: chris <inkbottle007@gmail.com>
Link: https://orgmode.org/list/5790810.DvuYhMxLoT@nixos
2024-02-19 13:19:11 +03:00
Ihor Radchenko d6c3ab08b4
org-dynamic-block-insert-dblock: Do not call non-commands interactively
* lisp/org.el (org-dynamic-block-insert-dblock): When insert command
for a dynamic block is not interactive, do not try to call it
interactively.

Reported-by: chris <inkbottle007@gmail.com>
Link: https://orgmode.org/list/5790810.DvuYhMxLoT@nixos
2024-02-19 13:18:10 +03:00
Martin Edström a8443f2c79
org-latex-to-html-convert-command: Enhance the docstring
* org.el (org-latex-to-html-convert-command): Add a note in the
docstring about proper shell-quoting.

It can trip you up because wrongly quoted input still works with some
math snippets, so the command may work during testing but not later
when you have different math snippets in play.

TINYCHANGE
2024-02-19 11:28:06 +03:00
Ihor Radchenko d314882301
org-narrow-to-subtree: Fix when current narrowing intersects subtree
* lisp/org.el (org-narrow-to-subtree): Fix error when current
narrowing intersects the current subtree.  When intersection happens,
behave historically, like the previous version of the command (that
did not use org-element).
2024-02-18 17:47:18 +01:00
Ihor Radchenko 7360c6b427
Merge branch 'bugfix' 2024-02-18 17:29:35 +01:00
Ihor Radchenko 85aafac417
ox-md.el: Fix adding blank lines between table rows in derived exporters
* lisp/ox-md.el (org-md-separate-elements): Do not add blank lines
between table cells.  Even though table-cell elements are not exported
by ox-md itself, derived backends do not expect blank lines appearing
there.

Reported-by: Rohit Patnaik <quanticle@quanticle.net>
Link: https://orgmode.org/list/d84d5df0-108f-4a75-b7d2-299392613052@app.fastmail.com
2024-02-18 17:25:27 +01:00
Ihor Radchenko ea487bffb5
org-fold-hide-drawer-all: Do not use point and mark when no region is active
* lisp/org-fold.el (org-fold-hide-drawer-all): Do not unconditionally
use point and mark.  Only use region boundaries when the region is
active.
2024-02-18 11:48:50 +01:00
Ihor Radchenko 388ba5b5c4
org-insert-link: Do not expand path arg when `org-link-file-path-type' is a function
* lisp/ol.el (org-insert-link): Drop `expand-file-name'.
(org-link-file-path-type): Update docstring.
* etc/ORG-NEWS (When ~org-link-file-path-type~ is a function, its
argument is now a filename as it  in the link; not an absolute
path): Announce the change.

Link: https://orgmode.org/list/871qahl0un.fsf@localhost
2024-02-17 16:25:19 +01:00
Ihor Radchenko c9fc4c03e8
org-manual: Fix inaccuracy about TOC placement
* doc/org-manual.org (Table of Contents): Clarify that TOC is placed
at the beginning of the file, not "before first heading".  If there is
a text before first heading, TOC will be placed before that text.

Reported-by: Kodi Arfer <kodi@arfer.net>
Link: https://orgmode.org/list/dd0ae51d-7d56-0ff6-5eb1-3786464adfe3@arfer.net
2024-02-17 14:34:48 +01:00
Ihor Radchenko 1cca1967e9
fixup! ox-org: Do not process citations by default
* lisp/ox.el (org-export-process-citations): Add missing defcustom keywords.
2024-02-14 15:36:51 +01:00
Ihor Radchenko 0e1f0e1605
ox-latex: Make errors/warnings during PDF generation more obvious
* lisp/ox-latex.el (org-latex-compile--postprocess): Display a
warning, not message when there are problems with PDF generation.
2024-02-14 15:34:19 +01:00
Juan Manuel Macias 9eec4af620
lisp/ox-latex.el: Add missing character warnings
* (org-latex-known-warnings): Two missing character warnings are
added: one for LuaLaTeX/XelaTeX and another for pdfLaTeX.
2024-02-14 15:29:30 +01:00
Ihor Radchenko 97cc71b594
lisp/org-element.el, lisp/ox.el: Add Ihor Radchenko as a maintainer
* lisp/org-element.el:
* lisp/ox.el:
2024-02-14 13:41:21 +01:00
Ihor Radchenko fd45bfa648
Acknowledge that Nicolas Goaziou is no longer maintaining Org libraries
* lisp/ox-ascii.el:
* lisp/ox-beamer.el:
* lisp/ox-icalendar.el:
* lisp/ox-md.el:
* lisp/ox-org.el:
* lisp/ox-publish.el:
* lisp/ox-texinfo.el:
* lisp/ox.el: Remove "Maintainer" line.
2024-02-14 13:41:21 +01:00
Ihor Radchenko b8ee1315a1
ox-org: Do not process citations by default
* lisp/ox.el (org-export-options-alist): Add new export option
:with-cite-processors that allows disabling citation processors.
(org-export-process-citations): New customization (t by default)
defining the default value of :with-cite-processors export option.
(org-export-as):
(org-export--annotate-info): Disable citation processors when
:with-cite-processors is nil.
* lisp/ox-org.el (org-org-with-cite-processors): New custom
option (nil by default) controlling whether to use citation processors
when exporting to Org.
(org): Set :with-cite-processors according to the new option.  Declare
transcoders for citation and citation-reference objects.
* doc/org-manual.org (Summary of the export process): Update the
export flow description.
* etc/ORG-NEWS (Org export backends can now disable citation processors):
(=ox-org= disables citation processors by default):
(New option ~org-export-process-citations~):
(New option ~org-org-with-cite-processors~): Document the changes.

The change in ox-org behavior also fixes citation objects being
removed unconditionally from table src block results.

Reported-by: Stanislav Vlasov <S.Vlasov@tilburguniversity.edu>
Link: https://orgmode.org/list/87edrin6jw.fsf@localhost
2024-02-14 13:16:57 +01:00
Ihor Radchenko 666bd90497
fixup! ox-org: Export special table rows by default
* lisp/ox-org.el (org-org-with-special-rows): Add missing keywords for defcustom.
2024-02-14 12:50:17 +01:00
Ihor Radchenko a250fc745f
org-compile-file: Retain all the logs when PROCESS is a list
* lisp/org-macs.el (org-compile-file): When PROCESS is a list of shell
commands, do not erase logs of all but last commands.
2024-02-13 12:59:38 +01:00
Ihor Radchenko 61c235b778
org-element-paragraph-parser: Fix edge case; fix tests
* lisp/org-element.el (org-element-paragraph-parser): Fix edge case
when 🔚 is in the middle of a paragraph.
*
testing/lisp/test-org-element.el (test-org-element/paragraph-parser):
Fix point position in the tests.  Add test case for ending lines of
incomplete blocks/drawers.  Remove test for incomplete dynamic blocks
- they are keywords.

Reported-by: Tom Alexander <tom@fizz.buzz>
Link: https://orgmode.org/list/87o7hiwzma.fsf@localhost
2024-02-13 12:46:58 +01:00
Martin Marshall 38dd882685
org-ctags: Fix regexp to not break radio-target links
* org-ctags.el (org-ctags-tag-regexp): Add left angle-bracket to
excluded characters for tag text.

Link: https://orgmode.org/list/87frxylw33.fsf@martinmarshall.com

TINYCHANGE
2024-02-12 15:04:41 +01:00
Ihor Radchenko 5cbaa87473
doc/org-manual.org (Include Files): Add link to export flow
Add reference to export flow where the exact export sequence is
explained in details.

Reported-by: Tim Landscheidt <tim@tim-landscheidt.de>
Link: https://orgmode.org/list/87fs9axxcm.fsf@localhost
2024-02-12 14:56:42 +01:00
Ihor Radchenko a70f216e3f
doc/org-manual.org (Summary of the export process): Reference `org-export-as' 2024-02-12 14:23:52 +01:00
Ihor Radchenko f9fc9d95c7
org-export-as: Add reference to export flow in the manual
* lisp/ox.el (org-export-as): Update docstring.
2024-02-12 14:23:51 +01:00
Ihor Radchenko 1087a7b4af
doc/org-manual.org: Add link to WORG export reference page
* doc/org-manual.org (Extending an existing backend): Link to WORG
page describing more details about writing export backends.
2024-02-12 14:23:51 +01:00
Ihor Radchenko 46cf76259c
doc/org-manual.org: Describe export flow
* doc/org-manual.org (Summary of the export process): Explain how the
export process is handled in Org mode.
2024-02-12 14:23:50 +01:00
Ihor Radchenko 1ff72e0918
doc/org-manual.org: Fix some obsolete variable names
* doc/org-manual.org (Export hooks): Use the new
`org-export-before-processing-functions' and
`org-export-before-parsing-functions' instead of their obsolete
aliases.
2024-02-12 14:23:49 +01:00
Ihor Radchenko cf7ef80a13
org-manual: Undocument `org-fast-tag-selection-include-todo'
* doc/org-manual.org (Fast access to TODO states): Remove references
to `org-fast-tag-selection-include-todo' to honour its docstring that
discourages using this option.  Renumber the footnotes.

Link: https://orgmode.org/list/87ttnmw818.fsf@localhost
2024-02-12 14:01:13 +01:00
Ihor Radchenko 6ff0de5c3e
ox-org: Export special table rows by default
* lisp/ox.el (org-export-options-alist): New internal plist option -
:with-special-rows.  Defaults to nil.
(org-export--skip-p): Do not skip special table rows when
:with-special-rows is non-nil.
* lisp/ox-org.el (org-org-with-special-rows): New custom option
controlling whether to export special table rows.  t by default.
(org): Use `org-org-with-special-rows' as the value of
:with-special-rows option.
* etc/ORG-NEWS (=ox-org= now exports special table rows by default):
(New option ~org-org-with-special-rows~): Announce the change.
2024-02-12 12:55:37 +01:00
Ihor Radchenko f4f0fc8bda
lisp/org-colview.el (org-columns--compute-spec): Fix columns in inlinetasks
* lisp/org-colview.el (org-columns--compute-spec): When summarizing
columns, limit the length of LVALS vector to maximum (not minimal!)
possible inlinetask depth.
2024-02-11 16:39:11 +01:00
Ihor Radchenko 807bf95c49
lisp/org-colview.el (org-columns): Avoid calling expensive `move-marker'
Just rely on garbage collector to do the right thing.  `move-marker'
significantly slows down column creation.   More than GC.
2024-02-11 16:34:44 +01:00
Ihor Radchenko 7e547fd3b6
org-columns--display-here: Cache result of `substitute-command-keys'
* lisp/org-colview.el (org-columns--read-only-string):
(org-columns--display-here): Cache return value of
`substitede-command-keys' in a variable.  It is otherwise slow to call
it every time a row is displayed.
2024-02-11 16:25:37 +01:00
Ihor Radchenko 2a999b298f
org-columns--display-here: Avoid calling `face-remap-add-relative' when possible
* lisp/org-colview.el (org-columns--display-here): Do not call
`face-remap-add-relative' multiple times in the same buffer.
2024-02-11 16:24:56 +01:00
Ihor Radchenko 01a074d0b5
fixup! Obsolete `org-icompleting-read' and `org-completing-read-no-i'
* lisp/ol.el (org-insert-link):
* lisp/org-ctags.el (org-ctags-find-tag-interactive):
* lisp/ox-odt.el (org-odt-convert-read-params): Remove the remaining
uses and references to ido-mode.  Rely upon built-in Emacs completion
system using the necessary completion backend rather than directly
calling ido functions.

This commit removes leftovers after
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=fdbf441560

Reported-by: Martin Marshall <law@martinmarshall.com>
2024-02-11 15:57:27 +01:00
Ihor Radchenko 5be39ff798
Reapply "lisp/org-element-ast.el (org-element-property-raw): Simplify implementation"
This reverts commit 942b4d97c1.

The cause was not this commit, but missing (require 'subr-x).
2024-02-11 15:11:39 +01:00
Ihor Radchenko 130382779b
testing/lisp/test-duplicates-detector.el: Fix Emacs 27 compatibility
*
testing/lisp/test-duplicates-detector.el (test-duplicates-detector--find-duplicates):
Do not use `while-let' that is not yet available in Emacs 27.
2024-02-11 15:11:11 +01:00
Ihor Radchenko 112f1c5fcd
lisp/org-element-ast.el: Fix compilation for Emacs 27 2024-02-11 15:10:55 +01:00
Ihor Radchenko ce1da4d201
fixup! org-startup-folded: Make values consistent with #+STARTUP keyword 2024-02-11 15:10:48 +01:00
Ihor Radchenko c2a58bbd53
org-startup-folded: Make values consistent with #+STARTUP keyword
* lisp/org.el (org-startup-folded): Document all the allowed values in
the docstring.  Allow symbols named the same as #+STARTUP option.
(org-startup-options): Allow `org-startup-folded' to have values
corresponding to the corresponding #+STARTUP options.
2024-02-11 13:40:17 +01:00
Ihor Radchenko bc0e14a1ab
Update version number for the 9.6.19 release 2024-02-11 12:50:12 +01:00
Ihor Radchenko d3a1394270
fixup! org-ctags.el: Fix use of "ctags" executable
* lisp/org-ctags.el (org-ctags-create-tags): Quote spaces and other
special characters in path.
2024-02-10 22:18:20 +01:00
Ihor Radchenko 8c7313d397
org-babel: New babel backend API function org-babel-session-buffer:<lang>
* lisp/ob-core.el (org-babel-session-buffer): New API function that
return session buffer, if such buffer exists and is live.
(org-babel-execute-src-block): Use `org-babel-session-buffer'.
* lisp/ob-lua.el (org-babel-session-buffer:lua):
* lisp/ob-python.el (org-babel-session-buffer:python): Provide API to
retrieve session buffer name.
(org-babel-python-initiate-session-by-key): Use
`org-babel-session-buffer:python'.
* etc/ORG-NEWS (Org babel backends are now expected to define an
additional API function ~org-babel-session-buffer:<lang>~): Declare
the API addition.

Link: https://orgmode.org/list/87r0hr9f3b.fsf@localhost
2024-02-10 21:57:52 +01:00
Jack Kamm 644bf846d6
ob-comint: Make file results from async sessions respect :dir header
* lisp/ob-comint.el (org-babel-comint-async-filter): Set
default-directory before calling `org-babel-insert-result'

https://list.orgmode.org/875xz9o4nj.fsf@localhost/T/#t
2024-02-10 21:57:13 +01:00
Ihor Radchenko 13d0f8bf8e
org-babel-execute-src-block: Force :dir according to live session
* lisp/ob-core.el (org-babel-execute-src-block): Force eval directory
to follow live session buffer, if any.  This is consistent with what
we promise in the manual section "16.4 Environment of a Code
Block">Choosing a working directory.

Link: https://orgmode.org/list/87mssi8ht2.fsf@gmail.com
2024-02-10 21:57:08 +01:00
Ihor Radchenko cbfe1354b3
org-insert-subheading: Never insert sub-heading above current
* lisp/org.el (org-insert-subheading): When at bol, do not insert
heading above (default behavior of `org-insert-heading').  Instead,
force `org-insert-heading' to insert below.  Improve docstring,
explaining how the prefix arguments are used and the new different
with `org-insert-heading'.
* etc/ORG-NEWS (~org-insert-subheading~ no longer inserts a
sub-heading above current when point is at the beginning of line):
Document the breaking change.

Reported-by: Michael Dauer <mick.dauer@gmail.com>
Link: https://list.orgmode.org/CAP7OBx+whiB8Jo_hEcfL6MajDU1EH=E5j0ZOvHB3dPRK+Aj4mQ@mail.gmail.com/
2024-02-10 16:57:59 +01:00
Ihor Radchenko 9ddfb66996
lisp/org.el (org-insert-subheading): Improve docstring 2024-02-10 16:57:42 +01:00
Ihor Radchenko 942b4d97c1
Revert "lisp/org-element-ast.el (org-element-property-raw): Simplify implementation"
This reverts commit cfb48624f3.

The commit is not compatible with Emacs 27, which is still supported.
2024-02-10 16:39:13 +01:00
Gerard Vermeulen 80e7c9f80f
ox-latex: String variables are not file local safe
* lisp/ox-latex.el (org-latex-default-figure-position):
(org-latex-default-quote-environment, org-latex-image-default-scale):
(org-latex-reference-command): File local safe string variables allow
to write Org files allowing to inject any command.

Link: https://list.orgmode.org/ffa77c01d47b15dfc0ae687cab95fb01@posteo.net/
2024-02-10 15:55:44 +01:00
Martin Marshall 981402a93d
org-ctags.el: Fix use of "ctags" executable
* lisp/org-ctags.el (org-ctags-create-tags): Allow file globbing in
`shell-command' invocation of "ctags".

TINYCHANGE
2024-02-10 15:25:08 +01:00
Ihor Radchenko cfb48624f3
lisp/org-element-ast.el (org-element-property-raw): Simplify implementation 2024-02-10 14:07:52 +01:00
Ihor Radchenko 7319136420
org-element-cache-map: Fix when :next-re is provided
* lisp/org-element.el (org-element-cache-map): Fix searching next-re
in move-start-to-next-match.  The if confition was erroneously always
true due to the last `cl-incf'.  Do not map over failing entry when
next-re did not match and continue-flag is set.  Do not move point to
next entry before calling FUNC.
* testing/lisp/test-org.el (test-org/map-entries): Add new test case.
2024-02-09 21:32:54 +01:00
Ihor Radchenko df1f9be7f8
fixup! Add testing/lisp/test-duplicates-detector.el
*
testing/lisp/test-duplicates-detector.el (test-duplicates-detector--find-duplicates):
Provide third argument to `mapconcat' for Emacs <29.
2024-02-09 19:55:01 +01:00
Ihor Radchenko aa3724dbde
org-capture: Obsolete `org-capture-bookmark' in favor of `org-bookmark-names-plist'
* lisp/org-capture.el (org-capture-bookmark):
* lisp/org-compat.el (org-capture-bookmark): Mark obsolete.
* lisp/org-capture.el (org-capture-store-last-position): Add comment
about obsoletion.
* doc/org-manual.org (Using capture): Mention
`org-bookmark-names-plist' instead of `org-capture-bookmark'.

Reported-by: Tim Wichmann <schwurg@arcor.de>
Link: https://orgmode.org/list/87bk8r2ig1.fsf@localhost
2024-02-09 17:47:57 +01:00
Ihor Radchenko 0d77cf8421
org-latex-headline: Prevent footnotes in TOC/footers
* lisp/ox-latex.el (org-latex-headline): When headline contains
footnotes and does not have ALT_TITLE, arrange alternative title that
will appear in TOC and footers to not have any footnotes.

Reported-by: Eric Anderson <kluwak@gmail.com>
Link: https://orgmode.org/list/691643eb-49d0-45c3-ab7f-a1edbd093bef@gmail.com
2024-02-09 17:38:43 +01:00
Ihor Radchenko 27d6f8305c
lisp/ob-comint.el: Introduce a fallback prompt regexp
* lisp/ob-comint.el (org-babel-comint-prompt-regexp-old): New variable
storing the default value of `comint-prompt-regexp' to be used when
the prompt set by Org mode changes for some reason.
(org-babel-comint-fallback-regexp-threshold): New customization to set
the time Org babel waits for comint command to finish until trying
fallback prompt regexp.
(org-babel-comint--set-fallback-prompt): New internal function that
sets the fallback prompt regexp, if there is any available.
(org-babel-comint-with-output):
(org-babel-comint-wait-for-output): Try fallback prompt regexp when we
cannot find comint command end for too long.
* lisp/ob-haskell.el (org-babel-interpret-haskell):
* lisp/ob-ruby.el (org-babel-ruby-initiate-session):
* lisp/ob-shell.el (org-babel-sh-initiate-session):
* lisp/ob-clojure.el (ob-clojure-eval-with-inf-clojure): Set
`org-babel-comint-prompt-regexp-old' when initializing the inferior
shell.
* etc/ORG-NEWS (New option
~org-babel-comint-fallback-regexp-threshold~): Document the new
customization.

Reported-by: Jack Kamm <jackkamm@tatersworld.org>
Link: https://orgmode.org/list/87sf2q9ubd.fsf@gmail.com
2024-02-09 17:35:58 +01:00
Ihor Radchenko c76d498f44
mk/default.mk: Use make single by default
This is compatible with parallel execution and can also help to catch
native compilation errors (native compilation compiles .elc files
separately), like the one discussed in bug#68851.
2024-02-09 17:17:12 +01:00
Ihor Radchenko 71fbe92c2e
mk: Allow parallel execution
* lisp/Makefile (.NOTPARALLEL): Do not suppress parallel execution.
(all compile compile-dirty):
(compile-single):
(compile-native):
(compile-source):
(compile-slint1):
(compile-slint2): Explicitly declare prerequisites that must be run
sequentially.
* mk/targets.mk (.NOTPARALLEL): Do not suppress parallel execution.
(uncompiled):
(update update2):
(repro): Explicitly declare prerequisites that must be run
sequentially.
2024-02-09 17:15:53 +01:00
Stefan Monnier ecb5b605d7
lisp/org-element-ast.el: Fix compile-time inline expansion
* lisp/org-element-ast.el (org-element--property-idx): Define inline
expansion within `eval-and-compile' to make sure that the expanded is
available at compile time.

See Emacs bug#68851.
2024-02-09 16:31:10 +01:00
Ihor Radchenko 8e2ed45bb1
test-org/file-contents: Refactor duplicate test
* testing/lisp/test-org.el (test-org/file-contents): Avoid safety
prompt when testing.  Fix duplicate test testing optional argument for
`org-file-contents' (the argument were not passed previously).
2024-02-09 15:07:35 +01:00
Ihor Radchenko e3f327d1e6
ob-haskell/session-named-none-means-one-shot-sessions: Remove duplicate
*
testing/lisp/test-ob-haskell-ghci.el (ob-haskell/session-named-none-means-one-shot-sessions):
Remove duplicate from the test.
2024-02-09 14:57:57 +01:00
Ilya Chernyshov 8d2fcfea99
Add testing/lisp/test-duplicates-detector.el
* testing/lisp/test-duplicates-detector.el: Add test unit that checks
for duplicate ert-deftests and forms inside of them.
2024-02-09 14:57:54 +01:00
Ihor Radchenko 4797ebf834
lisp/org-crypt.el (org-current-level): Fix compiler warning 2024-02-09 13:44:33 +01:00
Ihor Radchenko adf841219d
mk: Use ` quotes instead of complex '"'"'
* mk/default.mk (req-ob-lang):
(req-extra):
(BTEST_LOAD):
(BATCHO):
(BATCHL):

Reported-by: Stefan Monnier <monnier@iro.umontreal.ca>
Link: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=68851#50
2024-02-09 12:55:43 +01:00
Ihor Radchenko ee395b9b8e
Add new make target for native compilation
* lisp/Makefile (LISPN): New variable listing all the valid .eln
targets.
(_ORGCM_):
(compile-native):
(native): New compile target.
(%.eln): Rule how to compile .eln files from .el files.
* mk/default.mk (ELN): Command to perform native compilation of a
single .eln file.
* mk/targets.mk (.PHONY):
(CONF_CALL): List the new targets and variables.
(native): Add target.
2024-02-08 20:16:51 +01:00
Ihor Radchenko bfc0cb3723
lisp/org-num.el: Autoload safe variables
* lisp/org-num.el (org-num-face):
(org-num-max-level):
(org-num-skip-commented):
(org-num-skip-footnotes):
(org-num-skip-tags):
(org-num-skip-unnumbered): Autoload variables with :safe
specification.  Without autoloading, if org-num is not loaded,
unexpected warning may be displayed when opening an Org file.

Reported-by: Chang Xiaoduan <drcxd@sina.com>
Link: https://list.orgmode.org/orgmode/87jznf7gqo.fsf@PWRD-20230207OU./
2024-02-08 16:17:34 +01:00
Ihor Radchenko 62956196d0
org-agenda: Fix entries with timestamps without day name
* lisp/org-agenda.el (org-agenda-get-timestamps):
(org-agenda-get-progress): When matching specific date in timestamp,
do not demand that timestamp to contain day name.

Reported-by: Stephen J. Eglen <sje30@cam.ac.uk>
Link: https://orgmode.org/list/874jejrij6.fsf@localhost
2024-02-08 16:01:29 +01:00
Rick Lupton f016545aa1
org-link-search-must-match-exact-headline: Improve docstring
* lisp/ol.el (org-link-search-must-match-exact-headline): Make the
docstring more accurately describe behaviour.

Link: https://list.orgmode.org/87cytdithi.fsf@localhost/
2024-02-08 15:51:10 +01:00
Ihor Radchenko b26745b985
org-agenda: Fix meaning of 'repeated-after-deadline value of `org-agenda-skip-scheduled-if-deadline-is-shown'
* lisp/org-agenda.el (org-agenda-skip-scheduled-if-deadline-is-shown):
Move 'repeated-after-deadline value into a new custom option.
(org-agenda-skip-scheduled-repeats-after-deadline): Create a new
custom option to make agenda hide scheduled entries repeated past
deadline.
* lisp/org-agenda.el (org-agenda-get-scheduled): Use the new custom
option.  Do not demand deadline to be actually shown when deciding
whether to skip scheduled repeats past deadline.  This fixes a bug
when repeats continue to be displayed if past deadline is not
displayed within agenda span.
* doc/org-manual.org (Repeated tasks): Adjust manual entry, mentioning
the new custom option.
* etc/ORG-NEWS (~repeated-after-deadline~ value of
~org-agenda-skip-scheduled-repeats-after-deadline~ is moved to a new
customization): Announce the change.
*
testing/lisp/test-org-agenda.el (test-org-agenda/skip-scheduled-repeats-after-deadline):
Add new test.

Reported-by: Morgan Smith <Morgan.J.Smith@outlook.com>
Link: https://orgmode.org/list/874jft6vpj.fsf@localhost
2024-02-07 13:21:34 +01:00
Sławomir Grochowski 18d98ee655
org-colview: Extract functions `org-columns-move-up' & `org-columns-move-down'
* lisp/org-colview.el (org-defkey): Do not use anonymous function as a
binding.
2024-02-06 20:31:01 +01:00
Ihor Radchenko 8ccda1737b
fixup! org-capture-set-target-location: Improve error reporting for malformed target
Reported-by: Zhitao <zhitaao.gong@gmail.com>
Link: https://orgmode.org/list/CACcmFoCvtyGBKR7mTjdQOd-w82wz-xcavnpEVT=6mFOWpo1T1w@mail.gmail.com
2024-02-06 20:02:40 +01:00
Ihor Radchenko 4254a54f88
org-update-parent-todo-statistics: Do not modify buffer unnecessarily
* lisp/org.el (org-update-parent-todo-statistics): When the updated
statistics cookie is unchanged, do not modify buffer.  This prevents
unnecessary queries to element cache.
2024-02-05 22:12:03 +01:00
Pedro A. Aranda Gutiérrez 10d2868c58
org-footnote-new: Add an option to create new anonymous labels
* lisp/org-footnote.el (org-footnote-new, org-footnote-auto-label):
Add symbol `anonymous' to `org-footnote-auto-label'.  With this,
anonymous footnotes will be created.  This is sometimes useful in long
texts.  Mimics \footnote{} in LaTeX.  Modify `org-footnote-new' to
generate anonymous footnotes directly.

* lisp/org.el (org-startup-options): Add `fnanon' to startup options.

* testing/lisp/test-org-footnote.el (test-org-footnote/new-anon): Add
a test for creation of anonymous footnotes.

* etc/ORG-NEWS:
(~org-footnote-new~ can be configured to create anonymous footnotes):
Announce new anonymous footnote support.

* doc/org-manual.org (Summary of In-Buffer Settings): Document
"fnanon" startup option.
2024-02-05 15:38:48 +01:00
Ihor Radchenko 7f5e085cad
org-decrypt-entry: Adjust headline levels in decrypted subtree
* lisp/org-crypt.el (org-decrypt-entry): When decrypted subtree
contains headings with levels below the containing heading, demote
that subtree, so that originally encrypted text remains under the same
parent heading.  This is useful when encrypted heading is promoted.
2024-02-05 14:04:52 +01:00
Ihor Radchenko f4414f5dbb
ox-latex: Fix references to src block results without #+name
* lisp/ox-latex.el (org-latex--label): Consider :results property in
addition to :name property of the datum.  For datums that are results
of evaluation, the label may not only come from #+name keyword, but
can also be duplicated from the generating src block.
(org-latex--wrap-label): Do not limit label to elements with #+name.
Rely on `org-latex--label' to return appropriate label (or nil).

Reported-by: gerard.vermeulen@posteo.net
Link: https://orgmode.org/list/6d9db4be5d42236391d5c4e530250ee1@posteo.net
2024-02-05 13:29:05 +01:00
Sławomir Grochowski 0938795fd7
org-colview: Replace anonymous function with `forward-char'
* lisp/org-colview.el (org-defkey): Do not use anonymous function as a
binding.
2024-02-04 17:48:04 +01:00
Ihor Radchenko 0a58a53eda
org-capture-set-target-location: Improve error reporting for malformed target
* lisp/org-capture.el (org-capture-set-target-location): Tighten
matching the template target location when the location value is not
properly formatted.
2024-02-04 14:47:23 +01:00
Ihor Radchenko b2ee10545e
Merge branch 'bugfix' 2024-02-04 14:31:31 +01:00
Ihor Radchenko 1abff38597
org-fontify-extend-region: Fix edge case
* lisp/org.el (org-fontify-extend-region): Extend region for an extra
character, just as `font-lock-extend-jit-lock-region-after-change'
does.  This fixes a reported edge case.

Also, see https://debbugs.gnu.org/cgi/bugreport.cgi?bug=68849

Reported-by: Kostas Papadakis <papadakis.k@yandex.com>
Link: https://orgmode.org/list/c5fb9f63-185c-4e36-b13f-e887a4a29aae@yandex.com
2024-02-04 14:29:23 +01:00
Ihor Radchenko 97f4ae0c2d
Update version number for the 9.6.18 release 2024-02-04 13:53:02 +01:00
Ihor Radchenko 7a6bb0904d
org-table-justify-field-maybe: Do not leak alignment data from other tables
* lisp/org-table.el (org-table-justify-field-maybe): Make sure that
`org-table-last-alignment' and `org-table-last-column-widths' do not
lea from another table that was re-aligned recently.

Link: https://old.reddit.com/r/emacs/comments/10gegwa/recalculating_an_orgmode_table_causes/
2024-02-03 15:58:41 +01:00
Ihor Radchenko 09ced6d2c2
org-link-plain-re: Improve regexp heuristics
* lisp/ol.el (org-link-make-regexps): Match <...> and <...> balanced
brackets.

This change detects plain links like
http://dx.doi.org/10.1002/(SICI)1521-396X(199901)171:1<239::AID-PSSA239>3.0.CO;2-M
2024-02-03 15:15:46 +01:00
Ihor Radchenko 5cb52f379b
org-html-example-block: Combine :class attributes using space
* lisp/ox-html.el (org-html-example-block): Avoid creating duplicate
class= attributes when example block has #+ATTR_HTML: :class foo.

Multiple class attributes must be combined with space, as per
https://www.w3schools.com/html/html_classes.asp

Reported-by: Joshua Honeycutt <joshua.honeycutt@gmail.com>
Link: https://orgmode.org/list/87fsfxfzex.fsf@localhost
2024-02-03 15:09:11 +01:00
Ihor Radchenko 3f4bdf80cb
Merge branch 'bugfix' 2024-02-02 21:01:30 +01:00
Ihor Radchenko 56748ea4e2
org: Fix security prompt for downloading remote resource
* lisp/org.el (org--confirm-resource-safe): Do not assume that
resource is safe when user replies "n" (do not download).

Reported-by: Max Nikulin <manikulin@gmail.com>
Link: https://orgmode.org/list/upj6uk$b7o$1@ciao.gmane.io
2024-02-02 20:59:41 +01:00
Ihor Radchenko 57f1c02556
doc/org-manual.org: Clarify the default export language for LaTeX export
* doc/org-manual.org (LaTeX specific export settings): Link to
`org-export-default-language' customization and mention its default
value.
2024-02-02 17:22:28 +01:00
Ihor Radchenko c67af5c24a
test-org-fold/org-fold-display-inline-images: Fix skip condition in older Emacs
*
testing/lisp/test-org-fold.el (test-org-fold/org-fold-display-inline-images):
Use skip-unless available in older Emacs rather than skip-when.
2024-02-02 17:03:35 +01:00
Ihor Radchenko 1156554aaf
test-org-fold/org-fold-display-inline-images: Fix test, disable when non-interactive
* testing/lisp/test-org-fold.el (test-org-fold/org-fold-display-inline-images):
2024-02-02 16:24:32 +01:00
Ihor Radchenko 844bd9f1f1
lisp/org.el (org-copy-visible): Fix when using overlays for folding 2024-02-02 16:24:16 +01:00
Ihor Radchenko 83bc81b750
lisp/org-list.el (org-list-swap-items): Fix re-folding after swap 2024-02-02 16:23:50 +01:00
Ihor Radchenko 96944e8d43
org-fold-core--process-delayed: Fix delayed folding in killed buffers
* lisp/org-fold-core.el (org-fold-core--process-delayed): Do not fold
when markers point to killed buffers.
2024-02-02 16:23:05 +01:00
Gerard Vermeulen 71fa0014db
lisp/ox-latex.el: make org-latex-prefer-user-labels safe file local
* lisp/ox-latex.el (org-latex-prefer-user-labels): make it a safe file
local variable for consistency with `org-latex-reference-command' and
`org-html-prefer-user-labels' being also safe file local variables.
2024-02-02 14:50:33 +01:00
Ihor Radchenko 344d4624e1
lisp/org-compat.el: Fix compiler warning when make single
* lisp/org-compat.el (org-switch-to-buffer-other-window): Do not use
obsolete macro.  Even with `with-no-warnings', a warning is emitted.
2024-02-02 14:33:01 +01:00
Ihor Radchenko 62c6d5668d
org-fold-core-style: Use 'overlays in Emacs >=29
* lisp/org-fold-core.el (org-fold-core-style): Set default value to
'overlays in newer Emacs versions.  Newer Emacs does not have
performance issues with overlays and using text-properties there is
not beneficial due to numerous issues with most of Emacs code and
third-party packages that assume overlay-based folding.
2024-02-02 14:21:31 +01:00
Sławomir Grochowski 614d534a9d
fixup! doc/org-manual.org: Checkboxes, add checkbox states examples
Description of example of a checkbox list ("The ‘[2/4]’ and ‘[1/3]’...")
should be right below the example.
2024-02-01 16:49:22 +01:00
Tommy Kelly 055ed4a2f6
doc/org-manual.org: Clarify what TIMESTAMP and TIMESTAMP_IA refer to
* doc/org-manual.org (Special Properties): Improve description of the
special properties.

Re-number footnotes.

Link: https://orgmode.org/list/CAMg28OtQTFsk8SRSvN6B83M_Rf1AaTskgtYGcND_XnaazDnRww@mail.gmail.com

TINYCHANGE
2024-02-01 16:35:01 +01:00
Ihor Radchenko 40d1352b29
org-babel: Declare :async header argument in the backends that support it
* lisp/ob-R.el (org-babel-header-args:R):
* lisp/ob-python.el (org-babel-header-args:python): Declare async
header argument.
* lisp/ob-shell.el (org-babel-header-args:shell): Add variable.
(org-babel-shell-initialize): Propagate base
`org-babel-header-args:shell' to `org-babel-header-args:<shell-name>'.

Without declaration, org-lint would not recognize :async argument.
2024-02-01 16:15:50 +01:00
Ihor Radchenko 14acf626fe
org: Fontify whole table rows with `org-table-row' face
* lisp/org-faces.el (org-table-row): New face.
* lisp/org.el (org-set-font-lock-defaults): Use ~org-table-row~ face
to fontify the whole table rows, including indentation and newlines.
* etc/ORG-NEWS (Org mode now fontifies whole table lines (including
newline) according to ~org-table~ face): Announce the change.
2024-02-01 15:30:18 +01:00
Ihor Radchenko 788af56753
doc/org-manual.org (Summary): Clarify the Org markup is human-readable
Readability of raw Org text is one of the core principles we maintain
when designing Org markup language.  Let's state it explicitly in the
manual.
2024-02-01 13:16:11 +01:00
Ihor Radchenko 402643f194
Merge branch 'bugfix' 2024-02-01 12:45:32 +01:00
Gerard Vermeulen 84f56c47f2
lisp/ox-latex.el: improve org-latex-toc-command docstring
* lisp/ox-latex.el (org-latex-toc-command): specify clearer which
option settings use `org-latex-toc-command'.  This shows also how
to specify a table of contents depth.
2024-02-01 12:44:41 +01:00
Ihor Radchenko 5f22a1be40
org-table-header-set-header: Fix header calculation
* lisp/org-table.el (org-table-header-set-header): Make sure that
Emacs finishes any queued redisplay before calculating window
boundaries.  Do not make assumptions about the same character width of
table lines.
(org-table-row-get-visible-string): Refactor calculation of the visual
text representation.  Inherit all the text properties - in particular,
composition.  Collect non-intersecting overlays into text properties.

Reported-by: Ypo <ypuntot@gmail.com>
Link: https://orgmode.org/list/87a605oyht.fsf@localhost
2024-01-31 15:56:26 +01:00
Eric S Fraga c9ed0388e7
lisp/ox-beamer.el: Add BEAMER_ACT to column definition
* ox-beamer.el (org-beamer--format-block): Process BEAMER_ACT if given
for column block.
2024-01-31 15:26:48 +01:00
Ihor Radchenko 13a8a74a99
Merge branch 'bugfix' 2024-01-31 14:07:50 +01:00
Ihor Radchenko d4eaf8fe5f
org-publish-sitemap-file-entry-format: Do not refer to non-existing symbol
* lisp/org-compat.el (org-publish-sitemap-file-entry-format): Update
the docstring.

Reported-by: Stefan Kangas <stefankangas@gmail.com>
Link: https://orgmode.org/list/CADwFkmnsjEg+d7ty0bjT5RGQiS-SdKcvRUy+KHDh+maa92bp1w@mail.gmail.com
2024-01-31 14:07:18 +01:00
Ihor Radchenko 28e38a47aa
doc/org-manual.org (Generating a sitemap): Fix property list
* doc/org-manual.org (Generating a sitemap): Add missing
:sitemap-style property description.  Remove deprecated
:sitemap-file-entry-format and :sitemap-date-format.

Reported-by: Stefan Kangas <stefankangas@gmail.com>
Link: https://orgmode.org/list/CADwFkmnsjEg+d7ty0bjT5RGQiS-SdKcvRUy+KHDh+maa92bp1w@mail.gmail.com
2024-01-31 14:07:12 +01:00
Ihor Radchenko ee0196e6af
doc/org-manual.org (Generating a sitemap): Link to `org-publish-project-alist' 2024-01-31 14:07:08 +01:00
Ihor Radchenko f1978ede29
org-odt-get-table-cell-styles: Fix reference to obsolete text property
* lisp/ox-odt.el (org-odt-get-table-cell-styles): Remove reference to
long-obsolete text property used to store table alignment info.
Instead, refer to table alignment cookies described in the manual.

Reported-by: Stefan Kangas <stefankangas@gmail.com>
Link: https://orgmode.org/list/CADwFkmnsjEg+d7ty0bjT5RGQiS-SdKcvRUy+KHDh+maa92bp1w@mail.gmail.com
2024-01-31 14:06:50 +01:00
Ihor Radchenko ad90ff7cb2
lisp/org-table.el: Fix reference to non-existing function
* lisp/org-table.el (org-table--read-column-selection): Fix the
docstring, pointing to the right function that explains the format of
SELECT argument.

Reported-by: Stefan Kangas <stefankangas@gmail.com>
Link: https://orgmode.org/list/CADwFkmnsjEg+d7ty0bjT5RGQiS-SdKcvRUy+KHDh+maa92bp1w@mail.gmail.com
2024-01-31 14:06:30 +01:00
Ihor Radchenko 75b6f2712a
lisp/org-table.el (org-table-copy-down): Fix typo 2024-01-31 14:06:16 +01:00
Ihor Radchenko a5e84c2fb8
org-link-translation-function: Remove reference to removed function
* lisp/ol.el (org-link-translation-function): Remove reference to
no-longer-available `org-translate-link-from-planner' from the
docstring.

Reported-by: Stefan Kangas <stefankangas@gmail.com>
Link: https://orgmode.org/list/CADwFkmnsjEg+d7ty0bjT5RGQiS-SdKcvRUy+KHDh+maa92bp1w@mail.gmail.com
2024-01-31 14:06:03 +01:00
Ihor Radchenko 4aced687b8
lisp/org-tempo.el: Do not refer to removed function in the commentary
Reported-by: Stefan Kangas <stefankangas@gmail.com>
Link: https://orgmode.org/list/CADwFkmnsjEg+d7ty0bjT5RGQiS-SdKcvRUy+KHDh+maa92bp1w@mail.gmail.com
2024-01-31 14:05:46 +01:00
Ihor Radchenko ede8294cf7
lisp/ox.el: Fix removed variable in the commentary
Reported-by: Stefan Kangas <stefankangas@gmail.com>
Link: https://orgmode.org/list/CADwFkmnsjEg+d7ty0bjT5RGQiS-SdKcvRUy+KHDh+maa92bp1w@mail.gmail.com
2024-01-31 14:05:30 +01:00
Ihor Radchenko fe663b6c80
lisp/org-element-ast.el (org-element--property-idx): Simplify implementation
Reported-by: Stefan Monnier <monnier@iro.umontreal.ca>
Link: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=68818#11
2024-01-31 14:01:33 +01:00
Ihor Radchenko 03b383df8b
ox-latex: Remove org-latex-line-break-safe
This reverts commit 3f60acff77 and
subsequent relevant comments.

* lisp/ox-latex.el (org-latex-line-break-safe): Remove constant.  The
\\[0pt] is actually not safe to use in some scenarios. We use a
different approach to avoid plain text [...] being interpreted as
LaTeX optional argument - we escape [ like {[}; that's what pandoc
does.
(org-latex-clock):
(org-latex-line-break):
(org-latex-plain-text):
(org-latex-planning):
(org-latex--org-table):
(org-latex--math-table):
(org-latex-table-row):
(org-latex-verse-block):
* testing/lisp/test-org-table.el (test-org-table/to-latex):
* testing/lisp/test-ox-latex.el (test-ox-latex/verse):
(test-ox-latex/longtable): Remove references to
`org-latex-line-break-safe'.
* etc/ORG-NEWS (=ox-latex=: ~org-latex-line-break-safe~ is removed):
Announce removal.
* lisp/org-compat.el (org-latex-line-break-safe): Make obsolete.

Link: https://orgmode.org/list/878r4jg37s.fsf@posteo.net
2024-01-31 12:35:29 +01:00
Ihor Radchenko bd305ecdf6
ox-latex: Make sure that [text] is not misinterpreted as LaTeX argument
* lisp/ox-latex.el (org-latex-plain-text): Protect plain text starting
from [.  It might be misinterpreted as optional command argument if
previous exported fragment ends with a command accepting such.
*
testing/lisp/test-ox-latex.el (text-ox-latex/protect-square-brackets):
Add new test.

Link: https://orgmode.org/list/87o7dju9vn.fsf@posteo.net
2024-01-31 12:34:21 +01:00
Ihor Radchenko 15e51d7083
lisp/org-persist.el (and): Fix typo
Use `unless' instead of erroneous `when' in the test whether to run
lockfile timer.

Reported-by: Karthik Chikmagalur
2024-01-31 12:18:54 +01:00
Ihor Radchenko afc529b4a0
lisp/org-element-ast.el (org-element-type-p): Simplify implementation
Reported-by: Stefan Monnier <monnier@iro.umontreal.ca>
Link: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=68818#11
2024-01-30 17:19:05 +01:00
Hunter Jozwiak 86c4038da6
ob-scheme: Allow ob-scheme to accept a remote connection
* lisp/org/ob-scheme.el (org-babel-scheme-get-repl): Introduce two
optional arguments: host and port.  If these are not given, just run
Geiser as before.  In the case when both are given, connect to the
remotely running Scheme process.
* lisp/org/ob-scheme (org-babel-scheme-execute-with-geiser,
org-babel-execute:scheme): Take these  optional arguments into account.
* lisp/org/ob-scheme.el (org-babel-header-args:scheme): Define host
and port header arguments for completion.

TINYCHANGE
2024-01-30 16:42:23 +01:00
Ihor Radchenko da9ac6da1d
Merge branch 'bugfix' 2024-01-30 15:28:02 +01:00
Ihor Radchenko 7de8b3917c
org-todo: Fix tag alignment when title contains a folded link
* lisp/org.el (org-todo): When title contains link, we cannot use
`org-fold-region' to unfold everything - this may cause unexpected tag
alignment when the link is revealed and font-locking is not yet
triggered.  Instead of unfolding everything, just remove outline folds.

Reported-by: Peter Solodov <solodov@gmail.com>
Link: https://orgmode.org/list/413C89C3-25DB-425B-A367-FA683E7ADD05@gmail.com
2024-01-30 15:25:00 +01:00
Ihor Radchenko a5c977b43e
org-cycle-set-visibility-according-to-property: Honor inner VISIBILITY settings
* lisp/org-cycle.el (org-cycle-set-visibility-according-to-property):
Do not ignore :VISIBILITY: properties when parent also has
:VISIBILITY:.
*
testing/lisp/test-org-fold.el (test-org-fold/set-visibility-according-to-property):
Add new test.

Similar to how :VISIBILITY: overrides #+STARTUP folding settings,
child :VISIBILITY: should override parent :VISIBILITY:.

The previous version of the code was skipping child VISIBILITY
property to address
https://lists.gnu.org/r/emacs-orgmode/2019-01/msg00402.html
However, that problem in that bug report was not with child VISIBILITY
property, but rather with previous implementation detail that
`org-reveal' was called prior to setting VISIBILITY. That affected
parent headings as well and no longer a problem.

Reported-by: John Mathena <jmmathena@gmail.com>
Link: https://orgmode.org/list/87tucu99od.fsf@localhost
2024-01-30 14:43:08 +01:00
Ihor Radchenko e2144f5f32
org-publish-sitemap-file-entry-format: Do not refer to non-existing symbol
* lisp/org-compat.el (org-publish-sitemap-file-entry-format): Update
the docstring.

Reported-by: Stefan Kangas <stefankangas@gmail.com>
Link: https://orgmode.org/list/CADwFkmnsjEg+d7ty0bjT5RGQiS-SdKcvRUy+KHDh+maa92bp1w@mail.gmail.com
2024-01-30 13:41:42 +01:00
Ihor Radchenko cfef7f85f1
doc/org-manual.org (Generating a sitemap): Fix property list
* doc/org-manual.org (Generating a sitemap): Add missing
:sitemap-style property description.  Remove deprecated
:sitemap-file-entry-format and :sitemap-date-format.

Reported-by: Stefan Kangas <stefankangas@gmail.com>
Link: https://orgmode.org/list/CADwFkmnsjEg+d7ty0bjT5RGQiS-SdKcvRUy+KHDh+maa92bp1w@mail.gmail.com
2024-01-30 13:40:11 +01:00
Ihor Radchenko 6533eedc41
doc/org-manual.org (Generating a sitemap): Link to `org-publish-project-alist' 2024-01-30 13:39:57 +01:00
54 changed files with 1617 additions and 552 deletions

View File

@ -22,6 +22,9 @@ Org Mode is an authoring tool and a TODO lists manager for GNU Emacs.
It relies on a lightweight plain-text markup language used in files
with the =.org= extension.
Authoring Org files is best supported by Emacs, but you can view,
understand, and change them with any text editor.
As an authoring tool, Org helps you write structured documents and
provides exporting facilities. Org files can also be used for literate
programming and reproducible research. As a TODO lists manager, Org
@ -4108,10 +4111,9 @@ meaning here.]. For example:
(sequence "|" "CANCELED(c)")))
#+end_src
#+vindex: org-fast-tag-selection-include-todo
If you then press {{{kbd(C-c C-t)}}} followed by the selection key,
the entry is switched to this state. {{{kbd(SPC)}}} can be used to
remove any TODO keyword from an entry[fn:15].
remove any TODO keyword from an entry.
*** Setting up keywords for individual files
:PROPERTIES:
@ -4367,7 +4369,7 @@ example, with the setting
You not only define global TODO keywords and fast access keys, but
also request that a time is recorded when the entry is set to =DONE=,
and that a note is recorded when switching to =WAIT= or
=CANCELED=[fn:16]. The setting for =WAIT= is even more special: the
=CANCELED=[fn:15]. The setting for =WAIT= is even more special: the
=!= after the slash means that in addition to the note taken when
entering the state, a timestamp should be recorded when /leaving/ the
=WAIT= state, if and only if the /target/ state does not configure
@ -4665,7 +4667,7 @@ of) a large number of subtasks (see [[*Checkboxes]]).
#+cindex: checkboxes
#+vindex: org-list-automatic-rules
Every item in a plain list[fn:17] (see [[*Plain Lists]]) can be made into
Every item in a plain list[fn:16] (see [[*Plain Lists]]) can be made into
a checkbox by starting it with the string =[ ]=. This feature is
similar to TODO items (see [[*TODO Items]]), but is more lightweight.
Checkboxes are not included into the global TODO list, so they are
@ -4685,37 +4687,6 @@ Here is an example of a checkbox list.
- [X] talk to the neighbors
#+end_example
A checkbox can be in one of the three states:
1. not checked =[ ]=
2. partially checked =[-]=
3. checked =[X]=
Checkboxes work hierarchically, so if a checkbox item has children
that are checkboxes, toggling one of the children checkboxes makes the
parent checkbox reflect if none, some, or all of the children are
checked.
If all child checkboxes are not checked, the parent checkbox is also not checked.
#+begin_example
- [ ] call people
- [ ] Peter
- [ ] Sarah
#+end_example
If some but not all child checkboxes are checked, the parent checkbox is partially checked.
#+begin_example
- [-] call people
- [X] Peter
- [ ] Sarah
#+end_example
If all child checkboxes are checked, the parent checkbox is also checked.
#+begin_example
- [X] call people
- [X] Peter
- [X] Sarah
#+end_example
#+cindex: statistics, for checkboxes
#+cindex: checkbox statistics
#+cindex: @samp{COOKIE_DATA}, property
@ -4746,6 +4717,37 @@ If the current outline node has an =ORDERED= property, checkboxes must
be checked off in sequence, and an error is thrown if you try to check
off a box while there are unchecked boxes above it.
A checkbox can be in one of the three states:
1. not checked =[ ]=
2. partially checked =[-]=
3. checked =[X]=
Checkboxes work hierarchically, so if a checkbox item has children
that are checkboxes, toggling one of the children checkboxes makes the
parent checkbox reflect if none, some, or all of the children are
checked.
If all child checkboxes are not checked, the parent checkbox is also not checked.
#+begin_example
- [ ] call people
- [ ] Peter
- [ ] Sarah
#+end_example
If some but not all child checkboxes are checked, the parent checkbox is partially checked.
#+begin_example
- [-] call people
- [X] Peter
- [ ] Sarah
#+end_example
If all child checkboxes are checked, the parent checkbox is also checked.
#+begin_example
- [X] call people
- [X] Peter
- [X] Sarah
#+end_example
The following commands work with checkboxes:
- {{{kbd(C-c C-c)}}} (~org-toggle-checkbox~) ::
@ -5465,8 +5467,8 @@ not be used as keys in the properties drawer:
| =PRIORITY= | The priority of the entry, a string with a single letter. |
| =SCHEDULED= | The scheduling timestamp. |
| =TAGS= | The tags defined directly in the headline. |
| =TIMESTAMP= | The first keyword-less timestamp in the entry. |
| =TIMESTAMP_IA= | The first inactive timestamp in the entry. |
| =TIMESTAMP= | The first active keyword-less timestamp in the entry.[fn:17] |
| =TIMESTAMP_IA= | The first inactive keyword-less timestamp in the entry. |
| =TODO= | The TODO keyword of the entry. |
** Property Searches
@ -6677,16 +6679,16 @@ special repeaters =++= and =.+=. For example:
Marking this DONE shifts the date to exactly one hour from now.
#+end_example
#+vindex: org-agenda-skip-scheduled-if-deadline-is-shown
#+vindex: org-agenda-skip-scheduled-repeats-after-deadline
You may have both scheduling and deadline information for a specific
task. If the repeater is set for the scheduling information only, you
probably want the repeater to be ignored after the deadline. If so,
set the variable ~org-agenda-skip-scheduled-if-deadline-is-shown~ to
~repeated-after-deadline~. However, any scheduling information
without a repeater is no longer relevant once the task is done, and
thus, removed upon repeating the task. If you want both scheduling
and deadline information to repeat after the same interval, set the
same repeater for both timestamps.
set the variable ~org-agenda-skip-scheduled-repeats-after-deadline~ to
~t~. However, any scheduling information without a repeater is no
longer relevant once the task is done, and thus, removed upon
repeating the task. If you want both scheduling and deadline
information to repeat after the same interval, set the same repeater
for both timestamps.
An alternative to using a repeater is to create a number of copies of
a task subtree, with dates shifted in each copy. The command
@ -7819,10 +7821,10 @@ with prefix commands:
Visit the last stored capture item in its buffer.
#+vindex: org-capture-bookmark
#+vindex: org-bookmark-names-plist
#+vindex: org-capture-last-stored
You can also jump to the bookmark ~org-capture-last-stored~, which is
automatically created unless you set ~org-capture-bookmark~ to ~nil~.
automatically created unless you customize ~org-bookmark-names-plist~.
To insert the capture at point in an Org buffer, call ~org-capture~
with a {{{kbd(C-0)}}} prefix argument.
@ -12432,11 +12434,11 @@ value.
#+end_example
#+cindex: @samp{TOC}, keyword
Org normally inserts the table of contents directly before the first
headline of the file. To move the table of contents to a different
location, first turn off the default with ~org-export-with-toc~
variable or with =#+OPTIONS: toc:nil=. Then insert =#+TOC: headlines
N= at the desired location(s).
Org normally inserts the table of contents in front of the exported
document. To move the table of contents to a different location,
first turn off the default with ~org-export-with-toc~ variable or with
=#+OPTIONS: toc:nil=. Then insert =#+TOC: headlines N= at the desired
location(s).
#+begin_example
,#+OPTIONS: toc:nil
@ -12496,7 +12498,7 @@ the table of contents.
#+cindex: export, include files
#+cindex: @samp{INCLUDE}, keyword
During export, you can include the content of another file. For
[[*Summary of the export process][During export]], you can include the content of another file. For
example, to include your =.emacs= file, you could use:
: #+INCLUDE: "~/.emacs" src emacs-lisp
@ -13934,8 +13936,11 @@ general options (see [[*Export Settings]]).
#+cindex: @samp{LANGUAGE}, keyword
#+vindex: org-latex-packages-alist
#+vindex: org-latex-language-alist
#+vindex: org-export-default-language
Language code of the primary document language.
Language code of the primary document language. When =LANGUAGE=
keyword is not not specified use the value of
~org-export-default-language~ (by default - =en=, American English)
The list of language codes supported by Org is stored in the
variable ~org-latex-language-alist~.
@ -16432,12 +16437,14 @@ for usage and configuration details.
:END:
#+vindex: org-export-before-processing-hook
#+vindex: org-export-before-processing-functions
#+vindex: org-export-before-parsing-hook
The export process executes two hooks before the actual exporting
begins. The first hook, ~org-export-before-processing-hook~, runs
before any expansions of macros, Babel code, and include keywords in
the buffer. The second hook, ~org-export-before-parsing-hook~, runs
before the buffer is parsed.
begins. The first hook, ~org-export-before-processing-functions~,
runs before any expansions of macros, Babel code, and include keywords
in the buffer. The second hook,
~org-export-before-parsing-functions~, runs before the buffer is
parsed.
Functions added to these hooks are called with a single argument: the
export backend actually used, as a symbol. You may use them for
@ -16456,7 +16463,7 @@ BACKEND is the export backend being used, as a symbol."
;; the docstring of `org-map-entries' for details.
(setq org-map-continue-from (point)))))
(add-hook 'org-export-before-parsing-hook #'my-headline-removal)
(add-hook 'org-export-before-parsing-functions #'my-headline-removal)
#+end_src
*** Filters
@ -16538,6 +16545,158 @@ debugging.
,#+END_SRC
#+end_example
*** Summary of the export process
:PROPERTIES:
:UNNUMBERED: notoc
:END:
#+findex: org-export-as
Org mode export is a multi-step process that works on a temporary copy
of the buffer. The export process consists of 4 major steps:
1. Process the temporary copy, making necessary changes to the buffer
text;
2. Parse the buffer, converting plain Org markup into an abstract
syntax tree (AST);
3. Convert the AST to text, as prescribed by the selected export
backend;
4. Post-process the resulting exported text.
#+texinfo: @noindent
Process temporary copy of the source Org buffer [fn::Unless
otherwise specified, each step of the export process only operates on
the accessible portion of the buffer. When subtree export is selected
(see [[*The Export Dispatcher]]), the buffer is narrowed to the body of
the selected subtree, so that the rest of the buffer text, except
export keywords, does not contribute to the export output.]:
1. Execute ~org-export-before-processing-functions~ (see [[*Export hooks]]);
2. Expand =#+include= keywords in the whole buffer (see
[[*Include Files]]);
3. Remove commented subtrees in the whole buffer (see [[*Comment
Lines]]);
4. Replace macros in the whole buffer (see [[*Macro Replacement]]);
5. When ~org-export-use-babel~ is non-nil (default), process code
blocks:
- Leave code blocks inside archived subtrees (see [[*Internal
archiving]]) as is;
- Evaluate all the other code blocks according to code block
headers (see [[*Limit code block evaluation]]);
- Remove code, results of evaluation, both, or neither according
to =:exports= header argument (see [[*Exporting Code Blocks]]).
#+texinfo: @noindent
Parse the temporary buffer, creating AST:
1. Execute ~org-export-before-parsing-functions~ (see [[*Export hooks]]).
The hook functions may still modify the buffer;
2. Calculate export option values according to subtree-specific export
settings, in-buffer keywords, =#+BIND= keywords, and buffer-local
and global customization. The whole buffer is considered;
3. When ~org-org-with-cite-processors~ is non-nil (default), determine
contributing bibliographies and record them into export options
(see [[*Citations]]). The whole buffer is considered;
4. Execute ~org-export-filter-options-functions~;
5. Parse the accessible portion of the temporary buffer to generate an
AST. The AST is a nested list of lists representing Org syntax
elements (see [[https://orgmode.org/worg/dev/org-element-api.html][Org Element API]] for more details):
: (org-data ...
: (heading
: (section
: (paragraph (plain-text) (bold (plain-text))))
: (heading)
: (heading (section ...))))
Past this point, modifications to the temporary buffer no longer
affect the export; Org export works only with the AST;
6. Remove elements that are not exported from the AST:
- Headings according to =SELECT_TAGS= and =EXCLUDE_TAGS= export
keywords; =task=, =inline=, =arch= export options (see
[[*Export Settings]]);
- Comments;
- Clocks, drawers, fixed-width environments, footnotes, LaTeX
environments and fragments, node properties, planning lines,
property drawers, statistics cookies, timestamps, etc according
to =#+OPTIONS= keyword (see [[*Export Settings]]);
- Table rows containing width and alignment markers (see [[*Column
Width and Alignment]]);
- Table columns containing recalc marks (see [[*Advanced features]]).
7. Expand environment variables in file link AST nodes according to
the =expand-links= export option (see [[*Export Settings]]);
8. Execute ~org-export-filter-parse-tree-functions~. These
functions can modify the AST by side effects;
9. When ~org-org-with-cite-processors~ is non-nil (default), replace
citation AST nodes and =#+print_bibliography= keyword AST nodes as
prescribed by the selected citation export processor (see [[*Citation
export processors]]).
#+texinfo: @noindent
Convert the AST to text by traversing the AST nodes, depth-first:
1. Convert the leaf nodes (without children) to text as prescribed
by "transcoders" in the selected export backend
[fn:: See transcoders and ~:translate-alist~ in the docstrings
of ~org-export-define-backend~ and ~org-export-define-derived-backend~.];
2. Pass the converted nodes through the corresponding export
filters (see [[*Filters]]);
3. Concatenate all the converted child nodes to produce parent
node contents;
4. Convert the nodes with children to text, passing the nodes
themselves and their contents to the corresponding transcoders
and then to the export filters (see [[*Filters]]).
#+texinfo: @noindent
Post-process the exported text:
1. Post-process the converted AST, as prescribed by the export
backend. [fn:: See ~inner-template~ in the docstring of ~org-export-define-backend~.]
This step usually adds generated content (like Table of Contents)
to the exported text;
2. Execute ~org-export-filter-body-functions~;
3. Unless body-only export is selected (see [[*The Export Dispatcher]]),
add the necessary metadata to the final document, as prescribed
by the export backend. Examples: Document author/title; HTML
headers/footers; LaTeX preamble;
4. When ~org-org-with-cite-processors~ is non-nil (default), add
bibliography metadata, as prescribed by the citation export
processor;
5. Execute ~org-export-filter-final-output-functions~.
*** Extending an existing backend
:PROPERTIES:
:UNNUMBERED: notoc
@ -16594,7 +16753,9 @@ buffer:
Further steps to consider would be an interactive function,
self-installing an item in the export dispatcher menu, and other
user-friendly improvements.
user-friendly improvements. See
<https://orgmode.org/worg/dev/org-export-reference.html> for more
details.
*** Export features
**** The underlying idea
@ -17357,6 +17518,7 @@ to HTML, the following links all point to a dedicated anchor in
:END:
#+cindex: sitemap, of published pages
#+vindex: org-publish-project-alist
The following properties may be used to control publishing of
a map of files for a given project.
@ -17374,6 +17536,12 @@ a map of files for a given project.
Title of sitemap page. Defaults to name of file.
- ~:sitemap-style~ ::
Can be ~list~ (site-map is just an itemized list of the titles of
the files involved) or ~tree~ (the directory structure of the
source files is reflected in the site-map). Defaults to ~tree~.
- ~:sitemap-format-entry~ ::
#+findex: org-publish-find-date
@ -17419,21 +17587,6 @@ a map of files for a given project.
Should sorting be case-sensitive? Default ~nil~.
- ~:sitemap-file-entry-format~ ::
With this option one can tell how a sitemap's entry is formatted in
the sitemap. This is a format string with some escape sequences:
~%t~ stands for the title of the file, ~%a~ stands for the author of
the file and ~%d~ stands for the date of the file. The date is
retrieved with the ~org-publish-find-date~ function and formatted
with ~org-publish-sitemap-date-format~. Default ~%t~.
- ~:sitemap-date-format~ ::
Format string for the ~format-time-string~ function that tells how
a sitemap entry's date is to be formatted. This property bypasses
~org-publish-sitemap-date-format~ which defaults to ~%Y-%m-%d~.
*** Generating an index
:PROPERTIES:
:DESCRIPTION: An index that reaches across pages.
@ -20772,6 +20925,7 @@ changes.
| =fnconfirm= | Offer automatic label for editing or confirmation. |
| =fnadjust= | Automatically renumber and sort footnotes. |
| =nofnadjust= | Do not renumber and sort automatically. |
| =fnanon= | Create anonymous footnotes with ~org-footnote-new~. |
#+vindex: org-hide-block-startup
#+vindex: org-hide-drawer-startup
@ -23206,20 +23360,20 @@ from the list of stored links. To keep it in the list for later use,
use a triple {{{kbd(C-u)}}} prefix argument to {{{kbd(C-c C-l)}}}, or
configure the option ~org-link-keep-stored-after-insertion~.
[fn:15] Check also the variable ~org-fast-tag-selection-include-todo~,
it allows you to change the TODO state through the tags interface (see
[[*Setting Tags]]), in case you like to mingle the two concepts. Note
that this means you need to come up with unique keys across both sets
of keywords.
[fn:16] It is possible that Org mode records two timestamps when you
[fn:15] It is possible that Org mode records two timestamps when you
are using both ~org-log-done~ and state change logging. However, it
never prompts for two notes: if you have configured both, the state
change recording note takes precedence and cancel the closing note.
[fn:17] With the exception of description lists. But you can allow it
[fn:16] With the exception of description lists. But you can allow it
by modifying ~org-list-automatic-rules~ accordingly.
[fn:17] For both =TIMESTAMP= and =TIMESTAMP_IA=: the word "first"
refers to the first occurrence in the entry, not the earliest in time;
the prefix =CLOCK:= at the beginning of a clock entry is considered a
keyword in this context; and timestamps inside property drawers are
ignored.
[fn:18] An age can be defined as a duration, using units defined in
~org-duration-units~, e.g., =3d 1h=. If any value in the column is as
such, the summary is also expressed as a duration.
@ -23410,7 +23564,6 @@ values.
,#+END_SRC
#+end_example
[fn:50] Org Indent mode also sets ~wrap-prefix~ correctly for
indenting and wrapping long lines of headlines or text. This minor
mode also handles Visual Line mode and directly applied settings

View File

@ -13,6 +13,103 @@ Please send Org bug reports to mailto:emacs-orgmode@gnu.org.
* Version 9.7 (not released yet)
** Important announcements and breaking changes
*** When ~org-link-file-path-type~ is a function, its argument is now a filename as it is read by ~org-insert-link~; not an absolute path
Previously, when ~org-link-file-path-type~ is set to a function, the
function argument was the filename from the link expanded via
~expand-file-name~. Now, a bare filename is passed to the function.
*** Org export backends can now disable citation processors
A new global export option ~:with-cite-processors~, when set to nil,
disables citation processors completely. This option is available to
export backends via ~:options-alist~ when defining the backend.
The backends disabling citation processors must take care about
exporting citation objects and =print_bibliography= keywords via
transcoders.
Users can disable citations processors by customizing new
~org-export-process-citations~ option.
*** =ox-org= disables citation processors by default
Previously, when exporting to Org, all the citations and
=print_bibliography= keywords, were transformed according to the
chosen citation processor.
This is no loner the case. All the citation-related markup is now
exported as is.
The previous behavior can be reverted by setting new custom option
~org-org-with-cite-processors~.
*** =ox-org= now exports special table rows by default
Previously, when exporting to Org, special table rows (for example,
width cookies) were not exported. Now, they are exported by default.
You can customize new option ~org-org-with-special-rows~ to fall back to previous behavior.
*** Org babel backends are now expected to define an additional API function ~org-babel-session-buffer:<lang>~
Org babel now uses session buffer (if it exists) to retrieve
~default-directory~ environment during src block evaluation.
By default, buffer named like session is checked. All the backends
that create sessions inside buffers named differently should provide a
function ~org-babel-session-buffer:<lang>~. The function must accept
two arguments - session name and info list (as returned by
~org-babel-get-src-block-info~); and return the session buffer name.
*** ~org-insert-subheading~ no longer inserts a sub-heading above current when point is at the beginning of line
Previously, calling ~org-insert-subheading~ on
: * Heading 1
: <point>* Heading 2
yielded
: * Heading 1
: ** <point>
: * Heading 2
This is no longer the case. The sub-heading is always created below
current heading (prefix arguments have the same meaning as in
~org-insert-heading~):
: * Heading 1
: * Heading 2
: ** <point>
*** Org mode now fontifies whole table lines (including newline) according to ~org-table~ face
Previously, leading indentation and trailing newline in table rows
were not fontified using ~org-table~ face. ~default~ face was used instead.
This made it impossible to scale line height when ~org-table~ face has
smaller height than default (Emacs calculates line height using the tallest face).
Now, new ~org-table-row~ face is used on the whole table row lines,
including indentation and the final newline. This face, by default,
inherits from ~org-table~ face.
If the new behavior is not desired, ~org-table-row~ face can be
changed to inherit from ~default~ face.
~org-table~ takes precedence over ~org-table-row~ for the parts of
table rows without indentation and newline.
*** =ox-latex=: ~org-latex-line-break-safe~ is deprecated
~org-latex-line-break-safe~ constant was previously introduced to deal
with edge cases when LaTeX interprets [...] as LaTeX command
argument. However, it caused a number of other issues and proved
itself not to be as "safe" as it supposed to be.
We now use a Pandoc's approach to deal with the same problem,
utilizing ={[}= to escape =[...]= instances where needed.
*** ob-python now sets ~python-shell-buffer-name~ in Org edit buffers
When editing a Python src block, the editing buffer is now associated
@ -593,6 +690,62 @@ The change is breaking when ~org-use-property-inheritance~ is set to ~t~.
The =TEST= parameter is better served by Emacs debugging tools.
** New and changed options
*** New option ~org-export-process-citations~
The new option controls whether to use citation processors to process
citations.
*** New option ~org-org-with-cite-processors~
The new option controls whether to use citation processors to process
citations when exporting to Org.
*** New option ~org-org-with-special-rows~
The new options controls whether to export special table rows in
Org-Org (=ox-org=) export. The default value is ~t~.
*** New option ~org-babel-comint-fallback-regexp-threshold~
Org babel is often using Emacs' interactive REPL feature to implement
:session functionality in code blocks. However, Emacs' REPLs use
heuristics to detect which lines in the REPL buffer correspond to
output and which lines are user prompts.
Normally, Org babel changes the default prompt to something unique. It
avoids incorrect detection of code block output.
Sometimes, the Org-configured prompt is changed manually by users or
when running a sub-REPL (for example, when running ssh/python
interpreter inside shell).
The new option controls Org mode's heuristics for catching
user-changed prompt in interactive Org babel sessions. When Org mode
cannot find REPL's prompt for more than
~org-babel-comint-fallback-regexp-threshold~ seconds, imprecise
generic prompt is tried to detect whether the code block output has
arrived.
Users who often work with altering REPL prompts may consider reducing
the default 5 second value of the new option.
*** ~repeated-after-deadline~ value of ~org-agenda-skip-scheduled-repeats-after-deadline~ is moved to a new customization
A new custom option ~org-agenda-skip-scheduled-repeats-after-deadline~
is introduced in place of ~repeated-after-deadline~ value of
~org-agenda-skip-scheduled-repeats-after-deadline~.
Introducing a new option allow more control over agenda display and
resolves a confusion about the meaning of ~repeated-after-deadline~.
~repeated-after-deadline~ has nothing to do with /showing/ deadline.
It just prevents agenda display repeated scheduled entries past
deadline. The following example illustrates the meaning:
: * TODO Do me every day before Jan, 12th (included)
: SCHEDULED: <2024-01-03 Wed +1d> DEADLINE: <2024-01-05 Fri>
The old customization will continue to work, ensuring backwards compatibility.
*** New custom setting ~org-icalendar-ttl~ for the ~ox-icalendar~ backend
The option ~org-icalendar-ttl~ allows to advise a subscriber to the
@ -1041,6 +1194,14 @@ Completion is enabled for links to man pages added using ~org-insert-link~:
=C-c C-l man RET emacscl TAB= to get =emacsclient=. Of course, the ~ol-man~
library should be loaded first.
*** ~org-footnote-new~ can be configured to create anonymous footnotes
When ~org-footnote-auto-label~ is set to ~'anonymous~, create
anonymous footnotes automatically with ~org-footnote-new~.
The same can be done via startup options:
: #+STARTUP: fnanon
** New functions and changes in function arguments
*** New API functions to store data within ~org-element-cache~

View File

@ -1,4 +1,3 @@
.NOTPARALLEL: # always run this make serially
.SUFFIXES: # we don't need default suffix rules
ifeq ($(MAKELEVEL), 0)
$(error This make needs to be started as a sub-make from the toplevel directory.)
@ -10,7 +9,8 @@ LISPA := $(LISPV) $(LISPI)
LISPB := $(LISPA:%el=%elc) org-install.elc
LISPF := $(filter-out $(LISPA),$(sort $(wildcard *.el)))
LISPC := $(filter-out $(LISPB) $(LISPN:%el=%elc),$(LISPF:%el=%elc))
_ORGCM_ := dirall single source slint1 slint2
LISPN := $(filter-out $(LISPB) $(LISPN:%el=%eln),$(LISPF:%el=%eln))
_ORGCM_ := dirall single native source slint1 slint2
-include local.mk
.PHONY: all compile compile-dirty \
@ -19,7 +19,7 @@ _ORGCM_ := dirall single source slint1 slint2
install clean cleanauto cleanall cleanelc clean-install
# do not clean here, done in toplevel make
all compile compile-dirty:: autoloads
all compile compile-dirty:: | autoloads
ifeq ($(filter-out $(_ORGCM_),$(ORGCM)),)
$(MAKE) compile-$(ORGCM)
else
@ -27,10 +27,11 @@ else
endif
compile-dirall: dirall
compile-single: single $(LISPC)
compile-source: source dirall
compile-slint1: dirall slint1
compile-slint2: source dirall slint1
compile-single: $(LISPC) | single
compile-native: $(LISPN) | native
compile-source: | source dirall
compile-slint1: | dirall slint1
compile-slint2: | source dirall slint1
# internal
dirall:
@ -38,6 +39,8 @@ dirall:
@$(ELCDIR)
single:
@$(info ==================== $@ ====================)
native:
@$(info ==================== $@ ====================)
source: cleanelc
@$(info ==================== $@ ====================)
@$(foreach elc,$(LISPC),$(MAKE) $(elc) && $(RM) $(elc);)
@ -49,6 +52,10 @@ slint1:
@$(info Compiling single $(abspath $<)...)
-@$(ELC) $<
%.eln: %.el
@$(info Native compiling single $(abspath $<)...)
-@$(ELN) $<
autoloads: cleanauto $(LISPI) $(LISPV)
$(LISPV): $(LISPF)

View File

@ -64,6 +64,7 @@
(colormodel . :any)
(useDingbats . :any)
(horizontal . :any)
(async . ((yes no)))
(results . ((file list vector table scalar verbatim)
(raw html latex org code pp drawer)
(replace silent none append prepend)

View File

@ -237,7 +237,9 @@ or set the `:backend' header argument"))))
"clojure" (format "clojure -A%s" alias)
cmd0)
cmd0)))
(setq comint-prompt-regexp inf-clojure-comint-prompt-regexp)
(setq
org-babel-comint-prompt-regexp-old comint-prompt-regexp
comint-prompt-regexp inf-clojure-comint-prompt-regexp)
(funcall-interactively #'inf-clojure cmd)
(goto-char (point-max))))
(sit-for 1))

View File

@ -58,6 +58,22 @@ executed inside the protection of `save-excursion' and
(let ((comint-input-filter (lambda (_input) nil)))
,@body))))))
(defvar-local org-babel-comint-prompt-regexp-old nil
"Fallback regexp used to detect prompt.")
(defcustom org-babel-comint-fallback-regexp-threshold 5.0
"Waiting time until trying to use fallback regexp to detect prompt.
This is useful when prompt unexpectedly changes."
:type 'float
:group 'org-babel)
(defun org-babel-comint--set-fallback-prompt ()
"Swap `comint-prompt-regexp' and `org-babel-comint-prompt-regexp-old'."
(when org-babel-comint-prompt-regexp-old
(let ((tmp comint-prompt-regexp))
(setq comint-prompt-regexp org-babel-comint-prompt-regexp-old
org-babel-comint-prompt-regexp-old tmp))))
(defmacro org-babel-comint-with-output (meta &rest body)
"Evaluate BODY in BUFFER and return process output.
Will wait until EOE-INDICATOR appears in the output, then return
@ -96,14 +112,29 @@ or user `keyboard-quit' during execution of body."
;; pass FULL-BODY to process
,@body
;; wait for end-of-evaluation indicator
(while (progn
(goto-char comint-last-input-end)
(not (save-excursion
(and (re-search-forward
(regexp-quote ,eoe-indicator) nil t)
(re-search-forward
comint-prompt-regexp nil t)))))
(accept-process-output (get-buffer-process (current-buffer))))
(let ((start-time (current-time)))
(while (progn
(goto-char comint-last-input-end)
(not (save-excursion
(and (re-search-forward
(regexp-quote ,eoe-indicator) nil t)
(re-search-forward
comint-prompt-regexp nil t)))))
(accept-process-output
(get-buffer-process (current-buffer))
org-babel-comint-fallback-regexp-threshold)
(when (and org-babel-comint-prompt-regexp-old
(> (float-time (time-since start-time))
org-babel-comint-fallback-regexp-threshold)
(progn
(goto-char comint-last-input-end)
(save-excursion
(and
(re-search-forward
(regexp-quote ,eoe-indicator) nil t)
(re-search-forward
org-babel-comint-prompt-regexp-old nil t)))))
(org-babel-comint--set-fallback-prompt))))
;; replace cut dangling text
(goto-char (process-mark (get-buffer-process (current-buffer))))
(insert dangling-text)
@ -148,11 +179,23 @@ The input will not be echoed."
Note: this is only safe when waiting for the result of a single
statement (not large blocks of code)."
(org-babel-comint-in-buffer buffer
(while (progn
(goto-char comint-last-input-end)
(not (and (re-search-forward comint-prompt-regexp nil t)
(goto-char (match-beginning 0)))))
(accept-process-output (get-buffer-process buffer)))))
(let ((start-time (current-time)))
(while (progn
(goto-char comint-last-input-end)
(not (and (re-search-forward comint-prompt-regexp nil t)
(goto-char (match-beginning 0)))))
(accept-process-output
(get-buffer-process buffer)
org-babel-comint-fallback-regexp-threshold)
(when (and org-babel-comint-prompt-regexp-old
(> (float-time (time-since start-time))
org-babel-comint-fallback-regexp-threshold)
(progn
(goto-char comint-last-input-end)
(save-excursion
(re-search-forward
org-babel-comint-prompt-regexp-old nil t))))
(org-babel-comint--set-fallback-prompt))))))
(defun org-babel-comint-eval-invisibly-and-wait-for-file
(buffer file string &optional period)
@ -224,6 +267,8 @@ STRING contains the output originally inserted into the comint buffer."
(file-callback org-babel-comint-async-file-callback)
(combined-string (concat org-babel-comint-async-dangling string))
(new-dangling combined-string)
;; Assumes comint filter called with session buffer current
(session-dir default-directory)
;; list of UUID's matched by `org-babel-comint-async-indicator'
uuid-list)
(with-temp-buffer
@ -248,7 +293,8 @@ STRING contains the output originally inserted into the comint buffer."
(let* ((info (org-babel-get-src-block-info))
(params (nth 2 info))
(result-params
(cdr (assq :result-params params))))
(cdr (assq :result-params params)))
(default-directory session-dir))
(org-babel-insert-result
(funcall file-callback
(nth
@ -291,7 +337,8 @@ STRING contains the output originally inserted into the comint buffer."
(let* ((info (org-babel-get-src-block-info))
(params (nth 2 info))
(result-params
(cdr (assq :result-params params))))
(cdr (assq :result-params params)))
(default-directory session-dir))
(org-babel-insert-result
res-str result-params info))
t))))

View File

@ -767,8 +767,30 @@ When `:file-desc' is missing, return nil."
(`(:file-desc) result)
(`(:file-desc . ,(and (pred stringp) val)) val)))
(defvar *this*) ; Dynamically bound in `org-babel-execute-src-block'
; and `org-babel-read'
(defvar *this*)
;; Dynamically bound in `org-babel-execute-src-block'
;; and `org-babel-read'
(defun org-babel-session-buffer (&optional info)
"Return buffer name for session associated with current code block.
Return nil when no such live buffer with process exists.
When INFO is non-nil, it should be a list returned by
`org-babel-get-src-block-info'.
This function uses org-babel-session-buffer:<lang> function to
retrieve backend-specific session buffer name."
(declare-function org-babel-comint-buffer-livep "ob-comint" (buffer))
(when-let* ((info (or info (org-babel-get-src-block-info 'no-eval)))
(lang (nth 0 info))
(session (cdr (assq :session (nth 2 info))))
(cmd (intern (concat "org-babel-session-buffer:" lang)))
(buffer-name
(if (fboundp cmd)
(funcall cmd session info)
;; Use session name as buffer name by default.
session)))
(require 'ob-comint)
(when (org-babel-comint-buffer-livep buffer-name)
buffer-name)))
;;;###autoload
(defun org-babel-execute-src-block (&optional arg info params executor-type)
@ -840,14 +862,16 @@ guess will be made."
(dir (cdr (assq :dir params)))
(mkdirp (cdr (assq :mkdirp params)))
(default-directory
(cond
((not dir) default-directory)
((member mkdirp '("no" "nil" nil))
(file-name-as-directory (expand-file-name dir)))
(t
(let ((d (file-name-as-directory (expand-file-name dir))))
(make-directory d 'parents)
d))))
(cond
((not dir) default-directory)
((when-let ((session (org-babel-session-buffer info)))
(buffer-local-value 'default-directory (get-buffer session))))
((member mkdirp '("no" "nil" nil))
(file-name-as-directory (expand-file-name dir)))
(t
(let ((d (file-name-as-directory (expand-file-name dir))))
(make-directory d 'parents)
d))))
(cmd (intern (concat "org-babel-execute:" lang)))
result exec-start-time)
(unless (fboundp cmd)

View File

@ -152,8 +152,10 @@ This function should only be called by `org-babel-execute:haskell'."
(org-require-package 'inf-haskell "haskell-mode")
(add-hook 'inferior-haskell-hook
(lambda ()
(setq-local comint-prompt-regexp
(concat haskell-prompt-regexp "\\|^λ?> "))))
(setq-local
org-babel-comint-prompt-regexp-old comint-prompt-regexp
comint-prompt-regexp
(concat haskell-prompt-regexp "\\|^λ?> "))))
(org-babel-haskell-with-session session params
(cl-labels
((send-txt-to-ghci (txt)

View File

@ -184,6 +184,11 @@ Emacs-lisp table, otherwise return the results as a string."
name
(format "*%s*" name))))
(defun org-babel-session-buffer:lua (session &optional _)
"Return session buffer name for SESSION."
(or (org-babel-lua-session-buffer session)
(org-babel-lua-with-earmuffs session)))
(defun org-babel-lua-without-earmuffs (session)
"Remove stars around *SESSION*, leaving SESSION."
(let ((name (if (stringp session) session (format "%s" session))))

View File

@ -43,7 +43,8 @@
(defconst org-babel-header-args:python
'((return . :any)
(python . :any))
(python . :any)
(async . ((yes no))))
"Python-specific header arguments.")
(defcustom org-babel-python-command 'auto
@ -259,6 +260,11 @@ results as a string."
(substring name 1 (- (length name) 1))
name)))
(defun org-babel-session-buffer:python (session &optional _)
"Return session buffer name for SESSION."
(or (org-babel-python-session-buffer session)
(org-babel-python-with-earmuffs session)))
(defun org-babel-python--python-util-comint-end-of-output-p ()
"Return non-nil if the last prompt matches input prompt.
Backport of `python-util-comint-end-of-output-p' to emacs28. To
@ -301,8 +307,7 @@ already been configured as such, do nothing. Return the
initialized session."
(save-window-excursion
(let* ((session (if session (intern session) :default))
(py-buffer (or (org-babel-python-session-buffer session)
(org-babel-python-with-earmuffs session)))
(py-buffer (org-babel-session-buffer:python session))
(python-shell-buffer-name
(org-babel-python-without-earmuffs py-buffer))
(existing-session-p (comint-check-proc py-buffer))

View File

@ -191,7 +191,9 @@ Session settings (`:ruby' header arg value) are taken from PARAMS."
;; uniquely by regexp.
(when new-session?
(with-current-buffer session-buffer
(setq-local comint-prompt-regexp (concat "^" org-babel-ruby-prompt))
(setq-local
org-babel-comint-prompt-regexp-old comint-prompt-regexp
comint-prompt-regexp (concat "^" org-babel-ruby-prompt))
(insert org-babel-ruby-define-prompt ";")
(insert "_org_prompt_mode=conf.prompt_mode;conf.prompt_mode=:CUSTOM;")
(insert "conf.echo=false\n")

View File

@ -54,7 +54,7 @@
(defvar geiser-debug-jump-to-debug-p) ; Defined in geiser-debug.el
(defvar geiser-repl-use-other-window) ; Defined in geiser-repl.el
(defvar geiser-repl-window-allow-split) ; Defined in geiser-repl.el
(declare-function geiser-connect "ext:geiser-repl" (impl &optional host port))
(declare-function run-geiser "ext:geiser-repl" (impl))
(declare-function geiser "ext:geiser-repl" (impl))
(declare-function geiser-mode "ext:geiser-mode" ())
@ -78,6 +78,9 @@
(defvar org-babel-default-header-args:scheme '()
"Default header arguments for scheme code blocks.")
(defconst org-babel-header-args:scheme '((host . :any)
(port . :any))
"Header arguments supported in Scheme.")
(defun org-babel-scheme-expand-header-arg-vars (vars)
"Expand :var header arguments given as VARS."
@ -121,13 +124,17 @@
(with-current-buffer (set-buffer buffer)
geiser-impl--implementation))
(defun org-babel-scheme-get-repl (impl name)
"Switch to a scheme REPL, creating it if it doesn't exist."
(defun org-babel-scheme-get-repl (impl name &optional host port)
"Switch to a Scheme REPL, creating it if it doesn't exist.
If the variables HOST and PORT are set, connect to the running Scheme REPL."
(let ((buffer (org-babel-scheme-get-session-buffer name)))
(or buffer
(progn
(if (fboundp 'geiser)
(geiser impl)
(if (and host port)
(geiser-connect impl host port)
(geiser impl))
;; Obsolete since Geiser 0.26.
(run-geiser impl))
(when name
@ -164,7 +171,7 @@ org-babel-scheme-execute-with-geiser will use a temporary session."
,@body
(current-message))))
(defun org-babel-scheme-execute-with-geiser (code output impl repl)
(defun org-babel-scheme-execute-with-geiser (code output impl repl &optional host port)
"Execute code in specified REPL.
If the REPL doesn't exist, create it using the given scheme
implementation.
@ -180,7 +187,7 @@ is true; otherwise returns the last value."
(let ((geiser-repl-window-allow-split nil)
(geiser-repl-use-other-window nil))
(let ((repl-buffer (save-current-buffer
(org-babel-scheme-get-repl impl repl))))
(org-babel-scheme-get-repl impl repl host port))))
(when (not (eq impl (org-babel-scheme-get-buffer-impl
(current-buffer))))
(message "Implementation mismatch: %s (%s) %s (%s)" impl (symbolp impl)
@ -244,6 +251,8 @@ This function is called by `org-babel-execute-src-block'."
geiser-scheme-implementation
geiser-default-implementation
(car geiser-active-implementations)))
(host (cdr (assq :host params)))
(port (cdr (assq :port params)))
(session (org-babel-scheme-make-session-name
source-buffer-name (cdr (assq :session params)) impl))
(full-body (org-babel-expand-body:scheme body params))
@ -253,7 +262,9 @@ This function is called by `org-babel-execute-src-block'."
full-body ; code
(string= result-type "output") ; output?
impl ; implementation
(and (not (string= session "none")) session)))) ; session
(and (not (string= session "none")) session) ; session
host ; REPL host
port))) ; REPL port
(let ((table
(org-babel-reassemble-table
result

View File

@ -45,6 +45,11 @@
(declare-function orgtbl-to-generic "org-table" (table params))
(defvar org-babel-default-header-args:shell '())
(defconst org-babel-header-args:shell
'((async . ((yes no))))
"Shell-specific header arguments.")
(defvar org-babel-shell-names)
(defconst org-babel-shell-set-prompt-commands
@ -86,6 +91,9 @@ variables."
name))
(funcall (if (fboundp 'defvar-1) #'defvar-1 #'set) ;Emacs-29
(intern (concat "org-babel-default-header-args:" name))
nil)
(funcall (if (fboundp 'defvar-1) #'defvar-1 #'set) ;Emacs-29
(intern (concat "org-babel-header-args:" name))
nil)))
(defcustom org-babel-shell-names
@ -265,9 +273,11 @@ var of the same value."
org-babel-shell-set-prompt-commands))
(alist-get t org-babel-shell-set-prompt-commands))
org-babel-sh-prompt))
(setq-local comint-prompt-regexp
(concat "^" (regexp-quote org-babel-sh-prompt)
" *"))
(setq-local
org-babel-comint-prompt-regexp-old comint-prompt-regexp
comint-prompt-regexp
(concat "^" (regexp-quote org-babel-sh-prompt)
" *"))
;; Needed for Emacs 23 since the marker is initially
;; undefined and the filter functions try to use it without
;; checking.

View File

@ -246,7 +246,7 @@ adaptive Use relative path for files in the current directory and sub-
directories of it. For other files, use an absolute path.
Alternatively, users may supply a custom function that takes the
full filename as an argument and returns the path."
filename in the link as an argument and returns the path."
:group 'org-link
:type '(choice
(const relative)
@ -368,14 +368,17 @@ another window."
(const wl-other-frame)))))
(defcustom org-link-search-must-match-exact-headline 'query-to-create
"Non-nil means internal fuzzy links can only match headlines.
"Control fuzzy link behaviour when specific matches not found.
When nil, the fuzzy link may point to a target or a named
construct in the document. When set to the special value
`query-to-create', offer to create a new headline when none
matched.
When nil, if a fuzzy link does not match a more specific
target (such as a heading, named block, target, or code ref),
attempt a regular text search. When set to the special value
`query-to-create', offer to create a new heading matching the
link instead. Otherwise, signal an error rather than attempting
a regular text search.
Spaces and statistics cookies are ignored during heading searches."
This option only affects behaviour in Org buffers. Spaces and
statistics cookies are ignored during heading searches."
:group 'org-link-follow
:version "24.1"
:type '(choice
@ -853,12 +856,12 @@ This should be called after the variable `org-link-parameters' has changed."
org-link-plain-re
(let* ((non-space-bracket "[^][ \t\n()<>]")
(parenthesis
`(seq "("
`(seq (any "<([")
(0+ (or (regex ,non-space-bracket)
(seq "("
(seq (any "<([")
(0+ (regex ,non-space-bracket))
")")))
")")))
(any "])>"))))
(any "])>"))))
;; Heuristics for an URL link inspired by
;; https://daringfireball.net/2010/07/improved_regex_for_matching_urls
(rx-to-string
@ -1927,9 +1930,8 @@ non-interactively, don't allow to edit the default description."
(mapcar (lambda (x) (concat x ":")) all-prefixes)
(mapcar #'car org-stored-links)
;; Allow description completion. Avoid "nil" option
;; in the case of `completing-read-default' and
;; an error in `ido-completing-read' when some links
;; have no description.
;; in the case of `completing-read-default' when
;; some links have no description.
(delq nil (mapcar 'cadr org-stored-links)))
nil nil nil
'org-link--history
@ -1993,8 +1995,7 @@ non-interactively, don't allow to edit the default description."
((eq org-link-file-path-type 'relative)
(setq path (file-relative-name path)))
((functionp org-link-file-path-type)
(setq path (funcall org-link-file-path-type
(expand-file-name path))))
(setq path (funcall org-link-file-path-type path)))
(t
(save-match-data
(if (string-match (concat "^" (regexp-quote

View File

@ -894,17 +894,13 @@ the entry is scheduled today or was scheduled previously is not
shown.
When set to the symbol `not-today', skip scheduled previously,
but not scheduled today.
When set to the symbol `repeated-after-deadline', skip scheduled
items if they are repeated beyond the current deadline."
but not scheduled today."
:group 'org-agenda-skip
:group 'org-agenda-daily/weekly
:type '(choice
(const :tag "Never" nil)
(const :tag "Always" t)
(const :tag "Not when scheduled today" not-today)
(const :tag "When repeated past deadline" repeated-after-deadline)))
(const :tag "Not when scheduled today" not-today)))
(defcustom org-agenda-skip-timestamp-if-deadline-is-shown nil
"Non-nil means skip timestamp line if same entry shows because of deadline.
@ -1341,10 +1337,16 @@ When set to the symbol `next' only the first future repeat is shown."
(const :tag "Show all repeated entries" t)
(const :tag "Show next repeated entry" next)
(const :tag "Do not show repeated entries" nil))
:version "26.1"
:package-version '(Org . "9.1")
:safe #'symbolp)
(defcustom org-agenda-skip-scheduled-repeats-after-deadline nil
"Non-nil hides scheduled repeated entries past deadline."
:group 'org-agenda-daily/weekly
:type 'boolean
:package-version '(Org . "9.7")
:safe t)
(defcustom org-agenda-prefer-last-repeat nil
"Non-nil sets date for repeated entries to their last repeat.
@ -5826,7 +5828,7 @@ displayed in agenda view."
(if org-agenda-include-inactive-timestamps "[[<]" "<")
(regexp-quote
(format-time-string
(org-time-stamp-format nil 'no-brackets)
"%Y-%m-%d" ; We do not use `org-time-stamp-format' to not demand day name in timestamps.
(org-encode-time ; DATE bound by calendar
0 0 0 (nth 1 date) (car date) (nth 2 date))))
"\\|\\(<[0-9]+-[0-9]+-[0-9]+[^>\n]+?\\+[0-9]+[hdwmy]>\\)"
@ -6108,7 +6110,7 @@ then those holidays will be skipped."
" *\\["
(regexp-quote
(format-time-string
(org-time-stamp-format nil 'no-brackets)
"%Y-%m-%d" ; We do not use `org-time-stamp-format' to not demand day name in timestamps.
(org-encode-time ; DATE bound by calendar
0 0 0 (nth 1 date) (car date) (nth 2 date))))))
(org-agenda-search-headline-for-time nil)
@ -6661,18 +6663,25 @@ scheduled items with an hour specification like [h]h:mm."
;; Skip entry if it already appears as a deadline, per
;; `org-agenda-skip-scheduled-if-deadline-is-shown'. This
;; doesn't apply to habits.
(when (or org-agenda-skip-scheduled-repeats-after-deadline
;; FIXME: Backwards-compatibility.
(eq org-agenda-skip-scheduled-if-deadline-is-shown
'repeated-after-deadline))
(let ((deadline
(time-to-days
(when (org-element-property :deadline el)
(org-time-string-to-time
(org-element-interpret-data
(org-element-property :deadline el)))))))
(when (and (or (<= (org-agenda--timestamp-to-absolute s) deadline)
(not (= schedule current)))
(> current deadline))
(throw :skip nil))))
(when (pcase org-agenda-skip-scheduled-if-deadline-is-shown
((guard
(or (not (memq (line-beginning-position 0) deadline-pos))
habitp))
nil)
(`repeated-after-deadline
(let ((deadline (time-to-days
(when (org-element-property :deadline el)
(org-time-string-to-time
(org-element-interpret-data
(org-element-property :deadline el)))))))
(and (<= schedule deadline) (> current deadline))))
(`not-today pastschedp)
(`t t)
(_ nil))

View File

@ -501,12 +501,6 @@ The capture buffer is current and still narrowed."
:version "24.1"
:type 'hook)
(defcustom org-capture-bookmark t
"When non-nil, add bookmark pointing at the last stored position when capturing."
:group 'org-capture
:version "24.3"
:type 'boolean)
;;; The property list for keeping information about the capture process
(defvar org-capture-plist nil
@ -1001,12 +995,12 @@ Store them in the capture property list."
((or `here
`(here))
(org-capture-put :exact-position (point) :insert-here t))
(`(file ,path)
(`(file ,(and path (pred stringp)))
(set-buffer (org-capture-target-buffer path))
(org-capture-put-target-region-and-position)
(widen)
(setq target-entry-p nil))
(`(id ,id)
(`(id ,(and id (or (pred stringp) (pred symbolp))))
(pcase (org-id-find id)
(`(,path . ,position)
(set-buffer (org-capture-target-buffer path))
@ -1014,7 +1008,7 @@ Store them in the capture property list."
(org-capture-put-target-region-and-position)
(goto-char position))
(_ (error "Cannot find target ID \"%s\"" id))))
(`(file+headline ,path ,headline)
(`(file+headline ,(and path (pred stringp)) ,(and headline (pred stringp)))
(set-buffer (org-capture-target-buffer path))
;; Org expects the target file to be in Org mode, otherwise
;; it throws an error. However, the default notes files
@ -1036,7 +1030,7 @@ Store them in the capture property list."
(unless (bolp) (insert "\n"))
(insert "* " headline "\n")
(forward-line -1)))
(`(file+olp ,path . ,outline-path)
(`(file+olp ,(and path (pred stringp)) . ,(and outline-path (guard outline-path)))
(let ((m (org-find-olp (cons (org-capture-expand-file path)
outline-path))))
(set-buffer (marker-buffer m))
@ -1044,7 +1038,7 @@ Store them in the capture property list."
(widen)
(goto-char m)
(set-marker m nil)))
(`(file+regexp ,path ,regexp)
(`(file+regexp ,(and path (pred stringp)) ,(and regexp (pred stringp)))
(set-buffer (org-capture-target-buffer path))
(org-capture-put-target-region-and-position)
(widen)
@ -1057,7 +1051,7 @@ Store them in the capture property list."
(org-capture-put :exact-position (point))
(setq target-entry-p
(and (derived-mode-p 'org-mode) (org-at-heading-p)))))
(`(file+olp+datetree ,path . ,outline-path)
(`(file+olp+datetree ,(and path (pred stringp)) . ,outline-path)
(let ((m (if outline-path
(org-find-olp (cons (org-capture-expand-file path)
outline-path))
@ -1112,7 +1106,7 @@ Store them in the capture property list."
;; the following is the keep-restriction argument for
;; org-datetree-find-date-create
(when outline-path 'subtree-at-point))))
(`(file+function ,path ,function)
(`(file+function ,(and path (pred stringp)) ,(and function (pred functionp)))
(set-buffer (org-capture-target-buffer path))
(org-capture-put-target-region-and-position)
(widen)
@ -1120,7 +1114,7 @@ Store them in the capture property list."
(org-capture-put :exact-position (point))
(setq target-entry-p
(and (derived-mode-p 'org-mode) (org-at-heading-p))))
(`(function ,fun)
(`(function ,(and fun (pred functionp)))
(funcall fun)
(org-capture-put :exact-position (point))
(setq target-entry-p
@ -1506,7 +1500,9 @@ Of course, if exact position has been required, just put it there."
(point))))))
(with-current-buffer (buffer-base-buffer (current-buffer))
(org-with-point-at pos
(when org-capture-bookmark
;; FIXME: `org-capture-bookmark' is obsolete. To be removed
;; in future Org releases.
(when (with-no-warnings org-capture-bookmark)
(let ((bookmark (plist-get org-bookmark-names-plist :last-capture)))
(when bookmark
(condition-case err

View File

@ -183,28 +183,10 @@ See `org-columns-summary-types' for details.")
(org-defkey org-columns-map "\M-b" #'backward-char)
(org-defkey org-columns-map "a" #'org-columns-edit-allowed)
(org-defkey org-columns-map "s" #'org-columns-edit-attributes)
(org-defkey org-columns-map "\M-f"
(lambda () (interactive) (goto-char (1+ (point)))))
(org-defkey org-columns-map [right]
(lambda () (interactive) (goto-char (1+ (point)))))
(org-defkey org-columns-map [down]
(lambda () (interactive)
(let ((col (current-column)))
(forward-line 1)
(while (and (org-invisible-p2) (not (eobp)))
(forward-line 1))
(move-to-column col)
(if (derived-mode-p 'org-agenda-mode)
(org-agenda-do-context-action)))))
(org-defkey org-columns-map [up]
(lambda () (interactive)
(let ((col (current-column)))
(forward-line -1)
(while (and (org-invisible-p2) (not (bobp)))
(forward-line -1))
(move-to-column col)
(if (eq major-mode 'org-agenda-mode)
(org-agenda-do-context-action)))))
(org-defkey org-columns-map "\M-f" #'forward-char)
(org-defkey org-columns-map [right] #'forward-char)
(org-defkey org-columns-map [up] #'org-columns-move-up)
(org-defkey org-columns-map [down] #'org-columns-move-down)
(org-defkey org-columns-map [(shift right)] #'org-columns-next-allowed-value)
(org-defkey org-columns-map "n" #'org-columns-next-allowed-value)
(org-defkey org-columns-map [(shift left)] #'org-columns-previous-allowed-value)
@ -383,13 +365,15 @@ ORIGINAL is the real string, i.e., before it is modified by
"Store the relative remapping of column header-line.
This is needed to later remove this relative remapping.")
(defvar org-columns--read-only-string nil)
(defun org-columns--display-here (columns &optional dateline)
"Overlay the current line with column display.
COLUMNS is an alist (SPEC VALUE DISPLAYED). Optional argument
DATELINE is non-nil when the face used should be
`org-agenda-column-dateline'."
(when (and (ignore-errors (require 'face-remap))
org-columns-header-line-remap)
(when (and (not org-columns-header-line-remap)
(or (fboundp 'face-remap-add-relative)
(ignore-errors (require 'face-remap))))
(setq org-columns-header-line-remap
(face-remap-add-relative 'header-line '(:inherit default))))
(save-excursion
@ -456,9 +440,11 @@ DATELINE is non-nil when the face used should be
(line-end-position 0)
(line-beginning-position 2)
'read-only
(substitute-command-keys
"Type \\<org-columns-map>`\\[org-columns-edit-value]' \
to edit property")))))))
(or org-columns--read-only-string
(setq org-columns--read-only-string
(substitute-command-keys
"Type \\<org-columns-map>`\\[org-columns-edit-value]' \
to edit property")))))))))
(defun org-columns--truncate-below-width (string width)
"Return a substring of STRING no wider than WIDTH.
@ -911,7 +897,6 @@ When COLUMNS-FMT-STRING is non-nil, use it as the column format."
(setq truncate-lines t))
(dolist (entry cache)
(goto-char (car entry))
(move-marker (car entry) nil)
(org-columns--display-here (cdr entry)))))))))
(defun org-columns-new (&optional spec &rest attributes)
@ -996,6 +981,30 @@ details."
(interactive "p")
(org-columns-widen (- arg)))
(defun org-columns-move-up ()
"In column view, move cursor up one row.
When in agenda column view, also call `org-agenda-do-context-action'."
(interactive)
(let ((col (current-column)))
(forward-line -1)
(while (and (org-invisible-p2) (not (bobp)))
(forward-line -1))
(move-to-column col)
(if (eq major-mode 'org-agenda-mode)
(org-agenda-do-context-action))))
(defun org-columns-move-down ()
"In column view, move cursor down one row.
When in agenda column view, also call `org-agenda-do-context-action'."
(interactive)
(let ((col (current-column)))
(forward-line 1)
(while (and (org-invisible-p2) (not (eobp)))
(forward-line 1))
(move-to-column col)
(if (derived-mode-p 'org-agenda-mode)
(org-agenda-do-context-action))))
(defun org-columns-move-right ()
"Swap this column with the one to the right."
(interactive)
@ -1207,8 +1216,8 @@ Return the result as a duration."
SPEC is a column format specification. When optional argument
UPDATE is non-nil, summarized values can replace existing ones in
properties drawers."
(let* ((lmax (if (bound-and-true-p org-inlinetask-min-level)
org-inlinetask-min-level
(let* ((lmax (if (bound-and-true-p org-inlinetask-max-level)
org-inlinetask-max-level
29)) ;Hard-code deepest level.
(lvals (make-vector (1+ lmax) nil))
(level 0)

View File

@ -641,6 +641,24 @@ Counting starts at 1."
(define-obsolete-function-alias 'org-file-url-p 'org-url-p "9.6")
(define-obsolete-variable-alias 'org-plantuml-executable-args 'org-plantuml-args
"Org 9.6")
(defconst org-latex-line-break-safe "\\\\[0pt]"
"Linebreak protecting the following [...].
Without \"[0pt]\" it would be interpreted as an optional argument to
the \\\\.
This constant, for example, makes the below code not err:
\\begin{tabular}{c|c}
[t] & s\\\\[0pt]
[I] & A\\\\[0pt]
[m] & kg
\\end{tabular}")
(make-obsolete 'org-latex-line-break-safe
"should not be used - it is not safe in all the scenarios."
"9.7")
(defun org-in-fixed-width-region-p ()
"Non-nil if point in a fixed-width region."
(save-match-data
@ -1062,8 +1080,9 @@ INFO is a plist containing export properties."
"Switch to buffer in a second window on the current frame.
In particular, do not allow pop-up frames.
Returns the newly created buffer."
(with-no-warnings (org-no-popups (apply #'switch-to-buffer-other-window args))))
(make-obsolete 'org-switch-to-buffer-other-window "no longer used" "9.7")
(let (pop-up-frames pop-up-windows)
(apply #'switch-to-buffer-other-window args)))
(make-obsolete 'org-switch-to-buffer-other-window "no longer used" "9.7")
(make-obsolete 'org-refresh-category-properties "no longer used" "9.7")
(make-obsolete 'org-refresh-effort-properties "no longer used" "9.7")
@ -1156,13 +1175,23 @@ See `org-link-parameters' for documentation on the other parameters."
(org-unbracket-string "<" ">" s))
(make-obsolete 'org-remove-angle-brackets 'org-unbracket-string "9.0")
(defcustom org-capture-bookmark t
"When non-nil, add bookmark pointing at the last stored position when capturing."
:group 'org-capture
:version "24.3"
:type 'boolean)
(make-obsolete-variable
'org-capture-bookmark
"use `org-bookmark-names-plist' instead."
"9.7")
(defcustom org-publish-sitemap-file-entry-format "%t"
"Format string for site-map file entry.
You could use brackets to delimit on what part the link will be.
%t is the title.
%a is the author.
%d is the date formatted using `org-publish-sitemap-date-format'."
%d is the date."
:group 'org-export-publish
:type 'string)
(make-obsolete-variable

View File

@ -71,6 +71,7 @@
(defvar epg-context)
(declare-function org-back-over-empty-lines "org" ())
(declare-function org-current-level "org" ())
(declare-function org-back-to-heading "org" (&optional invisible-ok))
(declare-function org-before-first-heading-p "org" ())
(declare-function org-end-of-meta-data "org" (&optional full))
@ -251,6 +252,7 @@ Assume `epg-context' is set."
(org-fold-subtree t))
nil)))))
(defvar org-outline-regexp-bol)
;;;###autoload
(defun org-decrypt-entry ()
"Decrypt the content of the current headline."
@ -266,6 +268,7 @@ Assume `epg-context' is set."
(save-excursion
(org-previous-visible-heading 1)
(point))))
(level (org-current-level))
(encrypted-text (org-crypt--encrypted-text beg end))
(decrypted-text
(decode-coding-string
@ -276,15 +279,27 @@ Assume `epg-context' is set."
;; outline property starts at the \n of the heading.
(delete-region (1- (point)) end)
(setq origin-marker (point-marker))
;; Store a checksum of the decrypted and the encrypted text
;; value. This allows reusing the same encrypted text if the
;; text does not change, and therefore avoid a re-encryption
;; process.
(insert "\n"
(propertize decrypted-text
'org-crypt-checksum (sha1 decrypted-text)
'org-crypt-key (org-crypt-key-for-heading)
'org-crypt-text encrypted-text))
(if (string-match (org-headline-re level) decrypted-text)
;; If decrypted text contains other headings with levels
;; below LEVEL, adjust the subtree.
(let ((start 0) (min-level level))
(while (string-match (org-headline-re level) decrypted-text start)
(setq min-level (min min-level (1- (length (match-string 0 decrypted-text))))
start (match-end 0)))
(insert "\n"
(replace-regexp-in-string
org-outline-regexp-bol
(concat (make-string (1+ (- level min-level)) ?*) "\\&")
decrypted-text)))
;; Store a checksum of the decrypted and the encrypted text
;; value. This allows reusing the same encrypted text if the
;; text does not change, and therefore avoid a re-encryption
;; process.
(insert "\n"
(propertize decrypted-text
'org-crypt-checksum (sha1 decrypted-text)
'org-crypt-key (org-crypt-key-for-heading)
'org-crypt-text encrypted-text)))
;; Apply initial visibility.
(save-restriction
(narrow-to-region origin-marker (point))

View File

@ -149,7 +149,7 @@
(defvar org-ctags-enabled-p t
"Activate ctags support in org mode?")
(defvar org-ctags-tag-regexp "/<<([^>]+)>>/\\1/d,definition/"
(defvar org-ctags-tag-regexp "/<<([^<>]+)>>/\\1/d,definition/"
"Regexp expression used by ctags external program.
The regexp matches tag destinations in Org files.
Format is: /REGEXP/TAGNAME/FLAGS,TAGTYPE/
@ -484,11 +484,11 @@ its subdirectories contain large numbers of taggable files."
(setq exitcode
(shell-command
(format (concat "%s --langdef=orgmode --langmap=orgmode:.org "
"--regex-orgmode=\"%s\" -f \"%s\" -e -R \"%s\"")
"--regex-orgmode=\"%s\" -f \"%s\" -e -R %s")
org-ctags-path-to-ctags
org-ctags-tag-regexp
(expand-file-name (concat dir-name "/TAGS"))
(expand-file-name (concat dir-name "/*")))))
(expand-file-name (concat (shell-quote-argument dir-name) "/*")))))
(cond
((eql 0 exitcode)
(setq-local org-ctags-tag-list
@ -506,12 +506,11 @@ its subdirectories contain large numbers of taggable files."
(defun org-ctags-find-tag-interactive ()
"Prompt for the name of a tag, with autocompletion, then visit the named tag.
Uses `ido-mode' if available.
If the user enters a string that does not match an existing tag, create
a new topic."
(interactive)
(let* ((tag (ido-completing-read "Topic: " org-ctags-tag-list
nil 'confirm nil 'org-ctags-find-tag-history)))
(let* ((tag (completing-read "Topic: " org-ctags-tag-list
nil 'confirm nil 'org-ctags-find-tag-history)))
(when tag
(cond
((member tag org-ctags-tag-list)

View File

@ -615,7 +615,7 @@ With a numeric prefix, show all headlines up to that level."
(cond
;; `fold' is technically not allowed value, but it is often
;; intuitively tried by users by analogy with #+STARTUP: fold.
((memq org-startup-folded '(t fold))
((memq org-startup-folded '(t fold overview))
(org-cycle-overview))
((eq org-startup-folded 'content)
(org-cycle-content))
@ -667,8 +667,7 @@ With a numeric prefix, show all headlines up to that level."
(org-cycle-content))))
((or "all" "showall")
(org-fold-show-subtree))
(_ nil)))
(org-end-of-subtree t)))))))
(_ nil)))))))))
(defun org-cycle-overview ()
"Switch to overview mode, showing only top-level headlines."

View File

@ -205,6 +205,7 @@
(require 'org-macs)
(require 'inline) ; load indentation rules
(require 'subr-x) ;; FIXME: Required for Emacs 27
;;;; Syntax node type
@ -230,16 +231,11 @@ when NODE is an anonymous node."
(define-inline org-element-type-p (node types)
"Return non-nil when NODE type is one of TYPES.
TYPES can be a type symbol or a list of symbols."
(if (inline-const-p types)
(if (listp (inline-const-val types))
(inline-quote (memq (org-element-type ,node t) ,types))
(inline-quote (eq (org-element-type ,node t) ,types)))
(inline-letevals (node types)
(inline-quote
(if (listp ,types)
(memq (org-element-type ,node t) ,types)
(eq (org-element-type ,node t) ,types))))))
TYPES can be a type symbol or a list of symbols."
(inline-letevals (node types)
(if (listp (inline-const-val types))
(inline-quote (memq (org-element-type ,node t) ,types))
(inline-quote (eq (org-element-type ,node t) ,types)))))
(defun org-element-secondary-p (node)
"Non-nil when NODE directly belongs to a secondary node.
@ -353,18 +349,15 @@ node types.")
(setq plist (plist-put plist property idx)))
org-element--standard-properties)
plist)
"Property list holding standard indexes for `org-element--standard-properties'."))
"Property list holding standard indexes for `org-element--standard-properties'.")
(define-inline org-element--property-idx (property)
"Return standard property index or nil."
(declare (pure t))
(if (inline-const-p property)
(define-inline org-element--property-idx (property)
"Return standard property index or nil."
(declare (pure t))
(inline-letevals (property)
(plist-get
org-element--standard-properties-idxs
(inline-const-val property))
(inline-quote (plist-get
org-element--standard-properties-idxs
,property))))
(inline-const-val property)))))
(define-inline org-element--parray (node)
"Return standard property array for NODE."
@ -413,26 +406,16 @@ Ignore standard property array."
Do not resolve deferred values.
If PROPERTY is not present, return DFLT."
(declare (pure t))
(let ((idx (and (inline-const-p property)
(org-element--property-idx property))))
(if idx
(inline-letevals (node)
(inline-quote
(if-let ((parray (org-element--parray ,node)))
(pcase (aref parray ,idx)
(`org-element-ast--nil ,dflt)
(val val))
;; No property array exists. Fall back to `plist-get'.
(org-element--plist-property ,property ,node ,dflt))))
(inline-letevals (node property)
(inline-quote
(let ((idx (org-element--property-idx ,property)))
(if-let ((parray (and idx (org-element--parray ,node))))
(pcase (aref parray idx)
(`org-element-ast--nil ,dflt)
(val val))
;; No property array exists. Fall back to `plist-get'.
(org-element--plist-property ,property ,node ,dflt))))))))
(inline-letevals (node property)
(let ((idx (org-element--property-idx (inline-const-val property))))
(inline-quote
(let ((idx (or ,idx (org-element--property-idx ,property))))
(if-let ((parray (and idx (org-element--parray ,node))))
(pcase (aref parray idx)
(`org-element-ast--nil ,dflt)
(val val))
;; No property array exists. Fall back to `plist-get'.
(org-element--plist-property ,property ,node ,dflt)))))))
(define-inline org-element--put-parray (node &optional parray)
"Initialize standard property array in NODE.

View File

@ -3,6 +3,7 @@
;; Copyright (C) 2012-2024 Free Software Foundation, Inc.
;; Author: Nicolas Goaziou <n.goaziou at gmail dot com>
;; Maintainer: Ihor Radchenko <yantar92 at posteo dot net>
;; Keywords: outlines, hypermedia, calendar, wp
;; This file is part of GNU Emacs.
@ -2870,6 +2871,7 @@ Assume point is at the beginning of the paragraph."
(progn (forward-line 0) t))))
((looking-at-p org-element-drawer-re)
(save-excursion
(forward-line 1)
(re-search-forward "^[ \t]*:END:[ \t]*$" limit t)))
((looking-at "[ \t]*#\\+BEGIN_\\(\\S-+\\)")
(save-excursion
@ -7989,10 +7991,10 @@ the cache."
(if org-element--cache-map-statistics
(progn
(setq before-time (float-time))
(re-search-forward (or (car-safe ,re) ,re) nil 'move)
(cl-incf re-search-time
(- (float-time)
before-time)))
(prog1 (re-search-forward (or (car-safe ,re) ,re) nil 'move)
(cl-incf re-search-time
(- (float-time)
before-time))))
(re-search-forward (or (car-safe ,re) ,re) nil 'move)))
(unless (or (< (point) (or start -1))
(and data
@ -8176,22 +8178,21 @@ the cache."
(move-start-to-next-match
(if last-match next-re fail-re)))
(when (and (or (not start) (eq (org-element-begin data) start))
(< (org-element-begin data) to-pos))
(< (org-element-begin data) to-pos)
(not continue-flag))
;; Calculate where next possible element
;; starts and update START if needed.
(setq start (next-element-start))
(goto-char start)
;; Move START further if possible.
(when (and next-element-re
;; Do not move if we know for
;; sure that cache does not
;; contain gaps. Regexp
;; searches are not cheap.
(not (cache-gapless-p)))
(move-start-to-next-match next-element-re)
;; Make sure that point is at START
;; before running FUNC.
(goto-char start))
(save-excursion
(when (and next-element-re
;; Do not move if we know for
;; sure that cache does not
;; contain gaps. Regexp
;; searches are not cheap.
(not (cache-gapless-p)))
(move-start-to-next-match next-element-re)))
;; Try FUNC if DATA matches all the
;; restrictions. Calculate new START.
(when (or (not restrict-elements)

View File

@ -389,6 +389,10 @@ changes."
"Face used for tables."
:group 'org-faces)
(defface org-table-row '((t :inherit org-table))
"Face used to fontify whole table rows (including newlines and indentation)."
:group 'org-faces)
(defface org-table-header '((t :inherit org-table
:background "LightGray"
:foreground "Black"))

View File

@ -280,12 +280,13 @@
;;; Customization
(defcustom org-fold-core-style 'text-properties
(defcustom org-fold-core-style (if (version< emacs-version "29")
'text-properties
'overlays)
"Internal implementation detail used to hide folded text.
Can be either `text-properties' or `overlays'.
The former is faster on large files, while the latter is generally
less error-prone with regard to third-party packages that haven't yet
adapted to the new folding implementation.
The former is faster on large files in Emacs <29, while the latter is
generally less error-prone with regard to third-party packages.
Important: This variable must be set before loading Org."
:group 'org
@ -1356,7 +1357,9 @@ Pass the same FROM, TO, FLAG, and SPEC-OR-ALIAS."
"Perform folding for `org-fold-core--region-delayed-list'."
(when org-fold-core--region-delayed-list
(mapc (lambda (args)
(when (< (nth 0 args) (nth 1 args))
(when (and (buffer-live-p (marker-buffer (nth 0 args)))
(buffer-live-p (marker-buffer (nth 1 args)))
(< (nth 0 args) (nth 1 args)))
(org-with-point-at (car args)
(apply #'org-fold-core-region args))))
;; Restore the initial folding order.

View File

@ -595,7 +595,8 @@ Return a non-nil value when toggling is successful."
(defun org-fold-hide-drawer-all (&optional begin end)
"Fold all drawers in the current buffer or active region BEGIN..END."
(interactive "r")
(interactive (list (and (use-region-p) (region-beginning))
(and (use-region-p) (region-end))))
(let ((begin (or begin (point-min)))
(end (or end (point-max))))
(org-fold--hide-drawers begin end)))

View File

@ -137,6 +137,7 @@ Possible values are:
nil Prompt the user for each label.
t Create unique labels of the form [fn:1], [fn:2], etc.
anonymous Create anonymous footnotes
confirm Like t, but let the user edit the created value.
The label can be removed from the minibuffer to create
an anonymous footnote.
@ -146,6 +147,7 @@ random Automatically generate a unique, random label."
(const :tag "Prompt for label" nil)
(const :tag "Create automatic [fn:N]" t)
(const :tag "Offer automatic [fn:N] for editing" confirm)
(const :tag "Create anoymous [fn::]" anonymous)
(const :tag "Create a random label" random))
:safe #'symbolp)
@ -666,15 +668,16 @@ or new, let the user edit the definition of the footnote."
(user-error "Cannot insert a footnote here"))
(let* ((all (org-footnote-all-labels))
(label
(if (eq org-footnote-auto-label 'random)
(format "%x" (abs (random)))
(org-footnote-normalize-label
(let ((propose (org-footnote-unique-label all)))
(if (eq org-footnote-auto-label t) propose
(completing-read
"Label (leave empty for anonymous): "
(mapcar #'list all) nil nil
(and (eq org-footnote-auto-label 'confirm) propose))))))))
(unless (eq org-footnote-auto-label 'anonymous)
(if (eq org-footnote-auto-label 'random)
(format "%x" (abs (random)))
(org-footnote-normalize-label
(let ((propose (org-footnote-unique-label all)))
(if (eq org-footnote-auto-label t) propose
(completing-read
"Label (leave empty for anonymous): "
(mapcar #'list all) nil nil
(and (eq org-footnote-auto-label 'confirm) propose)))))))))
(cond ((not label)
(insert "[fn::]")
(backward-char 1))

View File

@ -1152,7 +1152,7 @@ This function modifies STRUCT."
(org-fold-core-regions (cdr folds) :relative beg-A)
(org-fold-core-regions
(car folds)
:relative (+ beg-B (- size-B size-A (length between-A-no-blank-and-B))))
:relative (+ beg-A size-B (length between-A-no-blank-and-B)))
;; 2. Now modify struct. No need to re-read the list, the
;; transformation is just a shift of positions. Some special
;; attention is required for items ending at END-A and END-B

View File

@ -1898,7 +1898,9 @@ it for output."
(cond
((functionp command)
(funcall command (shell-quote-argument relname)))
((stringp command) (shell-command command log-buf)))))
((stringp command)
(let ((shell-command-dont-erase-buffer t))
(shell-command command log-buf))))))
;; Check for process failure. Output file is expected to be
;; located in the same directory as SOURCE.
(unless (org-file-newer-than-p output time)

View File

@ -83,6 +83,7 @@
;;; Customization
;;;###autoload
(defcustom org-num-face nil
"Face to use for numbering.
When nil, use the same face as the headline. This value is
@ -104,6 +105,7 @@ Any `face' text property on the returned string overrides
:package-version '(Org . "9.3")
:type 'function)
;;;###autoload
(defcustom org-num-max-level nil
"Level below which headlines are not numbered.
When set to nil, all headlines are numbered."
@ -113,6 +115,7 @@ When set to nil, all headlines are numbered."
(integer :tag "Stop numbering at level"))
:safe (lambda (val) (or (null val) (wholenump val))))
;;;###autoload
(defcustom org-num-skip-commented nil
"Non-nil means commented sub-trees are not numbered."
:group 'org-appearance
@ -120,6 +123,7 @@ When set to nil, all headlines are numbered."
:type 'boolean
:safe #'booleanp)
;;;###autoload
(defcustom org-num-skip-footnotes nil
"Non-nil means footnotes sections are not numbered."
:group 'org-appearance
@ -127,6 +131,7 @@ When set to nil, all headlines are numbered."
:type 'boolean
:safe #'booleanp)
;;;###autoload
(defcustom org-num-skip-tags nil
"List of tags preventing the numbering of sub-trees.
@ -141,6 +146,7 @@ control tag inheritance."
:type '(repeat (string :tag "Tag"))
:safe (lambda (val) (and (listp val) (cl-every #'stringp val))))
;;;###autoload
(defcustom org-num-skip-unnumbered nil
"Non-nil means numbering obeys to UNNUMBERED property."
:group 'org-appearance

View File

@ -1327,11 +1327,11 @@ such scenario."
(defvar org-persist--refresh-gc-lock-timer nil
"Timer used to refresh session timestamp in `org-persist-gc-lock-file'.")
(when (and org-persist--disable-when-emacs-Q
;; FIXME: This is relying on undocumented fact that
;; Emacs sets `user-init-file' to nil when loaded with
;; "-Q" argument.
(not user-init-file))
(unless (and org-persist--disable-when-emacs-Q
;; FIXME: This is relying on undocumented fact that
;; Emacs sets `user-init-file' to nil when loaded with
;; "-Q" argument.
(not user-init-file))
(unless org-persist--refresh-gc-lock-timer
(setq org-persist--refresh-gc-lock-timer
(run-at-time nil org-persist-gc-lock-interval #'org-persist--refresh-gc-lock))))

View File

@ -467,16 +467,17 @@ prevents it from hanging Emacs."
This may be useful when columns have been shrunk."
(save-excursion
(when pos (goto-char pos))
(goto-char (line-beginning-position))
(let ((end (line-end-position)) str)
(goto-char (1- pos))
(while (progn (forward-char 1) (< (point) end))
(let ((ov (car (overlays-at (point)))))
(if (not ov)
(push (char-to-string (char-after)) str)
(push (overlay-get ov 'display) str)
(goto-char (1- (overlay-end ov))))))
(format "|%s" (mapconcat #'identity (reverse str) "")))))
(let* ((beg (line-beginning-position))
(end (line-end-position))
(str (buffer-substring beg end)))
;; FIXME: This does not handle intersecting overlays.
(dolist (ov (overlays-in beg end))
(when (overlay-get ov 'display)
(put-text-property
(- (overlay-start ov) beg) (- (overlay-end ov) beg)
'display (overlay-get ov 'display)
str)))
str)))
(defvar-local org-table-header-overlay nil)
(put 'org-table-header-overlay 'permanent-local t)
@ -487,19 +488,24 @@ This may be useful when columns have been shrunk."
(progn
(when (overlayp org-table-header-overlay)
(delete-overlay org-table-header-overlay))
;; We might be called after scrolling but before display is
;; updated. Make sure that any queued redisplay is executed
;; before we look into `window-start'.
(redisplay)
(let* ((ws (window-start))
(beg (save-excursion
(goto-char (org-table-begin))
(while (or (org-at-table-hline-p)
(looking-at-p ".*|\\s-+<[rcl]?\\([0-9]+\\)?>"))
(move-beginning-of-line 2))
(line-beginning-position)))
(end (save-excursion (goto-char beg) (line-end-position))))
(line-beginning-position))))
(if (pos-visible-in-window-p beg)
(when (overlayp org-table-header-overlay)
(delete-overlay org-table-header-overlay))
(setq org-table-header-overlay
(make-overlay ws (+ ws (- end beg))))
(make-overlay
(save-excursion (goto-char ws) (line-beginning-position))
(save-excursion (goto-char ws) (line-end-position))))
(org-overlay-display
org-table-header-overlay
(org-table-row-get-visible-string beg)
@ -4468,46 +4474,48 @@ Optional argument NEW may specify text to replace the current field content."
(cond
((and (not new) org-table-may-need-update)) ; Realignment will happen anyway
((org-at-table-hline-p))
((and (not new)
(or (not (eq (marker-buffer org-table-aligned-begin-marker)
(current-buffer)))
(< (point) org-table-aligned-begin-marker)
(>= (point) org-table-aligned-end-marker)))
;; This is not the same table, force a full re-align.
(setq org-table-may-need-update t))
(t
;; Realign the current field, based on previous full realign.
(let ((pos (point))
(col (org-table-current-column)))
(when (> col 0)
(skip-chars-backward "^|")
(if (not (looking-at " *\\(?:\\([^|\n]*?\\) *\\(|\\)\\|\\([^|\n]+?\\) *\\($\\)\\)"))
(setq org-table-may-need-update t)
(let* ((align (nth (1- col) org-table-last-alignment))
(width (nth (1- col) org-table-last-column-widths))
(cell (match-string 0))
(field (match-string 1))
(properly-closed? (/= (match-beginning 2) (match-end 2)))
(new-cell
(save-match-data
(cond (org-table-may-need-update
(format " %s |" (or new field)))
((not properly-closed?)
(setq org-table-may-need-update t)
(format " %s |" (or new field)))
((not new)
(concat (org-table--align-field field width align)
"|"))
((and width (<= (org-string-width new nil 'org-table) width))
(concat (org-table--align-field new width align)
"|"))
(t
(setq org-table-may-need-update t)
(format " %s |" new))))))
(unless (equal new-cell cell)
(let (org-table-may-need-update)
(replace-match new-cell t t)))
(goto-char pos))))))))
(when (or (not (eq (marker-buffer org-table-aligned-begin-marker)
(current-buffer)))
(< (point) org-table-aligned-begin-marker)
(>= (point) org-table-aligned-end-marker))
;; This is not the same table, force a full re-align.
(setq org-table-may-need-update t
org-table-last-alignment nil
org-table-last-column-widths nil))
(when new
;; Realign the current field, based on previous full realign.
(let ((pos (point))
(col (org-table-current-column)))
(when (> col 0)
(skip-chars-backward "^|")
(if (not (looking-at " *\\(?:\\([^|\n]*?\\) *\\(|\\)\\|\\([^|\n]+?\\) *\\($\\)\\)"))
(setq org-table-may-need-update t)
(let* ((align (nth (1- col) org-table-last-alignment))
(width (nth (1- col) org-table-last-column-widths))
(cell (match-string 0))
(field (match-string 1))
(properly-closed? (/= (match-beginning 2) (match-end 2)))
(new-cell
(save-match-data
(cond (org-table-may-need-update
(format " %s |" (or new field)))
((not properly-closed?)
(setq org-table-may-need-update t)
(format " %s |" (or new field)))
((not new)
(concat (org-table--align-field field width align)
"|"))
((and width (<= (org-string-width new nil 'org-table) width))
(concat (org-table--align-field new width align)
"|"))
(t
(setq org-table-may-need-update t)
(format " %s |" new))))))
(unless (equal new-cell cell)
(let (org-table-may-need-update)
(replace-match new-cell t t)))
(goto-char pos)))))))))
;;;###autoload
(defun org-table-sort-lines

View File

@ -1005,7 +1005,30 @@ equivalent option for agenda views."
:group 'org)
(defcustom org-startup-folded 'showeverything
"Non-nil means entering Org mode will switch to OVERVIEW.
"Initial folding state of headings when entering Org mode.
Allowed values are:
symbol `nofold'
Do not fold headings.
symbol `fold'
Fold everything, leaving only top-level headings visible.
symbol `content'
Leave all the headings and sub-headings visible, but hide their
text. This is an equivalent of table of contents.
symbol `show2levels', `show3levels', `show4levels', `show5levels'
Show headings up to Nth level.
symbol `showeverything' (default)
Start Org mode in fully unfolded state. Unlike all other allowed
values, this value prevents drawers, blocks, and archived subtrees
from being folded even when `org-cycle-hide-block-startup',
`org-cycle-open-archived-trees', or `org-cycle-hide-drawer-startup'
are non-nil. Per-subtree visibility settings (see manual node
`(org)Initial visibility)') are also ignored.
This can also be configured on a per-file basis by adding one of
the following lines anywhere in the buffer:
@ -1022,8 +1045,8 @@ time."
:group 'org-startup
:package-version '(Org . "9.4")
:type '(choice
(const :tag "nofold: show all" nil)
(const :tag "fold: overview" t)
(const :tag "nofold: show all" nofold)
(const :tag "fold: overview" fold)
(const :tag "fold: show two levels" show2levels)
(const :tag "fold: show three levels" show3levels)
(const :tag "fold: show four levels" show4evels)
@ -3818,10 +3841,10 @@ After a match, the following groups carry important information:
4 the second time, if it is a range.")
(defconst org-startup-options
'(("fold" org-startup-folded t)
("overview" org-startup-folded t)
("nofold" org-startup-folded nil)
("showall" org-startup-folded nil)
'(("fold" org-startup-folded fold)
("overview" org-startup-folded overview)
("nofold" org-startup-folded nofold)
("showall" org-startup-folded showall)
("show2levels" org-startup-folded show2levels)
("show3levels" org-startup-folded show3levels)
("show4levels" org-startup-folded show4levels)
@ -3876,6 +3899,7 @@ After a match, the following groups carry important information:
("fnplain" org-footnote-auto-label plain)
("fnadjust" org-footnote-auto-adjust t)
("nofnadjust" org-footnote-auto-adjust nil)
("fnanon" org-footnote-auto-label anonymous)
("constcgs" constants-unit-system cgs)
("constSI" constants-unit-system SI)
("noptag" org-tag-persistent-alist nil)
@ -4483,7 +4507,7 @@ returns non-nil if any of them match."
(if (and (= char ?f) current-file)
(concat "file://" current-file) uri))
"\\'")))))
(prog1 (memq char '(?y ?n ?! ?d ?\s ?f))
(prog1 (memq char '(?y ?! ?d ?\s ?f))
(quit-window t)))))))
(defun org-extract-log-state-settings (x)
@ -5368,7 +5392,9 @@ for the start and end of inline results, respectively."
(defun org-fontify-extend-region (beg end _old-len)
(let ((end (if (progn (goto-char end) (looking-at-p "^[*#]"))
(1+ end) end))
(min (point-max) (1+ end))
;; See `font-lock-extend-jit-lock-region-after-change' and bug#68849.
(min (point-max) (1+ end))))
(begin-re "\\(\\\\\\[\\|\\(#\\+begin_\\|\\\\begin{\\)\\S-+\\)")
(end-re "\\(\\\\\\]\\|\\(#\\+end_\\|\\\\end{\\)\\S-+\\)")
(extend
@ -5623,7 +5649,8 @@ needs to be inserted at a specific position in the font-lock sequence.")
(2 (org-get-level-face 2))
(3 (org-get-level-face 3)))
;; Table lines
'("^[ \t]*\\(\\(|\\|\\+-[-+]\\).*\\S-\\)"
'("^[ \t]*\\(\\(|\\|\\+-[-+]\\).*\\S-\\)\n?"
(0 'org-table-row t)
(1 'org-table t))
;; Table internals
'("^[ \t]*|\\(?:.*?|\\)? *\\(:?=[^|\n]*\\)" (1 'org-formula t))
@ -6424,8 +6451,12 @@ unchecked check box."
(defun org-insert-subheading (arg)
"Insert a new subheading and demote it.
Works for outline headings and for plain lists alike."
Works for outline headings and for plain lists alike.
The prefix argument ARG is passed to `org-insert-heading'.
Unlike `org-insert-heading', when point is at the beginning of a
heading, still insert the new sub-heading below."
(interactive "P")
(when (bolp) (forward-char))
(org-insert-heading arg)
(cond
((org-at-heading-p) (org-do-demote))
@ -6433,7 +6464,8 @@ Works for outline headings and for plain lists alike."
(defun org-insert-todo-subheading (arg)
"Insert a new subheading with TODO keyword or checkbox and demote it.
Works for outline headings and for plain lists alike."
Works for outline headings and for plain lists alike.
The prefix argument ARG is passed to `org-insert-todo-heading'."
(interactive "P")
(org-insert-todo-heading arg)
(cond
@ -7138,11 +7170,19 @@ With optional argument ELEMENT narrow to subtree around ELEMENT."
(org-element-lineage
(or element (org-element-at-point))
'headline 'with-self))
(begin (org-element-begin heading))
(end (org-element-end heading)))
(if (and heading end)
(narrow-to-region (org-element-begin heading)
(if (= end (point-max))
end (1- end)))
(if (and heading end
;; Preserve historical behavior throwing an error when
;; current heading starts before active narrowing.
(<= (point-min) begin))
(narrow-to-region
begin
;; Preserve historical behavior not extending the active
;; narrowing when the subtree extends beyond it.
(min (point-max)
(if (= end (point-max))
end (1- end))))
(signal 'outline-before-first-heading nil))))
(defun org-toggle-narrow-to-subtree ()
@ -8688,7 +8728,7 @@ TYPE is the dynamic block type, as a string."
(defun org-dynamic-block-define (type func)
"Define dynamic block TYPE with FUNC.
TYPE is a string. FUNC is the function creating the dynamic
block of such type."
block of such type. FUNC must be able to accept zero arguments."
(pcase (assoc type org-dynamic-block-alist)
(`nil (push (cons type func) org-dynamic-block-alist))
(def (setcdr def func))))
@ -8704,7 +8744,7 @@ is non-nil, call the dynamic block function interactively."
(pcase (org-dynamic-block-function type)
(`nil (error "No such dynamic block: %S" type))
((and f (pred functionp))
(if interactive-p (call-interactively f) (funcall f)))
(if (and interactive-p (commandp f)) (call-interactively f) (funcall f)))
(_ (error "Invalid function for dynamic block %S" type))))
(defun org-dblock-update (&optional arg)
@ -9252,7 +9292,7 @@ When called through ELisp, arg is also interpreted in the following way:
(unless (org-invisible-p (line-beginning-position))
(org-fold-region (line-beginning-position)
(line-end-position)
nil)))
nil 'outline)))
(cond ((and org-state (equal this org-state))
(message "TODO state was already %s" (org-trim next)))
((not (pos-visible-in-window-p hl-pos))
@ -9620,10 +9660,11 @@ statistics everywhere."
(max 1 cnt-all)))
(format "[%d/%d]" cnt-done cnt-all))
ndel (- (match-end 0) checkbox-beg))
(goto-char checkbox-beg)
(insert new)
(delete-region (point) (+ (point) ndel))
(when org-auto-align-tags (org-fix-tags-on-the-fly))))
(unless (string-equal new (buffer-substring checkbox-beg (match-end 0)))
(goto-char checkbox-beg)
(insert new)
(delete-region (point) (+ (point) ndel))
(when org-auto-align-tags (org-fix-tags-on-the-fly)))))
(when cookie-present
(run-hook-with-args 'org-after-todo-statistics-hook
cnt-done (- cnt-all cnt-done))))))
@ -17028,18 +17069,11 @@ this numeric value."
(interactive "r")
(let ((result ""))
(while (/= beg end)
(if (eq org-fold-core-style 'text-properties)
(progn
(while (org-invisible-p beg)
(setq beg (org-fold-next-visibility-change beg end)))
(let ((next (org-fold-next-visibility-change beg end)))
(setq result (concat result (buffer-substring beg next)))
(setq beg next)))
(when (invisible-p beg)
(setq beg (next-single-char-property-change beg 'invisible nil end)))
(let ((next (next-single-char-property-change beg 'invisible nil end)))
(setq result (concat result (buffer-substring beg next)))
(setq beg next))))
(while (org-invisible-p beg)
(setq beg (org-fold-next-visibility-change beg end)))
(let ((next (org-fold-next-visibility-change beg end)))
(setq result (concat result (buffer-substring beg next)))
(setq beg next)))
;; Prevent Emacs from adding full selected text to `kill-ring'
;; when `select-enable-primary' is non-nil. This special value of
;; `deactivate-mark' only works since Emacs 29.

View File

@ -3,7 +3,6 @@
;; Copyright (C) 2012-2024 Free Software Foundation, Inc.
;; Author: Nicolas Goaziou <n.goaziou at gmail dot com>
;; Maintainer: Nicolas Goaziou <mail@nicolasgoaziou.fr>
;; Keywords: outlines, hypermedia, calendar, wp
;; This file is part of GNU Emacs.

View File

@ -4,7 +4,6 @@
;; Author: Carsten Dominik <carsten.dominik AT gmail DOT com>
;; Nicolas Goaziou <n.goaziou AT gmail DOT com>
;; Maintainer: Nicolas Goaziou <mail@nicolasgoaziou.fr>
;; Keywords: org, wp, tex
;; This file is part of GNU Emacs.
@ -513,6 +512,18 @@ used as a communication channel."
(options (if raw-options
(org-beamer--normalize-argument raw-options 'option)
""))
;; also process actions
(raw-action (org-element-property :BEAMER_ACT headline))
(action (if raw-action
;; If BEAMER_act property has its value enclosed in square
;; brackets, it is a default overlay specification and
;; overlay specification is empty. Otherwise, it is an
;; overlay specification and the default one is nil.
(org-beamer--normalize-argument
raw-action
(if (string-match "\\`\\[.*\\]\\'" raw-action) 'defaction
'action))
""))
;; Start a "columns" environment when explicitly requested or
;; when there is no previous headline or the previous
;; headline do not have a BEAMER_column property.
@ -522,12 +533,12 @@ used as a communication channel."
(or (equal environment "columns")
(and column-width
(not (and parent-env
(equal (downcase parent-env) "columns")))
(equal (downcase parent-env) "columns")))
(or (org-export-first-sibling-p headline info)
(not (org-element-property
:BEAMER_COL
(org-export-get-previous-element
headline info)))))))
:BEAMER_COL
(org-export-get-previous-element
headline info)))))))
;; End the "columns" environment when explicitly requested or
;; when there is no next headline or the next headline do not
;; have a BEAMER_column property.
@ -535,11 +546,11 @@ used as a communication channel."
(or (equal environment "columns")
(and column-width
(not (and parent-env
(equal (downcase parent-env) "columns")))
(equal (downcase parent-env) "columns")))
(or (org-export-last-sibling-p headline info)
(not (org-element-property
:BEAMER_COL
(org-export-get-next-element headline info))))))))
:BEAMER_COL
(org-export-get-next-element headline info))))))))
(concat
(when start-columns-p
;; Column can accept options only when the environment is
@ -547,10 +558,13 @@ used as a communication channel."
(if (not (equal environment "columns")) "\\begin{columns}\n"
(format "\\begin{columns}%s\n" options)))
(when column-width
(format "\\begin{column}%s{%s}\n"
(format "\\begin{column}%s%s{%s}\n"
;; One can specify placement for column only when
;; HEADLINE stands for a column on its own.
(if (equal environment "column") options "")
options
(if env-format
"" ; Inner environment is specified - pass actions later.
action)
(format "%s\\columnwidth" column-width)))
;; Block's opening string.
(when (nth 2 env-format)
@ -558,23 +572,18 @@ used as a communication channel."
(org-fill-template
(nth 2 env-format)
(nconc
;; If BEAMER_act property has its value enclosed in square
;; brackets, it is a default overlay specification and
;; overlay specification is empty. Otherwise, it is an
;; overlay specification and the default one is nil.
(let ((action (org-element-property :BEAMER_ACT headline)))
(cond
((not action) (list (cons "a" "") (cons "A" "") (cons "R" "")))
((and (string-prefix-p "[" action)
(string-suffix-p "]" action))
(list
(cons "A" (org-beamer--normalize-argument action 'defaction))
(cons "a" "")
(cons "R" action)))
(t
(list (cons "a" (org-beamer--normalize-argument action 'action))
(cons "A" "")
(cons "R" action)))))
(cond
((not action) (list (cons "a" "") (cons "A" "") (cons "R" "")))
((and (string-prefix-p "[" action)
(string-suffix-p "]" action))
(list
(cons "A" (org-beamer--normalize-argument action 'defaction))
(cons "a" "")
(cons "R" raw-action)))
(t
(list (cons "a" action)
(cons "A" "")
(cons "R" raw-action))))
(list (cons "o" options)
(cons "O" (or raw-options ""))
(cons "h" title)

View File

@ -1679,7 +1679,7 @@ https://developer.mozilla.org/en-US/docs/Mozilla/Mobile/Viewport_meta_tag"
;;;; LaTeX Fragments
(defcustom org-latex-to-html-convert-command nil
"Command to convert LaTeX fragments to HTML.
"Shell command to convert LaTeX fragments to HTML.
This command is very open-ended: the output of the command will
directly replace the LaTeX fragment in the resulting HTML.
Replace format-specifiers in the command as noted below and use
@ -1687,7 +1687,12 @@ Replace format-specifiers in the command as noted below and use
%i: The LaTeX fragment to be converted.
For example, this could be used with LaTeXML as
\"latexmlc \\='literal:%i\\=' --profile=math --preload=siunitx.sty 2>/dev/null\"."
\"latexmlc \\='literal:%i\\=' --profile=math --preload=siunitx.sty 2>/dev/null\".
The LaTeX fragment is replaced as is, without escaping special shell
syntax. It may be necessary to use single-quotes around \\='%i\\=', not
double-quotes. Else a math fragment such as \"$y = 200$\" may be
expanded to \" = 200\"."
:group 'org-latex
:package-version '(Org . "9.4")
:type '(choice
@ -2726,7 +2731,10 @@ information."
(let ((attributes (org-export-read-attribute :attr_html example-block)))
(if (plist-get attributes :textarea)
(org-html--textarea-block example-block)
(format "<pre class=\"example\"%s>\n%s</pre>"
(if-let ((class-val (plist-get attributes :class)))
(setq attributes (plist-put attributes :class (concat "example " class-val)))
(setq attributes (plist-put attributes :class "example")))
(format "<pre%s>\n%s</pre>"
(let* ((reference (org-html--reference example-block info))
(a (org-html--make-attribute-string
(if (or (not reference) (plist-member attributes :id))

View File

@ -375,23 +375,10 @@ cdr is a property list. Valid keywords for this list can be:
- `:script-tag' the script otf tag.")
(defconst org-latex-line-break-safe "\\\\[0pt]"
"Linebreak protecting the following [...].
Without \"[0pt]\" it would be interpreted as an optional argument to
the \\\\.
This constant, for example, makes the below code not err:
\\begin{tabular}{c|c}
[t] & s\\\\[0pt]
[I] & A\\\\[0pt]
[m] & kg
\\end{tabular}")
(defconst org-latex-table-matrix-macros `(("bordermatrix" . "\\cr")
(defconst org-latex-table-matrix-macros '(("bordermatrix" . "\\cr")
("qbordermatrix" . "\\cr")
("kbordermatrix" . ,org-latex-line-break-safe))
("kbordermatrix" . "\\\\"))
"Alist between matrix macros and their row ending.")
(defconst org-latex-math-environments-re
@ -491,7 +478,8 @@ references."
:group 'org-export-latex
:type 'boolean
:version "26.1"
:package-version '(Org . "8.3"))
:package-version '(Org . "8.3")
:safe #'booleanp)
(defcustom org-latex-reference-command "\\ref{%s}"
"Format string that takes a reference to produce a LaTeX reference command.
@ -502,8 +490,7 @@ use of a package such as hyperref or cleveref and then change the format string
to \"\\autoref{%s}\" or \"\\cref{%s}\" for example."
:group 'org-export-latex
:type 'string
:package-version '(Org . "9.5")
:safe #'stringp)
:package-version '(Org . "9.5"))
;;;; Preamble
@ -697,8 +684,9 @@ which is replaced with the subtitle."
(defcustom org-latex-toc-command "\\tableofcontents\n\n"
"LaTeX command to set the table of contents, list of figures, etc.
This command only applies to the table of contents generated with
the toc:nil option, not to those generated with #+TOC keyword."
This command only applies to the table of contents generated with the
toc:t, toc:1, toc:2, toc:3, ... options, not to those generated with
the #+TOC keyword."
:group 'org-export-latex
:type 'string)
@ -822,8 +810,7 @@ or if the image is wrapped within a \"wrapfigure\" environment.
Scale overrides width and height."
:group 'org-export-latex
:package-version '(Org . "9.3")
:type 'string
:safe #'stringp)
:type 'string)
(defcustom org-latex-image-default-height ""
"Default height for images.
@ -840,8 +827,7 @@ environment."
:group 'org-export-latex
:type 'string
:version "26.1"
:package-version '(Org . "9.0")
:safe #'stringp)
:package-version '(Org . "9.0"))
(defcustom org-latex-inline-image-rules
`(("file" . ,(rx "."
@ -885,8 +871,7 @@ default we use here encompasses both."
"Default environment used to `quote' blocks."
:group 'org-export-latex
:package-version '(Org . "9.5")
:type 'string
:safe #'stringp)
:type 'string)
(defcustom org-latex-default-table-mode 'table
"Default mode for tables.
@ -1638,6 +1623,8 @@ logfiles to remove, set `org-latex-logfiles-extensions'."
("Underfull \\hbox" . "[underfull hbox]")
("Overfull \\hbox" . "[overfull hbox]")
("Citation.*?undefined" . "[undefined citation]")
("^!.+Unicode character" . "[unicode character(s) not set up for use with pdflatex. You can run lualatex or xelatex instead]")
("Missing character: There is no" . "[Missing character(s): please load an appropriate font with the fontspec package]")
("Undefined control sequence" . "[undefined control sequence]"))
"Alist of regular expressions and associated messages for the user.
The regular expressions are used to find possible warnings in the
@ -1675,12 +1662,11 @@ this case always return a unique label.
Eventually, if FULL is non-nil, wrap label within \"\\label{}\"."
(let* ((type (org-element-type datum))
(user-label
(org-element-property
(cl-case type
((headline inlinetask) :CUSTOM_ID)
(target :value)
(otherwise :name))
datum))
(cl-case type
((headline inlinetask) (org-element-property :CUSTOM_ID datum))
(target (org-element-property :value datum))
(otherwise (or (org-element-property :name datum)
(car (org-element-property :results datum))))))
(label
(and (or user-label force)
(if (and user-label (plist-get info :latex-prefer-user-labels))
@ -1939,11 +1925,11 @@ nil."
INFO is the current export state, as a plist. This function
should not be used for floats. See
`org-latex--caption/label-string'."
(if (not (and (org-string-nw-p output) (org-element-property :name element)))
output
(concat (format "\\phantomsection\n\\label{%s}\n"
(org-latex--label element info))
output)))
(let ((label (org-latex--label element info)))
(if (not (and (org-string-nw-p output) label))
output
(concat (format "\\phantomsection\n\\label{%s}\n" label)
output))))
(defun org-latex--protect-text (text)
"Protect special characters in string TEXT and return it."
@ -2406,7 +2392,7 @@ information."
(concat (org-timestamp-translate (org-element-property :value clock))
(let ((time (org-element-property :duration clock)))
(and time (format " (%s)" time)))))
org-latex-line-break-safe))
"\\\\"))
;;;; Code
@ -2594,9 +2580,22 @@ holding contextual information."
;; with \texttt.
(code . (lambda (o _ _) (org-latex--protect-texttt (org-element-property :value o))))
(verbatim . (lambda (o _ _) (org-latex--protect-texttt (org-element-property :value o)))))))
;; Create a temporary export backend that strips footnotes from title.
;; Footnotes are not allowed in \section and similar
;; commands that contribute to TOC and footers.
;; See https://orgmode.org/list/691643eb-49d0-45c3-ab7f-a1edbd093bef@gmail.com
;; https://texfaq.org/FAQ-ftnsect
(section-no-footnote-backend
(org-export-create-backend
:parent section-backend
:transcoders
`((footnote-reference . ignore))))
(text
(org-export-data-with-backend
(org-element-property :title headline) section-backend info))
(text-no-footnote
(org-export-data-with-backend
(org-element-property :title headline) section-no-footnote-backend info))
(todo
(and (plist-get info :with-todo-keywords)
(let ((todo (org-element-property :todo-keyword headline)))
@ -2610,6 +2609,9 @@ holding contextual information."
;; The latter is required to remove tags from toc.
(full-text (funcall (plist-get info :latex-format-headline-function)
todo todo-type priority text tags info))
(full-text-no-footnote
(funcall (plist-get info :latex-format-headline-function)
todo todo-type priority text-no-footnote tags info))
;; Associate \label to the headline for internal links.
(headline-label (org-latex--label headline info t t))
(pre-blanks
@ -2667,10 +2669,14 @@ holding contextual information."
(string-match-p "\\<local\\>" v)
(format "\\stopcontents[level-%d]" level)))))
info t)))))
(if (and opt-title
(not (equal opt-title full-text))
(if (and (or (and opt-title (not (equal opt-title full-text)))
;; Heading contains footnotes. Add optional title
;; version without footnotes to avoid footnotes in
;; TOC/footers.
(and (not (equal full-text-no-footnote full-text))
(setq opt-title full-text-no-footnote)))
(string-match "\\`\\\\\\(.+?\\){" section-fmt))
(format (replace-match "\\1[%s]" nil nil section-fmt 1)
(format (replace-match "\\1[%s]" nil nil section-fmt 1)
;; Replace square brackets with parenthesis
;; since square brackets are not supported in
;; optional arguments.
@ -3007,7 +3013,7 @@ CONTENTS is nil. INFO is a plist holding contextual information."
(defun org-latex-line-break (_line-break _contents _info)
"Transcode a LINE-BREAK object from Org to LaTeX.
CONTENTS is nil. INFO is a plist holding contextual information."
(concat org-latex-line-break-safe "\n"))
"\\\\\n")
;;;; Link
@ -3377,9 +3383,16 @@ contextual information."
;; Handle break preservation if required.
(when (plist-get info :preserve-breaks)
(setq output (replace-regexp-in-string
"\\(?:[ \t]*\\\\\\\\\\)?[ \t]*\n"
(concat org-latex-line-break-safe "\n")
output nil t)))
"\\(?:[ \t]*\\\\\\\\\\)?[ \t]*\n" "\\\\\n" output nil t)))
;; Protect [foo] at the beginning of lines / beginning of the
;; plain-text object. This prevents LaTeX from unexpectedly
;; interpreting @@latex:\pagebreak@@ [foo] as a command with
;; optional argument.
(setq output (replace-regexp-in-string
(rx bol (0+ space) (group "["))
"{[}"
output
nil nil 1))
;; Return value.
output))
@ -3415,7 +3428,7 @@ information."
(format (plist-get info :latex-active-timestamp-format)
(org-timestamp-translate scheduled)))))))
" ")
org-latex-line-break-safe))
"\\\\"))
;;;; Property Drawer
@ -4198,11 +4211,11 @@ This function assumes TABLE has `org' as its `:type' property and
(format "\\begin{%s}%s{%s}\n" table-env width alignment)
(and above?
(org-string-nw-p caption)
(concat caption org-latex-line-break-safe "\n"))
(concat caption "\\\\\n"))
contents
(and (not above?)
(org-string-nw-p caption)
(concat caption org-latex-line-break-safe "\n"))
(concat caption "\\\\\n"))
(format "\\end{%s}" table-env)
(and fontsize "}"))))
(t
@ -4287,7 +4300,7 @@ This function assumes TABLE has `org' as its `:type' property and
(lambda (cell)
(substring (org-element-interpret-data cell) 0 -1))
(org-element-map row 'table-cell #'identity info) "&")
(or (cdr (assoc env org-latex-table-matrix-macros)) org-latex-line-break-safe)
(or (cdr (assoc env org-latex-table-matrix-macros)) "\\\\")
"\n")))
(org-element-map table 'table-row #'identity info) "")))
(concat
@ -4362,7 +4375,7 @@ a communication channel."
(setq table-head-cache (make-hash-table :test #'eq))
(plist-put info :org-latex-table-head-cache table-head-cache))
(if-let ((head-contents (gethash (org-element-parent table-row) table-head-cache)))
(puthash (org-element-parent table-row) (concat head-contents org-latex-line-break-safe "\n" contents)
(puthash (org-element-parent table-row) (concat head-contents "\\\\\n" contents)
table-head-cache)
(puthash (org-element-parent table-row) contents table-head-cache))))
;; Return LaTeX string as the transcoder.
@ -4371,7 +4384,7 @@ a communication channel."
;; hline was specifically marked.
(and booktabsp (not (org-export-get-previous-element table-row info))
"\\toprule\n")
contents org-latex-line-break-safe "\n"
contents "\\\\\n"
(cond
;; Special case for long tables. Define header and footers.
((and longtablep (org-export-table-row-ends-header-p table-row info))
@ -4379,9 +4392,9 @@ a communication channel."
(org-element-lineage table-row 'table) info))))
(format "%s
\\endfirsthead
\\multicolumn{%d}{l}{%s} \\\\[0pt]
\\multicolumn{%d}{l}{%s} \\\\
%s
%s \\\\[0pt]\n
%s \\\\\n
%s
\\endhead
%s\\multicolumn{%d}{r}{%s} \\\\
@ -4490,15 +4503,15 @@ contextual information."
(replace-regexp-in-string
(if (not lit)
(rx-to-string
`(seq (group ,org-latex-line-break-safe "\n")
(1+ (group line-start (0+ space) ,org-latex-line-break-safe "\n"))))
(concat "^[ \t]*" (regexp-quote org-latex-line-break-safe) "$"))
`(seq (group "\\\\\n")
(1+ (group line-start (0+ space) "\\\\\n"))))
"^[ \t]*\\\\$")
(if (not lit)
(if lin "\\\\!\n\n" "\n\n")
"\\vspace*{\\baselineskip}")
(replace-regexp-in-string
"\\([ \t]*\\\\\\\\\\)?[ \t]*\n"
(concat org-latex-line-break-safe "\n")
"\\\\\n"
(if (not lit)
(concat (org-trim contents t) "\n")
contents)
@ -4723,11 +4736,17 @@ log files (as specified by `org-latex-logfiles-extensions') are deleted."
(regexp-opt org-latex-logfiles-extensions))
t)))
(let ((warnings (org-latex--collect-warnings log-buf)))
(message (concat "PDF file produced"
(cond
((eq warnings 'error) " with errors.")
(warnings (concat " with warnings: " warnings))
(t ".")))))))
(funcall
(if warnings
(apply-partially
#'display-warning
'(ox-latex))
#'message)
(concat "PDF file produced"
(cond
((eq warnings 'error) " with errors.")
(warnings (concat " with warnings: " warnings))
(t ".")))))))
(defun org-latex--collect-warnings (buffer)
"Collect some warnings from \"pdflatex\" command output.
@ -4738,7 +4757,11 @@ encountered or nil if there was none."
(save-excursion
(goto-char (point-max))
(when (re-search-backward "^[ \t]*This is .*?TeX.*?Version" nil t)
(if (re-search-forward "^!" nil t) 'error
(if (and
(re-search-forward "^!\\(.+\\)" nil t)
;; This error is passed as missing character warning
(not (string-match-p "Unicode character" (match-string 1))))
'error
(let ((case-fold-search t)
(warnings ""))
(dolist (warning org-latex-known-warnings)

View File

@ -3,7 +3,6 @@
;; Copyright (C) 2012-2024 Free Software Foundation, Inc.
;; Author: Nicolas Goaziou <n.goaziou@gmail.com>
;; Maintainer: Nicolas Goaziou <mail@nicolasgoaziou.fr>
;; Keywords: org, wp, markdown
;; This file is part of GNU Emacs.
@ -152,8 +151,8 @@ headings for its own use."
TREE is the parse tree being exported. BACKEND is the export
backend used. INFO is a plist used as a communication channel.
Enforce a blank line between elements. There are two exceptions
to this rule:
Enforce a blank line between elements. There are exceptions to this
rule:
1. Preserve blank lines between sibling items in a plain list,
@ -161,8 +160,12 @@ to this rule:
paragraph and the next sub-list when the latter ends the
current item.
3. Do not add blank lines after table rows. (This is irrelevant for
md exporter, but may surprise derived backends).
Assume BACKEND is `md'."
(org-element-map tree (remq 'item org-element-all-elements)
(org-element-map tree
(remq 'table-row (remq 'item org-element-all-elements))
(lambda (e)
(org-element-put-property
e :post-blank

View File

@ -4356,15 +4356,15 @@ The list of the form (OUTPUT-FMT-1 OUTPUT-FMT-2 ...)."
(defun org-odt-convert-read-params ()
"Return IN-FILE and OUT-FMT params for `org-odt-do-convert'.
This is a helper routine for interactive use."
(let* ((input (if (featurep 'ido) 'ido-completing-read 'completing-read))
(in-file (read-file-name "File to be converted: "
(let* ((in-file (read-file-name "File to be converted: "
nil buffer-file-name t))
(in-fmt (file-name-extension in-file))
(out-fmt-choices (org-odt-reachable-formats in-fmt))
(out-fmt
(or (and out-fmt-choices
(funcall input "Output format: "
out-fmt-choices nil nil nil))
(completing-read
"Output format: "
out-fmt-choices nil nil nil))
(error
"No known converter or no known output formats for %s files"
in-fmt))))

View File

@ -3,7 +3,6 @@
;; Copyright (C) 2013-2024 Free Software Foundation, Inc.
;; Author: Nicolas Goaziou <n.goaziou@gmail.com>
;; Maintainer: Nicolas Goaziou <mail@nicolasgoaziou.fr>
;; Keywords: org, wp
;; This file is part of GNU Emacs.
@ -54,6 +53,20 @@ setting of `org-html-htmlize-output-type' is `css'."
(const :tag "Don't include external stylesheet link" nil)
(string :tag "URL or local href")))
(defcustom org-org-with-special-rows t
"Non-nil means export special table rows.
Special rows are the rows containing special marking characters, as
described in the Info node `(org)Advanced features'."
:group 'org-export-org
:type 'boolean
:package-version '(Org . "9.7"))
(defcustom org-org-with-cite-processors nil
"Non-nil means use citation processors when exporting citations."
:group 'org-export-org
:type 'boolean
:package-version '(Org . "9.7"))
(org-export-define-backend 'org
'((babel-call . org-org-identity)
(bold . org-org-identity)
@ -75,6 +88,8 @@ setting of `org-html-htmlize-output-type' is `css'."
(inline-src-block . org-org-identity)
(inlinetask . org-org-identity)
(italic . org-org-identity)
(citation . org-org-identity)
(citation-reference . org-org-identity)
(item . org-org-identity)
(keyword . org-org-keyword)
(latex-environment . org-org-identity)
@ -112,7 +127,11 @@ setting of `org-html-htmlize-output-type' is `css'."
(lambda (a s v b)
(if a (org-org-export-to-org t s v b)
(org-open-file (org-org-export-to-org nil s v b)))))))
:filters-alist '((:filter-parse-tree . org-org--add-missing-sections)))
:filters-alist '((:filter-parse-tree . org-org--add-missing-sections))
:options-alist
;; Export special table rows.
'((:with-special-rows nil nil org-org-with-special-rows)
(:with-cite-processors nil nil org-org-with-cite-processors)))
(defun org-org--add-missing-sections (tree _backend _info)
"Ensure each headline has an associated section.

View File

@ -2,7 +2,6 @@
;; Copyright (C) 2006-2024 Free Software Foundation, Inc.
;; Author: David O'Toole <dto@gnu.org>
;; Maintainer: Nicolas Goaziou <mail@nicolasgoaziou.fr>
;; Keywords: hypermedia, outlines, wp
;; This file is part of GNU Emacs.

View File

@ -2,7 +2,6 @@
;; Copyright (C) 2012-2024 Free Software Foundation, Inc.
;; Author: Jonathan Leech-Pepin <jonathan.leechpepin at gmail dot com>
;; Maintainer: Nicolas Goaziou <mail@nicolasgoaziou.fr>
;; Keywords: outlines, hypermedia, calendar, wp
;; This file is part of GNU Emacs.

View File

@ -3,7 +3,7 @@
;; Copyright (C) 2012-2024 Free Software Foundation, Inc.
;; Author: Nicolas Goaziou <mail@nicolasgoaziou.fr>
;; Maintainer: Nicolas Goaziou <mail@nicolasgoaziou.fr>
;; Maintainer: Ihor Radchenko <yantar92 at posteo dot net>
;; Keywords: outlines, hypermedia, calendar, wp
;; This file is part of GNU Emacs.
@ -140,6 +140,7 @@
(:with-properties nil "prop" org-export-with-properties)
(:with-smart-quotes nil "'" org-export-with-smart-quotes)
(:with-special-strings nil "-" org-export-with-special-strings)
(:with-special-rows nil nil nil)
(:with-statistics-cookies nil "stat" org-export-with-statistics-cookies)
(:with-sub-superscript nil "^" org-export-with-sub-superscripts)
(:with-toc nil "toc" org-export-with-toc)
@ -150,6 +151,7 @@
(:with-title nil "title" org-export-with-title)
(:with-todo-keywords nil "todo" org-export-with-todo-keywords)
;; Citations processing.
(:with-cite-processors nil nil org-export-process-citations)
(:cite-export "CITE_EXPORT" nil org-cite-export-processors))
"Alist between export properties and ways to set them.
@ -385,6 +387,14 @@ e.g. \"date:nil\"."
:type 'boolean
:safe #'booleanp)
(defcustom org-export-process-citations t
"Non-nil means process citations using citation processors.
nil will leave citation processing to export backend."
:group 'org-export-general
:type 'boolean
:package-version '(Org . "9.7")
:safe #'booleanp)
(defcustom org-export-date-timestamp-format nil
"Timestamp format string to use for DATE keyword.
@ -1902,7 +1912,9 @@ not exported."
(and (org-export-table-has-special-column-p
(org-element-lineage datum 'table))
(org-export-first-sibling-p datum options)))
(table-row (org-export-table-row-is-special-p datum options))
(table-row
(unless (plist-get options :with-special-rows)
(org-export-table-row-is-special-p datum options)))
(timestamp
;; `:with-timestamps' only applies to isolated timestamps
;; objects, i.e. timestamp objects in a paragraph containing only
@ -3530,6 +3542,9 @@ returned by the function."
(backend &optional subtreep visible-only body-only ext-plist)
"Transcode current Org buffer into BACKEND code.
See info node `(org)Advanced Export Configuration' for the details of
the transcoding process.
BACKEND is either an export backend, as returned by, e.g.,
`org-export-create-backend', or a symbol referring to
a registered backend.
@ -3606,7 +3621,8 @@ Return code as a string."
(if (or (not (functionp template)) body-only) full-body
(funcall template full-body info))))
;; Call citation export finalizer.
(setq output (org-cite-finalize-export output info))
(when (plist-get info :with-cite-processors)
(setq output (org-cite-finalize-export output info)))
;; Remove all text properties since they cannot be
;; retrieved from an external process. Finally call
;; final-output filter and return result.
@ -3676,8 +3692,9 @@ still inferior to file-local settings."
info (org-export-get-environment backend subtreep ext-plist)))
;; Pre-process citations environment, i.e. install
;; bibliography list, and citation processor in INFO.
(org-cite-store-bibliography info)
(org-cite-store-export-processor info)
(when (plist-get info :with-cite-processors)
(org-cite-store-bibliography info)
(org-cite-store-export-processor info))
;; De-activate uninterpreted data from parsed keywords.
(dolist (entry (append (org-export-get-all-options backend)
org-export-options-alist))
@ -3717,8 +3734,9 @@ still inferior to file-local settings."
;; Process citations and bibliography. Replace each citation
;; and "print_bibliography" keyword in the parse tree with
;; the output of the selected citation export processor.
(org-cite-process-citations info)
(org-cite-process-bibliography info)
(when (plist-get info :with-cite-processors)
(org-cite-process-citations info)
(org-cite-process-bibliography info))
;; Install all the feature conditions and implementations.
(org-export-process-features info)
info))

View File

@ -69,13 +69,13 @@ REPRO_ARGS ?=
##----------------------------------------------------------------------
# How to run tests
req-ob-lang = --eval '(require '"'"'ob-$(ob-lang))'
req-ob-lang = --eval '(require `ob-$(ob-lang))'
lst-ob-lang = ($(ob-lang) . t)
req-extra = --eval '(require '"'"'$(req))'
req-extra = --eval '(require `$(req))'
BTEST_RE ?= \\(org\\|ob\\|ox\\)
BTEST_LOAD = \
--eval '(add-to-list '"'"'load-path (concat default-directory "lisp"))' \
--eval '(add-to-list '"'"'load-path (concat default-directory "testing"))'
--eval '(add-to-list `load-path (concat default-directory "lisp"))' \
--eval '(add-to-list `load-path (concat default-directory "testing"))'
BTEST_INIT = $(BTEST_PRE) $(BTEST_LOAD) $(BTEST_POST)
BTEST = $(BATCH) $(BTEST_INIT) \
@ -124,7 +124,7 @@ BATCH = $(EMACSQ) -batch \
# Emacs must be started in toplevel directory
BATCHO = $(BATCH) \
--eval '(add-to-list '"'"'load-path "./lisp")'
--eval '(add-to-list `load-path "./lisp")'
# How to generate local.mk
MAKE_LOCAL_MK = $(BATCHO) \
@ -134,7 +134,7 @@ MAKE_LOCAL_MK = $(BATCHO) \
# Emacs must be started in lisp directory
BATCHL = $(BATCH) \
--eval '(add-to-list '"'"'load-path ".")'
--eval '(add-to-list `load-path ".")'
# How to generate org-loaddefs.el
MAKE_ORG_INSTALL = $(BATCHL) \
@ -156,6 +156,10 @@ ELCDIR = $(BATCHL) \
ELC = $(BATCHL) \
--eval '(batch-byte-compile)'
# How to native-compile a single file
ELN = $(BATCHL) \
--eval '(batch-native-compile)'
# How to make a pdf file from a texinfo file
TEXI2PDF = texi2pdf --batch --clean --expand
@ -199,9 +203,10 @@ SUDO = sudo
INSTALL_INFO = install-info
# target method for 'compile'
ORGCM = dirall
ORGCM = single
# ORGCM = dirall # 1x slowdown compared to default compilation method
# ORGCM = single # 4x one Emacs process per compilation
# ORGCM = native # 4x one Emacs process per native compilation
# ORGCM = source # 5x ditto, but remove compiled file immediately
# ORGCM = slint1 # 3x possibly elicit more warnings
# ORGCM = slint2 # 7x possibly elicit even more warnings

View File

@ -1,5 +1,4 @@
.EXPORT_ALL_VARIABLES:
.NOTPARALLEL: .PHONY
# Additional distribution files
DISTFILES_extra= Makefile etc
@ -27,7 +26,7 @@ ifneq ($(GITSTATUS),)
GITVERSION := $(GITVERSION:.dirty=).dirty
endif
.PHONY: all oldorg update update2 up0 up1 up2 single $(SUBDIRS) \
.PHONY: all oldorg update update2 up0 up1 up2 single native $(SUBDIRS) \
check test install $(INSTSUB) \
info html pdf card refcard doc docs \
autoloads cleanall clean $(CLEANDIRS:%=clean%) \
@ -41,7 +40,7 @@ CONF_BASE = EMACS DESTDIR ORGCM ORG_MAKE_DOC
CONF_DEST = lispdir infodir datadir testdir
CONF_TEST = BTEST_PRE BTEST_POST BTEST_OB_LANGUAGES BTEST_EXTRA BTEST_RE
CONF_EXEC = CP MKDIR RM RMR FIND CHMOD SUDO PDFTEX TEXI2PDF TEXI2HTML MAKEINFO INSTALL_INFO
CONF_CALL = BATCH BATCHL ELC ELCDIR NOBATCH BTEST MAKE_LOCAL_MK MAKE_ORG_INSTALL MAKE_ORG_VERSION
CONF_CALL = BATCH BATCHL ELC ELN ELCDIR NOBATCH BTEST MAKE_LOCAL_MK MAKE_ORG_INSTALL MAKE_ORG_VERSION
config-eol:: EOL = \#
config-eol:: config-all
config config-all::
@ -67,13 +66,16 @@ config config-test config-exe config-all config-version::
@echo ""
oldorg: compile info # what the old makefile did when no target was specified
uncompiled: cleanlisp autoloads # for developing
uncompiled: | cleanlisp autoloads # for developing
refcard: card
update update2:: up0 all
update update2:: | up0 all
single: ORGCM=single
single: compile
native: ORGCM=native
native: compile
.PRECIOUS: local.mk
local.mk:
$(info ======================================================)
@ -126,7 +128,7 @@ $(INSTSUB):
autoloads: lisp
$(MAKE) -C $< $@
repro: cleanall autoloads
repro: | cleanall autoloads
-@$(REPRO) &
cleandirs:

View File

@ -0,0 +1,321 @@
;;; test-duplicates-detector.el --- Tests for finding duplicates in Org tests -*- lexical-binding: t; -*-
;; Copyright (C) 2023 Ilya Chernyshov
;; Authors: Ilya Chernyshov <ichernyshovvv@gmail.com>
;; This file is not part of GNU Emacs.
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
;;
;;; Commentary:
;; Unit tests that check for duplicate forms and tests in all Org test files.
;; Forms are considered duplicate if they:
;; 1. are `equal-including-properties',
;; 2. have the same nesting path,
;; 3. either are `should-' macros or have `should-' macros inside.
;; To ignore a form or a group of forms, wrap them in
;; `org-test-ignore-duplicate'.
;; `ert-deftest' are considered duplicate if their body are
;; `equal-including-properties.' When comparing, the docstrings are not taken
;; into account.
;;; Code:
(require 'org-test "../testing/org-test")
;;;; Variables
(defvar test-duplicates-progn-forms
'( progn prog1 let dolist dotimes
org-test-with-temp-text
org-test-with-temp-text-in-file
org-test-at-id
org-test-ignore-duplicate)
"List of forms equivalent to `progn'.
Immediate children inside these are not checked for duplicates.")
(defvar test-duplicates-detector-file-path
(expand-file-name "test-duplicates-detector.el"
(expand-file-name "lisp" org-test-dir)))
(defvar test-duplicates-detector-files
(remove
test-duplicates-detector-file-path
(directory-files
(expand-file-name "lisp" org-test-dir) t "\\.el$")))
(defvar test-duplicates-detector-duplicate-forms nil
"A list where each element is either:
((file test-name [(form-1 . numerical-order)
(form-2 . numerical-order) ...])
(dup-form-1 . (numerical-order [numerical-order ...]))
[ (dup-form-2 . (numerical-order [numerical-order ...]))
(dup-form-3 . (numerical-order [numerical-order ...]))
...])
or
(test-1-symbol . duplicate-of-test-1-symbol)
Where
(file test-name [(form-1 . numerical-order)
(form-2 . numerical-order) ...])
is a path to duplicates. For example, the path for the
duplicates in the following test:
test-file.el
(ertdeftest test-name ()
\"Docstring.\"
(let ((var-1 \"value\"))
(when var-1
(should-not
(equal 2 (some-func \"string\" \"x\" nil)))
(some-func \"string\" \"x=2\")
(should-not
(equal 2 (some-func \"string\" \"x\" nil)))
(some-func \"string\" \"x=2\"))))
would look like this:
(\"/absolute/path/to/test-file.el\"
test-name
(let . 4) (when . 2))
And the records about the duplicates would look like this:
((should-not
(equal 2 (some-func \"string\" \"x\" nil))) 4 2)")
(defvar test-duplicates-detector-forms nil
"Nested alist of found forms and paths to them (not filtered).")
;;;; Macros
(defmacro org-test-ignore-duplicate (&rest body)
"Eval BODY forms sequentially and return value of last one.
The macro's body will be ignored by `test-duplicates-detector.el'
tests to skip duplicate forms inside the body."
(declare (indent 0))
`(progn ,@body))
;;;; ERT tests
(ert-deftest test-org-tests/find-duplicates ()
"Try to find duplicate forms and ert-deftests in FILES."
(should-not
(test-duplicates-detector--find-duplicates
test-duplicates-detector-files)))
;;;; Auxiliary functions
(defun test-duplicates-detector--find-duplicates (files)
"Try to find duplicate forms and ert-deftests in FILES.
Duplicate forms will be written to
`test-duplicates-detector-duplicate-forms'.
`message' paths to them in a human-readable format."
(setq test-duplicates-detector-forms nil)
(let (found-deftests duplicate-tests)
(dolist (file files)
(with-current-buffer (find-file-noselect file)
(save-excursion
(goto-char (point-min))
(while (search-forward "(ert-deftest" nil t)
(goto-char (match-beginning 0))
(let (deftest test-name)
(ignore-errors
(while (setq deftest (read (current-buffer)))
(setq test-name (cadr deftest))
(when (eq (car deftest) 'ert-deftest)
(if-let ((f (seq-find
(lambda (x)
(equal-including-properties
;; if cadddr is a docstring
(if (stringp (cadddr deftest))
(cddddr deftest)
(cdddr deftest))
(if (stringp (cadddr x))
(cddddr x)
(cdddr x))))
found-deftests)))
(push (cons test-name (cadr f)) duplicate-tests)
(push deftest found-deftests)
(test-duplicates-detector--search-forms-recursively
deftest (list file test-name)))))))))))
(setq test-duplicates-detector-duplicate-forms
(seq-filter
#'cdr
(mapcar
(lambda (file)
(cons
(car file)
(seq-filter
(lambda (x)
(and (caddr x)
(seq-intersection
'(should-not should should-error)
(flatten-list (car x)))))
(cdr file))))
test-duplicates-detector-forms)))
(when test-duplicates-detector-duplicate-forms
(message
"Found duplicates (To ignore the duplicate forms,
wrap them in `org-test-ignore-duplicate'):
%s"
(mapconcat
(lambda (path)
(let* ((file (file-relative-name (caar path)))
(test-name (symbol-name (cadar path)))
(string-path (append (list file test-name)
(mapcar (lambda (x)
(symbol-name (car x)))
(cddar path))))
(indent -1)
(print-level 3))
(concat
(mapconcat
(lambda (x)
(concat (make-string (* (setq indent (1+ indent)) 2) ? )
x "\n"))
string-path
"")
(mapconcat
(lambda (x)
(format "%s%S: %d times\n"
(make-string (* indent 2) ? )
(car x)
(length (cdr x))))
(cdr path)
""))))
test-duplicates-detector-duplicate-forms
"")))
(when duplicate-tests
(message "Duplicate ERT tests found:\n%s\n"
(mapconcat (lambda (x) (format "%S" x))
duplicate-tests "\n")))
(append test-duplicates-detector-duplicate-forms
duplicate-tests)))
(defun test-duplicates-detector--search-forms-recursively (form form-path)
"Search for forms recursively in FORM.
FORM-PATH is list of the form:
(\"file-path\" ert-test-symbol
(symbol-1 . sexp-order-1) (symbol-2 . sexp-order-2))
Write each form to `test-duplicates-detector-forms'"
(let ((idx 0))
(dolist (sub-form form)
(when (consp sub-form)
(unless (memq (car-safe form) test-duplicates-progn-forms)
(push idx (alist-get
sub-form
(alist-get form-path test-duplicates-detector-forms
nil nil #'equal)
nil nil #'equal-including-properties)))
(unless (memq (car sub-form)
'(should-not should should-error))
(test-duplicates-detector--search-forms-recursively
sub-form
(append form-path (list (cons (car sub-form) idx))))))
(cl-incf idx))))
;;;; Testing the detector itself
(ert-deftest test-org-tests/test-duplicates-detector-testing-find-duplicates ()
"Test `test-duplicates-detector--find-duplicates'."
(should
(equal
(test-duplicates-detector--find-duplicates
(list test-duplicates-detector-file-path))
`(((,test-duplicates-detector-file-path
test-org-tests/test-with-nested-duplicates)
((let ((var "string")) (should (message "123 %s" var))) 6 4))
((,test-duplicates-detector-file-path
test-org-tests/test-with-duplicates-at-root)
((should (message "123")) 6 4))
(test-org-tests/duplicate-test-2 . test-org-tests/duplicate-test-1)))))
;;;;; Tests with duplicate forms
(ert-deftest test-org-tests/test-with-duplicates-at-root ()
"Test with duplicates at the root."
(should (message "123"))
(format "%s" "string")
(should
(message "123")))
(ert-deftest test-org-tests/test-with-nested-duplicates ()
"Test with nested duplicates."
(let ((var "string"))
(should
(message "123 %s" var)))
(format "%s" "string")
(let ((var "string"))
(should (message "123 %s" var)))
(format "%s" "string"))
;;;;; Tests without duplicates
(ert-deftest test-org-tests/test-without-duplicates-1 ()
"Test without duplicates."
(let ((var-1 "asd"))
(concat "string" var-1))
(should
(let ((var-1 "asd"))
(concat "string" var-1))))
(ert-deftest test-org-tests/test-without-duplicates-2 ()
"Test without duplicates.
Equal `should' macros, but different nesting paths."
(let ((var "string"))
(should (format "123 %s" "asd")))
(+ 5 6 9)
(should (format "123 %s" "asd")))
;;;;; Duplicate deftests (maybe different names, but same body)
(ert-deftest test-org-tests/duplicate-test-1 ()
"Docstring of duplicate-test-1."
(let ((var 99))
(+ 5 6 9 var)
(should (format "123 %s" "asd")))
(should (format "123 %s" "asd")))
(ert-deftest test-org-tests/duplicate-test-2 ()
"Docstring of duplicate-test-2."
(let ((var 99))
(+ 5 6 9 var)
(should (format "123 %s" "asd")))
(should (format "123 %s" "asd")))
(provide 'test-duplicates-detector)
;; Local Variables:
;; outline-regexp: "\\(;\\{3,\\} \\)"
;; End:
;;; test-duplicates-detector.el ends here

View File

@ -117,8 +117,6 @@ main
(ert-deftest ob-haskell/session-named-none-means-one-shot-sessions ()
"When no session, use a new session.
\"none\" is a special name that means `no session'."
(test-ob-haskell-ghci ":session none" "x=2" nil)
(should-not (equal 2 (test-ob-haskell-ghci ":session \"none\"" "x" nil)))
(test-ob-haskell-ghci ":session none" "x=2" nil)
(should-not (equal 2 (test-ob-haskell-ghci ":session \"none\"" "x" nil))))

View File

@ -590,6 +590,63 @@ DEADLINE: " (cdr timestamp))))
(org-agenda nil "f")
(buffer-string))))))))))))
(ert-deftest test-org-agenda/skip-scheduled-repeats-after-deadline ()
"Test `org-agenda-skip-scheduled-repeats-after-deadline'."
(cl-assert (not org-agenda-sticky) nil "precondition violation")
(cl-assert (not (org-test-agenda--agenda-buffers))
nil "precondition violation")
(dolist (org-agenda-skip-scheduled-repeats-after-deadline '(nil t))
(org-test-at-time "2024-01-01 8:00"
(org-test-with-temp-text-in-file "
* TODO Do me every day before Jan, 12th (included)
SCHEDULED: <2024-01-03 Wed +1d> DEADLINE: <2024-01-05 Fri>
"
(let ((org-agenda-span 'week)
(org-agenda-files `(,(buffer-file-name))))
;; NOTE: Be aware that `org-agenda-list' may or may not display
;; past scheduled items depending whether the date is today
;; `org-today' or not.
(org-agenda-list nil "<2024-01-01 Mon>")
(set-buffer org-agenda-buffer-name)
(if org-agenda-skip-scheduled-repeats-after-deadline
(should
;; Not displayed after deadline.
(string-match-p
"Week-agenda (W01):
Monday 1 January 2024 W01
[^:]+:In 4 d.: TODO Do me every day before Jan, 12th (included)
Tuesday 2 January 2024
Wednesday 3 January 2024
[^:]+:Scheduled: TODO Do me every day before Jan, 12th (included)
Thursday 4 January 2024
[^:]+:Scheduled: TODO Do me every day before Jan, 12th (included)
Friday 5 January 2024
[^:]+:Scheduled: TODO Do me every day before Jan, 12th (included)
[^:]+:Deadline: TODO Do me every day before Jan, 12th (included)
Saturday 6 January 2024
Sunday 7 January 2024"
(buffer-string)))
(should
;; Displayed after deadline.
(string-match-p
"Week-agenda (W01):
Monday 1 January 2024 W01
[^:]+:In 4 d.: TODO Do me every day before Jan, 12th (included)
Tuesday 2 January 2024
Wednesday 3 January 2024
[^:]+:Scheduled: TODO Do me every day before Jan, 12th (included)
Thursday 4 January 2024
[^:]+:Scheduled: TODO Do me every day before Jan, 12th (included)
Friday 5 January 2024
[^:]+:Scheduled: TODO Do me every day before Jan, 12th (included)
[^:]+:Deadline: TODO Do me every day before Jan, 12th (included)
Saturday 6 January 2024
[^:]+:Scheduled: TODO Do me every day before Jan, 12th (included)
Sunday 7 January 2024
[^:]+:Scheduled: TODO Do me every day before Jan, 12th (included)"
(buffer-string))))))
(org-test-agenda--kill-all-agendas))))
(ert-deftest test-org-agenda/goto-date ()
"Test `org-agenda-goto-date'."
(unwind-protect

View File

@ -2629,30 +2629,34 @@ e^{i\\pi}+1=0
(org-element-map (org-element-parse-buffer) 'paragraph 'identity)))
;; Include incomplete-drawers.
(should
(org-test-with-temp-text ":TEST:\nParagraph"
(org-test-with-temp-text "<point>:TEST:\nParagraph"
(let ((elem (org-element-at-point)))
(and (eq (org-element-type elem) 'paragraph)
(= (point-max) (org-element-property :end elem))))))
(should
(org-test-with-temp-text "<point>foo\n:end:\nbar"
(let ((elem (org-element-at-point)))
(and (eq (org-element-type elem) 'paragraph)
(= (point-max) (org-element-property :end elem))))))
;; Include incomplete blocks.
(should
(org-test-with-temp-text "#+BEGIN_CENTER\nParagraph"
(org-test-with-temp-text "<point>#+BEGIN_CENTER\nParagraph"
(let ((elem (org-element-at-point)))
(and (eq (org-element-type elem) 'paragraph)
(= (point-max) (org-element-property :end elem))))))
;; Include incomplete dynamic blocks.
(should
(org-test-with-temp-text "#+BEGIN: \n<point>Paragraph"
(org-test-with-temp-text "<point>foo\n#+END_CENTER\nbar"
(let ((elem (org-element-at-point)))
(and (eq (org-element-type elem) 'paragraph)
(= (point-max) (org-element-property :end elem))))))
;; Include incomplete latex environments.
(should
(org-test-with-temp-text "\begin{equation}\nParagraph"
(org-test-with-temp-text "<point>\begin{equation}\nParagraph"
(let ((elem (org-element-at-point)))
(and (eq (org-element-type elem) 'paragraph)
(= (point-max) (org-element-property :end elem))))))
(should
(org-test-with-temp-text "Paragraph\n\begin{equation}"
(org-test-with-temp-text "<point>Paragraph\n\begin{equation}"
(let ((elem (org-element-at-point)))
(and (eq (org-element-type elem) 'paragraph)
(= (point-max) (org-element-property :end elem))))))

View File

@ -418,7 +418,8 @@ Contents
*** <point>c"
(org-set-visibility-according-to-property)
(not (invisible-p (point)))))
;; When VISIBILITY properties are nested, ignore inner ones.
;; When VISIBILITY properties are nested, do not alter parent
;; visibility unless necessary.
(should
(org-test-with-temp-text
"
@ -431,7 +432,20 @@ Contents
:VISIBILITY: folded
:END:"
(org-set-visibility-according-to-property)
(invisible-p (point)))))
(invisible-p (point))))
(should
(org-test-with-temp-text
"
* A
:PROPERTIES:
:VISIBILITY: folded
:END:
** <point>B
:PROPERTIES:
:VISIBILITY: content
:END:"
(org-set-visibility-according-to-property)
(not (invisible-p (point))))))
(ert-deftest test-org-fold/visibility-show-branches ()
"Test visibility of inline archived subtrees."
@ -680,6 +694,7 @@ Unfolded Paragraph.
(ert-deftest test-org-fold/org-fold-display-inline-images ()
"Test inline images displaying when cycling."
(skip-unless (not noninteractive))
(let* ((org-cycle-inline-images-display t)
(images-dir (expand-file-name "examples/images/" org-test-dir))
(org-logo-image (expand-file-name "Org mode logo mono-color.png" images-dir)))
@ -701,11 +716,18 @@ Unfolded Paragraph.
(org-show-subtree)
(org-fold-subtree t)
(run-hook-with-args 'org-cycle-hook 'folded)
(should (null org-inline-image-overlays))
(should (null (overlays-in (point-min) (point-max))))
(org-show-subtree)
(should-not org-inline-image-overlays)
(should-not (overlays-in (point-min) (point-max))))))
(should-not
(cl-every
(lambda (ov) (overlay-get ov 'org-image-overlay))
(overlays-in (point-min) (point-max))))
(org-show-subtree)
(run-hook-with-args 'org-cycle-hook 'subtree)
(should org-inline-image-overlays)
(should
(cl-every
(lambda (ov) (overlay-get ov 'org-image-overlay))
(overlays-in (point-min) (point-max)))))))
(provide 'test-org-fold)

View File

@ -21,6 +21,18 @@
(require 'org-footnote)
(ert-deftest test-org-footnote/new-anon ()
"Test `org-footnote-new' specifications."
;; `org-footnote-auto-label' is `anonymous'.
(should
(string-match-p
"Test\\[fn::\\]"
(org-test-with-temp-text "Test<point>"
(let ((org-footnote-auto-label 'anonymous)
(org-footnote-section nil))
(org-footnote-new))
(buffer-string)))))
(ert-deftest test-org-footnote/new ()
"Test `org-footnote-new' specifications."
;; `org-footnote-auto-label' is t.

View File

@ -1633,11 +1633,11 @@ See also `test-org-table/copy-field'."
(ert-deftest test-org-table/to-latex ()
"Test `orgtbl-to-latex' specifications."
(should
(equal "\\begin{tabular}{l}\na\\\\[0pt]\n\\end{tabular}"
(equal "\\begin{tabular}{l}\na\\\\\n\\end{tabular}"
(orgtbl-to-latex (org-table-to-lisp "| a |") nil)))
;; Test :environment parameter.
(should
(equal "\\begin{tabularx}{l}\na\\\\[0pt]\n\\end{tabularx}"
(equal "\\begin{tabularx}{l}\na\\\\\n\\end{tabularx}"
(orgtbl-to-latex (org-table-to-lisp "| a |")
'(:environment "tabularx"))))
;; Test :booktabs parameter.
@ -1646,7 +1646,7 @@ See also `test-org-table/copy-field'."
"\\toprule" (orgtbl-to-latex (org-table-to-lisp "| a |") '(:booktabs t))))
;; Handle LaTeX snippets.
(should
(equal "\\begin{tabular}{l}\n\\(x\\)\\\\[0pt]\n\\end{tabular}"
(equal "\\begin{tabular}{l}\n\\(x\\)\\\\\n\\end{tabular}"
(orgtbl-to-latex (org-table-to-lisp "| $x$ |") nil)))
;; Test pseudo objects and :raw parameter.
(should

View File

@ -2855,7 +2855,7 @@ test <point>
(should (org-find-olp '("Headline" "headline8") t))))
(ert-deftest test-org/map-entries ()
"Test `org-map-entries' specifications."
"Test `org-map-entries' and `org-element-cache-map' specifications."
(dolist (org-element-use-cache '(t nil))
;; Full match.
(should
@ -3097,7 +3097,16 @@ Lets stop here
(lambda ()
(delete-region (point) (line-beginning-position 2))
(setq org-map-continue-from (point))))
(buffer-string))))))
(buffer-string))))
;; :next-re in `org-element-cache-map'
(org-test-with-temp-text
"* one
* TODO two
* three
* four
"
(should (equal '("two")
(org-element-cache-map (lambda (el) (org-element-property :title el)) :next-re "TODO"))))))
(ert-deftest test-org/edit-headline ()
"Test `org-edit-headline' specifications."
@ -3309,7 +3318,7 @@ Lets stop here
(list org-priority-highest org-priority-lowest org-priority-default))))
;; STARTUP keyword.
(should
(equal '(t t)
(equal '(fold t)
(org-test-with-temp-text "#+STARTUP: fold odd"
(org-mode-restart)
(list org-startup-folded org-odd-levels-only))))
@ -3982,8 +3991,9 @@ SCHEDULED: <2017-05-06 Sat>
(org-file-contents "http://some-valid-url"))
(kill-buffer buffer))))))
;; Throw error when trying to access an invalid URL.
(should-error
(let ((buffer (generate-new-buffer "url-retrieve-output")))
(should-not
(let ((buffer (generate-new-buffer "url-retrieve-output"))
(org-resource-download-policy t))
(unwind-protect
;; Simulate unsuccessful retrieval of a URL.
(cl-letf (((symbol-function 'url-retrieve-synchronously)
@ -3991,11 +4001,12 @@ SCHEDULED: <2017-05-06 Sat>
(with-current-buffer buffer
(insert "HTTP/1.1 404 Not found\n\ndoes not matter"))
buffer)))
(org-file-contents "http://this-url-must-not-exist"))
(org-file-contents "http://this-url-must-not-exist" 'noerror))
(kill-buffer buffer))))
;; Try to access an invalid URL, but do not throw an error.
(should-error
(let ((buffer (generate-new-buffer "url-retrieve-output")))
(let ((buffer (generate-new-buffer "url-retrieve-output"))
(org-resource-download-policy t))
(unwind-protect
;; Simulate unsuccessful retrieval of a URL.
(cl-letf (((symbol-function 'url-retrieve-synchronously)
@ -4006,7 +4017,8 @@ SCHEDULED: <2017-05-06 Sat>
(org-file-contents "http://this-url-must-not-exist"))
(kill-buffer buffer))))
(should
(let ((buffer (generate-new-buffer "url-retrieve-output")))
(let ((buffer (generate-new-buffer "url-retrieve-output"))
(org-resource-download-policy t))
(unwind-protect
;; Simulate unsuccessful retrieval of a URL.
(cl-letf (((symbol-function 'url-retrieve-synchronously)

View File

@ -29,6 +29,29 @@
(ert-deftest text-ox-latex/protect-square-brackets ()
"Test [foo] being interpreted as plain text even after LaTeX commands."
(org-test-with-exported-text
'latex
"* This is test
lorem @@latex:\\pagebreak@@ [ipsum]
#+begin_figure
[lorem] figure
#+end_figure
| [foo] | 2 |
| [bar] | 3 |
- [bax]
- [aur]
"
(goto-char (point-min))
(should (search-forward "lorem \\pagebreak {[}ipsum]"))
(should (search-forward "{[}lorem] figure"))
(should (search-forward "{[}foo]"))
(should (search-forward "\\item {[}bax]"))))
(ert-deftest test-ox-latex/verse ()
"Test verse blocks."
(org-test-with-exported-text
@ -48,14 +71,14 @@ lorem ipsum dolor
(should
(search-forward
"\\begin{verse}
lorem ipsum dolor\\\\[0pt]
lorem ipsum dolor\\\\
lorem ipsum dolor
lorem ipsum dolor\\\\[0pt]
lorem ipsum dolor\\\\
lorem ipsum dolor
lorem ipsum dolor\\\\[0pt]
lorem ipsum dolor\\\\[0pt]
lorem ipsum dolor\\\\
lorem ipsum dolor\\\\
\\end{verse}"))))
(ert-deftest test-ox-latex/longtable ()
@ -75,15 +98,15 @@ lorem ipsum dolor\\\\[0pt]
(should
(search-forward
"\\begin{longtable}{lr}
First & Second\\\\[0pt]
Column & Column\\\\[0pt]
First & Second\\\\
Column & Column\\\\
\\hline
\\endfirsthead"))
(goto-char (point-min))
(should
(search-forward
"First & Second\\\\[0pt]
Column & Column \\\\[0pt]
"First & Second\\\\
Column & Column \\\\
\\hline
\\endhead"))