Compare commits

..

227 Commits

Author SHA1 Message Date
TEC a6451f10fd
---END PERSONAL NOPUSH DIVIDER---
--
2.42.0
2024-01-30 13:49:43 +08:00
TEC d564f2ed17
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-01-30 13:49:43 +08:00
TEC 0ee106cd10
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-01-30 13:49:43 +08:00
TEC 0b25451f29
---NOPUSH PERSONAL DIVIDER---
--
2.42.0
2024-01-30 13:49:43 +08:00
TEC b282700bb5
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-01-30 13:49:43 +08:00
TEC f57913dd24
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-01-30 13:49:43 +08:00
TEC afb95b911d
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-01-30 13:49:43 +08:00
TEC 912d7d21cb
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-01-30 13:49:43 +08:00
TEC 7a4afe164d
org-latex-preview: Tweak to be rebased later
* lisp/org-latex-preview.el (org-latex-preview--cache-image):
2024-01-30 13:49:43 +08:00
Karthik Chikmagalur 76a24ffe8d
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-01-30 13:49:43 +08:00
TEC a0c549ac07
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-01-30 13:49:43 +08:00
TEC 4c17eeaafc
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-01-30 13:49:43 +08:00
TEC 6e45ddd6c2
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-01-30 13:49:43 +08:00
TEC cbe742ff38
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-01-30 13:49:43 +08:00
Karthik Chikmagalur fe8e735884
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-01-30 13:49:43 +08:00
TEC 18112f6843
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-01-30 13:49:43 +08:00
TEC 2420a40d0d
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-01-30 13:49:43 +08:00
TEC 7e619fc006
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-01-30 13:49:43 +08:00
TEC 00aa7db260
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-01-30 13:49:42 +08:00
TEC 2ed373ead6
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-01-30 13:49:42 +08:00
TEC f3874648ec
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-01-30 13:49:42 +08:00
TEC 0f5147865c
org: Introduce semantic seperator fontification
* lisp/org.el (org-fontify-semantic-seperator,
org-set-font-lock-defaults): TODO
2024-01-30 13:49:42 +08:00
TEC 69b4ce7c38
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-01-30 13:49:42 +08:00
TEC caabbf0b4f
---PATCH SET DIVIDER---
--
2.42.0
2024-01-30 13:49:42 +08:00
TEC 702a90d461
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-01-30 13:49:42 +08:00
Karthik Chikmagalur dcf99158a7
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-01-30 13:49:42 +08:00
Karthik Chikmagalur a1e7d0b532
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-01-30 13:49:42 +08:00
Karthik Chikmagalur e0cb43756a
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-01-30 13:49:42 +08:00
TEC f801251b6a
---LIVE PREVIEW DIVIDER--- 2024-01-30 13:49:42 +08:00
TEC 1e9116daa1
org-latex-preview: Update copyright years 2024-01-30 13:49:42 +08:00
TEC 13ae0b499f
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-01-30 13:49:42 +08:00
Karthik Chikmagalur 2e50ea9143
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-01-30 13:49:42 +08:00
TEC f4be85a80c
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-01-30 13:49:42 +08:00
TEC 6d926e34e1
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-01-30 13:49:42 +08:00
TEC d2662ce816
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-01-30 13:49:42 +08:00
TEC 3d20460c20
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-01-30 13:49:42 +08:00
TEC cbad8bde44
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-01-30 13:49:42 +08:00
TEC 6b8385164a
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-01-30 13:49:42 +08:00
TEC 23b338f9be
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-01-30 13:49:42 +08:00
TEC 3cffef76cb
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-01-30 13:49:42 +08:00
TEC fb607bc874
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-01-30 13:49:42 +08:00
TEC bbe8d4d604
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-01-30 13:49:42 +08:00
TEC a02c34c29f
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-01-30 13:49:42 +08:00
Karthik Chikmagalur 00c2ee0a69
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-01-30 13:49:42 +08:00
Karthik Chikmagalur 99689a57b3
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-01-30 13:49:42 +08:00
Karthik Chikmagalur 93b3eba23e
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-01-30 13:49:42 +08:00
Karthik Chikmagalur dfc2b3f124
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-01-30 13:49:42 +08:00
Karthik Chikmagalur d3995ea07d
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-01-30 13:49:42 +08:00
Karthik Chikmagalur ce20f0a483
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-01-30 13:49:42 +08:00
Karthik Chikmagalur 346d1885f6
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-01-30 13:49:42 +08:00
Karthik Chikmagalur e2fcea2c19
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-01-30 13:49:42 +08:00
Karthik Chikmagalur 99f142355a
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-01-30 13:49:42 +08:00
Karthik Chikmagalur 03cbd00c63
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-01-30 13:49:42 +08:00
Karthik Chikmagalur a49fd1e759
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-01-30 13:49:42 +08:00
Karthik Chikmagalur 91b0db1ef2
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-01-30 13:49:42 +08:00
Karthik Chikmagalur 3e648d95b6
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-01-30 13:49:42 +08:00
Karthik Chikmagalur 0f2943b10e
org-latex-preview: Option to fine-tune preview opening
* lisp/org-latex-preview.el (org-latex-preview-auto-blacklist,
org-latex-preview-auto--open-this-overlay): 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-01-30 13:49:42 +08:00
Karthik Chikmagalur 45fa70ad69
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-01-30 13:49:42 +08:00
Karthik Chikmagalur d16eeda85e
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-01-30 13:49:42 +08:00
Karthik Chikmagalur 47e0bb0bea
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-01-30 13:49:42 +08:00
Karthik Chikmagalur 73d4f7bbe8
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-01-30 13:49:42 +08:00
Karthik Chikmagalur 97cc8bf881
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-01-30 13:49:42 +08:00
Karthik Chikmagalur 34a6ffc897
Update ORG-NEWS
* etc/ORG-NEWS: Add summary of `org-latex-preview' changes.
2024-01-30 13:49:42 +08:00
Karthik Chikmagalur c9cd1569e1
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-01-30 13:49:42 +08:00
TEC ea5ca70312
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-01-30 13:49:42 +08:00
TEC 0dffd0af9b
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-01-30 13:49:42 +08:00
TEC d431174ebf
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-01-30 13:49:42 +08:00
TEC 942328c197
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-01-30 13:49:42 +08:00
TEC c854ad9db2
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-01-30 13:49:42 +08:00
TEC 058f82fb87
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-01-30 13:49:42 +08:00
TEC b40a4b381d
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-01-30 13:49:42 +08:00
TEC 0732c64705
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-01-30 13:49:42 +08:00
TEC dbc403ad7b
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-01-30 13:49:42 +08:00
TEC 18a5b5fc80
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-01-30 13:49:42 +08:00
TEC c77e17d72a
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-01-30 13:49:42 +08:00
TEC 14282746be
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-01-30 13:49:42 +08:00
Karthik Chikmagalur 0ea2c5bc9b
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-01-30 13:49:42 +08:00
TEC 8bda5692ea
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-01-30 13:49:42 +08:00
TEC a049271167
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-01-30 13:49:42 +08:00
TEC ac31c2b785
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-01-30 13:49:42 +08:00
TEC 801399fd8b
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-01-30 13:49:42 +08:00
TEC 186e07645d
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-01-30 13:49:42 +08:00
TEC 665f6d9bf9
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-01-30 13:49:42 +08:00
TEC e51ef5a772
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-01-30 13:49:42 +08:00
TEC 48fba2831a
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-01-30 13:49:42 +08:00
TEC 9d3880915e
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-01-30 13:49:42 +08:00
TEC 0dd8a751cc
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-01-30 13:49:42 +08:00
Karthik Chikmagalur 6d5e980de5
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-01-30 13:49:42 +08:00
TEC 0b794cf836
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-01-30 13:49:42 +08:00
TEC 1f540d1345
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-01-30 13:49:42 +08:00
TEC dec99fe96b
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-01-30 13:49:42 +08:00
TEC ad5cd0e31c
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-01-30 13:49:42 +08:00
TEC ed6bcc0708
org-latex-preview: org-latex-conditional-features
* lisp/org-latex-preview.el (org-latex-preview--get-preamble):
2024-01-30 13:49:42 +08:00
Karthik Chikmagalur 9017b2eedd
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-01-30 13:49:42 +08:00
TEC 9eda71e2fe
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-01-30 13:49:42 +08:00
TEC 2c5a51b1a8
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-01-30 13:49:42 +08:00
Karthik Chikmagalur e71d4a8fb9
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-01-30 13:49:42 +08:00
TEC bab8a67f7e
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-01-30 13:49:42 +08:00
Karthik Chikmagalur 16d898bd1e
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-01-30 13:49:42 +08:00
TEC baec52ef9e
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-01-30 13:49:42 +08:00
TEC 663da1e185
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-01-30 13:49:42 +08:00
Karthik Chikmagalur f5175458d9
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-01-30 13:49:42 +08:00
Karthik Chikmagalur 60dc0aec2a
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-01-30 13:49:42 +08:00
Karthik Chikmagalur 4196c69bc0
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-01-30 13:49:42 +08:00
TEC 9988a9edd5
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-01-30 13:49:41 +08:00
TEC 41dc4ebc9b
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-01-30 13:49:41 +08:00
TEC 6ba1a63b86
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-01-30 13:49:41 +08:00
TEC c1842966e2
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-01-30 13:49:41 +08:00
Karthik Chikmagalur 3d2f045d51
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-01-30 13:49:41 +08:00
Karthik Chikmagalur 670ea09100
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-01-30 13:49:41 +08:00
Karthik Chikmagalur af39210b45
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-01-30 13:49:41 +08:00
Karthik Chikmagalur 0af0d672f8
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-01-30 13:49:41 +08:00
TEC 889db46200
org-persist: Add situational write inhibition
* lisp/org-persist.el (org-persist-write, org-persist--inhibit-write): TODO
2024-01-30 13:49:41 +08:00
Karthik Chikmagalur 535c8f32fb
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-01-30 13:49:41 +08:00
Karthik Chikmagalur 2a8cd44894
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-01-30 13:49:41 +08:00
TEC c6496966ec
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-01-30 13:49:41 +08:00
TEC 07efd246fb
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-01-30 13:49:41 +08:00
Karthik Chikmagalur a0951ba07c
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-01-30 13:49:41 +08:00
TEC 8adb7d9781
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-01-30 13:49:41 +08:00
TEC 72942cbc71
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-01-30 13:49:41 +08:00
TEC 877ee3985a
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-01-30 13:49:41 +08:00
TEC e524949263
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-01-30 13:49:41 +08:00
TEC 079b27e880
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-01-30 13:49:41 +08:00
Karthik Chikmagalur a27b15f6c7
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-01-30 13:49:41 +08:00
TEC 854bd51317
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-01-30 13:49:41 +08:00
TEC 9ec7a8f80d
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-01-30 13:49:41 +08:00
Karthik Chikmagalur 5c5dd92b12
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-01-30 13:49:41 +08:00
Karthik Chikmagalur 892e91f9d9
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-01-30 13:49:41 +08:00
TEC aedf687e31
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-01-30 13:49:41 +08:00
TEC 75b0b72ed3
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-01-30 13:49:41 +08:00
Karthik Chikmagalur 374956b359
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-01-30 13:49:41 +08:00
Karthik Chikmagalur 06a3bc4c64
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-01-30 13:49:41 +08:00
Karthik Chikmagalur 89ead6da97
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-01-30 13:49:41 +08:00
Karthik Chikmagalur 33b59ad218
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-01-30 13:49:41 +08:00
TEC 48c1fa8692
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-01-30 13:49:41 +08:00
Karthik Chikmagalur 22e0871f08
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-01-30 13:49:41 +08:00
TEC c446865160
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-01-30 13:49:41 +08:00
TEC 1afe0c1938
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-01-30 13:49:41 +08:00
TEC e2c44f75ff
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-01-30 13:49:41 +08:00
TEC dc7f691275
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-01-30 13:49:41 +08:00
TEC 46607c8f0c
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-01-30 13:49:41 +08:00
TEC 309f43757d
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-01-30 13:49:41 +08:00
TEC 437bb14318
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-01-30 13:49:41 +08:00
TEC 571d481b78
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-01-30 13:49:41 +08:00
TEC 9129ce9451
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-01-30 13:49:41 +08:00
TEC 1ba95da6fb
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-01-30 13:49:41 +08:00
Karthik Chikmagalur 4fbc83d312
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-01-30 13:49:41 +08:00
Karthik Chikmagalur fdfb13393c
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-01-30 13:49:41 +08:00
Karthik Chikmagalur f570be9d3f
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-01-30 13:49:41 +08:00
TEC fd6091ecef
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-01-30 13:49:41 +08:00
Karthik Chikmagalur 945ac194f0
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-01-30 13:49:41 +08:00
TEC c25fc98fb4
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-01-30 13:49:41 +08:00
TEC ec028e3620
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-01-30 13:49:41 +08:00
TEC 9369fec755
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-01-30 13:49:41 +08:00
TEC ed8f8eaab4
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-01-30 13:49:41 +08:00
TEC c899071c12
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-01-30 13:49:41 +08:00
Karthik Chikmagalur c4ab98d0fb
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-01-30 13:49:41 +08:00
Karthik Chikmagalur 0a5655f4c3
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-01-30 13:49:41 +08:00
TEC 1d1170237b
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-01-30 13:49:41 +08:00
TEC 69f86a3445
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-01-30 13:49:41 +08:00
TEC d339f20c51
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-01-30 13:49:41 +08:00
TEC 3c7990a0f3
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-01-30 13:49:41 +08:00
TEC 398e7d7295
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-01-30 13:49:41 +08:00
Karthik Chikmagalur 04361565bc
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-01-30 13:49:41 +08:00
Karthik Chikmagalur f50fc99f88
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-01-30 13:49:41 +08:00
TEC d8ccc3390f
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-01-30 13:49:41 +08:00
Karthik Chikmagalur 61b57f2aae
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-01-30 13:49:41 +08:00
TEC 58b1a05f5d
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-01-30 13:49:41 +08:00
TEC 5de1be41a9
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-01-30 13:49:41 +08:00
TEC 7e8496cc0f
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-01-30 13:49:41 +08:00
TEC 87524b7087
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-01-30 13:49:41 +08:00
TEC d43c4936cc
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-01-30 13:49:41 +08:00
TEC 47df774306
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-01-30 13:49:41 +08:00
TEC d43435d48e
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-01-30 13:49:41 +08:00
TEC 31f180f5cf
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-01-30 13:49:41 +08:00
TEC 8347d796c8
---PATCH SET DIVIDER--- 2024-01-30 13:49:41 +08:00
TEC dce8fd6dd3
org-manual: Document export features
* doc/org-manual.org (+*** Export features): Initial manual entry on
export features.
2024-01-30 13:49:41 +08:00
TEC 3925dfbea8
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-01-30 13:49:41 +08:00
TEC 40084fde5f
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-01-30 13:49:41 +08:00
TEC d62f6a2e28
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-01-30 13:49:21 +08:00
TEC a94d282cb9
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-01-30 13:40:29 +08:00
Andrew Hyatt f490c1548a
org-agenda: New customization `org-agenda-start-with-archives-mode'
* lisp/org-agenda.el: Add `org-agenda-start-with-archives-mode'.
(org-agenda-mode): Set value of `org-agenda-archive-mode' according to
value of new variable `org-agenda-start-with-archives-mode'.

* doc/org-manual.org: Note new variable in the documentation of
`org-agenda-archives-mode'.

* etc/ORG-NEWS: Note change to add
`org-agenda-start-with-archives-mode'.
2024-01-29 17:56:42 +01:00
Gerard Vermeulen 813614cff4
lisp/org-src.el: complete `org-src-preserve-indentation' docstring
* lisp/org-src.el (org-src-preserve-indentation): Add that this
option is also honored by `org-indent-block'. Remove \\<org-mode-map>
since such forms serve for major mode documentation strings.
2024-01-29 16:50:53 +01:00
Ihor Radchenko 22050243b8
org-update-parent-todo-statistics: Use parser to match statistics cookie
* lisp/org.el (org-update-parent-todo-statistics): Ignore text
matching statistics cookie that is inside verbatim environments or
otherwise not detected by parser.  Leave a single exception for
headline properties for backwards compatibility.
2024-01-29 16:38:07 +01:00
Ihor Radchenko 522d7d0afe
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-29 14:38:01 +01:00
Ihor Radchenko 107cbc74a9
ob-python: Set Python shell in Org edit buffer
* lisp/ob-python.el (org-babel-python-associate-session): New function
setting `python-shell-buffer-name' in *Org Src* buffer according to
source block's :session parameter.  This function will be triggered by
`org-src-associate-babel-session'.
* etc/ORG-NEWS (ob-python now sets ~python-shell-buffer-name~ in Org
edit buffers): Announce the change.

Co-authored-by: Liu Hui <liuhui1610@gmail.com>

Link: https://orgmode.org/list/CAOQTW-MdC=jiGf+3bEVtfww+izSZix7csBJ+mZ4eZ2BQHDR42w@mail.gmail.com
2024-01-29 14:29:45 +01:00
Pedro A. Aranda Gutierrez a4a880d1f9
org-latex-default-packages-alist: Refine packages for font management
* lisp/org.el (org-latex-default-packages-alist): Change to refine
font management depending on the latex compiler.

Differentiate between pdflatex and lualatex/xetex
packages for font management.  lualatex/xetex should use
fontspec instead of fontenc/inputenc.  When using
fontspec, you need to load amsmath before fontspec
and you don't need amssymb.
2024-01-29 14:26:30 +01:00
Detlef Steuer da2b61b09e lisp/ox-icalendar.el: Add time-to-live functionality to ox-icalendar
This commit adds functionality for ox-icalendar to set X-PUBLISHED-TTL
in the exported ICS, which advises a subscriber to the exported ICS
file to reload after the given time interval.

* lisp/ox-icalendar.el (org-icalendar-ttl): New option to set
X-PUBLISHED-TTL in exported ICS
(icalendar): Add ICAL-TTL export keyword
(org-icalendar--vcalendar): Add argument for TTL
(org-icalendar-template, org-icalendar-export-current-agenda,
org-icalendar--combine-files): Pass TTL to `org-icalendar--vcalendar'

Co-authored-by: Ihor Radchenko <yantar92@posteo.net>
Co-authored-by: Jack Kamm <jackkamm@gmail.com>
2024-01-28 13:45:41 -08:00
Ihor Radchenko e24ca9fa05
org-switch-to-buffer-other-window: Suppress compiler warning
* lisp/org-compat.el (org-switch-to-buffer-other-window): Suppress
compiler warning - we are using obsolete macro instead obsolete
function.  They will be removed together.
2024-01-28 20:08:53 +01:00
Ihor Radchenko 319563cef7
ob-R, ob-julia: Do not force-start session in Org Src buffers
* lisp/ob-R.el (org-babel-R-associate-session): Set
`ess-gen-proc-buffer-name-function' to associate the right session
buffer if user requests session interaction from inside Org Src edit
buffer.
(org-babel-edit-prep:R): Remove in favor of
`org-babel-R-associate-session'.
* lisp/ob-julia.el (org-babel-julia-associate-session): Implement
analogous functionality.
(org-babel-edit-prep:julia): Remove in favor of
`org-babel-julia-associate-session'.
* etc/ORG-NEWS (~org-edit-special~ no longer force-starts session in R
and Julia source blocks): Document the change.
* lisp/org-src.el (org-src-associate-babel-session): Run
org-babel-<lang>-associate-session even when session is not yet
initiated.

Link: https://orgmode.org/list/87r0ir2ln8.fsf@gmail.com
2024-01-28 20:04:31 +01:00
Ihor Radchenko 5e98599f50
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-28 14:50:30 +01:00
Matthew Trzcinski eacc9aa3ca doc/org-manual.org: Minor language fixes
* doc/org-manual.org (Property Syntax): Give article for "buffer
level" and "headline".  Fix plural confusion on "needs".  Change
"allowing" language; authors should only allow comments above buffer
level property blocks because Org requires it.
2024-01-28 12:31:54 +01:00
Ihor Radchenko ef23b4706b
org-babel-tangle: Do not allow tangling into self
* lisp/ob-tangle.el (org-babel-tangle): Throw an error when trying to
tangle into the org file we tangle from.
* etc/ORG-NEWS (It is no longer allowed to tangle into the same file
as Org source): Document the breaking change.
* testing/lisp/test-ob-tangle.el (ob-tangle/tangle-to-self): New test.
2024-01-26 16:54:04 +01:00
Ihor Radchenko 13bbe6743d
lisp/org-table.el (org-table-copy-down): Fix typo 2024-01-26 15:04:19 +01:00
Jack Kamm 44385f5bc4 lisp/ox-icalendar.el: Add Jack Kamm as maintainer
Link: https://list.orgmode.org/87fryllemw.fsf@localhost/T/#m1d51f9256be03ba0e77256c8442e0ce6776aff1e
2024-01-25 21:01:02 -08:00
Ihor Radchenko 19c90dd947
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-25 15:22:22 +01:00
Ihor Radchenko 8ec89c53ca
ox-icalendar: Add support for multi-line SUMMARY, LOCATION, and DESCRIPTION
* lisp/ox-icalendar.el (org-icalendar-entry): Use `org-entry-get' to
account for both PROP and PROP+ in SUMMARY, LOCATION, and DESCRIPTION
properties.  Use newline as accumulated value separator.
* etc/ORG-NEWS (iCalendar export now supports multiline =SUMMARY=,
=LOCATION=, and =DESCRIPTION= properties): Announce the breaking
change.
* doc/org-manual.org (iCalendar Export): Add an example in the manual.

Reported-by: Hanno Perrey <hanno@hoowl.se>
Link: https://orgmode.org/list/87o821dv7o.fsf@localhost
2024-01-25 14:20:22 +01:00
Ihor Radchenko 46b9769a02
org-attach-store-link-p: Change default value to 'attached
* lisp/org-attach.el (org-attach-store-link-p): Change the default
value.
* etc/ORG-NEWS (The default value of ~org-attach-store-link-p~ is now
~attached~): Announce the change.
2024-01-25 13:59:58 +01:00
Ihor Radchenko ea529007d7
ox-html: Fix links to targets that do not have a number
* lisp/ox.el (org-export-get-ordinal): Return nil when ELEMENT does
not match PREDICATE.  `ox-html-link' expects this behavior when a link
refers to target that does not have a caption.
* testing/lisp/test-ox.el (test-org-export/get-ordinal): Fix tests.

Reported-by: gerard.vermeulen@posteo.net
Link: https://orgmode.org/list/7bf1f79071a714750634e76130fe5963@posteo.net
2024-01-25 13:30:35 +01:00
Ihor Radchenko d2986be076
lisp/org-lint.el (org-lint-named-result): Improve accuracy and message
Reported-by: gerard.vermeulen@posteo.net
Link: https://orgmode.org/list/b3dc0bd4368f3db0c7afe136d9f9ca97@posteo.net
2024-01-24 16:47:20 +01:00
Ihor Radchenko 228d6ccfcf
doc/org-manual.org (Repeated tasks): Clarify that all the timestamps are shifted
* doc/org-manual.org (Repeated tasks): Add a paragraph explaining that
marking task with repeaters DONE shifts all the timestamps with
repeater inside.
2024-01-24 15:13:55 +01:00
Ihor Radchenko 78dc58508d
Obsolete org-switch-to-buffer-other-window and org-no-popups
* lisp/org-compat.el (org-switch-to-buffer-other-window):
(org-no-popups): Move from org-macs.el and mark obsolete.
* lisp/ob-lilypond.el (org-babel-lilypond-execute-tangled-ly):
(org-babel-lilypond-mark-error-line):
* lisp/ol.el (org-insert-link):
* lisp/org-agenda.el (org-agenda-get-restriction-and-command):
(org-agenda-prepare-window):
(org-agenda-goto):
(org-agenda-open-link):
(org-agenda-clock-goto):
(org-agenda-diary-entry-in-org-file):
(org-agenda-add-entry-to-org-agenda-diary-file):
(org-agenda-show-the-flagging-note):
* lisp/org-attach.el (org-attach):
* lisp/org-capture.el (org-capture-place-template):
(org-capture-fill-template):
* lisp/org-clock.el (org-clock-select-task):
* lisp/org-macs.el (org-mks):
* lisp/org-src.el (org-src-switch-to-buffer):
* lisp/org-table.el (org-table-edit-field):
(org-table-edit-formulas):
(org-table-show-reference):
* lisp/org.el (org-fast-todo-selection):
(org-add-log-note):
(org-fast-tag-selection):
* lisp/ox.el (org-export-stack-view):
(org-export--dispatch-ui): Use `switch-to-buffer-other-window'.
* etc/ORG-NEWS (Org mode no longer disallows configuring
~display-buffer-alist~ to open Org popups in other frame): Document
the breaking change.

Reported-by: Jan Seeger
Link: https://orgmode.org/list/87pmr3mfq3.fsf@localhost
2024-01-24 15:00:26 +01:00
Ihor Radchenko b980f7abb8
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-24 13:24:14 +01:00
Ihor Radchenko 9ef18956bd
org-element: Allow more objects inside citations
* lisp/org-element.el (org-element-object-restrictions): Allow all but
citation, citation-reference, line-break, table-cell, link and
footnote-reference objects inside citations.

Reported-by: M. ‘quintus’ Gülker <post+orgmodeml@guelker.eu>
Link: https://orgmode.org/list/87tu425pla.fsf@guelker.eu
2024-01-24 12:27:15 +01:00
Ihor Radchenko 793cdbea68
fixup! org-fold: Honor :extend face property in folded headings/blocks/drawers 2024-01-22 16:27:06 +01:00
Ihor Radchenko 2ade16bbc2
org-fold: Honor :extend face property in folded headings/blocks/drawers
* lisp/org-fold-core.el (org-fold-core-region): When folding, when the
fold ends at a newline, copy 'face property from the beginning of the
fold, so that the trailing newline after ellipsis does not appear
with different face.  This fixes :extend t in headlines, blocks, and
drawers not being honored when the headlines are folded.

* etc/ORG-NEWS (Folded lines can now extend their face beyond
ellipsis): Announce the change.

Link: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=65896
2024-01-22 15:43:29 +01:00
Ihor Radchenko dd4fd02995
Allow per-buffer setting of org-link-descriptive via #+STARTUP options
* lisp/org.el (org-startup-options): Add new startup options to set
`org-link-descriptive'.
(org-mode): Move #+startup keyword parsing before setting up link
visibility.
* doc/org-manual.org (Link Format):
(Summary of In-Buffer Settings): Document the new startup option.
* etc/ORG-NEWS (~org-link-descriptive~ can now be set per-buffer via
=#+STARTUP= options): Announce the new feature.

Link: https://orgmode.org/list/87bkst1nfl.fsf@ucl.ac.uk
2024-01-22 13:58:30 +01:00
Ihor Radchenko 6dab5c317d
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-22 12:25:04 +01:00
Ihor Radchenko 83696bf21f
org-export-activate-smart-quotes: Fix edge case with multiple secondary strings
* lisp/ox.el (org-export--smart-quote-status): Do not hash quote
status by parent syntax node - it will create clashes when parent has
multiple secondary strings.  Instead, hash by parent + secondary
string property.
* testing/lisp/test-ox.el (test-org-export/activate-smart-quotes): Add
new test case.

Reported-by: William Denton <william@williamdenton.org>
Link: https://orgmode.org/list/TarY7-tR4TEmIu8jawOtTyyi03K93WIg7DsS1eXNylelCy2Hv-6OFNKOMQMukf70Tzf3uO_2F1Qe7xwrzb43SpJc4jxJZLN3W0MioKYbgzI=@williamdenton.org
2024-01-21 13:44:50 +01:00
Ihor Radchenko ac1c72376c
org-open-at-point-global: Match multiline links
* lisp/org.el (org-open-at-point-global): Match multiline links
spanning up to a paragraph.

Reported-by: Omar Antolín Camarena <omar@matem.unam.mx>
Link: https://orgmode.org/list/87o7df7psx.fsf@localhost
2024-01-21 13:17:12 +01:00
Kyle Meyer 6e17ddd334 Merge branch 'bugfix' 2024-01-20 21:33:37 -05:00
Kyle Meyer de060c36d4 Merge branch 'km/from-emacs-29' into bugfix 2024-01-20 21:27:59 -05:00
Stefan Kangas 50183ada86 Backport commit 725a3f32f from Emacs
; Fix typos in symbol names
725a3f32f8ba78ac5fffcd03be5b82cbc2c1b275
Stefan Kangas
Sun Jan 14 15:16:54 2024 +0100
2024-01-20 21:25:59 -05:00
Stefan Kangas 6e0fdd1714 Backport commit 6653ee66c from Emacs
* lisp/ox-latex.el (org-latex-src-block-backend)
(org-latex-engraved-theme): Improve docstring; mention that
engrave-faces is a GNU ELPA package.

Improve two docstrings in ox-latex
6653ee66ca5ebd42322613a09d4c0d2e35af924b
Stefan Kangas
Sun Jan 14 14:52:17 2024 +0100
2024-01-20 21:24:44 -05:00
Ihor Radchenko 037e3b3eb7
lisp/ob-tangle.el (org-babel-detangle): Improve docstring 2024-01-20 19:35:34 +01:00
Ihor Radchenko 4edb7d43ba
doc/org-manual.org (The Agenda Dispatcher): Remove obsolete convention
We should not advertise obsolete conventions in the manual.
2024-01-20 16:04:42 +01:00
Ihor Radchenko 92c53f23d3
org-get-outline-path: Drop COMMENT keywords from the outline path
* lisp/org.el (org--get-outline-path-1): Remove comment keyword from
title when current heading is commented.
* testing/lisp/test-org.el (test-org/get-outline-path): Add test.
2024-01-18 15:13:04 +01:00
Ihor Radchenko a19a72f7d3
org-agenda: Fix grid lines when `org-agenda-default-appointment-duration' is non-nil
* lisp/org-agenda.el (org-agenda-add-time-grid-maybe): Let-bind
`org-agenda-default-appointment-duration' to nil when formatting the
grid lines.  Otherwise, `org-agenda-format-item' logic fails to
produce the expected result.
* testing/lisp/test-org-agenda.el (test-org-agenda/time-grid): Add new
test set covering the bug and several simpler cases.
* testing/examples/agenda-file2.org (two): New test file example.

Reported-by: Detlef Steuer <steuer@hsu-hh.de>
Link: https://orgmode.org/list/87edv5fv1w.fsf@localhost
2024-01-17 15:40:24 +01:00
Ihor Radchenko 4ce2ad4eb1
lisp/org.el (org-agenda-files): Avoid duplicates
Duplicate entries in agenda files cause scanning the same file
twice, producing duplicates in the agenda.

Reported-by: Christopher M. Miles <numbchild@gmail.com>
Link: https://orgmode.org/list/65a75fd3.170a0220.be4f3.67c9@mx.google.com
2024-01-17 12:52:37 +01:00
José Miguel García Urrutia 490260ceb8
orgcard.tex: Allow correct rendering in PDF format and US letter page size
* doc/orgcard.tex: orgcard now can be printed as a triptych.  Shorten
titles to prevent overflows.

Link: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=64578

TINYCHANGE
2024-01-17 12:42:37 +01:00
Ihor Radchenko 2da9253e7d
doc/org-manual.org: Clarify context of evaluation code block references
* doc/org-manual.org (Noweb Reference Syntax):
(Passing arguments): Explain that referenced code block evaluation
happens with point at the referenced block.
2024-01-16 16:33:50 +01:00
Joseph Turner 0254854eea
lisp/ol.el (org-link-open): Use let-bound :follow function
TINYCHANGE
2024-01-16 14:38:43 +01:00
Ihor Radchenko 87da1ff15b
org-cite-basic-export-citation: Fix prefix/suffix being ignored
* lisp/oc-basic.el (org-cite-basic-export-citation): Honour prefix and
suffix in citation references and citations.
* testing/examples/Basic.bib: New example bibliography used by tests.
* testing/lisp/test-oc-basic.el:
(test-org-cite-basic/parse-bibliography):
(test-org-cite-basic/export-citation): New file, adding tests for
oc-basic processor.

Reported-by: William Denton <william@williamdenton.org>
Link: https://orgmode.org/list/FMaPNvYf_8jqVxcU2L5kgiMuejm0NqK3e9D7CzhSzG-fmESTZKgtAJy1LG_zNDLS6o_oQ-gF_G-6DXlXA2iQ_yAjNjLgeB86JTU46Sv8Wec=@williamdenton.org
2024-01-16 13:38:27 +01:00
Ihor Radchenko e6e8f0933a
org-cite-basic-export-citation: Fix suffix inside brackets (year suffix)
* lisp/oc-basic.el (org-cite-basic-export-citation): Fix formatting
citation reference with brackets.  When year is placed inside
brackets, put the reference suffix outside.
2024-01-16 13:36:18 +01:00
Ihor Radchenko d51723102a
lisp/ox-latex.el: Honor non-list value of `org-latex-caption-above'
* lisp/ox-latex.el (org-latex-generate-engraved-preamble):
(org-latex-latex-environment):  Use
`org-latex--caption-above-p' to query whether an element should have
its caption above.

Reported-by: Mads Bach Villadsen <mbvilladsen@pm.me>
Link: https://orgmode.org/list/m2zfx69uhb.fsf@pm.me
2024-01-16 12:33:01 +01:00
Matthew Trzcinski b79d9dd604 lisp/ob-shell.el: Remove unnecessary prompt template
(org-babel-shell-set-prompt-commands): "posh" is POSIX complaint and
uses PS1 and PS2 to define the shell prompt.  A separate template is
not needed.

Link: https://list.orgmode.org/18cfa388d12.f0069ffe919377.6846036599039377431@excalamus.com/
2024-01-15 20:57:20 +01:00
Ihor Radchenko 25c786f0fb
Update version number for the 9.6.17 release 2024-01-14 12:50:34 +01:00
35 changed files with 823 additions and 230 deletions

View File

@ -3172,7 +3172,8 @@ precise behavior depends on how point arrived there---see
incomplete and the internals are again displayed as plain text.
Inserting the missing bracket hides the link internals again. To show
the internal structure of all links, use the menu: Org \rarr
Hyperlinks \rarr Literal links.
Hyperlinks \rarr Literal links, customize ~org-link-descriptive~, or use
=literallinks= [[*Summary of In-Buffer Settings][startup option]].
** Internal Links
:PROPERTIES:
@ -5311,10 +5312,10 @@ disks in a box like this:
:END:
#+end_example
Properties can be inserted on buffer level. That means they apply
Properties can be inserted at the buffer level. That means they apply
before the first headline and can be inherited by all entries in a
file. Property blocks defined before first headline needs to be
located at the top of the buffer, allowing only comments above.
file. Property blocks defined before the first headline must be at
the top of the buffer with only comments above them.
Properties can also be defined using lines like:
@ -6627,6 +6628,9 @@ state to =DONE= would actually switch the date like this:
DEADLINE: <2005-11-01 Tue +1m>
#+end_example
When task contains multiple timestamps with repeater interval, all
these timestamps are shifted.
To mark a task with a repeater as DONE, use {{{kbd(C-- 1 C-c C-t)}}},
i.e., ~org-todo~ with a numeric prefix argument of =-1=.
@ -8892,10 +8896,9 @@ commands:
#+kindex: < < @r{(Agenda dispatcher)}
If there is an active region, restrict the following agenda command
to the region. Otherwise, restrict it to the current subtree[fn::
For backward compatibility, you can also press {{{kbd(0)}}} to
restrict to the current region/subtree.]. After pressing {{{kbd(<
<)}}}, you still need to press the character selecting the command.
to the region. Otherwise, restrict it to the current subtree.
After pressing {{{kbd(< <)}}}, you still need to press the character
selecting the command.
- {{{kbd(*)}}} ::
@ -10074,9 +10077,13 @@ the other commands, point needs to be in the desired line.
#+kindex: v a
#+findex: org-agenda-archives-mode
#+vindex: org-agenda-start-with-archives-mode
Toggle Archives mode. In Archives mode, trees that are archived
(see [[*Internal archiving]]) are also scanned when producing the
agenda. To exit archives mode, press {{{kbd(v a)}}} again.
agenda. To exit archives mode, press {{{kbd(v a)}}} again. The
initial setting for this mode in new agenda buffers can set with the
variable ~org-agenda-start-with-archives-mode~, which can be set
with the same values as ~org-agenda-archives-mode~.
- {{{kbd(v A)}}} ::
@ -16347,6 +16354,18 @@ when exporting. To force the backend to inherit the =LOCATION=,
=TIMEZONE= and =CLASS= properties, configure the
~org-use-property-inheritance~ variable.
=SUMMARY=, =LOCATION=, and =DESCRIPTION= properties can define
multi-line summary, location, or description using =<PROPERTY>+=
syntax (see [[*Property Syntax]]):
: * Meeting at location with multi-line address
: <2024-01-08 Mon 14:20-15:00>
: :PROPERTIES:
: :LOCATION: Someplace
: :LOCATION+: Some Street 5
: :LOCATION+: 12345 Small Town
: :END:
#+vindex: org-icalendar-include-body
When Org entries do not have =SUMMARY=, =DESCRIPTION=, =LOCATION= and
=CLASS= properties, the iCalendar export backend derives the summary
@ -16371,6 +16390,15 @@ information. The iCalendar standard defines three visibility classes:
The server should treat unknown class properties the same as
=PRIVATE=.
#+cindex: @samp{ICAL-TTL}, keyword
#+vindex: org-icalendar-ttl
The exported iCalendar file can advise clients how often to check for
updates. This duration can be set globally with the
~org-icalendar-ttl~ variable, or on a per-document basis with the
=ICAL-TTL= keyword. This option should be set using the iCalendar
notation for time durations; consult the docstring of
~org-icalendar-ttl~ for more details.
Exporting to iCalendar format depends in large part on the
capabilities of the destination application. Some are more lenient
than others. Consult the Org mode FAQ for advice on specific
@ -18388,6 +18416,7 @@ a colon, for example: =:var table=other-file.org:example-table=.
A code block name, as assigned by =NAME= keyword, followed by
parentheses and optional arguments passed within the parentheses.
The block is evaluated with point at its location.
#+begin_example
,#+NAME: double
@ -19814,9 +19843,10 @@ By default a newline separates each noweb reference concatenation. To
use a different separator, edit the =noweb-sep= header argument.
Alternatively, Org can include the results of evaluation of a single
code block rather than its body. Evaluation occurs when parentheses,
possibly including arguments, are appended to the code block name, as
shown below.
code block rather than its body [[fn::The reference is evaluated with
point at the referenced block, using its header arguments (including
inherited)]. Evaluation occurs when parentheses, possibly including
arguments, are appended to the code block name, as shown below.
: <<NAME(optional arguments)>>
@ -20660,6 +20690,17 @@ changes.
| =inlineimages= | Show inline images. |
| =noinlineimages= | Do not show inline images on startup. |
#+vindex: org-link-descriptive
Bracket links in Org buffers are displayed hiding the link path and
brackets. For example, =[[https://orgmode.org][Org Website]]= is,
by default, displayed as "Org Website", hiding the link itself and
just displaying its description. Alternatively, the links can be
displayed in full. The corresponding variable is
~org-link-descriptive~.
| =descriptivelinks= | Hide path and brackets in links. |
| =literallinks= | Do not hide anything. |
#+vindex: org-log-done
#+vindex: org-log-note-clock-out
#+vindex: org-log-repeat

View File

@ -9,10 +9,14 @@
% Specify how many you want here.
\columnsperpage=3
% Set letterpaper to 0 for A4 paper, 1 for letter (US) paper. Useful
% only when columnsperpage is 2 or 3.
\letterpaper=1
% PDF output layout. 0 for A4, 1 for letter (US), a `l' is added for
% a landscape layout.
\input pdflayout.sty
\pdflayout=(0l)
\pdflayout=(1l)
% Nothing else needs to be changed below this line.
% Copyright (C) 1987, 1993, 1996--1997, 2001--2024 Free Software
@ -108,17 +112,14 @@
\footline{\hss\folio}
\def\makefootline{\baselineskip10pt\hsize6.5in\line{\the\footline}}
\else %2 or 3 columns uses prereduced size
\hsize 3.2in
\if 1\the\letterpaper
\hsize 3.2in
\vsize 7.95in
\hoffset -.75in
\voffset -.745in
\else
\hsize 3.2in
\vsize 7.65in
\hoffset -.25in
\voffset -.745in
\fi
\hoffset -.75in
\voffset -.745in
\font\titlefont=cmbx10 \scaledmag2
\font\headingfont=cmbx10 \scaledmag1
\font\smallfont=cmr6
@ -275,7 +276,7 @@
%**end of header
\title{Org-Mode Reference Card (1/2)}
\title{Org-Mode Reference Card}
\centerline{(for version \orgversionnumber)}
@ -477,7 +478,7 @@ after ``{\tt :}'', and dictionary words elsewhere.
\newcolumn
\title{Org-Mode Reference Card (2/2)}
\title{Org-Mode Reference Card}
\centerline{(for version \orgversionnumber)}

View File

@ -13,6 +13,77 @@ Please send Org bug reports to mailto:emacs-orgmode@gnu.org.
* Version 9.7 (not released yet)
** Important announcements and breaking changes
*** ob-python now sets ~python-shell-buffer-name~ in Org edit buffers
When editing a Python src block, the editing buffer is now associated
with the Python shell specified by the src block's ~:session~ header,
which means users can now send code directly from the edit buffer,
e.g., using ~C-c C-c~, to the session specified in the Org buffer.
*** ~org-edit-special~ no longer force-starts session in R and Julia source blocks
Previously, when R/Julia source block had =:session= header argument
set to a session name with "earmuffs" (like =*session-name*=),
~org-edit-special~ always started a session, if it does not exist.
Now, ~org-edit-special~ arranges that a new session with correct name
is initiated only when user explicitly executes R/Julia-mode commands
that trigger session interactions (requires ESS 24.01.0 or newer).
The same session will remain available in the context of Org babel.
*** It is no longer allowed to tangle into the same file as Org source
Previously, =file.org= with the following contents
: #+begin_src org :tangle file.org
: Text
: #+end_src
would overwrite itself.
Now, an error is thrown.
*** iCalendar export now supports multiline =SUMMARY=, =LOCATION=, and =DESCRIPTION= properties
Previously, it was not possible to specify multi-line location,
summary, or description when exporting to iCalendar.
In the following example, =LOCATION= was exported as "Someplace",
ignoring the other lines.
#+begin_src org
,* heading with multi-line property
:PROPERTIES:
:LOCATION: Someplace
:LOCATION+: Some Street 5
:LOCATION+: 12345 Small Town
:END:
#+end_src
Now, =SUMMARY+=, =LOCATION+=, and =DESCRIPTION+= properties can be
used to create multi-line values.
In the above example, =LOCATION= is now exported as
: Someplace
: Some Street 5
: 12345 Small Town
*** Org mode no longer disallows configuring ~display-buffer-alist~ to open Org popups in other frame
Previously, Org mode disallowed pop-up frames when displaying dispatch buffers.
This is no longer the case. ~display-buffer-alist~ is fully obeyed.
~org-switch-to-buffer-other-window~ and ~org-no-popups~ are now deprecated.
*** Folded lines can now extend their face beyond ellipsis
Previously, ~:extend t~ face attribute did not make folded headlines,
blocks, and drawers extend their face beyond end of line.
Now, the ellipsis and trailing newline use the same face as the last
character before the fold.
*** ~org-agenda-search-headline-for-time~ now ignores all the timestamp in headings
Previously, ~org-agenda-search-headline-for-time~ made Org agenda
@ -522,6 +593,36 @@ 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 custom setting ~org-icalendar-ttl~ for the ~ox-icalendar~ backend
The option ~org-icalendar-ttl~ allows to advise a subscriber to the
exported =.ics= file to reload after the given time interval.
This is useful i.e. if a calendar server subscribes to your exported
file and that file is updated regularly.
See IETF RFC 5545, Section 3.3.6 Duration and
https://en.wikipedia.org/wiki/ICalendar#Other_component_types for
details.
Default for ~org-icalendar-ttl~ is ~nil~. In that case the setting
will not be used in the exported ICS file.
The option may also be set using the =ICAL-TTL= keyword.
*** The default value of ~org-attach-store-link-p~ is now ~attached~
Now, after attaching a file, =[[attach:...]]= link to the attached file
is stored. It can later be inserted using =M-x org-insert-link=.
*** ~org-link-descriptive~ can now be set per-buffer via =#+STARTUP= options
In addition to ~org-link-descriptive~ custom option, link display can
now be controlled per-buffer as:
: #+STARTUP: literallinks
: #+STARTUP: descriptivelinks
*** New option ~org-fast-tag-selection-maximum-tags~
You can now limit the total number of tags displayed in the fast tag
@ -743,6 +844,11 @@ manner with ~run-python~.
This allows to run functions after ~org-indent~ intializes a buffer to
enrich its properties.
*** New option ~org-agenda-start-with-archives-mode~
This option starts the agenda to automatically include archives,
propagating the value for this variable to ~org-agenda-archives-mode~.
For acceptable values and their meaning, see the value of that variable.
** New features
*** =ob-plantuml.el=: Support tikz file format output

View File

@ -91,17 +91,6 @@ this variable.")
:version "24.1"
:type 'string)
(defvar ess-current-process-name) ; dynamically scoped
(defvar ess-local-process-name) ; dynamically scoped
(defun org-babel-edit-prep:R (info)
"Initiate R session for Org edit buffer, as needed.
The session name is taken from INFO."
(let ((session (cdr (assq :session (nth 2 info)))))
(when (and session
(string-prefix-p "*" session)
(string-suffix-p "*" session))
(org-babel-R-initiate-session session nil))))
;; The usage of utils::read.table() ensures that the command
;; read.table() can be found even in circumstances when the utils
;; package is not in the search path from R.
@ -264,6 +253,8 @@ Retrieve variables from PARAMS."
(t (format "%s <- %S" name (prin1-to-string value))))))
(defvar ess-current-process-name) ; dynamically scoped
(defvar ess-local-process-name) ; dynamically scoped
(defvar ess-ask-for-ess-directory) ; dynamically scoped
(defvar ess-gen-proc-buffer-name-function) ; defined in ess-inf.el
(defun org-babel-R-initiate-session (session params)
@ -296,9 +287,10 @@ Use PARAMS to set default directory when creating a new session."
"Associate R code buffer with an R session.
Make SESSION be the inferior ESS process associated with the
current code buffer."
(setq ess-local-process-name
(process-name (get-buffer-process session)))
(ess-make-buffer-current))
(when-let ((process (get-buffer-process session)))
(setq ess-local-process-name (process-name process))
(ess-make-buffer-current))
(setq-local ess-gen-proc-buffer-name-function (lambda (_) session)))
(defvar org-babel-R-graphics-devices
'((:bmp "bmp" "filename")

View File

@ -70,12 +70,15 @@
(defvar ess-local-process-name) ; dynamically scoped
(defvar ess-eval-visibly-p) ; dynamically scoped
(defvar ess-local-customize-alist); dynamically scoped
(defun org-babel-edit-prep:julia (info)
(let ((session (cdr (assq :session (nth 2 info)))))
(when (and session
(string-prefix-p "*" session)
(string-suffix-p "*" session))
(org-babel-julia-initiate-session session nil))))
(defvar ess-gen-proc-buffer-name-function) ; defined in ess-inf.el
(defun org-babel-julia-associate-session (session)
"Associate R code buffer with an R session.
Make SESSION be the inferior ESS process associated with the
current code buffer."
(when-let ((process (get-buffer-process session)))
(setq ess-local-process-name (process-name process))
(ess-make-buffer-current))
(setq-local ess-gen-proc-buffer-name-function (lambda (_) session)))
(defun org-babel-expand-body:julia (body params &optional _graphics-file)
"Expand BODY according to PARAMS, return the expanded body."
@ -178,7 +181,6 @@ end"
(format "%s = %s" name (org-babel-julia-quote-csv-field value))))
(defvar ess-ask-for-ess-directory) ; dynamically scoped
(defvar ess-gen-proc-buffer-name-function) ; defined in ess-inf.el
(defun org-babel-julia-initiate-session (session params)
"If there is not a current julia process then create one."
(unless (string= session "none")

View File

@ -230,7 +230,7 @@ If error in compilation, attempt to mark the error in lilypond org file."
(delete-file org-babel-lilypond-temp-file))
(rename-file org-babel-lilypond-tangled-file
org-babel-lilypond-temp-file))
(org-switch-to-buffer-other-window "*lilypond*")
(switch-to-buffer-other-window "*lilypond*")
(erase-buffer)
(org-babel-lilypond-compile-lilyfile org-babel-lilypond-temp-file)
(goto-char (point-min))
@ -280,7 +280,7 @@ FILE-NAME is full path to lilypond file."
"Mark the erroneous lines in the lilypond org buffer.
FILE-NAME is full path to lilypond file.
LINE is the erroneous line."
(org-switch-to-buffer-other-window
(switch-to-buffer-other-window
(concat (file-name-nondirectory
(org-babel-lilypond-switch-extension file-name ".org"))))
(let ((temp (point)))

View File

@ -83,6 +83,12 @@ If `org-babel-python-command' is set, then it overrides this option."
:package-version '(Org . "8.0")
:type 'symbol)
(defun org-babel-python-associate-session (session)
"Associate Python code buffer with an Python session.
Make SESSION without earmuffs be the Python buffer name."
(setq-local python-shell-buffer-name
(org-babel-python-without-earmuffs session)))
(defun org-babel-execute:python (body params)
"Execute Python BODY according to PARAMS.
This function is called by `org-babel-execute-src-block'."

View File

@ -52,8 +52,6 @@
("fish" . "function fish_prompt\n\techo \"%s\"\nend")
;; prompt2 is like PS2 in POSIX shells.
("csh" . "set prompt=\"%s\"\nset prompt2=\"\"")
;; PowerShell, similar to fish, does not have PS2 equivalent.
("posh" . "function prompt { \"%s\" }")
;; PROMPT_COMMAND can override PS1 settings. Disable it.
;; Disable PS2 to avoid garbage in multi-line inputs.
(t . "PROMPT_COMMAND=;PS1=\"%s\";PS2="))

View File

@ -256,7 +256,8 @@ matching a regular expression."
(when (equal arg '(16))
(or (cdr (assq :tangle (nth 2 (org-babel-get-src-block-info 'no-eval))))
(user-error "Point is not in a source code block"))))
path-collector)
path-collector
(source-file buffer-file-name))
(mapc ;; map over file-names
(lambda (by-fn)
(let ((file-name (car by-fn)))
@ -313,6 +314,13 @@ matching a regular expression."
(compare-buffer-substrings
nil nil nil
tangle-buf nil nil)))))))
(when (equal (if (file-name-absolute-p file-name)
file-name
(expand-file-name file-name))
(if (file-name-absolute-p source-file)
source-file
(expand-file-name source-file)))
(error "Not allowed to tangle into the same file as self"))
;; We do not erase, but overwrite previous file
;; to preserve any existing symlinks.
(write-region nil nil file-name)
@ -618,9 +626,12 @@ by `org-babel-get-src-block-info'."
;; de-tangling functions
(defun org-babel-detangle (&optional source-code-file)
"Propagate changes in source file back original to Org file.
"Propagate changes from current source buffer back to the original Org file.
This requires that code blocks were tangled with link comments
which enable the original code blocks to be found."
which enable the original code blocks to be found.
Optional argument SOURCE-CODE-FILE is the file path to be used instead
of the current buffer."
(interactive)
(save-excursion
(when source-code-file (find-file source-code-file))

View File

@ -667,22 +667,30 @@ export communication channel, as a property list."
;; "author" style.
(`(,(or "author" "a") . ,variant)
(let ((caps (member variant '("caps" "c"))))
(org-export-data
(org-cite-mapconcat
(lambda (key)
(or
(let ((author (org-cite-basic--get-author key info)))
(if caps (org-cite-capitalize author) author))
"??"))
(org-cite-get-references citation t)
org-cite-basic-author-year-separator)
(org-cite-basic--format-author-year
citation
(lambda (p c s) (org-cite-concat p c s))
(lambda (prefix author _ suffix)
(org-cite-concat
prefix
(if caps (org-cite-capitalize author) author)
suffix))
info)))
;; "noauthor" style.
(`(,(or "noauthor" "na") . ,variant)
(format (if (funcall has-variant-p variant 'bare) "%s" "(%s)")
(mapconcat (lambda (key) (or (org-cite-basic--get-year key info) "????"))
(org-cite-get-references citation t)
org-cite-basic-author-year-separator)))
(let ((bare? (funcall has-variant-p variant 'bare)))
(org-cite-basic--format-author-year
citation
(lambda (prefix contents suffix)
(org-cite-concat
(unless bare? "(")
prefix
contents
suffix
(unless bare? ")")))
(lambda (prefix _ year suffix)
(org-cite-concat prefix year suffix))
info)))
;; "nocite" style.
(`(,(or "nocite" "n") . ,_) nil)
;; "text" and "note" styles.
@ -700,8 +708,9 @@ export communication channel, as a property list."
(org-cite-concat p
(if caps (org-cite-capitalize a) a)
(if bare " " " (")
y s
(and (not bare) ")")))
y
(and (not bare) ")")
s))
info)))
;; "numeric" style.
;;

View File

@ -307,10 +307,7 @@ or emacs-wiki packages to Org syntax.
The function must accept two parameters, a TYPE containing the link
protocol name like \"rmail\" or \"gnus\" as a string, and the linked path,
which is everything after the link protocol. It should return a cons
with possibly modified values of type and path.
Org contains a function for this, so if you set this variable to
`org-translate-link-from-planner', you should be able follow many
links created by planner."
with possibly modified values of type and path."
:group 'org-link-follow
:type '(choice (const nil) (function))
:safe #'null)
@ -1161,9 +1158,9 @@ for internal and \"file\" links, or stored as a parameter in
;; argument, as it was mandatory before Org 9.4. This is
;; deprecated, but support it for now.
(condition-case nil
(funcall (org-link-get-parameter type :follow) path arg)
(funcall f path arg)
(wrong-number-of-arguments
(funcall (org-link-get-parameter type :follow) path)))))))))
(funcall f path)))))))))
(defun org-link-open-from-string (s &optional arg)
"Open a link in the string S, as if it was in Org mode.
@ -1883,7 +1880,7 @@ non-interactively, don't allow to edit the default description."
(t
;; Read link, with completion for stored links.
(org-link--fontify-links-to-this-file)
(org-switch-to-buffer-other-window "*Org Links*")
(switch-to-buffer-other-window "*Org Links*")
(with-current-buffer "*Org Links*"
(read-only-mode 1)
(let ((inhibit-read-only t)

View File

@ -1102,6 +1102,14 @@ removed from entry text before it is shown in the agenda."
:group 'org-agenda
:type 'string)
(defcustom org-agenda-start-with-archives-mode nil
"Initial value of archive-mode in a newly created agenda window.
See `org-agenda-archives-mode' for acceptable values and their
meaning."
:group 'org-agenda-startup
:package-version '(Org . "9.7")
:type 'symbol)
(defvar org-agenda-entry-text-cleanup-hook nil
"Hook that is run after basic cleanup of entry text to be shown in agenda.
This cleanup is done in a temporary buffer, so the function may inspect and
@ -2372,7 +2380,8 @@ The following commands are available:
(setq org-agenda-follow-mode org-agenda-start-with-follow-mode
org-agenda-entry-text-mode org-agenda-start-with-entry-text-mode
org-agenda-show-log org-agenda-start-with-log-mode
org-agenda-clockreport-mode org-agenda-start-with-clockreport-mode))
org-agenda-clockreport-mode org-agenda-start-with-clockreport-mode
org-agenda-archives-mode org-agenda-start-with-archives-mode))
(add-to-invisibility-spec '(org-filtered))
(org-fold-core-initialize `(,org-link--description-folding-spec
,org-link--link-folding-spec))
@ -3113,7 +3122,7 @@ Agenda views are separated by `org-agenda-block-separator'."
line lines left right n n1)
(save-window-excursion
(delete-other-windows)
(org-switch-to-buffer-other-window " *Agenda Commands*")
(switch-to-buffer-other-window " *Agenda Commands*")
(erase-buffer)
(insert (eval-when-compile
(let ((header
@ -3915,7 +3924,7 @@ FILTER-ALIST is an alist of filters we need to apply when
((eq org-agenda-window-setup 'current-window)
(pop-to-buffer-same-window abuf))
((eq org-agenda-window-setup 'other-window)
(org-switch-to-buffer-other-window abuf))
(switch-to-buffer-other-window abuf))
((eq org-agenda-window-setup 'other-frame)
(switch-to-buffer-other-frame abuf))
((eq org-agenda-window-setup 'other-tab)
@ -3927,7 +3936,7 @@ FILTER-ALIST is an alist of filters we need to apply when
(pop-to-buffer-same-window abuf))
((eq org-agenda-window-setup 'reorganize-frame)
(delete-other-windows)
(org-switch-to-buffer-other-window abuf)))
(switch-to-buffer-other-window abuf)))
(setq org-agenda-tag-filter (cdr (assq 'tag filter-alist)))
(setq org-agenda-category-filter (cdr (assq 'cat filter-alist)))
(setq org-agenda-effort-filter (cdr (assq 'effort filter-alist)))
@ -7142,7 +7151,11 @@ TODAYP is t when the current agenda view is on today."
(gridtimes (nth 1 org-agenda-time-grid))
(req (car org-agenda-time-grid))
(remove (member 'remove-match req))
new time)
new time
;; We abuse `org-agenda-format-item' to format grid lines
;; here. Prevent it from adding default duration, if any
;; to the grid lines.
(org-agenda-default-appointment-duration nil))
(when (and (member 'require-timed req) (not have))
;; don't show empty grid
(throw 'exit list))
@ -9206,7 +9219,6 @@ When called with a prefix argument, include all archive files as well."
(org-agenda-error)))
(buffer (marker-buffer marker))
(pos (marker-position marker)))
;; FIXME: use `org-switch-to-buffer-other-window'?
(switch-to-buffer-other-window buffer)
(widen)
(push-mark)
@ -9461,9 +9473,8 @@ It also looks at the text of the entry itself."
(when (search-forward l nil lkend)
(goto-char (match-beginning 0))
(org-open-at-point)))
;; This is an internal link, widen the buffer
;; FIXME: use `org-switch-to-buffer-other-window'?
(switch-to-buffer-other-window buffer)
;; This is an internal link, widen the buffer
(widen)
(goto-char marker)
(when (search-forward l nil lkend)
@ -10268,7 +10279,7 @@ buffer, display it in another window."
;; If the currently clocked entry is not in the agenda
;; buffer, we visit it in another window:
((bound-and-true-p org-clock-current-task)
(org-switch-to-buffer-other-window (org-clock-goto)))
(switch-to-buffer-other-window (org-clock-goto)))
(t (message "No running clock, use `C-c C-x C-j' to jump to the most recent one")))))
(defun org-agenda-diary-entry-in-org-file ()
@ -10306,7 +10317,7 @@ buffer, display it in another window."
(org-agenda-add-entry-to-org-agenda-diary-file 'block text d1 d2)
(and (equal (buffer-name) org-agenda-buffer-name) (org-agenda-redo)))
((equal char ?j)
(org-switch-to-buffer-other-window
(switch-to-buffer-other-window
(find-file-noselect org-agenda-diary-file))
(require 'org-datetree)
(org-datetree-find-date-create d1)
@ -10344,7 +10355,7 @@ If TEXT is not empty, it will become the headline of the new entry, and
the resulting entry will not be shown. When TEXT is empty, switch to
`org-agenda-diary-file' and let the user finish the entry there."
(let ((cw (current-window-configuration)))
(org-switch-to-buffer-other-window
(switch-to-buffer-other-window
(find-file-noselect org-agenda-diary-file))
(widen)
(goto-char (point-min))
@ -11040,7 +11051,7 @@ tag and (if present) the flagging note."
(unless note
(user-error "No flagging note"))
(org-kill-new note)
(org-switch-to-buffer-other-window "*Flagging Note*")
(switch-to-buffer-other-window "*Flagging Note*")
(erase-buffer)
(insert note)
(goto-char (point-min))

View File

@ -142,7 +142,7 @@ Selective means to respect the inheritance setting in
(const :tag "Inherit parent node attachments" t)
(const :tag "Respect org-use-property-inheritance" selective)))
(defcustom org-attach-store-link-p nil
(defcustom org-attach-store-link-p 'attached
"Non-nil means store a link to a file when attaching it.
When t, store the link to original file location.
When `file', store link to the attached file location.
@ -320,7 +320,7 @@ Shows a list of commands and prompts for another key to execute a command."
(save-excursion
(save-window-excursion
(unless org-attach-expert
(org-switch-to-buffer-other-window "*Org Attach*")
(switch-to-buffer-other-window "*Org Attach*")
(erase-buffer)
(setq cursor-type nil
header-line-format "Use C-v, M-v, C-n or C-p to navigate.")

View File

@ -1177,7 +1177,7 @@ may have been stored before."
(unless inhibit-wconf-store
(org-capture-put :return-to-wconf (current-window-configuration)))
(delete-other-windows)
(org-switch-to-buffer-other-window
(switch-to-buffer-other-window
(org-capture-get-indirect-buffer (org-capture-get :buffer) "CAPTURE"))
(widen)
(org-fold-show-all)
@ -1694,7 +1694,7 @@ Expansion occurs in a temporary Org mode buffer."
(message "no template") (ding)
(sit-for 1))
(save-window-excursion
(org-switch-to-buffer-other-window (get-buffer-create "*Capture*"))
(switch-to-buffer-other-window (get-buffer-create "*Capture*"))
(erase-buffer)
(setq buffer-file-name nil)
(setq mark-active nil)

View File

@ -665,7 +665,7 @@ there is no recent clock to choose from."
(if (zerop chl)
(user-error "No recent clock")
(save-window-excursion
(org-switch-to-buffer-other-window
(switch-to-buffer-other-window
(get-buffer-create "*Clock Task Select*"))
(erase-buffer)
(when (marker-buffer org-clock-default-task)

View File

@ -1052,6 +1052,19 @@ INFO is a plist containing export properties."
(define-obsolete-function-alias 'org--math-always-on
'org--math-p "9.7")
(defmacro org-no-popups (&rest body)
"Suppress popup windows and evaluate BODY."
`(let (pop-up-frames pop-up-windows)
,@body))
(make-obsolete 'org-no-popups "no longer used" "9.7")
(defun org-switch-to-buffer-other-window (&rest args)
"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")
(make-obsolete 'org-refresh-category-properties "no longer used" "9.7")
(make-obsolete 'org-refresh-effort-properties "no longer used" "9.7")

View File

@ -412,10 +412,14 @@ Don't modify it, set `org-element-affiliated-keywords' instead.")
subscript superscript underline verbatim))
(standard-set
(remq 'citation-reference (remq 'table-cell org-element-all-objects)))
(standard-set-no-line-break (remq 'line-break standard-set)))
(standard-set-no-line-break (remq 'line-break standard-set))
(standard-set-for-citations (seq-difference
standard-set-no-line-break
'( citation citation-reference
footnote-reference link))))
`((bold ,@standard-set)
(citation citation-reference)
(citation-reference ,@minimal-set)
(citation-reference ,@standard-set-for-citations)
(footnote-reference ,@standard-set)
(headline ,@standard-set-no-line-break)
(inlinetask ,@standard-set-no-line-break)
@ -6951,7 +6955,7 @@ the expected result."
(error "org-element: Parsing aborted by user. Cache has been cleared.
If you observe Emacs hangs frequently, please report this to Org mode mailing list (M-x org-submit-bug-report)"))
(message (substitute-command-keys
"`org-element--parse-buffer': Suppressed `\\[keyboard-quit]'. Press `\\[keyboard-quit]' %d more times to force interruption.")
"`org-element--parse-to': Suppressed `\\[keyboard-quit]'. Press `\\[keyboard-quit]' %d more times to force interruption.")
(- org-element--cache-interrupt-C-g-max-count
org-element--cache-interrupt-C-g-count)))
(unless element

View File

@ -433,7 +433,7 @@ Return nil when there is no matching folding spec."
(org-fold-core-get-folding-spec-from-alias spec-or-alias))
(defsubst org-fold-core--check-spec (spec-or-alias)
"Throw an error if SPEC-OR-ALIAS is not in `org-fold-core--spec-priority-list'."
"Throw an error if SPEC-OR-ALIAS is not in `org-fold-core-folding-spec-list'."
(unless (org-fold-core-folding-spec-p spec-or-alias)
(error "%s is not a valid folding spec" spec-or-alias)))
@ -1033,6 +1033,26 @@ If SPEC-OR-ALIAS is omitted and FLAG is nil, unfold everything in the region."
(when spec (org-fold-core--check-spec spec))
(with-silent-modifications
(org-with-wide-buffer
;; Arrange face property of newlines after all the folds
;; between FROM and TO to match the first character before the
;; fold; not the last as per Emacs defaults. This makes
;; :extend faces span past the ellipsis.
;; See bug#65896.
(if flag ; folding
(when (equal ?\n (char-after to))
(put-text-property to (1+ to) 'face (get-text-property from 'face)))
;; unfolding
(dolist (region (org-fold-core-get-regions :from from :to to :specs spec))
(when (equal ?\n (char-after (cadr region)))
(if-let ((specs (remq spec (org-fold-core-get-folding-spec 'all (1- (cadr region))))))
;; There are multiple folds, re-apply 'face according
;; to the folds that will stay after unfolding SPEC.
(put-text-property
(cadr region) (1+ (cadr region)) 'face
(get-text-property
(car (org-fold-core-get-region-at-point (car specs) (1- (cadr region))))
'face))
(font-lock-flush (cadr region) (1+ (cadr region)))))))
(when (eq org-fold-core-style 'overlays)
(if org-fold-core--keep-overlays
(mapc
@ -1092,7 +1112,14 @@ If SPEC-OR-ALIAS is omitted and FLAG is nil, unfold everything in the region."
(setq pos next))
(setq pos (next-single-char-property-change pos 'invisible nil to)))))))
(when (eq org-fold-core-style 'text-properties)
(remove-text-properties from to (list (org-fold-core--property-symbol-get-create spec) nil)))))))))
(remove-text-properties from to (list (org-fold-core--property-symbol-get-create spec) nil)))
;; FROM..TO may represent only a part of the fold. Transfer
;; 'face from the new char before fold, if there is any.
(when-let ((trailing-fold (org-fold-core-get-region-at-point spec to)))
(when (equal ?\n (char-after (cdr trailing-fold)))
(put-text-property
(cdr trailing-fold) (1+ (cdr trailing-fold))
'face (get-text-property to 'face))))))))))
(cl-defmacro org-fold-core-regions (regions &key override clean-markers relative)
"Fold every region in REGIONS list in current buffer.

View File

@ -1362,10 +1362,17 @@ Use \"export %s\" instead"
(defun org-lint-named-result (ast)
(org-element-map ast org-element-all-elements
(lambda (el)
(when (and (org-element-property :results el)
(org-element-property :name el))
(list (org-element-begin el)
"#+name: in results of evaluation will be replaced by re-evaluating the src block. Use #+name in the block instead.")))))
(when-let* ((result (org-element-property :results el))
(result-name (org-element-property :name el))
(origin-block
(if (org-string-nw-p (car result))
(condition-case _
(org-export-resolve-link (car result) `(:parse-tree ,ast))
(org-link-broken nil))
(org-export-get-previous-element el nil))))
(when (org-element-type-p origin-block 'src-block)
(list (org-element-begin el)
(format "Links to \"%s\" will not be valid during export unless the parent source block has :exports results or both" result-name)))))))
(defun org-lint-spurious-colons (ast)
(org-element-map ast '(headline inlinetask)

View File

@ -269,11 +269,6 @@ This function is only useful when called from Agenda buffer."
(unless modified
(restore-buffer-modified-p nil))))))))
(defmacro org-no-popups (&rest body)
"Suppress popup windows and evaluate BODY."
`(let (pop-up-frames pop-up-windows)
,@body))
(defmacro org-element-with-disabled-cache (&rest body)
"Run BODY without active org-element-cache."
(declare (debug (form body)) (indent 0))
@ -296,12 +291,6 @@ FILE is the file name passed to `find-buffer-visiting'."
(find-buffer-visiting file))))
(org-base-buffer buf)))
(defun org-switch-to-buffer-other-window (&rest args)
"Switch to buffer in a second window on the current frame.
In particular, do not allow pop-up frames.
Returns the newly created buffer."
(org-no-popups (apply #'switch-to-buffer-other-window args)))
(defun org-fit-window-to-buffer (&optional window max-height min-height
shrink-only)
"Fit WINDOW to the buffer, but only if it is not a side-by-side window.
@ -764,7 +753,7 @@ alist with (\"key\" \"description\") entries. When one of these
is selected, only the bare key is returned."
(save-window-excursion
(let ((inhibit-quit t)
(buffer (org-switch-to-buffer-other-window "*Org Select*"))
(buffer (switch-to-buffer-other-window "*Org Select*"))
(prompt (or prompt "Select: "))
case-fold-search
current)
@ -1366,7 +1355,7 @@ STRING width. When REFERENCE-FACE is nil, `default' face is used."
;; FIXME: Fallback to old limited version, because
;; `window-pixel-width' is buggy in older Emacs.
(org--string-width-1 string)
;; Wrap/line prefix will make `window-text-pizel-size' return too
;; Wrap/line prefix will make `window-text-pixel-size' return too
;; large value including the prefix.
(remove-text-properties 0 (length string)
'(wrap-prefix t line-prefix t)

View File

@ -119,15 +119,16 @@ These are the regions where each line starts with a colon."
(defcustom org-src-preserve-indentation nil
"If non-nil preserve leading whitespace characters on export.
\\<org-mode-map>
If non-nil leading whitespace characters in source code blocks
are preserved on export, and when switching between the org
buffer and the language mode edit buffer.
When this variable is nil, after editing with `\\[org-edit-src-code]',
the minimum (across-lines) number of leading whitespace characters
are removed from all lines, and the code block is uniformly indented
according to the value of `org-edit-src-content-indentation'."
If non-nil leading whitespace characters in source code blocks are
preserved on export, or adjusted while indenting or when switching
between the org buffer and the language mode edit buffer.
When this variable is nil, while indenting with `\\[org-indent-block]'
or after editing with `\\[org-edit-src-code]', the minimum (across-lines)
number of leading whitespace characters are removed from all lines,
and the code block is uniformly indented according to the value of
`org-edit-src-content-indentation'."
:group 'org-edit-structure
:type 'boolean)
@ -958,7 +959,6 @@ INFO should be a list similar in format to the return value of
(interactive)
(let ((session (cdr (assq :session (nth 2 info)))))
(and session (not (string= session "none"))
(org-babel-comint-buffer-livep session)
(let ((f (intern (format "org-babel-%s-associate-session"
(nth 0 info)))))
(and (fboundp f) (funcall f session))))))
@ -1045,7 +1045,7 @@ Raise an error when current buffer is not a source editing buffer."
(`current-window (pop-to-buffer-same-window buffer))
(`other-window
(let ((cur-win (selected-window)))
(org-switch-to-buffer-other-window buffer)
(switch-to-buffer-other-window buffer)
(when (eq context 'exit) (quit-restore-window cur-win))))
(`split-window-below
(if (eq context 'exit)
@ -1069,7 +1069,7 @@ Raise an error when current buffer is not a source editing buffer."
(_ (switch-to-buffer-other-frame buffer))))
(`reorganize-frame
(when (eq context 'edit) (delete-other-windows))
(org-switch-to-buffer-other-window buffer)
(switch-to-buffer-other-window buffer)
(when (eq context 'exit) (delete-other-windows)))
(`switch-invisibly (set-buffer buffer))
(_

View File

@ -1924,8 +1924,8 @@ However, when N is 0, do not increment the field at all."
(let ((org-table-may-need-update nil)) (org-table-next-row))
(org-table-blank-field))
;; Insert the new field. NEW-FIELD may be nil if
;; `org-table-increment' is nil, or N = 0. In that case, copy
;; FIELD.
;; `org-table-copy-increment' is nil, or N = 0. In that case,
;; copy FIELD.
(insert (or next-field field))
(org-table-maybe-recalculate-line)
(org-table-align)))
@ -2051,7 +2051,7 @@ toggle `org-table-follow-field-mode'."
(cw (current-window-configuration))
p)
(goto-char pos)
(org-switch-to-buffer-other-window "*Org Table Edit Field*")
(switch-to-buffer-other-window "*Org Table Edit Field*")
(when (and (local-variable-p 'org-field-marker)
(markerp org-field-marker))
(move-marker org-field-marker nil))
@ -3362,7 +3362,7 @@ Parameters get priority."
(titles '((column . "# Column Formulas\n")
(field . "# Field and Range Formulas\n")
(named . "# Named Field Formulas\n"))))
(org-switch-to-buffer-other-window "*Edit Formulas*")
(switch-to-buffer-other-window "*Edit Formulas*")
(erase-buffer)
;; Keep global-font-lock-mode from turning on font-lock-mode
(let ((font-lock-global-modes '(not fundamental-mode)))
@ -4092,8 +4092,8 @@ already hidden."
"Read column selection select as a list of numbers.
SELECT is a string containing column ranges, separated by white
space characters, see `org-table-hide-column' for details. MAX
is the maximum column number.
space characters, see `org-table-toggle-column-width' for details.
MAX is the maximum column number.
Return value is a sorted list of numbers. Ignore any number
outside of the [1;MAX] range."
@ -4992,8 +4992,8 @@ When LOCAL is non-nil, show references for the table at point."
(if (and (markerp pos) (marker-buffer pos))
(if (get-buffer-window (marker-buffer pos))
(select-window (get-buffer-window (marker-buffer pos)))
(org-switch-to-buffer-other-window (get-buffer-window
(marker-buffer pos)))))
(switch-to-buffer-other-window (get-buffer-window
(marker-buffer pos)))))
(goto-char pos)
(org-table--force-dataline)
(let ((table-start

View File

@ -24,7 +24,7 @@
;;; Commentary:
;;
;; Org Tempo reimplements completions of structure template before
;; point like `org-try-structure-completion' in Org v9.1 and earlier.
;; point in Org v9.1 and earlier.
;; For example, strings like "<e" at the beginning of the line will be
;; expanded to an example block.
;;

View File

@ -3187,7 +3187,12 @@ A nil value means to remove them, after a query, from the list."
(default-value var)))
(defcustom org-latex-default-packages-alist
'(("AUTO" "inputenc" t ("pdflatex"))
'(;; amsmath before fontspec for lualatex and xetex
("" "amsmath" t ("lualatex" "xetex"))
;; fontspec ASAP for lualatex and xetex
("" "fontspec" t ("lualatex" "xetex"))
;; inputenc and fontenc are for pdflatex only
("AUTO" "inputenc" t ("pdflatex"))
("T1" "fontenc" t ("pdflatex"))
("" "hyperref" nil))
"Alist of default packages to be inserted in the header.
@ -3198,6 +3203,9 @@ incompatibility with another package you are using.
The packages in this list are needed by one part or another of
Org mode to function properly:
- amsmath: for subscript and superscript and math environments
(automatically added when needed with pdflatex).
- fontspec: for font and character selection in lualatex and xetex
- inputenc, fontenc: for basic font and character selection
- wrapfig: for figure placement
- rotating: for sideways figures and tables
@ -3831,6 +3839,8 @@ After a match, the following groups carry important information:
("align" org-startup-align-all-tables t)
("noalign" org-startup-align-all-tables nil)
("shrink" org-startup-shrink-all-tables t)
("descriptivelinks" org-link-descriptive t)
("literallinks" org-link-descriptive nil)
("inlineimages" org-startup-with-inline-images t)
("noinlineimages" org-startup-with-inline-images nil)
("latexpreview" org-startup-with-latex-preview t)
@ -4617,6 +4627,17 @@ The following commands are available:
(org-load-modules-maybe)
(when org-agenda-file-menu-enabled
(org-install-agenda-files-menu))
(setq-local outline-regexp org-outline-regexp)
(setq-local outline-level 'org-outline-level)
;; Initialize cache.
(org-element-cache-reset)
(when (and org-element-cache-persistent
org-element-use-cache)
(org-persist-load
`((elisp org-element--cache) (version ,org-element-cache-version))
(current-buffer)
'match-hash :read-related t))
(org-set-regexps-and-options)
(when (and org-link-descriptive
(eq org-fold-core-style 'overlays))
(add-to-invisibility-spec '(org-link)))
@ -4627,8 +4648,6 @@ The following commands are available:
(if org-link-descriptive
(org-fold-core-set-folding-spec-property (car org-link--link-folding-spec) :visible nil)
(org-fold-core-set-folding-spec-property (car org-link--link-folding-spec) :visible t))
(setq-local outline-regexp org-outline-regexp)
(setq-local outline-level 'org-outline-level)
(when (and (stringp org-ellipsis) (not (equal "" org-ellipsis)))
(unless org-display-table
(setq org-display-table (make-display-table)))
@ -4637,15 +4656,6 @@ The following commands are available:
(vconcat (mapcar (lambda (c) (make-glyph-code c 'org-ellipsis))
org-ellipsis)))
(setq buffer-display-table org-display-table))
;; Initialize cache.
(org-element-cache-reset)
(when (and org-element-cache-persistent
org-element-use-cache)
(org-persist-load
`((elisp org-element--cache) (version ,org-element-cache-version))
(current-buffer)
'match-hash :read-related t))
(org-set-regexps-and-options)
(org-set-font-lock-defaults)
(when (and org-tag-faces (not org-tags-special-faces-re))
;; tag faces set outside customize.... force initialization.
@ -7295,6 +7305,8 @@ Assume buffer is widened and point is on a headline."
(replace-regexp-in-string
"\\[[0-9]+%\\]\\|\\[[0-9]+/[0-9]+\\]" ""
(match-string-no-properties 4))))))))
(when (org-element-property :commentedp (org-element-at-point))
(setq heading (replace-regexp-in-string (format "^%s[ \t]*" org-comment-string) "" heading)))
(if (org-up-heading-safe)
(let ((path (cons heading (org--get-outline-path-1 use-cache))))
(when use-cache
@ -8234,7 +8246,16 @@ Raise a user error when there is nothing to follow."
(interactive)
(let ((tap-url (thing-at-point 'url))
(tap-email (thing-at-point 'email)))
(cond ((org-in-regexp org-link-any-re)
(cond ((org-in-regexp
org-link-any-re
(let ((origin (point)))
(max
(save-excursion
(backward-paragraph)
(count-lines (point) origin))
(save-excursion
(forward-paragraph)
(count-lines origin (point))))))
(org-link-open-from-string (match-string-no-properties 0)))
((or (org-in-regexp org-ts-regexp-both nil t)
(org-in-regexp org-tsr-regexp-both nil t))
@ -9553,49 +9574,56 @@ statistics everywhere."
(while (re-search-forward box-re (line-end-position) t)
(setq cnt-all 0 cnt-done 0 cookie-present t)
(setq is-percent (match-end 2) checkbox-beg (match-beginning 0))
(save-match-data
(unless (outline-next-heading) (throw 'exit nil))
(while (and (looking-at org-complex-heading-regexp)
(> (setq l1 (length (match-string 1))) level))
(setq kwd (and (or recursive (= l1 ltoggle))
(match-string 2)))
(if (or (eq org-provide-todo-statistics 'all-headlines)
(and (eq org-provide-todo-statistics t)
(or (member kwd org-done-keywords)))
(and (listp org-provide-todo-statistics)
(stringp (car org-provide-todo-statistics))
(or (member kwd org-provide-todo-statistics)
(member kwd org-done-keywords)))
(and (listp org-provide-todo-statistics)
(listp (car org-provide-todo-statistics))
(or (member kwd (car org-provide-todo-statistics))
(and (member kwd org-done-keywords)
(member kwd (cadr org-provide-todo-statistics))))))
(setq cnt-all (1+ cnt-all))
(and (eq org-provide-todo-statistics t)
kwd
(setq cnt-all (1+ cnt-all))))
(when (or (and (member org-provide-todo-statistics '(t all-headlines))
(member kwd org-done-keywords))
(when (org-element-type-p
(save-excursion
(goto-char checkbox-beg)
(save-match-data (org-element-context)))
'(statistics-cookie
;; Special case - statistics cookie inside properties.
keyword))
(save-match-data
(unless (outline-next-heading) (throw 'exit nil))
(while (and (looking-at org-complex-heading-regexp)
(> (setq l1 (length (match-string 1))) level))
(setq kwd (and (or recursive (= l1 ltoggle))
(match-string 2)))
(if (or (eq org-provide-todo-statistics 'all-headlines)
(and (eq org-provide-todo-statistics t)
(or (member kwd org-done-keywords)))
(and (listp org-provide-todo-statistics)
(stringp (car org-provide-todo-statistics))
(or (member kwd org-provide-todo-statistics)
(member kwd org-done-keywords)))
(and (listp org-provide-todo-statistics)
(listp (car org-provide-todo-statistics))
(member kwd org-done-keywords)
(member kwd (cadr org-provide-todo-statistics)))
(and (listp org-provide-todo-statistics)
(stringp (car org-provide-todo-statistics))
(member kwd org-done-keywords)))
(setq cnt-done (1+ cnt-done)))
(outline-next-heading)))
(setq new
(if is-percent
(format "[%d%%]" (floor (* 100.0 cnt-done)
(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)))
(or (member kwd (car org-provide-todo-statistics))
(and (member kwd org-done-keywords)
(member kwd (cadr org-provide-todo-statistics))))))
(setq cnt-all (1+ cnt-all))
(and (eq org-provide-todo-statistics t)
kwd
(setq cnt-all (1+ cnt-all))))
(when (or (and (member org-provide-todo-statistics '(t all-headlines))
(member kwd org-done-keywords))
(and (listp org-provide-todo-statistics)
(listp (car org-provide-todo-statistics))
(member kwd org-done-keywords)
(member kwd (cadr org-provide-todo-statistics)))
(and (listp org-provide-todo-statistics)
(stringp (car org-provide-todo-statistics))
(member kwd org-done-keywords)))
(setq cnt-done (1+ cnt-done)))
(outline-next-heading)))
(setq new
(if is-percent
(format "[%d%%]" (floor (* 100.0 cnt-done)
(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))))
(when cookie-present
(run-hook-with-args 'org-after-todo-statistics-hook
cnt-done (- cnt-all cnt-done))))))
@ -9704,7 +9732,7 @@ where CURRENT-TODO-KEYWORD belongs over on in another sequence."
(set-buffer (get-buffer-create " *Org todo*"))
(delete-other-windows)
(set-window-buffer (split-window-vertically) (get-buffer-create " *Org todo*"))
(org-switch-to-buffer-other-window " *Org todo*"))
(switch-to-buffer-other-window " *Org todo*"))
;; Fill text in *Org todo* buffer.
(erase-buffer)
;; Copy `org-done-keywords' from the original Org buffer to be
@ -10432,7 +10460,7 @@ items are State notes."
(move-marker org-log-note-return-to (point))
(pop-to-buffer-same-window (marker-buffer org-log-note-marker))
(goto-char org-log-note-marker)
(org-switch-to-buffer-other-window "*Org Note*")
(switch-to-buffer-other-window "*Org Note*")
(erase-buffer)
(if (memq org-log-note-how '(time state))
(org-store-log-note)
@ -11854,7 +11882,7 @@ Returns the new tags string, or nil to not change the current settings."
(set-buffer (get-buffer-create " *Org tags*"))
(delete-other-windows)
(set-window-buffer (split-window-vertically) (get-buffer-create " *Org tags*"))
(org-switch-to-buffer-other-window " *Org tags*"))
(switch-to-buffer-other-window " *Org tags*"))
;; Fill text in *Org tags* buffer.
(erase-buffer)
(setq-local org-done-keywords done-keywords)
@ -11998,7 +12026,7 @@ Returns the new tags string, or nil to not change the current settings."
(setq expert-interface nil)
(delete-other-windows)
(set-window-buffer (split-window-vertically) " *Org tags*")
(org-switch-to-buffer-other-window " *Org tags*")
(switch-to-buffer-other-window " *Org tags*")
(org-fit-window-to-buffer)))
;; Quit.
((or ?\C-g
@ -15214,7 +15242,7 @@ used by the agenda files. If ARCHIVE is `ifmode', do this only if
(when (or (eq archives t)
(and (eq archives 'ifmode) (eq org-agenda-archives-mode t)))
(setq files (org-add-archive-files files)))
files))
(delete-dups files)))
(defun org-agenda-file-p (&optional file)
"Return non-nil, if FILE is an agenda file.

View File

@ -4,7 +4,7 @@
;; Author: Carsten Dominik <carsten.dominik@gmail.com>
;; Nicolas Goaziou <mail@nicolasgoaziou.fr>
;; Maintainer: Nicolas Goaziou <mail@nicolasgoaziou.fr>
;; Maintainer: Jack Kamm <jackkamm@gmail.com>
;; Keywords: outlines, hypermedia, calendar, wp
;; URL: https://orgmode.org
@ -331,6 +331,32 @@ Interesting value are:
(const :tag "Universal time" ":%Y%m%dT%H%M%SZ")
(string :tag "Explicit format")))
(defcustom org-icalendar-ttl nil
"Time to live for the exported calendar.
Subscribing clients to the exported ics file can derive the time
interval to read the file again from the server. One example of such
client is Nextcloud calendar, which respects the setting of
X-PUBLISHED-TTL in ICS files. Setting `org-icalendar-ttl' to \"PT1H\"
would advise a server to reload the file every hour.
See https://icalendar.org/iCalendar-RFC-5545/3-8-2-5-duration.html
for a complete description of possible specifications of this
option. For example, \"PT1H\" stands for 1 hour and
\"PT0H27M34S\" stands for 0 hours, 27 minutes and 34 seconds.
The default value is nil, which means no such option is set in
the ICS file. This option can also be set on a per-document basis
with the ICAL-TTL export keyword."
:group 'org-export-icalendar
:type '(choice
(const :tag "No refresh period" nil)
(const :tag "One hour" "PT1H")
(const :tag "One day" "PT1D")
(const :tag "One week" "PT7D")
(string :tag "Other"))
:package-version '(Org . "9.7"))
(defvar org-icalendar-after-save-hook nil
"Hook run after an iCalendar file has been saved.
This hook is run with the name of the file as argument. A good
@ -368,7 +394,8 @@ re-read the iCalendar file.")
(:icalendar-use-deadline nil nil org-icalendar-use-deadline)
(:icalendar-use-scheduled nil nil org-icalendar-use-scheduled)
(:icalendar-scheduled-summary-prefix nil nil org-icalendar-scheduled-summary-prefix)
(:icalendar-deadline-summary-prefix nil nil org-icalendar-deadline-summary-prefix))
(:icalendar-deadline-summary-prefix nil nil org-icalendar-deadline-summary-prefix)
(:icalendar-ttl "ICAL-TTL" nil org-icalendar-ttl))
:filters-alist
'((:filter-headline . org-icalendar-clear-blank-lines))
:menu-entry
@ -643,13 +670,15 @@ inlinetask within the section."
(let ((todo-type (org-element-property :todo-type entry))
(uid (or (org-element-property :ID entry) (org-id-new)))
(summary (org-icalendar-cleanup-string
(or (org-element-property :SUMMARY entry)
(org-export-data
(org-element-property :title entry) info))))
(loc (org-icalendar-cleanup-string
(org-export-get-node-property
:LOCATION entry
(org-property-inherit-p "LOCATION"))))
(or
(let ((org-property-separators '(("SUMMARY" . "\n"))))
(org-entry-get entry "SUMMARY" 'selective))
(org-export-data
(org-element-property :title entry) info))))
(loc
(let ((org-property-separators '(("LOCATION" . "\n"))))
(org-icalendar-cleanup-string
(org-entry-get entry "LOCATION" 'selective))))
(class (org-icalendar-cleanup-string
(org-export-get-node-property
:CLASS entry
@ -658,7 +687,8 @@ inlinetask within the section."
;; (headline) or contents (inlinetask).
(desc
(org-icalendar-cleanup-string
(or (org-element-property :DESCRIPTION entry)
(or (let ((org-property-separators '(("DESCRIPTION" . "\n"))))
(org-entry-get entry "DESCRIPTION" 'selective))
(let ((contents (org-export-data inside info)))
(cond
((not (org-string-nw-p contents)) nil)
@ -1018,25 +1048,30 @@ as a communication channel."
(or (org-string-nw-p org-icalendar-timezone) (format-time-string "%Z"))
;; Description.
(org-export-data (plist-get info :title) info)
;; TTL
(plist-get info :icalendar-ttl)
contents))
(defun org-icalendar--vcalendar (name owner tz description contents)
(defun org-icalendar--vcalendar (name owner tz description ttl contents)
"Create a VCALENDAR component.
NAME, OWNER, TZ, DESCRIPTION and CONTENTS are all strings giving,
NAME, OWNER, TZ, DESCRIPTION, TTL and CONTENTS are all strings giving,
respectively, the name of the calendar, its owner, the timezone
used, a short description and the other components included."
used, a short description, time to live (refresh period) and
the other components included."
(org-icalendar-fold-string
(concat (format "BEGIN:VCALENDAR
VERSION:2.0
X-WR-CALNAME:%s
PRODID:-//%s//Emacs with Org mode//EN
X-WR-TIMEZONE:%s
X-WR-CALDESC:%s
CALSCALE:GREGORIAN\n"
X-WR-CALDESC:%s\n"
(org-icalendar-cleanup-string name)
(org-icalendar-cleanup-string owner)
(org-icalendar-cleanup-string tz)
(org-icalendar-cleanup-string description))
(when ttl (format "X-PUBLISHED-TTL:%s\n"
(org-icalendar-cleanup-string ttl)))
"CALSCALE:GREGORIAN\n"
contents
"END:VCALENDAR\n")))
@ -1164,6 +1199,7 @@ This function assumes major mode for current buffer is
user-full-name
(or (org-string-nw-p org-icalendar-timezone) (format-time-string "%Z"))
org-icalendar-combined-description
org-icalendar-ttl
contents)))
(org-icalendar--post-process-file file)))
@ -1188,6 +1224,8 @@ FILES is a list of files to build the calendar from."
(format-time-string "%Z"))
;; Description.
org-icalendar-combined-description
;; TTL (Refresh period)
org-icalendar-ttl
;; Contents.
(concat
;; Agenda contents.

View File

@ -176,8 +176,13 @@
`((t !announce-start !announce-end
!guess-pollyglossia !guess-babel !guess-inputenc)
(,(lambda (info)
(org-element-map (plist-get info :parse-tree)
'(latex-fragment latex-environment) #'identity info t))
;; Since amsmath is added unconditionally when using
;; xelatex/lualatex (see `org-latex-default-packages-alist'),
;; and amssymb is not needed, we need not bother when using
;; thoese compilers.
(and (not (member (plist-get info :latex-compiler) '("xelatex" "lualatex")))
(org-element-map (plist-get info :parse-tree)
'(latex-fragment latex-environment) #'identity info t)))
maths)
(,(lambda (info)
(org-element-map (plist-get info :parse-tree)
@ -1070,7 +1075,7 @@ The most comprehensive option can be set with,
which causes source code to be run through
`engrave-faces-latex-buffer', which generates colorings using
Emacs' font-lock information. This requires the Emacs package
engrave-faces (available from ELPA), and the LaTeX package
engrave-faces (available from GNU ELPA), and the LaTeX package
fvextra be installed.
The styling of the engraved result can be customized with
@ -1374,9 +1379,10 @@ block-specific options, you may use the following syntax:
(defcustom org-latex-engraved-theme nil
"The theme that should be used for engraved code, when non-nil.
This can be set to any theme defined in `engrave-faces-themes' or
loadable by Emacs. When set to t, the current Emacs theme is
used. When nil, no theme is applied."
This can be set to any theme defined in `engrave-faces-themes'
(from the engrave-faces package) or loadable by Emacs. When set
to t, the current Emacs theme is used. When nil, no theme is
applied."
:group 'org-export-latex
:package-version '(Org . "9.6")
:type 'symbol)
@ -1448,7 +1454,8 @@ default values of which are given by `org-latex-engraved-preamble' and
\\floatname{listing}{\\listingsname}
\\newcommand{\\listoflistingsname}{List of Listings}
\\providecommand{\\listoflistings}{\\listof{listing}{\\listoflistingsname}}\n"
(if (memq 'src-block org-latex-caption-above)
(if (org-latex--caption-above-p
(org-element-create 'src-block) info)
"plaintop" "plain"))
t t
engraved-preamble)))
@ -2962,9 +2969,10 @@ CONTENTS is nil. INFO is a plist holding contextual information."
(org-latex--label latex-environment info nil t)
(org-latex--caption/label-string latex-environment info)))
(caption-above-p
(memq type (append (plist-get info :latex-caption-above) '(math)))))
(or (eq type 'math)
(org-latex--caption-above-p latex-environment info))))
(if (not (or (org-element-property :name latex-environment)
(org-element-property :caption latex-environment)))
(org-element-property :caption latex-environment)))
value
;; Environment is labeled: label must be within the environment
;; (otherwise, a reference pointing to that element will count
@ -4016,7 +4024,7 @@ CONTENTS is the contents of the object."
;; takes care of tables with a "verbatim" mode. Otherwise, it
;; delegates the job to either `org-latex--table.el-table',
;; `org-latex--org-table', `org-latex--math-table' or
;; `org-latex--org-tabbing' functions,
;; `org-latex--org-align-string-tabbing' functions,
;; depending of the type of the table and the mode requested.
;;
;; `org-latex--align-string' is a subroutine used to build alignment

View File

@ -3249,8 +3249,9 @@ Return a cons of (TABLE-CELL-STYLE-NAME . PARAGRAPH-STYLE-NAME).
When STYLE-SPEC is nil, style the table cell the conventional way
- choose cell borders based on row and column groupings and
choose paragraph alignment based on `org-col-cookies' text
property. See also `org-odt-table-style-spec'.
choose paragraph alignment based on table alignment cookies (see info
node `(org)Column Width and Alignment'). See also
`org-odt-table-style-spec'.
When STYLE-SPEC is non-nil, ignore the above cookie and return
styles congruent with the ODF-1.2 specification."

View File

@ -1698,11 +1698,10 @@ an alist where associations are (VARIABLE-NAME VALUE)."
;; `org-export--collect-tree-properties'.
;;
;; Dedicated functions focus on computing the value of specific tree
;; properties during initialization. Thus,
;; `org-export--populate-ignore-list' lists elements and objects that
;; should be skipped during export, `org-export--get-min-level' gets
;; the minimal exportable level, used as a basis to compute relative
;; level for headlines. Eventually
;; properties during initialization. Thus, `org-export--prune-tree'
;; lists elements and objects that should be skipped during export,
;; `org-export--get-min-level' gets the minimal exportable level, used
;; as a basis to compute relative level for headlines. Eventually
;; `org-export--collect-headline-numbering' builds an alist between
;; headlines and their numbering.
@ -5406,7 +5405,10 @@ objects of the same type."
(lambda (el)
(let ((cached (org-element-property :org-export--counter el)))
(cond
((eq element el) (1+ counter))
((and (eq element el)
(or (not predicate)
(funcall predicate el info)))
(1+ counter))
;; Use cached result.
((and cached
(equal predicate (car cached))
@ -6464,7 +6466,7 @@ INFO is the current export state, as a plist."
(let ((table (make-hash-table :test #'eq)))
(plist-put info :smart-quote-cache table)
table)))
(value (gethash parent cache 'missing-data)))
(value (gethash (cons parent (org-element-secondary-p s)) cache 'missing-data)))
(if (not (eq value 'missing-data)) (cdr (assq s value))
(let (level1-open full-status)
(org-element-map
@ -6532,7 +6534,7 @@ INFO is the current export state, as a plist."
(when current-status
(push (cons text (nreverse current-status)) full-status))))
info nil org-element-recursive-objects)
(puthash parent full-status cache)
(puthash (cons parent (org-element-secondary-p s)) full-status cache)
(cdr (assq s full-status))))))
(defun org-export-activate-smart-quotes (s encoding info &optional original)
@ -7518,8 +7520,8 @@ within Emacs."
(interactive "P")
(let ((source (org-export--stack-source-at-point)))
(cond ((processp source)
(org-switch-to-buffer-other-window (process-buffer source)))
((bufferp source) (org-switch-to-buffer-other-window source))
(switch-to-buffer-other-window (process-buffer source)))
((bufferp source) (switch-to-buffer-other-window source))
(t (org-open-file source in-emacs)))))
(defvar org-export-stack-mode-map
@ -7863,7 +7865,7 @@ back to standard interface."
;; At first call, create frame layout in order to display menu.
(unless (get-buffer "*Org Export Dispatcher*")
(delete-other-windows)
(org-switch-to-buffer-other-window
(switch-to-buffer-other-window
(get-buffer-create "*Org Export Dispatcher*"))
(setq cursor-type nil)
(setq header-line-format

View File

@ -0,0 +1,9 @@
@book{friends,
title = {{{LaTeX}} and Friends},
author = {van Dongen, M.R.C.},
date = {2012},
location = {Berlin},
publisher = {Springer},
doi = {10.1007/978-3-642-23816-1},
isbn = {9783642238161}
}

View File

@ -0,0 +1,8 @@
* TODO one
SCHEDULED: <2024-01-17 Wed 09:30-10:00>
* TODO two
SCHEDULED: <2024-01-17 Wed 10:00-12:30>
* TODO three
SCHEDULED: <2024-01-17 Wed 13:00-15:00>
* TODO four
SCHEDULED: <2024-01-17 Wed 19:00>

View File

@ -553,6 +553,20 @@ another block
(org-split-string (buffer-string))))
(delete-file file))))))
(ert-deftest ob-tangle/tangle-to-self ()
"Do not allow tangling into self."
(let ((file (make-temp-file "org-tangle-" nil ".org")))
(unwind-protect
(with-current-buffer (find-file-noselect file)
(insert
(format "
#+begin_src elisp :tangle %s
2
#+end_src
" file))
(should-error (org-babel-tangle)))
(delete-file file))))
(ert-deftest ob-tangle/detangle-false-positive ()
"Test handling of false positive link during detangle."
(let (buffer)

View File

@ -0,0 +1,160 @@
;;; test-oc-basic.el --- Tests for Org Cite basic processor -*- lexical-binding: t; -*-
;; Copyright (C) 2024 Ihor Radchenko
;; Author: Ihor Radchenko <yantar92 at posteo dot net>
;; 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 for Org cite basic processor.
;;; Code:
(require 'oc-basic)
(ert-deftest test-org-cite-basic/parse-bibliography ()
"Test `org-cite-basic--parse-bibliography'."
;; Bibtex bibliography.
(org-test-with-temp-text
(format "#+bibliography: %s"
(expand-file-name "examples/Basic.bib" org-test-dir))
(let ((data (org-cite-basic--parse-bibliography)))
(should (= 1 (length data)))
(should (equal (expand-file-name "examples/Basic.bib" org-test-dir)
(caar data)))
(dolist (k (hash-table-keys (cdar data)))
(when (equal k "friends")
(should (equal (gethash k (cdar data))
'((type . "book")
(id . "friends")
(title . "{{LaTeX}} and Friends")
(author . "van Dongen, M.R.C.")
(date . "2012")
(location . "Berlin")
(publisher . "Springer")
(doi . "10.1007/978-3-642-23816-1")
(isbn . "9783642238161")))))))))
(ert-deftest test-org-cite-basic/export-citation ()
"Test `org-cite-basic-export-citation'."
;; Default "nil" citation style.
(org-test-with-temp-text
(format
"#+bibliography: %s
#+cite_export: basic
Default: [cite:Citing ; @friends; and @friends also; is duplication.]"
(expand-file-name "examples/Basic.bib" org-test-dir))
(let ((export-buffer "*Test ASCII Export*")
(org-export-show-temporary-export-buffer nil))
(org-export-to-buffer 'ascii export-buffer)
(with-current-buffer export-buffer
(let ((case-fold-search t))
(search-forward "Default: (Citing van Dongen, M.R.C., 2012, and van Dongen, M.R.C., 2012
also is duplication.)" nil t)))))
;; "author" citation style.
(org-test-with-temp-text
(format
"#+bibliography: %s
#+cite_export: basic
Author: [cite/a:Citing ; @friends; and @friends also; is duplication.]"
(expand-file-name "examples/Basic.bib" org-test-dir))
(let ((export-buffer "*Test ASCII Export*")
(org-export-show-temporary-export-buffer nil))
(org-export-to-buffer 'ascii export-buffer)
(with-current-buffer export-buffer
(let ((case-fold-search t))
(should
(search-forward "Author: Citing van Dongen, M.R.C., and van Dongen, M.R.C. also is
duplication." nil t))))))
;; "note" citation style.
(org-test-with-temp-text
(format
"#+bibliography: %s
#+cite_export: basic
Note: [cite/ft:Citing ; @friends; and @friends also; is duplication.]"
(expand-file-name "examples/Basic.bib" org-test-dir))
(let ((export-buffer "*Test ASCII Export*")
(org-export-show-temporary-export-buffer nil))
(org-export-to-buffer 'ascii export-buffer)
(with-current-buffer export-buffer
(let ((case-fold-search t))
(should
(search-forward "[1] Citing van Dongen, M.R.C. (2012), and van Dongen, M.R.C. (2012) also
is duplication." nil t))))))
;; "nocite" citation style.
(org-test-with-temp-text
(format
"#+bibliography: %s
#+cite_export: basic
Nocite (should be blank): [cite/n:Citing ; @friends; and @friends also; is duplication.]"
(expand-file-name "examples/Basic.bib" org-test-dir))
(let ((export-buffer "*Test ASCII Export*")
(org-export-show-temporary-export-buffer nil))
(org-export-to-buffer 'ascii export-buffer)
(with-current-buffer export-buffer
(let ((case-fold-search t))
(should (search-forward "Nocite (should be blank):\n" nil t))
(goto-char (point-min))
(should-not (search-forward "2012" nil t))
(goto-char (point-min))
(should-not (search-forward "Dongen" nil t))))))
;; "noauthor" citation style.
(org-test-with-temp-text
(format
"#+bibliography: %s
#+cite_export: basic
Noauthor: [cite/na:Citing ; @friends; and @friends also; is duplication.]"
(expand-file-name "examples/Basic.bib" org-test-dir))
(let ((export-buffer "*Test ASCII Export*")
(org-export-show-temporary-export-buffer nil))
(org-export-to-buffer 'ascii export-buffer)
(with-current-buffer export-buffer
(let ((case-fold-search t))
(should
(search-forward "Noauthor: (Citing 2012, and 2012 also is duplication.)" nil t))))))
;; "numeric" citation style.
(org-test-with-temp-text
(format
"#+bibliography: %s
#+cite_export: basic
Numeric (should \"use global affixes and ignore local ones\"): [cite/nb:Citing ; @friends; and @friends also; is duplication.]"
(expand-file-name "examples/Basic.bib" org-test-dir))
(let ((export-buffer "*Test ASCII Export*")
(org-export-show-temporary-export-buffer nil))
(org-export-to-buffer 'ascii export-buffer)
(with-current-buffer export-buffer
(let ((case-fold-search t))
(should
(search-forward "Numeric (should \"use global affixes and ignore local ones\"): (Citing 1,
1 is duplication.)" nil t))))))
;; "text" citation style.
(org-test-with-temp-text
(format
"#+bibliography: %s
#+cite_export: basic
Text: [cite/t: Citing ; @friends; and @friends also; is duplication.]"
(expand-file-name "examples/Basic.bib" org-test-dir))
(let ((export-buffer "*Test ASCII Export*")
(org-export-show-temporary-export-buffer nil))
(org-export-to-buffer 'ascii export-buffer)
(with-current-buffer export-buffer
(let ((case-fold-search t))
(should
(search-forward "Text: Citing van Dongen, M.R.C. (2012), and van Dongen, M.R.C. (2012)
also is duplication." nil t)))))))
(provide 'test-oc-basic)
;;; test-oc-basic.el ends here

View File

@ -80,6 +80,100 @@
(should (= 3 (count-lines (point-min) (point-max)))))
(org-test-agenda--kill-all-agendas))
(ert-deftest test-org-agenda/time-grid ()
"Test time grid settings."
(cl-assert (not org-agenda-sticky) nil "precondition violation")
(cl-assert (not (org-test-agenda--agenda-buffers))
nil "precondition violation")
;; Default time grid.
(org-test-at-time "2024-01-17 8:00"
(let ((org-agenda-span 'day)
(org-agenda-files `(,(expand-file-name "examples/agenda-file2.org"
org-test-dir))))
;; 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-17 Fri>")
(set-buffer org-agenda-buffer-name)
(save-excursion
(goto-char (point-min))
(should (search-forward "8:00...... now - - - - - - - - - - - - - - - - - - - - - - - - -")))
(save-excursion
(goto-char (point-min))
(should (search-forward "agenda-file2: 9:30-10:00 Scheduled: TODO one")))
(save-excursion
(goto-char (point-min))
(should (search-forward "agenda-file2:10:00-12:30 Scheduled: TODO two")))
(save-excursion
(goto-char (point-min))
(should (search-forward "10:00...... ----------------")))
(save-excursion
(goto-char (point-min))
(should (search-forward "agenda-file2:13:00-15:00 Scheduled: TODO three")))
(save-excursion
(goto-char (point-min))
(should (search-forward "agenda-file2:19:00...... Scheduled: TODO four"))))
(org-test-agenda--kill-all-agendas))
;; Custom time grid strings
(org-test-at-time "2024-01-17 8:00"
(let ((org-agenda-span 'day)
(org-agenda-files `(,(expand-file-name "examples/agenda-file2.org"
org-test-dir)))
(org-agenda-time-grid '((daily today require-timed)
(800 1000 1200 1400 1600 1800 2000)
"..." "^^^^^^^^^^^^^^" )))
;; 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-17 Fri>")
(set-buffer org-agenda-buffer-name)
(save-excursion
(goto-char (point-min))
(should (search-forward "10:00... ^^^^^^^^^^^^^^"))))
(org-test-agenda--kill-all-agendas))
;; Time grid remove-match
(org-test-at-time "2024-01-17 8:00"
(let ((org-agenda-span 'day)
(org-agenda-files `(,(expand-file-name "examples/agenda-file2.org"
org-test-dir)))
(org-agenda-time-grid '((today remove-match)
(800 1000 1200 1400 1600 1800 2000)
"......" "----------------" )))
;; 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-17 Fri>")
(set-buffer org-agenda-buffer-name)
(save-excursion
(goto-char (point-min))
(should (search-forward "agenda-file2: 9:30-10:00 Scheduled: TODO one")))
(save-excursion
(goto-char (point-min))
(should-not (search-forward "10:00...... ----------------" nil t))))
(org-test-agenda--kill-all-agendas))
;; Time grid with `org-agenda-default-appointment-duration'
(org-test-at-time "2024-01-17 8:00"
(let ((org-agenda-span 'day)
(org-agenda-files `(,(expand-file-name "examples/agenda-file2.org"
org-test-dir)))
(org-agenda-time-grid '((today remove-match)
(800 1000 1200 1400 1600 1800 2000)
"......" "----------------" ))
(org-agenda-default-appointment-duration 60))
;; 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-17 Fri>")
(set-buffer org-agenda-buffer-name)
(save-excursion
(goto-char (point-min))
(should (search-forward "agenda-file2:19:00-20:00 Scheduled: TODO four")))
;; Bug https://list.orgmode.org/orgmode/20211119135325.7f3f85a9@hsu-hh.de/
(save-excursion
(goto-char (point-min))
(should (search-forward "14:00...... ----------------"))))
(org-test-agenda--kill-all-agendas)))
(ert-deftest test-org-agenda/todo-selector ()
"Test selecting keywords in `org-todo-list'."
(cl-assert (not org-agenda-sticky) nil "precondition violation")

View File

@ -2780,7 +2780,16 @@ test <point>
(org-get-outline-path)))
(should
(org-test-with-temp-text "* \n** H<point>"
(org-get-outline-path))))
(org-get-outline-path)))
;; Remove COMMENTED keywords.
(should
(equal '("This" "is")
(org-test-with-temp-text
"* COMMENT This
** COMMENT is
*** test<point>
"
(org-get-outline-path)))))
(ert-deftest test-org/format-outline-path ()
"Test `org-format-outline-path' specifications."

View File

@ -445,12 +445,12 @@ Paragraph"
(should (= 1 (org-export-get-ordinal table info)))
(should (= 2 (org-export-get-ordinal table info '(section))))
(should (= 1 (org-export-get-ordinal table info nil #'org-ascii--has-caption-p)))
(should (= 1 (org-export-get-ordinal table info nil from-third))))
(should-not (org-export-get-ordinal table info nil from-third)))
("Should be Table 2"
(should (= 2 (org-export-get-ordinal table info)))
(should (= 3 (org-export-get-ordinal table info '(section))))
(should (= 2 (org-export-get-ordinal table info nil #'org-ascii--has-caption-p)))
(should (= 1 (org-export-get-ordinal table info nil from-third))))
(should-not (org-export-get-ordinal table info nil from-third)))
("Should be Table 3"
(should (= 3 (org-export-get-ordinal table info)))
(should (= 4 (org-export-get-ordinal table info '(section))))
@ -4343,6 +4343,14 @@ This test does not cover listings and custom environments."
(org-element-map tree 'plain-text
(lambda (s) (org-export-activate-smart-quotes s :html info))
info)))))
;; Smart quotes when object has multiple secondary strings.
(should
(equal '(" &ldquo;prefix&rdquo; " " &ldquo;suffix&rdquo;")
(let ((org-export-default-language "en"))
(org-test-with-parsed-data "[cite:; \"prefix\" @key \"suffix\";]"
(org-element-map tree 'plain-text
(lambda (s) (org-export-activate-smart-quotes s :html info))
info)))))
;; Smart quotes in document keywords.
(should
(equal '("&ldquo;" "&rdquo;")