Compare commits

...

86 Commits
dev ... main

Author SHA1 Message Date
Max Nikulin b4d17c0629
ORG-NEWS: Reword inline image width note
* etc/ORG-NEWS: Avoid possible confusion related to
"#+attr_org: :width" example.
2024-05-13 15:40:02 +03:00
Ihor Radchenko f326cd58ba
org-display-inline-image--width: Fix unparable non #+ATTR_ORG widths
* lisp/org.el (org-display-inline-image--width): When there are
multiple #+ATTR_BACKEND :width attributes, skip over all the
attributes that cannot be parser to a number.  This way

 #+attr_html: :alt Image width test
 #+attr_beamer: :width \linewidth
 #+attr_latex: :width +.5\textwidth
 #+attr_md: :width 75%
 [[file:~/Downloads/wallpaper.png]]

will get +.5 relative width even though #+attr_beamer does specify
some :width value (not a number).

Reported-by: Max Nikulin <manikulin@gmail.com>
Link: https://orgmode.org/list/875xvoshex.fsf@localhost
2024-05-13 15:36:13 +03:00
Ihor Radchenko aa71facf6d
Respect `org-auto-align-tags' in all the editing commands
* lisp/org-mobile.el (org-mobile-edit):
* lisp/org.el (org-insert-heading):
(org-edit-headline):
(org-priority):
(org-set-tags):
(org-entry-put):
(org-self-insert-command):
(org-delete-backward-char):
(org-delete-char):
(org-kill-line): Only re-align tags when `org-auto-align-tags' is set
to non-nil.
* etc/ORG-NEWS (~org-auto-align-tags~ is now respected universally):
Announce the breaking change.

Link: https://orgmode.org/list/87msxoc3qp.fsf@localhost
2024-05-13 15:10:35 +03:00
Ihor Radchenko 62356cb44b
lisp/org.el (org-block-map): Fix mapping over nested blocks
* lisp/org.el (org-block-map): Do not bypass the whole block when
mapping.  Look inside the block body for child blocks as well.

Reported-by: mahmood sheikh <mahmod.m2015@gmail.com>
Link: https://orgmode.org/list/CAOj1L_cx9XP5fS3_=x=UJSSt3xjcfcQ68Uef6E4DTi68Kr_ABw@mail.gmail.com
2024-05-13 14:59:45 +03:00
Ihor Radchenko fffb87174e
testing/lisp/test-ox-md.el (ox-md/headline-style): New test 2024-05-12 14:53:39 +03:00
Lee Thompson 1a7d7a5a5b
lisp/ox-md.el: New mixed-style option for `org-md-headline-style'
* lisp/ox-md.el (org-md-headline-style): New setting `mixed' allows
for mixing Setext and ATX-style headlines when exporting to Markdown.
* doc/org-manual.org (Header and sectioning structure): Document
`mixed' headline style.
* etc/ORG-NEWS (New allowed value of ~org-md-headline-style~ to mix
ATX and Setext style headlines): Document the new feature.

When exporting to Markdown, there was previously no obvious way of
mixing Setext-style and ATX-style headlines.  Via the
`org-md-headline-style' custom setting, headlines could be exported as
either all-Setext or all-ATX, but not as a mix.

With this change setting `org-md-headline-style' to `'mixed' will
export the first two headline levels as Setext-style Markdown
headlines and the rest as ATX-style.

TINYCHANGE
2024-05-12 14:53:34 +03:00
Ihor Radchenko bc51dfcb74
org-agenda-kill: Fix deleting wrong entry when Org buffer is narrowed
* lisp/org-agenda.el (org-agenda-kill): Use `org-with-point-at' to
jump to origin Org buffer from agenda.  It automatically widens the
buffer.
(org-remove-subtree-entries-from-agenda): Temporarily lift narrowing
when calculating the list of headings to clean up from the agenda.

Link: https://old.reddit.com/r/emacs/comments/1cog1fb/agenda_kills_wrong_item_in_orgmode_when_buffer_is/
2024-05-11 19:32:50 +03:00
Ihor Radchenko db5478108c
org-agenda-tree-to-indirect-buffer: Obey `org-indirect-buffer-display'
* lisp/org-macs.el (org-display-buffer-in-window): New helper function
to display buffer in specific window (when it is live).
* lisp/org.el (org-tree-to-indirect-buffer): By default, reuse the
window previously used for an existing indirect buffer, if it is in
the same frame.
* lisp/org-agenda.el (org-agenda-do-tree-to-indirect-buffer): Remove.
(org-agenda-tree-to-indirect-buffer): Merge with
`org-agenda-do-tree-to-indirect-buffer' and remove special handling of
the existing indirect buffer window that overrides
`org-indirect-buffer-display'.
(org-agenda-do-context-action): Force `org-indirect-buffer-display' to
be 'other-window when displaying subtree at point in
org-agenda-follow-mode.

This patch reverts 35d6d9f50, implementing an alternative fix for
stabilizing indirect buffer window selection.  Unlike the existing
fix, it utilizes display buffer action and does not cause clashes with
custom `org-indirect-buffer-display'.

Reported-by: JV <misc@jeffvalk.com>
Link: https://orgmode.org/list/1a4c7a04-8536-40c7-899e-ba433a1252fd@jeffvalk.com
2024-05-11 16:19:52 +03:00
Ihor Radchenko e36a4fe20e
org-html-final-function: Suppress mode hooks when indenting
* lisp/ox-html.el (org-html-final-function): When setting indentation,
use defaults, suppressing major mode hook.  If we do not, all kinds of
user code may be executed.

This fix will only work starting from Emacs 30, after bug#70671 is
fixed:
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=70671

Reported-by: arozbiz@gmail.com
Link: https://orgmode.org/list/87tu21hsuk.fsf@localhost
2024-05-11 13:02:10 +03:00
Ihor Radchenko 4131926984
org: New Org-wide custom option `org-sort-function'
* lisp/org-macs.el (org-sort-function): New customization defining how
Org mode should sort headlines, table lines, agenda lines, etc.
(org-string<):
(org-string<=):
(org-string>=):
(org-string>): Use the new customization.
(org-string<>): Add docstring.
(org-sort-function-fallback): New helper function to help users on
MacOS where `string-collate-lessp' is not reliable.
* lisp/oc-basic.el (org-cite-basic--field-less-p):
* lisp/org-agenda.el (org-cmp-category):
(org-cmp-alpha):
* lisp/org-list.el (org-sort-list):
* lisp/org-mouse.el (org-mouse-list-options-menu):
* lisp/org-table.el (org-table-sort-lines):
* lisp/org.el (org-tags-sort-function):
(org-sort-entries):
* lisp/ox-publish.el (org-publish-sitemap): Honor the new
customization.
* lisp/org-mouse.el (org-mouse-tag-menu):
(org-mouse-popup-global-menu):
* lisp/org-agenda.el (org-cmp-tag): Honor `org-tags-sort-function' and
falling back to `org-string<' if note set.
* etc/ORG-NEWS (New option controlling how Org mode sorts things
~org-sort-function~): Announce the change.

This change aims to standardize the way Org mode performs sorting of
user data.  In particular, it addresses issues with oddities of string
collation rules on MacOS and tricky language environments like
Turkish.

Link: https://orgmode.org/list/87jzleptcs.fsf@localhost
2024-05-11 12:34:30 +03:00
Ihor Radchenko 4deb06ea0a
org-manual: Clarify what :results drawer does for inline code blocks
* doc/org-manual.org (Format): Move :results raw description up.
Adapt :results drawer description from the docstring of
`org-babel-insert-result', mentioning what it means in inline src
blocks.

Link: https://orgmode.org/list/87v8dfnwcp.fsf@localhost
2024-05-11 10:43:38 +03:00
Ihor Radchenko f64c8a5a5b
org-insert-heading: Prevent 0-blanks after heading when there is blank before
* lisp/org.el (org-insert-heading): When creating a new heading with
blank lines before results in the _next_ heading to have no blank
lines, add them.

Reported-by: gusbrs <gusbrs.2016@gmail.com>
Link: https://orgmode.org/list/877cjl67z6.fsf@localhost
2024-05-10 12:15:40 +03:00
Ihor Radchenko 3bf33c0d7b
org-clock-get-table-data: Fix error when :match uses LEVEL
* lisp/org-clock.el (org-clock-get-table-data): Pass headline level to
the clock table matcher.

Link: https://orgmode.org/list/8acdd46f-4137-4957-bb52-827d817eb5e7@uberco.de
2024-05-09 14:33:24 +03:00
Ihor Radchenko e380684c1a
doc/org-manual.org (The clock table): Fix too wide table in Texinfo output
* doc/org-manual.org (The clock table):
(Footnotes): Use numbered footnote to avoid too wide table columns.

Reported-by: Morgan Smith <Morgan.J.Smith@outlook.com>
Link: https://orgmode.org/list/CH3PR84MB34245E5ED43AA9A59D38E732C5E52@CH3PR84MB3424.NAMPRD84.PROD.OUTLOOK.COM
2024-05-09 14:07:52 +03:00
Ihor Radchenko 31748e67f0
doc/org-manual.org (Summary of the export process): Fix inaccuracies
* doc/org-manual.org (Summary of the export process): Mention that
some export backends may retain table rows with alignment markers.
Clarify that exporting parent nodes with children uses exported child
text.
2024-05-09 13:55:40 +03:00
Ihor Radchenko c6849a2bc8
org-store-link-functions: Fix the docstring
* lisp/ol.el (org-store-link-functions): Describe the actual sequence
of calling store functions.
2024-05-09 13:41:58 +03:00
Ihor Radchenko 96b3129265
org-create-file-search-functions: Allow to provide link description
* lisp/ol.el (org-create-file-search-functions): Fix the docstring,
replacing old broken way to set link description with
`org-link-store-props'.
(org-store-link): Allow the new behavior; get rid of redundant CPLTXT
internal variable - every time it is used, LINK is also set to it.

Reported-by: Magnus Therning <magnus@therning.org>
Link: https://orgmode.org/list/87wn9pppkl.fsf@localhost
2024-05-09 13:34:58 +03:00
Ihor Radchenko bd5665e017
org-table-make-reference: Address compiler warning
* lisp/org-table.el (org-table-make-reference): Drop branch of `if'
unused during runtime.  This preserves _interactive_ behavior.
* testing/lisp/test-org-table.el (test-org-table/org-table-make-reference/mode-string-none):
(test-org-table/org-table-make-reference/mode-string-N): Fix tests to
check for the existing _interactive_ behavior.  When running make
test (eq "" "") happens to return t and tests were passing previously
by accident despite actual behavior during user session being
different. Fix the tests to avoid breaking changes in the user
experience.

Link: https://list.orgmode.org/orgmode/20230827214320.46754-1-salutis@me.com/
2024-05-09 11:55:29 +03:00
Ihor Radchenko 24c4a40f79
org-fold-core-region: Fix isearch when fold style is overlays
* lisp/org-fold-core.el (org-fold-core--isearch-show): Only delete
overlay, when overlay is supplied.
(org-fold-core-region): Do not use custom "open temporarily" function
for overlay style.

Reported-by: Paul Stansell <paulstansell@gmail.com>
Link: https://orgmode.org/list/CAMJKaZy2Mt1_NeoP3nG3Uv68372H3rHHU1fcmSgO4xLpRQZi5Q@mail.gmail.com
2024-05-09 11:34:23 +03:00
Ihor Radchenko 773bba92a8
doc/org-manual.org: Improve example of publishing configuration
* doc/org-manual.org (Example: complex publishing configuration): Show
how to use evaluated expression with backquotes and `rx' macro in the
example.

Link: https://orgmode.org/list/LV8P223MB0920398F1619C446752BB1E1A2E42@LV8P223MB0920.NAMP223.PROD.OUTLOOK.COM
2024-05-07 12:21:46 +03:00
Max Nikulin 51aff8a11b
test-org-macro.el: Add test for CVE-2024-30202
* testing/lisp/test-org-macro.el (test-org-macro/initialize-templates):
A new test that no code is evaluated when an Org file is opened
(CVE-2024-30202).

Ihor Radchenko [ANN] Emergency bugfix release: Org mode 9.6.23.
Sun, 24 Mar 2024 17:16:50 +0000.
<https://list.orgmode.org/871q7zbldp.fsf@localhost>
2024-05-06 15:55:00 +03:00
Ihor Radchenko 48169da265
lisp/org.el (org-make-tags-matcher): Suppress compiler warning 2024-05-06 12:57:45 +03:00
Ihor Radchenko c8bd2092b1
org-agenda-mode: Honor hidden link descriptions
* lisp/org-agenda.el (org-agenda-mode): Hide 'org-link invisibility
spec, as in Org mode.

Reported-by: Bastien <bzg@gnu.org>
Link: https://orgmode.org/list/87seyww65g.fsf@gnu.org
2024-05-05 20:27:13 +03:00
Ihor Radchenko 56992b221e
Merge branch 'bugfix' 2024-05-05 20:26:17 +03:00
Ihor Radchenko 24feef95e4
ox-md: Fix exporting numbered items >=100
* lisp/ox-md.el (org-md-item): Always put at least one space after
item number.
* testing/lisp/test-ox-md.el (ox-md/item): New test.

Reported-by: Bastien <bzg@gnu.org>
Link: https://orgmode.org/list/87wmo8qll7.fsf@gnu.org
2024-05-05 20:25:22 +03:00
Andras Simonyi 288e0a11c2 oc-csl: Remove spaces before citations in superscript
* lisp/oc-csl.el (org-cite-csl--create-structure): Remove spaces before citation
if it is in superscript.
(org-cite-csl--style-cite-superscript-p): New function to check whether the used
CSL style produces citations in superscript.
2024-05-05 15:58:01 +02:00
Ihor Radchenko 43ba00b2b1
ob-latex: New custom option `org-babel-latex-process-alist'
* lisp/ob-latex.el (org-babel-latex-process-alist): New variable.
(org-babel-execute:latex): Override `org-preview-latex-process-alist'
when generating png output, making sure that the process yields an
actual png image, even when `org-preview-latex-default-process' is
non-default.
* etc/ORG-NEWS (=ob-latex= now uses a new option
~org-babel-latex-process-alist~ to generate png output): Announce the
change.

Reported-by: Ihor Radchenko <yantar92@posteo.net>
Link: https://orgmode.org/list/87cyretut7.fsf@localhost
2024-05-05 13:39:43 +03:00
Ihor Radchenko e09ad15a71
org-babel-read: Avoid `save-match-data'
* lisp/ob-core.el (org-babel-read): Avoid fiddling with match data -
it is not used.
2024-05-04 22:20:09 +03:00
Ihor Radchenko 0227e12605
org-babel-read: Read quotes strings ignoring leading/trailing newlines
* lisp/ob-core.el (org-babel-read): When reading "string", ignore
leading/trailing newlines in addition to spaces.
* testing/lisp/test-ob.el (test-ob/org-babel-read): Add more tests.

Reported-by: Max Nikulin <manikulin@gmail.com>
Link: https://orgmode.org/list/v15lva$hhl$1@ciao.gmane.io
2024-05-04 22:19:45 +03:00
Ihor Radchenko 105dedd0d9
ox-html: Fix exporting inlinetasks without contents
* lisp/ox-html.el (org-html-format-inlinetask-default-function): Do
not export no-contents as string "nil".  Just use empty string.
2024-05-04 15:26:10 +03:00
Ihor Radchenko edb5eaaac3
org-babel-read: Allow reading multi-line strings
* lisp/ob-core.el (org-babel-read): Fix regexp for detecting
string-like CELLs.  Avoid calling `read' twice.  Recover gracefully if
`read' errs.
* testing/lisp/test-ob.el (test-ob/org-babel-read): Add more tests.

Reported-by: Max Nikulin <manikulin@gmail.com>
Link: https://orgmode.org/list/v155g2$ncm$1@ciao.gmane.io
2024-05-04 14:46:46 +03:00
Ihor Radchenko 1523e21d82
org-babel-expand-noweb-references: Add trialing newline after comments
* lisp/ob-core.el (org-babel-expand-noweb-references): After closing
comment, when using :comments noweb, leave trailing newline after the
closing comment.
* testing/lisp/test-ob-tangle.el (ob-tangle/comment-noweb-relative):
Modify test to check for the newline.

Reported-by: João Pedro <jpedrodeamorim@gmail.com>
Link: https://orgmode.org/list/87fruy2rw6.fsf@ergo
2024-05-04 14:30:25 +03:00
Ihor Radchenko 0d24857ccf
ox-html: Fix exporting inlinetasks without contents
* lisp/ox-html.el (org-html-format-inlinetask-default-function): Do
not export no-contents as string "nil".  Just use empty string.
2024-05-04 13:37:46 +03:00
Ihor Radchenko dbea900d60
test-ob/org-babel-read: Fix for Emacs 27
* testing/lisp/test-ob.el (test-ob/org-babel-read): Do not use `dlet'
that is not yet available in Emacs 27.
2024-05-03 16:25:00 +03:00
Cook, Malcolm 09520a056c
org-manual: Document command line installation
* doc/org-manual.org (Using Emacs packaging system): Document how to
upgrade Org mode without risking version conflicts.

TINYCHANGE
2024-05-03 15:23:06 +03:00
Ihor Radchenko 2028bb15cd
org-babel-read: Fix reading multiple quoted strings
* lisp/ob-core.el (org-babel-read): Fix naive regexp for matching
escaped quotes.  Instead, check if `read' can read the whole CELL in
one go.
* testing/lisp/test-ob.el (test-ob/org-babel-read): Add tests.

Reported-by: Max Nikulin <manikulin@gmail.com>
Link: https://orgmode.org/list/v10k4s$et9$1@ciao.gmane.io
2024-05-03 15:04:52 +03:00
Ihor Radchenko 5da0eb6ea7
org-element-timestamp-parser: Allow time in diary sexp timestamps
* lisp/org-agenda.el (org-agenda-get-timestamps):
* lisp/org-element.el (org-element--timestamp-regexp): Adjust
timestamp regexp.
(org-element-timestamp-parser): Support the new syntax for diary sexp
timestamps.  The diary sexp is now stored in :diary-sexp property and
the time/time range is stored as usual.
(org-element-timestamp-interpreter): Interpret diary timestamp
according to its building blocks rather than raw value.
* testing/lisp/test-org-agenda.el (test-org-agenda/diary-timestamp):
New test checking for agenda support of times in diary timestamps.
*
testing/lisp/test-org-element.el (test-org-element/timestamp-interpreter):
Add parser tests.
* doc/org-manual.org (Timestamps): Add an example of the new syntax to
the manual.
* etc/ORG-NEWS (Diary type timestamps now support optional
time/timerange): Document the Org syntax addition.

This syntax modification is fixing an omission in org-element.el.  In
the past, org-agenda had explicit support for diary timestamps with
time/timerange, but that support was ad-hoc.  Now, after org-agenda
switched to use parser, we must modify Org syntax to fix the feature
regression.
2024-05-03 13:42:06 +03:00
Ihor Radchenko 3d0deadf41
Update version number for the 9.6.29 release 2024-05-03 10:32:09 +03:00
Ihor Radchenko 1cafe3e8e4
org-indent-line: Do not err in src blocks when there is no language mode
* lisp/org.el (org-indent-line): When attempting to indent as in major
mode, ignore any errors, like errors arising when the major mode is
not available.
2024-05-02 19:47:26 +03:00
Rudolf Adamkovič 7cdf835c71
Auto-complete PRINT_BIBLIOGRAPHY with a trailing colon
* lisp/org.el (org-options-keywords): Add a trailing colon to the
'PRINT_BIBLIOGRAPHY' keyword to avoid unnecessary user confusion.
2024-05-02 19:31:54 +03:00
Ihor Radchenko fede1c9909
org-display-inline-images: Prioritize #+attr_org over other #+attr_...
* lisp/org.el (org-display-inline-image--width): When there is
 #+attr_org defining :width, use it.  Fall back to #+attr_<other>
otherwise.  Update the docstring.
(org-image-actual-width): Improve docstring (credit: Matt Huszagh).
* etc/ORG-NEWS (Inline image width value in =#+attr_org= is preferred
over other =#+attr_...= keywords): Document the change.

Co-authored-by: Matt Huszagh <huszaghmatt@gmail.com>
Link: https://orgmode.org/list/871r2ucuhz.fsf@gmail.com
2024-05-02 19:26:48 +03:00
Ihor Radchenko 55795376b6
org-indent-line: Do not rely upon TAB being bound to indentation
* lisp/org.el (org-indent-line): When indenting natively in src
blocks, call `indent-line-function' instead of relying upon "TAB"
binding doing indentation.
2024-05-02 18:18:49 +03:00
Ihor Radchenko d8ac958836
ob-calc/matrix-inversion: Force `calc-float-format' in the test
* testing/lisp/test-ob-calc.el (ob-calc/matrix-inversion): When
testing, make sure that calc output follows the expected format.
This is needed on MacOS where Emacs defaults are not exactly the same.

Reported-by: Alexander Adolf <alexander.adolf@condition-alpha.com>
Link: https://list.orgmode.org/orgmode/91dfeb0fed1a1fe0564e5eb9b95a409d@condition-alpha.com/
2024-05-02 15:58:19 +03:00
Max Nikulin ac7c5c5d88
test-ob-shell.el: Skip based on feature detection
* testing/lisp/test-ob-shell.el (test-ob-shell/bash-uses-assoc-arrays)
(test-ob-shell/bash-uses-assoc-arrays-with-lists): Use feature detection
shell command instead of version comparison to skip tests for
associative arrays.

It affects macOS since Apple ships BASH 3.2 licensed as GPLv2.
2024-05-02 15:56:16 +03:00
Ihor Radchenko dd12e9c763
ob-calc.el: Fix assigning floating point numbers
* lisp/ob-calc.el (org-babel-execute:calc): Use internal calc format
when assigning variable values that are numbers.
* testing/lisp/test-ob-calc.el (ob-calc/float-var): New test.

Reported-by: Visuwesh <visuweshm@gmail.com>
Link: https://orgmode.org/list/87edbu4kdh.fsf@gmail.com
2024-05-02 15:24:15 +03:00
Ihor Radchenko a2e5685e49
Do not use org-fold to hide link parts
* lisp/ol.el (org-link--link-folding-spec):
(org-link--description-folding-spec):
(org-link-descriptive-ensure): Remove.
(org-toggle-link-display): Rely upon font-lock to update link display.
* lisp/org-agenda.el (org-agenda-mode): Remove no-longer-necessary
org-fold initializer.
* lisp/org-fold.el (org-fold-initialize): Remove link-related fold
types.
(org-fold-show-set-visibility):
* lisp/org-src.el (org-src-font-lock-fontify-block):
* lisp/org.el (org-do-emphasis-faces):
(org-unfontify-region): Remove special handling of link folds.
* lisp/org.el (org-mode): Remove folding setup for links.
(org-activate-links--text-properties): Remove.
(org-activate-links): Honor `org-link-descriptive' dynamically.

This change reflects de-facto situation where we cannot use folding
system to hide links reliably.  Even though we promise in Org 9.6 that
hidden parts of the link can be searched, the way it can be
implemented is not reliable and is working around upstream mechanisms.
Upstream changes are necessary to properly support isearch in text
hidden using text properties; workarounds attempted in org-fold-core
do not cut it because too many built-in Emacs libraries and also
third-party libraries rely upon internal implementation details of
isearch (due to limitations of its API).
2024-05-02 12:29:27 +03:00
Morgan Smith 646f6ec133
Obsolete `org-cached-entry-get' in favor of `org-entry-get'
We have a better performing cache mechanism in `org-entry-get'.

* lisp/org.el (org-make-tags-matcher): Replace uses of
`org-cached-entry-get' with `org-entry-get'.
(org-cached-entry-get): Move to ...
* lisp/org-compat.el (org-cached-entry-get): ... here.  Obsolete in
favor of `org-entry-get'.
2024-05-01 21:41:07 +03:00
Max Nikulin c6bbde4c78
test-org-ctags: Fix CI failures
* testing/lisp/test-org-ctags.el (test-org-ctags/with-fake-ctags): Do
not use function name not compatible with dash.
2024-04-30 16:41:01 +03:00
Max Nikulin 3c01767f7e
test-org-ctags.el: Test escaping of shell arguments
* testing/lisp/test-org-ctags.el (test-org-ctags/create-tags-escape):
A new test that tag regexp and directory names are properly quoted
while "*" wildcard is active.
(test-org-ctags/list-elements test-org-ctags/list-elements-equal-p)
(test-org-ctags/list-elements-equal-explain): Helpers to provide
informative failure messages.
(test-org-ctags/with-fake-ctags): A helper to create temporary
directories and a file and to temporary arrange a mock shell command
instead of ctags executable.
(test-org-ctags/mock-command test-org-ctags/get-args): Helpers to define
a mock shell command and to obtain its actual arguments.
2024-04-30 12:58:35 +03:00
Max Nikulin 0f0019e326
org-ctags.el: Protect shell specials in directory name
* lisp/org-ctags.el (org-ctags-create-tags): Escape shell specials.

Directory name (the argument or `default-directory') may contain various
characters interpreted by shell.  Effects may vary from just incorrect
actual path to execution of a command embedded into path.  Neither
double nor single quotes is a safe way to use directory name in shell
commands since the name may contain these characters.

A follow-up to
Martin Marshall. [PATCH] `org-ctags-create-tags` creates empty TAGS file.
Fri, 09 Feb 2024 18:57:48 -0500.
<https://list.orgmode.org/87h6ihgphf.fsf@martinmarshall.com>
2024-04-30 12:58:34 +03:00
Max Nikulin badb09d679
org-ctags.el: Do not activate on load
* etc/ORG-NEWS: Announce the change breaking for `org-ctags' users and
provide init file code to enable the feature.
* lisp/org-ctags.el (org-ctags-enable): Do no invoke this function
during library loading.  Collect all initialization code in its body.

Setting up hooks during library loading leads to various issues.
- Emacs coding conventions insist on incompatible changes if loading
  a library modifies behavior, see
  Info node `(elisp) Coding Conventions'.
- The library may be autoloaded for the sake of help completion
  breaking `org-open-at-point':
  Nick Dokos. org-ctags land grab. Mon, 20 Mar 2023 23:36:09 -0400.
  <https://list.orgmode.org/87o7omg4ie.fsf@alphaville.usersys.redhat.com>
- Unrelated unit tests fail due to user prompt:
  Ihor Radchenko. Re: [PATCH] org-ctags.el: Protect shell specials
  in directory name. Sun, 28 Apr 2024 12:53:38 +0000.
  <https://list.orgmode.org/87a5ldk5rh.fsf@localhost>
2024-04-30 12:49:52 +03:00
Max Nikulin 735334445f
org-ctags.el: Define unload function
* lisp/org-ctags.el (org-ctags-unload-function): New function to cleanup
during `unload-feature' call.
(org-ctags--open-link-functions-list org-ctags-open-link-functions):
Define and use list of options available for `org-open-link-functions'.
(org-ctags--visit-tags-table): Give a name to remove the function from
`org-mode-hook' on library unload.

Prevent the following error after library unloading

    Symbol’s function definition is void: org-ctags-find-tag
2024-04-30 12:49:51 +03:00
Ihor Radchenko 3e11b2eb88
org-make-tags-matcher: Byte-compile the returned function
* lisp/org.el (org-make-tags-matcher): Byte-compiling the constructed
function yields noticeable improvements in at least clocksum
generation.

Link: https://orgmode.org/list/CH3PR84MB3424390023D1A552D57395FAC51B2@CH3PR84MB3424.NAMPRD84.PROD.OUTLOOK.COM
2024-04-29 19:46:31 +03:00
Ihor Radchenko 89c68683f9
org-babel-import-elisp-from-file: Fix detecting delimiter in single-line data
* lisp/org-table.el (org-table-convert-region): When detecting
delimiter in, do not unconditionally fall back to CSV parser.  Only do
it when the line contains commas and use a simple single tab/space
split otherwise.  Add new special delimeter-detection strategy when
SEPARATOR is 'babel-auto - convert to | full line | table instead of
falling back to tab/space split when the region contains a single
line.
* lisp/ob-core.el (org-babel-import-elisp-from-file): Force special
strategy when converting data to lisp.

The commit fixes the problem with first `re-search-forward' in the
`cond' moving point to end of the region, making the third `cond'
branch never match.

A special strategy specific to babel is necessary to preserve the
historic behavior with lines like
: single line with spaces
being converted to a single table cell
: | single line with space |

Reported-by: Matt <matt@excalamus.com>
Link: https://orgmode.org/list/18f24d87b62.d55e94e24743657.3252620114689708448@excalamus.com
2024-04-29 14:42:12 +03:00
Ihor Radchenko a2514c97de
Merge branch 'bugfix' 2024-04-28 15:57:30 +03:00
Ihor Radchenko 36a9f6f185
org-clock: Autoload `org-clock-modify-effort-estimate'
* lisp/org-clock.el (org-clock-modify-effort-estimate): Autoload the
command.  It is used in the agenda menu without loading org-clock, so
we must autoload it.  Also, some users want to use the command before
clockin-in.

Link: https://orgmode.org/list/2fb82950-316e-4ebb-bb8b-a65b45e671eb@Spark
2024-04-28 15:55:45 +03:00
Ihor Radchenko e0f24a3f6d
org-html-footnote-reference: Fix duplicate IDs
* lisp/ox-html.el (org-html-footnote-reference): When multiple
footnote references point to a single footnote, make sure that the
reference ids are not duplicated.  Now, the ids for non-first
reference are constructed as fn.<footnote id>.<footnote reference
number>.  The reference number of counted across all the footnote
references referencing the same footnote.

Reported-by: Protesilaos Stavrou <info@protesilaos.com>
Link: https://orgmode.org/list/87cyqcv9q1.fsf@protesilaos.com
2024-04-28 13:35:31 +03:00
Ihor Radchenko 065af4b42a
ox-html: Use non-number footnote names as link anchors
* lisp/ox-html.el (org-html-footnote-section):
* lisp/ox-html.el (org-html-footnote-reference): When footnote has a
non-number name, build link anchors using this name.
* etc/ORG-NEWS (=ox-html=: When exporting footnotes with custom
non-number names, the names are used as link anchors): Announce the
change.

Link: https://orgmode.org/list/875xwngiwx.fsf@protesilaos.com

Co-authored-by: Protesilaos Stavrou <info@protesilaos.com>
2024-04-28 13:18:59 +03:00
Ihor Radchenko ba747598c6
org-icalendar-export-agenda-files: Report file name when export fails
* lisp/ox-icalendar.el (org-icalendar-export-agenda-files): When
export fails, display warning listing the error and the problematic
file.
2024-04-26 18:09:43 +03:00
Ihor Radchenko 64049aaddc
lisp/ox.el (org-export-data): Improve broken link error message
* lisp/ox.el (org-export-data): Link to `org-export-with-broken' links
in the error message.  Highlight that export is aborted.
2024-04-26 18:09:03 +03:00
Alexander Adolf fbf613ece9
lisp/org-colview.el: Move cleanup code to cleanup function
* lisp/org-colview.el (org-columns--clean-item): Additionally process
the result with `org-quote-vert'.
(org-columns--capture-view): Remove call to `org-quote-vert'.

`org-columns--clean-item' is used when formatting and inserting column
view dynamic blocks.  By moving the call to `org-quote-vert' to this
function, it can be used by all formatting functions, including
user-supplied ones, to format content to be safe for inclusion in a
table.
2024-04-26 15:44:47 +03:00
Alexander Adolf 4e6fa96e26
lisp/org-colview.el: Add link parameter to colview dynamic block
* lisp/org-colview.el (org-columns--capture-view): Add new link
parameter, which when non-nil causes ITEM headlines to be linked to
their origins.
(org-dblock-write:columnview): Pass new link parameter to
`org-columns--capture-view', and explain its use in the docstring.
* testing/lisp/test-org-colview.el (test-org-colview/dblock): Add
new test for link feature.
* doc/org-manual.org (Capturing column view): Describe new :link
parameter.
* etc/ORG-NEWS (=colview= dynamic block can link to headlines):
Describe new link feature.
2024-04-26 15:44:46 +03:00
Alexander Adolf 5a98b4c563
lisp/org-colview.el: Add formatter parameter to colview dynamic block
* lisp/org-colview.el (org-dblock-write:column view): Factor out the
existing formatting code to new function
`org-columns-dblock-write-default', and honour new dblock parameter
:formatter for specifying a different formatting function.
(org-columns-dblock-write-default): New function with current
formatting code.
(org-columns--capture-view): Amend docstring to better explain the
format of the data being passed to the formatting function.
(org-clock-clocktable-formatter): New option to define a global
default formatting function, defaulting to the current behaviour.
* testing/lisp/test-org-colview.el (test-org-colview/dblock): New test
for formatting function.
(test-org-colview/dblock-formatter): New function used in formatting
test.
* doc/org-manual.org (Capturing column view): Describe new :formatter
parameter.
* etc/ORG-NEWS (New option ~org-columns-dblock-formatter~): Announce
new option.
(=colview= dynamic block supports custom formatting function):
Describe new custom formatting function feature.
2024-04-26 15:44:44 +03:00
Pedro A. Aranda f124b616d9
oc-biblatex: Allow native biblatex options in CITE_EXPORT
* lisp/oc-biblatex.el: (org-cite-biblatex--package-options) Add support
for options in the native biblatex package format.
* doc/org-manual.org: Document the added format and add an example.
* etc/ORG-NEWS: Announce new format for #+cite_export biblatex options.
2024-04-26 15:23:29 +03:00
Ihor Radchenko e4ab416fcc
Only run Bash tests when relevant features are supported
* testing/lisp/test-ob-shell.el (test-ob-shell/bash-uses-arrays): Do
not run when Bash is not available.
(test-ob-shell/bash-uses-assoc-arrays):
(test-ob-shell/bash-uses-assoc-arrays-with-lists): Do not run when
Bash is not available or has <4.0 version without associative array
support.

Reported-by: Max Nikulin <manikulin@gmail.com>
Link: https://orgmode.org/list/ef03d3ca-a184-4398-8edb-35f84b48e850@gmail.com
2024-04-26 14:02:06 +03:00
Ihor Radchenko 510e8f9cc8
ox-publish: Do not store :title, :date, and :index in project cache
* lisp/ox-publish.el (org-publish-transient-cache): New transient
cache, used just during current publish process.
(org-publish-initialize-cache):
(org-publish-reset-cache): Initialize the transient cache.
(org-publish-cache-set-file-property): Add new optional argument to
store property in transient cache rather than persistent cache.
(org-publish-cache-get-file-property): Query transient cache first.
(org-publish-collect-index):
(org-publish-find-title):
(org-publish-find-date): Use transient cache.

This commit fixes situation when :title/:date/:index properties are
not updated even when the corresponding project file does get updated.

Link: https://emacs-china.org/t/org-mode-html/26896/2
2024-04-26 13:42:45 +03:00
Ihor Radchenko 68d592bae4
ox-man: Escape backslash characters in verbatim examples
* lisp/ox-man.el (org-man--protect-example): New helper function
protecting special escape characters inside literal examples.
(org-man-example-block):
(org-man-inline-src-block):
(org-man-src-block):
(org-man-table): Protect contents that is intended to be rendered
verbatim.

Reported-by: Greg Minshall <minshall@umich.edu>
Link: https://orgmode.org/list/2924644.1643637646@apollo2.minshall.org
2024-04-26 12:42:58 +03:00
Ihor Radchenko 0e743d0bfc
Update version number for the 9.6.28 release 2024-04-26 10:26:39 +03:00
Rudolf Adamkovič 252cc0be07
ob-lua: Support all types and multiple values in results
* etc/ORG-NEWS
(New and changed options): Describe the new option
'org-babel-lua-multiple-values-separator'.
(New features): Describe the main change, as per the title of this
commit message.
* lisp/ob-lua.el
(org-babel-lua-multiple-values-separator): Enable the user to
customize the string that separates the individual values in
multi-valued returns.
(org-babel-lua-wrapper-method): Support all Lua types and multi-valued
returns.  Further, do not pretty-print tables with one or more
extraneous newline characters.
(org-babel-lua-pp-wrapper-method): Remove in favor of the new, more
general 'org-babel-lua-wrapper-method'.
(org-babel-lua-evaluate-external-process): Adapt for the new
'org-babel-lua-wrapper-method'.
* testing/lisp/test-ob-lua.el
(test-ob-lua/colnames-yes-header-argument-pp):
(test-ob-lua/colnames-nil-header-argument):
(test-ob-lua/colnames-no-header-argument): Stop expecting extraneous
newlines, now that the pretty printer does not output them.
(test-ob-lua/types): Test nil, boolean, number, string, and table
results.
(test-ob-lua/multiple-values): Test multi-valued results.
2024-04-24 16:04:38 +03:00
Ihor Radchenko 9e88e1c822
Merge branch 'bugfix' 2024-04-24 15:46:32 +03:00
Ihor Radchenko d6353b283a
ox-ascii: Fix broken link export for broken fuzzy links
* lisp/ox-ascii.el (org-ascii--describe-links): Ignore all kinds of
broken links, not just broken id links.

Reported-by: Pablo Aguado <aguadopd@hotmail.com>
Link: https://orgmode.org/list/SA1P223MB070291E02E95707C31342244C2102@SA1P223MB0702.NAMP223.PROD.OUTLOOK.COM
2024-04-24 15:46:07 +03:00
Ihor Radchenko 80b474db00
ox-ascii: Fix broken link export for broken fuzzy links
* lisp/ox-ascii.el (org-ascii--describe-links): Ignore all kinds of
broken links, not just broken id links.

Reported-by: Pablo Aguado <aguadopd@hotmail.com>
Link: https://orgmode.org/list/SA1P223MB070291E02E95707C31342244C2102@SA1P223MB0702.NAMP223.PROD.OUTLOOK.COM
2024-04-24 15:42:39 +03:00
Ihor Radchenko c6c5474b7e
ob-exp: Preserve header arguments in source block after processing
* lisp/ob-exp.el (org-babel-exp-process-buffer): Fix infinite loop
when the inline src block replacement is the same as the existing src
block.
(org-babel-exp-code): Support new placeholder %header-args for
non-default header arguments.
(org-babel-exp-inline-code-template):
(org-babel-exp-code-template): Change the templates to include header
arguments.
* testing/lisp/test-ob-exp.el (ob-exp/exports-inline-code):
(ob-exp/exports-inline-code-double-eval-exports-both):
(ob-export/export-with-results-before-block): Adjust tests.
* etc/ORG-NEWS (=ox-org= preserves header non-default arguments in src
blocks): Document the breaking change.

This change fixes ox-org export for src blocks.  Previously src blocks
did not preserve their header arguments.  Now, non-default header
arguments are preserved.

Link: https://github.com/emacsorphanage/ox-pandoc/issues/37
2024-04-24 14:48:19 +03:00
Arash Esbati ff9d00c9c3
doc/org-manual.org: Document `org-emphasize'
* doc/org-manual.org (Emphasis and Monospace): Document the
command `org-emphasize'.

Link: https://lists.gnu.org/archive/html/emacs-orgmode/2024-04/msg00381.html
2024-04-23 14:30:52 +03:00
Alexander Gogl 46e13c3ebd
ox-latex: New option to customize LaTeX footnote command
* lisp/ox-latex.el (org-export-define-backend): Add option.
(org-latex-default-footnote-command): New custom variable.
(org-latex-footnote-reference): Replace string "\\footnote{%s%s}"
with custom variable.

* etc/ORG-NEWS (New and changed options): Add description to option.

Some LaTeX classes define their own footnote commands. For example,
kaobook (https://github.com/fmarotta/kaobook/blob/master/example_and_documentation.pdf)
has \footnotes and \sidenotes, whereby sidenotes (notes are put into
the outter margin) are the dominant form of putting notes in
kaobook. It would be great if you could make the footnote command in
the footnote function customizable. My proposal is in the attachment.

Modified from a feature request by Alexander Gogl.

Link: https://list.orgmode.org/m2v84fhj9u.fsf@gmail.com/T/#m71809443a3b328ed704712ba53e6bb78282249cc

TINYCHANGE
2024-04-23 13:58:14 +03:00
Ihor Radchenko 1ad03e77b1
org-fold: Fix regression after b03ece433
* lisp/org-fold-core.el (org-fold-core-add-folding-spec): Add new
folding spec property :font-lock.

Reported-by: StrawberryTea <look@strawberrytea.xyz>
Link: https://orgmode.org/list/87frvdtemx.fsf@strawberrytea.xyz
2024-04-22 22:20:49 +03:00
Ihor Radchenko 52bde22b9d
Merge branch 'bugfix' 2024-04-22 21:10:13 +03:00
Ihor Radchenko a9275d5fd1
doc/org-manual.org: Fix description of switches in literal examples
Fix erroneous assertion that switches are always at the end of "begin"
line.

Reported-by: João Pedro <jpedrodeamorim@gmail.com>
Link: https://orgmode.org/list/87zftm2ltt.fsf@ergo
2024-04-22 21:08:20 +03:00
Ihor Radchenko dba92f72d3
Merge branch 'bugfix' 2024-04-22 16:44:27 +03:00
Ihor Radchenko 0db82ee8f8
org-agenda-manipulate-query: Fix repeated canceled calls
* lisp/org-agenda.el (org-agenda-manipulate-query): When called
multiple times, discarding edits, prevent accumulating trailing + + +
- +{} in the query string.

Reported-by: Carlos Pita <carlosjosepita2@gmail.com>
Link: https://orgmode.org/list/87r1be97xd.fsf@localhost
2024-04-22 16:42:08 +03:00
Ihor Radchenko 5b0b7f2924
org-paste-subtree: With single/double prefix, force inserting sibling/child
* lisp/org.el (org-paste-subtree): When called with single or double
universal argument, force inserting sibling heading or child heading
accordingly.
* testing/lisp/test-org.el (test-org/paste-subtree): Add tests for the
new behavior.
* doc/org-manual.org (Structure Editing): Update the command description.
* etc/ORG-NEWS (~org-paste-subtree~ now handles =C-u= and =C-u C-u=
prefix arguments specially): Announce the change.

Link: https://orgmode.org/list/878rhxtszb.fsf@localhost
2024-04-21 14:59:37 +03:00
Ihor Radchenko 36d0928043
Clarify `org-use-sub-superscripts' and related options
* lisp/org.el (org-use-sub-superscripts): Update the docstring
explaining that (...) is understood as sub/superscript, even when
there are spaces inside.  Add a note that the underlying markup is not
altered.
* lisp/ox.el (org-export-with-sub-superscripts): Link to the
`org-use-sub-superscripts' docstring instead of duplicating the
docstring text.
* doc/org-manual.org (Subscripts and Superscripts): Clarify the
differences between `org-export-with-sub-superscripts' and
`org-use-sub-superscripts'.  Add a note that underlying markup does
not change.

Link: https://orgmode.org/list/87plvproor.fsf@localhost
2024-04-21 12:41:05 +03:00
Ihor Radchenko 769018718c
ox-odt: Fix regression when exporting file links after 72b0e9ff0
* lisp/ox-odt.el (org-odt-link--inline-image): Fix file path expansion
code.  Explicitly assert that the passed link must be a file
link (otherwise, the rest of the function logic does not make any
sense).
(org-odt-link): Remove special handling of http, https, ftp, and
mailto links, following the idea behind 72b0e9ff0.  Fix coderef link
handling - they must use raw coderef, not coderef:<ref>.

Reported-by: Fraga, Eric <e.fraga@ucl.ac.uk>
Link: https://orgmode.org/list/87r0f3ndvy.fsf@ucl.ac.uk
2024-04-20 15:19:11 +03:00
Morgan Smith 942a7320d0
org-element-cache-map: Fix edge case when we move to not-yet-cached element
* lisp/org-element.el (org-element-cache-map): Make sure that there is
always a cached element where we move START position.
* testing/lisp/test-org-element.el (test-org-element/cache-map): New
test.

Co-authored-by: Morgan Smith <Morgan.J.Smith@outlook.com>
2024-04-19 16:06:44 +03:00
Ihor Radchenko d73688faa4
org-paste-subtree: Fix pasting when point is on heading but not at bol
* lisp/org.el (org-paste-subtree): When point is on heading, but not
at bol, paste using heading level minimal between current heading
level and next visible heading level.
* testing/lisp/test-org.el (test-org/paste-subtree): Add test cases.

Reported-by: Philipp Kiefer <phil.kiefer@gmail.com>
Link: https://orgmode.org/list/878rhxtszb.fsf@localhost
2024-04-19 14:11:15 +03:00
Ihor Radchenko 037700c411
Update version number for the 9.6.27 release 2024-04-19 10:56:36 +03:00
50 changed files with 1982 additions and 927 deletions

View File

@ -120,6 +120,16 @@ visited, i.e., where no Org built-in function have been loaded.
Otherwise autoload Org functions will mess up the installation.
#+end_quote
To avoid interference with built-in Org mode, you can use command line:
#+begin_src sh
emacs -Q -batch -eval "(progn (require 'package) (package-initialize) (package-refresh-contents) (package-upgrade 'org))"
#+end_src
This approach has the advantage of isolating the upgrade process from
a running Emacs session, ensuring that version conflicts can not
arise.
*** Using Org's git repository
:PROPERTIES:
:UNNUMBERED: notoc
@ -921,7 +931,9 @@ The following commands jump to other headlines in the buffer.
Yank subtree from kill ring. This does modify the level of the
subtree to make sure the tree fits in nicely at the yank position.
The yank level can also be specified with a numeric prefix argument,
or by yanking after a headline marker like =****=.
or by yanking after a headline marker like =****=. With
{{{kbd(C-u)}}} prefix, force inserting as a sibling. With
{{{kbd(C-u C-u)}}} prefix argument, force inserting as a child.
- {{{kbd(C-y)}}} (~org-yank~) ::
@ -6007,11 +6019,23 @@ This dynamic block has the following parameters:
When non-~nil~, indent each =ITEM= field according to its level.
- =:link= ::
When non-~nil~, link the =ITEM= headlines in the table to their
origins.
- =:format= ::
Specify a column attribute (see [[*Column attributes]]) for the dynamic
block.
- =:formatter= ::
#+cindex: @samp{formatter}, dynamic block parameter
#+vindex: org-columns-dblock-formatter
A function to format column view data and insert it into the buffer.
See the option ~org-columns-dblock-formatter~.
The following commands insert or update the dynamic block:
- ~org-columns-insert-dblock~ ::
@ -6142,7 +6166,7 @@ the agenda (see [[*Weekly/daily agenda]]). We distinguish:
#+begin_example
,* 22:00-23:00 The nerd meeting on every 2nd Thursday of the month
<%%(diary-float t 4 2)>
<%%(diary-float t 4 2) 22:00-23:00>
#+end_example
- Time range ::
@ -7010,16 +7034,16 @@ be selected:
absolutely, or relative to the current time and may be any of these
formats:
| =2007-12-31= | New year eve 2007 |
| =2007-12= | December 2007 |
| =2007-W50= | ISO-week 50 in 2007 |
| =2007-Q2= | 2nd quarter in 2007 |
| =2007= | the year 2007 |
| =today=, =yesterday=, =today-N= | a relative day |
| =thisweek=, =lastweek=, =thisweek-N= | a relative week |
| =thismonth=, =lastmonth=, =thismonth-N= | a relative month |
| =thisyear=, =lastyear=, =thisyear-N= | a relative year |
| =untilnow=[fn:: When using ~:step~, ~untilnow~ starts from the beginning of 2003, not the beginning of time.] | all clocked time ever |
| =2007-12-31= | New year eve 2007 |
| =2007-12= | December 2007 |
| =2007-W50= | ISO-week 50 in 2007 |
| =2007-Q2= | 2nd quarter in 2007 |
| =2007= | the year 2007 |
| =today=, =yesterday=, =today-N= | a relative day |
| =thisweek=, =lastweek=, =thisweek-N= | a relative week |
| =thismonth=, =lastmonth=, =thismonth-N= | a relative month |
| =thisyear=, =lastyear=, =thisyear-N= | a relative year |
| =untilnow=[fn:28] | all clocked time ever |
#+vindex: org-clock-display-default-range
When this option is not set, Org falls back to the value in
@ -7225,7 +7249,7 @@ current clock, or applying it to another one.
#+vindex: org-clock-x11idle-program-name
By customizing the variable ~org-clock-idle-time~ to some integer,
such as 10 or 15, Emacs can alert you when you get back to your
computer after being idle for that many minutes[fn:28], and ask what
computer after being idle for that many minutes[fn:29], and ask what
you want to do with the idle time. There will be a question waiting
for you when you get back, indicating how much idle time has passed
constantly updated with the current amount, as well as a set of
@ -8018,7 +8042,7 @@ Now lets look at the elements of a template definition. Each entry in
- =(file+olp+datetree "filename" [ "Level 1 heading" ...])= ::
This target[fn:29] creates a heading in a date tree[fn:30] for
This target[fn:30] creates a heading in a date tree[fn:31] for
today's date. If the optional outline path is given, the tree
will be built under the node it is pointing to, instead of at top
level. Check out the ~:time-prompt~ and ~:tree-type~ properties
@ -8327,7 +8351,7 @@ capture templates in a similar way.]:
| | =%:date= (message date header field) |
| | =%:date-timestamp= (date as active timestamp) |
| | =%:date-timestamp-inactive= (date as inactive timestamp) |
| | =%:fromto= (either "to NAME" or "from NAME")[fn:31] |
| | =%:fromto= (either "to NAME" or "from NAME")[fn:32] |
| gnus | =%:group=, for messages also all email fields |
| w3, w3m | =%:url= |
| info | =%:file=, =%:node= |
@ -8993,7 +9017,7 @@ a paper agenda, showing all the tasks for the current week or day.
#+cindex: org-agenda, command
Compile an agenda for the current week from a list of Org files.
The agenda shows the entries for each day. With a numeric prefix
argument[fn:32]---like {{{kbd(C-u 2 1 M-x org-agenda a)}}}---you may
argument[fn:33]---like {{{kbd(C-u 2 1 M-x org-agenda a)}}}---you may
set the number of days to be displayed.
#+vindex: org-agenda-span
@ -9681,7 +9705,7 @@ filters and limits allow to flexibly narrow down the list of agenda
entries.
/Filters/ only change the visibility of items, are very fast and are
mostly used interactively[fn:33]. You can switch quickly between
mostly used interactively[fn:34]. You can switch quickly between
different filters without having to recreate the agenda. /Limits/ on
the other hand take effect before the agenda buffer is populated, so
they are mostly useful when defined as local variables within custom
@ -10767,7 +10791,7 @@ used for the matching. The example above will therefore define:
- {{{kbd(x)}}} ::
as a global search for agenda entries planned[fn:34] this week/day.
as a global search for agenda entries planned[fn:35] this week/day.
- {{{kbd(y)}}} ::
@ -10953,7 +10977,7 @@ export custom agenda views as plain text, HTML[fn:: For HTML you need
to install Hrvoje Nikšić's =htmlize.el= as an Emacs package from
[[https://elpa.nongnu.org/][NonGNU ELPA]] or from
[[https://github.com/hniksic/emacs-htmlize][Hrvoje Nikšić's repository]].],
Postscript, PDF[fn:35], and iCalendar files. If you
Postscript, PDF[fn:36], and iCalendar files. If you
want to do this only occasionally, use the following command:
- {{{kbd(C-x C-w)}}} (~org-agenda-write~) ::
@ -11231,7 +11255,17 @@ but not any simpler
You can make words =*bold*=, =/italic/=, =_underlined_=, ==verbatim==
and =~code~=, and, if you must, =+strike-through+=. Text in the code
and verbatim string is not processed for Org specific syntax; it is
exported verbatim.
exported verbatim. Org provides a single command as entry point for
inserting the marker character.
- {{{kbd(C-c C-x C-f)}}} (~org-emphasize~) ::
#+kindex: C-c C-x C-f
#+findex: org-emphasize
Prompt for a marker character and insert or change an emphasis. If
there is an active region, change that region to a new emphasis. If
there is no region, just insert the marker characters and position
the cursor between them.
#+vindex: org-fontify-emphasized-text
To turn off fontification for marked up text, you can set
@ -11274,15 +11308,20 @@ the radius of Alpha Centauri is R_{Alpha Centauri} = 1.28 x R_{sun}.
#+end_example
#+vindex: org-use-sub-superscripts
#+vindex: org-export-with-sub-superscripts
If you write a text where the underscore is often used in a different
context, Org's convention to always interpret these as subscripts can
get in your way. Configure the variable ~org-use-sub-superscripts~ to
change this convention. For example, when setting this variable to
~{}~, =a_b= is not interpreted as a subscript, but =a_{b}= is.
get in your way. Configure the variable ~org-use-sub-superscripts~
and/or ~org-export-with-sub-superscripts~ to change this convention.
For example, when setting these variables to ~{}~, =a_b= is not
displayed/exported[fn::The underlying markup still remains a
sub/superscript. Only the visual display and export behavior
changes.] as a subscript, but =a_{b}= is.
You can set ~org-use-sub-superscripts~ in a file using the export
option =^:= (see [[*Export Settings][Export Settings]]). For example, =#+OPTIONS: ^:{}=
sets ~org-use-sub-superscripts~ to ~{}~ and limits super- and
You can set both ~org-use-sub-superscripts~
~org-export-with-sub-superscripts~ in a file using the export option
=^:= (see [[*Export Settings][Export Settings]]). For example,
=#+OPTIONS: ^:{}= sets the two options to ~{}~ and limits super- and
subscripts to the curly bracket notation.
You can also toggle the visual display of super- and subscripts:
@ -11365,7 +11404,7 @@ converted into dashes, and =...= becomes a compact set of dots.
Plain ASCII is normally sufficient for almost all note taking.
Exceptions include scientific notes, which often require mathematical
symbols and the occasional formula. LaTeX[fn:36] is widely used to
symbols and the occasional formula. LaTeX[fn:37] is widely used to
typeset scientific documents. Org mode supports embedding LaTeX code
into its files, because many academics are used to writing and reading
LaTeX source code, and because it can be readily processed to produce
@ -11387,7 +11426,7 @@ into images (see [[*Previewing LaTeX fragments]]).
LaTeX fragments do not need any special marking at all. The following
snippets are identified as LaTeX source code:
- Environments of any kind[fn:37]. The only requirement is that the
- Environments of any kind[fn:38]. The only requirement is that the
=\begin= statement appears on a new line, preceded by only
whitespace.
@ -11436,7 +11475,7 @@ lines:
#+vindex: org-preview-latex-default-process
If you have a working LaTeX installation and =dvipng=, =dvisvgm= or
=convert= installed[fn:38], LaTeX fragments can be processed to
=convert= installed[fn:39], LaTeX fragments can be processed to
produce images of the typeset expressions to be used for inclusion
while exporting to HTML (see [[*LaTeX fragments]]), or for inline
previewing within Org mode.
@ -11592,9 +11631,9 @@ Here is an example
#+vindex: org-latex-src-block-backend
If the example is source code from a programming language, or any
other text that can be marked up by Font Lock in Emacs, you can ask
for the example to look like the fontified Emacs buffer[fn:39]. This
for the example to look like the fontified Emacs buffer[fn:40]. This
is done with the code block, where you also need to specify the name
of the major mode that should be used to fontify the example[fn:40],
of the major mode that should be used to fontify the example[fn:41],
see [[*Structure Templates]] for shortcuts to easily insert code blocks.
#+cindex: @samp{BEGIN_SRC}
@ -11608,13 +11647,15 @@ see [[*Structure Templates]] for shortcuts to easily insert code blocks.
#+end_example
Both in =example= and in =src= snippets, you can add a =-n= switch to
the end of the =#+BEGIN= line, to get the lines of the example
numbered. The =-n= takes an optional numeric argument specifying the
starting line number of the block. If you use a =+n= switch, the
numbering from the previous numbered snippet is continued in the
current one. The =+n= switch can also take a numeric argument. This
adds the value of the argument to the last line of the previous block
to determine the starting line number.
the =#+BEGIN= line[fn::In the =src= snippets, switches must be placed
right after the language name and before the [[*Structure of Code
Blocks][header arguments]]], to get the lines of the example numbered.
The =-n= takes an optional numeric argument specifying the starting
line number of the block. If you use a =+n= switch, the numbering
from the previous numbered snippet is continued in the current one.
The =+n= switch can also take a numeric argument. This adds the value
of the argument to the last line of the previous block to determine
the starting line number.
#+begin_example
,#+BEGIN_SRC emacs-lisp -n 20
@ -11863,7 +11904,7 @@ text. Markers always start with =fn:=. For example:
#+begin_example
The Org website[fn:1] now looks a lot better than it used to.
...
[fn:49] The link is: https://orgmode.org
[fn:50] The link is: https://orgmode.org
#+end_example
Org mode extends the number-based syntax to /named/ footnotes and
@ -12152,7 +12193,7 @@ global variables, include:
Language to use for translating certain strings
(~org-export-default-language~). With =#+LANGUAGE: fr=, for
example, Org translates =Table of contents= to the French =Table des
matières=[fn:41].
matières=[fn:42].
- =SELECT_TAGS= ::
@ -12452,7 +12493,7 @@ keyword:
#+cindex: excluding entries from table of contents
#+cindex: table of contents, exclude entries
Org includes both numbered and unnumbered headlines in the table of
contents[fn:42]. If you need to exclude an unnumbered headline,
contents[fn:43]. If you need to exclude an unnumbered headline,
along with all its children, set the =UNNUMBERED= property to =notoc=
value.
@ -12570,7 +12611,7 @@ be omitted to use the obvious defaults.
| =#+INCLUDE: "~/.emacs" :lines "10-"= | Include lines from 10 to EOF |
Inclusions may specify a file-link to extract an object matched by
~org-link-search~[fn:43] (see [[*Search Options in File Links]]). The
~org-link-search~[fn:44] (see [[*Search Options in File Links]]). The
ranges for =:lines= keyword are relative to the requested element.
Therefore,
@ -12610,7 +12651,7 @@ following syntax:
: #+MACRO: name replacement text; $1, $2 are arguments
#+texinfo: @noindent
which can be referenced using ={{{name(arg1, arg2)}}}=[fn:44]. For
which can be referenced using ={{{name(arg1, arg2)}}}=[fn:45]. For
example
#+begin_example
@ -13002,7 +13043,7 @@ should in principle be exportable as a Beamer presentation.
- Org exports a Beamer frame's objects as block environments. Org can
enforce wrapping in special block types when =BEAMER_ENV= property
is set[fn:45]. For valid values see
is set[fn:46]. For valid values see
~org-beamer-environments-default~. To add more values, see
~org-beamer-environments-extra~.
#+vindex: org-beamer-environments-default
@ -13620,7 +13661,7 @@ different ways on HTML pages. The default is to use the
with Org[fn:: By default, Org loads MathJax from
[[https://www.jsdelivr.com/][jsDelivr]], as recommended in
[[https://docs.mathjax.org/en/latest/web/start.html][Getting Started
with MathJax Components]].][fn:46]. Some MathJax display options can
with MathJax Components]].][fn:47]. Some MathJax display options can
be configured via ~org-html-mathjax-options~, or in the buffer. For
example, with the following settings,
@ -13939,7 +13980,7 @@ LaTeX export backend finds the compiler version to use from
Org file. See the docstring for the
~org-latex-default-packages-alist~ for loading packages with certain
compilers. Also see ~org-latex-bibtex-compiler~ to set the
bibliography compiler[fn:47].
bibliography compiler[fn:48].
*** LaTeX specific export settings
:PROPERTIES:
@ -14747,9 +14788,11 @@ https://en.wikipedia.org/wiki/Markdown for more details.
#+vindex: org-md-headline-style
Based on ~org-md-headline-style~, Markdown export can generate
headlines of both /atx/ and /setext/ types. /setext/ limits headline
levels to two whereas /atx/ limits headline levels to six. Beyond
these limits, the export backend converts headlines to lists. To set
a limit to a level before the absolute limit (see [[*Export Settings]]).
levels to two whereas /atx/ limits headline levels to six. /mixed/
exports headline levels one and two in /setext/-style, and headline
levels three through six as /atx/-style headlines. Beyond these
limits, the export backend converts headlines to lists. To set a
limit to a level before the absolute limit (see [[*Export Settings]]).
** OpenDocument Text Export
:PROPERTIES:
@ -16679,8 +16722,9 @@ Parse the temporary buffer, creating AST:
property drawers, statistics cookies, timestamps, etc according
to =#+OPTIONS= keyword (see [[*Export Settings]]);
- Table rows containing width and alignment markers (see [[*Column
Width and Alignment]]);
- Table rows containing width and alignment markers, unless the
selected export backend changes ~:with-special-rows~ export option
to non-nil (see [[*Column Width and Alignment]]);
- Table columns containing recalc marks (see [[*Advanced features]]).
@ -16711,8 +16755,8 @@ Convert the AST to text by traversing the AST nodes, depth-first:
node contents;
4. Convert the nodes with children to text, passing the nodes
themselves and their contents to the corresponding transcoders
and then to the export filters (see [[*Filters]]).
themselves and their exported contents to the corresponding
transcoders and then to the export filters (see [[*Filters]]).
#+texinfo: @noindent
@ -17374,12 +17418,12 @@ place on the web server, and publishing images to it.
#+begin_src emacs-lisp
(setq org-publish-project-alist
'(("orgfiles"
`(("orgfiles"
:base-directory "~/org/"
:base-extension "org"
:publishing-directory "/ssh:user@host:~/html/notebook/"
:publishing-function org-html-publish-to-html
:exclude "PrivatePage.org" ;; regexp
:exclude ,(rx (or "PrivateFile.org" (seq line-start "private/"))) ;; regexp
:headline-levels 3
:section-numbers nil
:with-toc nil
@ -17612,9 +17656,14 @@ your LaTeX installation, it won't export to anything but PDF.
specifies the =biblatex= export processor with the default =numeric=
style and the =bibtex= backend. Always define the style first and then
the rest of load-time options for the =biblatex=
package. Alternatively, use the ~org-cite-biblatex-options~ variable
in your Emacs configuration. It will only export to PDF, since it
relies on the ~biblatex~ processor of your LaTeX installation;
package. Alternatively, you can use the ~key=val,key=val~ format for
the options as documented in the =biblatex= package documentation:
: #+cite_export: biblatex backend=bibtex,style=numeric
The ~org-cite-biblatex-options~ variable in your Emacs configuration
uses this format. It will only export to PDF, since it relies on the
~biblatex~ processor of your LaTeX installation.
** Bibliography printing
@ -18555,7 +18604,7 @@ block, collects the results, and inserts them in the buffer.
#+cindex: @samp{CALL}, keyword
#+vindex: org-babel-inline-result-wrap
By calling a named code block[fn:48] from an Org mode buffer or
By calling a named code block[fn:49] from an Org mode buffer or
a table. Org can call the named code blocks from the current Org mode
buffer or from the "Library of Babel" (see [[*Library of Babel]]).
@ -18763,7 +18812,7 @@ they are mutually exclusive.
- =value= ::
Default for most Babel libraries[fn:48]. Functional mode. Org
Default for most Babel libraries[fn:49]. Functional mode. Org
gets the value by wrapping the code in a function definition in the
language of the source block. That is why when using =:results
value=, code should execute like a function and return a value. For
@ -18930,6 +18979,11 @@ Choose one of the options; they are mutually exclusive. The default
follows from the type specified above.
#+attr_texinfo: :sep ,
- =raw= ::
Interpreted as raw Org mode. Inserted directly into the buffer.
Aligned if it is a table. Usage example: =:results value raw=.
- =code= ::
Result enclosed in a code block. Useful for parsing. Usage
@ -18937,8 +18991,9 @@ follows from the type specified above.
- =drawer= ::
Result wrapped in a =RESULTS= drawer. Useful for containing =raw=
or =org= results for later scripting and automated processing.
Results are added directly to the Org file as with =raw=, but are
wrapped in a =RESULTS= drawer or results macro (for inline code
blocks), for later scripting and automated processing.
Usage example: =:results value drawer=.
- =html= ::
@ -18983,10 +19038,6 @@ follows from the type specified above.
block. Languages supported: Emacs Lisp, Python, and Ruby. Usage
example: =:results value pp=.
- =raw= ::
Interpreted as raw Org mode. Inserted directly into the buffer.
Aligned if it is a table. Usage example: =:results value raw=.
#+cindex: @samp{wrap}, header argument
The =wrap= header argument unconditionally marks the results block by
@ -19625,7 +19676,7 @@ the second code block is expanded as
#+end_example
Note that noweb expansion does not automatically carry over =:var=
header arguments[fn:49].
header arguments[fn:50].
You may also include the contents of multiple blocks sharing a common
=noweb-ref= header argument, which can be set at the file, subtree,
@ -20167,7 +20218,7 @@ in the desired amount with hard spaces and hiding leading stars.
To display the buffer in the indented view, activate Org Indent minor
mode, using {{{kbd(M-x org-indent-mode)}}}. Text lines that are not
headlines are prefixed with virtual spaces to vertically align with
the headline text[fn:50].
the headline text[fn:51].
#+vindex: org-indent-indentation-per-level
To make more horizontal space, the headlines are shifted by two
@ -20195,7 +20246,7 @@ use =STARTUP= keyword as follows:
It is possible to use hard spaces to achieve the indentation instead,
if the bare ASCII file should have the indented look also outside
Emacs[fn:51]. With Org's support, you have to indent all lines to
Emacs[fn:52]. With Org's support, you have to indent all lines to
line up with the outline headers. You would use these settings[fn::
~org-adapt-indentation~ can also be set to ='headline-data=, in which
case only data lines below the headline will be indented.]:
@ -21362,7 +21413,7 @@ Tags]]) only for those set in these variables.
#+vindex: org-mobile-directory
The mobile application needs access to a file directory on
a server[fn:52] to interact with Emacs. Pass its location through
a server[fn:53] to interact with Emacs. Pass its location through
the ~org-mobile-directory~ variable. If you can mount that directory
locally just set the variable to point to that directory:
@ -21406,7 +21457,7 @@ Symbolic links in ~org-directory~ need to have the same name as their
targets.].
Push creates a special Org file =agendas.org= with custom agenda views
defined by the user[fn:53].
defined by the user[fn:54].
Finally, Org writes the file =index.org=, containing links to other
files. The mobile application reads this file first from the server
@ -21772,7 +21823,7 @@ of these strategies:
To wrap a source table in LaTeX, use the =comment= environment
provided by =comment.sty=[fn:: https://www.ctan.org/pkg/comment]. To
activate it, put ~\usepackage{comment}~ in the document header.
Orgtbl mode inserts a radio table skeleton[fn:54] with the command
Orgtbl mode inserts a radio table skeleton[fn:55] with the command
{{{kbd(M-x orgtbl-insert-radio-table)}}}, which prompts for a table
name. For example, if =salesfigures= is the name, the template
inserts:
@ -21792,7 +21843,7 @@ The line =#+ORGTBL: SEND= tells Orgtbl mode to use the function
~orgtbl-to-latex~ to convert the table to LaTeX format, then insert
the table at the target (receive) location named =salesfigures=. Now
the table is ready for data entry. It can even use spreadsheet
features[fn:55]:
features[fn:56]:
#+begin_example
% BEGIN RECEIVE ORGTBL salesfigures
@ -23094,7 +23145,10 @@ With =lognoterepeat=, you will also be prompted for a note.
than 30 stars. This is a hard-coded limitation of ~lmax~ in
~org-clock-sum~.
[fn:28] On computers using macOS, idleness is based on actual user
[fn:28] When using ~:step~, ~untilnow~ starts from the beginning of
2003, not the beginning of time.
[fn:29] On computers using macOS, idleness is based on actual user
idleness, not just Emacs' idle time. For X11, you can install a
utility program =x11idle.c=, available in the =org-contrib/=
repository, or install the xprintidle package and set it to the
@ -23102,13 +23156,13 @@ variable ~org-clock-x11idle-program-name~ if you are running Debian,
to get the same general treatment of idleness. On other systems, idle
time refers to Emacs idle time only.
[fn:29] Org used to offer four different targets for date/week tree
[fn:30] Org used to offer four different targets for date/week tree
capture. Now, Org automatically translates these to use
~file+olp+datetree~, applying the ~:time-prompt~ and ~:tree-type~
properties. Please rewrite your date/week-tree targets using
~file+olp+datetree~ since the older targets are now deprecated.
[fn:30] A date tree is an outline structure with years on the highest
[fn:31] A date tree is an outline structure with years on the highest
level, months or ISO weeks as sublevels and then dates on the lowest
level.
@ -23122,15 +23176,15 @@ level.
TODO state, priority, tags, statistics cookies, and COMMENT keywords
are allowed in the tree structure.
[fn:31] This is always the other, not the user. See the variable
[fn:32] This is always the other, not the user. See the variable
~org-link-from-user-regexp~.
[fn:32] For backward compatibility, the universal prefix argument
[fn:33] For backward compatibility, the universal prefix argument
{{{kbd(C-u)}}} causes all TODO entries to be listed before the agenda.
This feature is deprecated, use the dedicated TODO list, or a block
agenda instead (see [[*Block agenda]]).
[fn:33] Custom agenda commands can preset a filter by binding one of
[fn:34] Custom agenda commands can preset a filter by binding one of
the variables ~org-agenda-tag-filter-preset~,
~org-agenda-category-filter-preset~, ~org-agenda-effort-filter-preset~
or ~org-agenda-regexp-filter-preset~ as an option. This filter is
@ -23140,72 +23194,72 @@ property of the entire agenda view---in a block agenda, you should
only set this in the global options section, not in the section of an
individual block.
[fn:34] /Planned/ means here that these entries have some planning
[fn:35] /Planned/ means here that these entries have some planning
information attached to them, like a timestamp, a scheduled or
a deadline string. See ~org-agenda-entry-types~ on how to set what
planning information is taken into account.
[fn:35] To create PDF output, the Ghostscript ps2pdf utility must be
[fn:36] To create PDF output, the Ghostscript ps2pdf utility must be
installed on the system. Selecting a PDF file also creates the
postscript file.
[fn:36] LaTeX is a macro system based on Donald\nbsp{}E.\nbsp{}Knuth's TeX
[fn:37] LaTeX is a macro system based on Donald\nbsp{}E.\nbsp{}Knuth's TeX
system. Many of the features described here as "LaTeX" are really
from TeX, but for simplicity I am blurring this distinction.
[fn:37] When MathJax is used, only the environments recognized by
[fn:38] When MathJax is used, only the environments recognized by
MathJax are processed. When dvipng, dvisvgm, or ImageMagick suite is
used to create images, any LaTeX environment is handled.
[fn:38] These are respectively available at
[fn:39] These are respectively available at
[[https://sourceforge.net/projects/dvipng/]], [[http://dvisvgm.bplaced.net/]]
and from the ImageMagick suite. Choose the converter by setting the
variable ~org-preview-latex-default-process~ accordingly.
[fn:39] This works automatically for the HTML backend (it requires
[fn:40] This works automatically for the HTML backend (it requires
version 1.34 of the =htmlize.el= package, which you need to install).
Fontified code chunks in LaTeX can be achieved using either the
[[https://www.ctan.org/pkg/listings][listings]] LaTeX package, [[https://www.ctan.org/pkg/minted][minted]] LaTeX package, or by using
[[https://elpa.gnu.org/packages/engrave-faces.html][engrave-faces]] . Refer to ~org-latex-src-block-backend~ for details.
[fn:40] Source code in code blocks may also be evaluated either
[fn:41] Source code in code blocks may also be evaluated either
interactively or on export. See [[*Working with Source Code]] for more
information on evaluating code blocks.
[fn:41] For export to LaTeX format---or LaTeX-related formats such as
[fn:42] For export to LaTeX format---or LaTeX-related formats such as
Beamer---, the =org-latex-package-alist= variable needs further
configuration. See [[LaTeX specific export settings]].
[fn:42] At the moment, some export backends do not obey this
[fn:43] At the moment, some export backends do not obey this
specification. For example, LaTeX export excludes every unnumbered
headline from the table of contents.
[fn:43] Note that ~org-link-search-must-match-exact-headline~ is
[fn:44] Note that ~org-link-search-must-match-exact-headline~ is
locally bound to non-~nil~. Therefore, ~org-link-search~ only matches
headlines and named elements.
[fn:44] Since commas separate the arguments, commas within arguments
[fn:45] Since commas separate the arguments, commas within arguments
have to be escaped with the backslash character. So only those
backslash characters before a comma need escaping with another
backslash character.
[fn:45] If =BEAMER_ENV= is set, Org export adds =B_environment= tag
[fn:46] If =BEAMER_ENV= is set, Org export adds =B_environment= tag
to make it visible. The tag serves as a visual aid and has no
semantic relevance.
[fn:46] Please note that exported formulas are part of an HTML
[fn:47] Please note that exported formulas are part of an HTML
document, and that signs such as =<=, =>=, or =&= have special
meanings. See [[https://docs.mathjax.org/en/latest/input/tex/html.html#tex-and-latex-in-html-documents][MathJax TeX and LaTeX in HTML documents]].
[fn:47] This does not allow setting different bibliography compilers
[fn:48] This does not allow setting different bibliography compilers
for different files. However, "smart" LaTeX compilation systems, such
as latexmk, can select the correct bibliography compiler.
[fn:48] Actually, the constructs =call_<name>()= and =src_<lang>{}=
[fn:49] Actually, the constructs =call_<name>()= and =src_<lang>{}=
are not evaluated when they appear in a keyword (see [[*Summary of
In-Buffer Settings]]).
[fn:49] In the following example, attempting to evaluate
[fn:50] In the following example, attempting to evaluate
the second code block will give an error, because the variables
defined in the first code block will not be defined in the second
block.
@ -23233,29 +23287,29 @@ values.
,#+END_SRC
#+end_example
[fn:50] Org Indent mode also sets ~wrap-prefix~ correctly for
[fn:51] Org Indent mode also sets ~wrap-prefix~ correctly for
indenting and wrapping long lines of headlines or text. This minor
mode also handles Visual Line mode and directly applied settings
through ~word-wrap~.
[fn:51] This works, but requires extra effort. Org Indent mode is
[fn:52] This works, but requires extra effort. Org Indent mode is
more convenient for most applications.
[fn:52] For a server to host files, consider using a WebDAV server,
[fn:53] For a server to host files, consider using a WebDAV server,
such as [[https://nextcloud.com][Nextcloud]]. Additional help is at this [[https://orgmode.org/worg/org-faq.html#mobileorg_webdav][FAQ entry]].
[fn:53] While creating the agendas, Org mode forces =ID= properties
[fn:54] While creating the agendas, Org mode forces =ID= properties
on all referenced entries, so that these entries can be uniquely
identified if Org Mobile flags them for further action. To avoid
setting properties configure the variable
~org-mobile-force-id-on-agenda-items~ to ~nil~. Org mode then relies
on outline paths, assuming they are unique.
[fn:54] By default this works only for LaTeX, HTML, and Texinfo.
[fn:55] By default this works only for LaTeX, HTML, and Texinfo.
Configure the variable ~orgtbl-radio-table-templates~ to install
templates for other modes.
[fn:55] If the =TBLFM= keyword contains an odd number of dollar
[fn:56] If the =TBLFM= keyword contains an odd number of dollar
characters, this may cause problems with Font Lock in LaTeX mode. As
shown in the example you can fix this by adding an extra line inside
the =comment= environment that is used to balance the dollar

View File

@ -13,6 +13,49 @@ Please send Org bug reports to mailto:emacs-orgmode@gnu.org.
* Version 9.7 (not released yet)
** Important announcements and breaking changes
*** ~org-auto-align-tags~ is now respected universally
Previously, only a subset of Org editing commands respected
~org-auto-align-tags~ option. Now, it is no longer the case. All the
editing commands, including typing (~org-self-insert-command~) and
deletion respect the option.
~org-auto-align-tags~ is still enabled by default. For users who
customized ~org-auto-align-tags~ to nil, ~org-edit-headline~,
~org-priority~, ~org-set-tags~, ~org-entry-put~, ~org-kill-line~, and
typing/deleting in headlines will no longer unconditionally auto-align
the tags.
*** ~org-create-file-search-functions~ can use ~org-list-store-props~ to suggest link description
In Org <9.0, ~org-create-file-search-functions~ could set ~description~
variable to suggest link description for the stored link. However,
this feature stopped working since Org 9.0 switched to lexical binding.
Now, it is again possible for ~org-create-file-search-functions~ to
supply link descriptions using ~(org-list-store-props :description
"suggested description")~ in the search function body.
*** Inline image width value in =#+attr_org= is preferred over other =#+attr_...= keywords
Previously, when ~org-image-actual-width~ is a list or nil, Org used the
first =#+attr_...= keyword containing =:width ...= to compute the inline
image width. Now, =#+attr_org=, if present, takes precedence.
In the following example the image preview has width of 75%
while earlier versions pick 33%.
: #+attr_html: :width 33%
: #+attr_org: :width 0.75
: [[image.png]]
*** =ox-html=: When exporting footnotes with custom non-number names, the names are used as link anchors
Previously, link anchors for footnote references and footnote
definitions were based on the footnote number: =fn.1=, =fnr.15=, etc.
Now, when the footnote has a non-number name, it is used as an anchor:
=fn.name=, =fnr.name=.
*** Underline syntax now takes priority over subscript when both are applicable
Previously, Org mode interpreted =(_text_)= as subscript.
@ -83,6 +126,11 @@ transcoders.
Users can disable citations processors by customizing new
~org-export-process-citations~ option.
*** =ox-org= preserves header non-default arguments in src blocks
Previously, all the header arguments where stripped from src blocks
during export. Now, header arguments are preserved as long as their
values are not equal to the default header argument values.
*** =ox-org= disables citation processors by default
@ -314,7 +362,43 @@ Now, ~org-store-link~ moves the stored link to front of the list of
stored links. This way, the link will show up first in the completion
and when inserting all the stored links with ~org-insert-all-links~.
*** Major changes and additions to Org API
*** Major changes and additions to Org element API
**** Diary type timestamps now support optional time/timerange
Previously, diary type timestamps could not specify time.
Now, it is allowed to add a time or time range:
: <%%(diary-float t 4 2) 22:00-23:00>
: <%%(diary-float t 4 2) 10:30>
The parsed representation of such timestamps will have ~:hour-start~,
~:minute-start~, ~:hour-end~, ~:minute-end~, and ~:range-type~
properties set appropriately. In addition, a new ~:diary-sexp~
property will store the diary sexp value.
For example,
: <%%(diary-float t 4 2) 22:00-23:00>
will have the following properties
#+begin_src emacs-lisp
:type: diary
:range-type: timerange
:raw-value: "<%%(diary-float t 4 2) 22:00-23:00>"
:year-start: nil
:month-start: nil
:day-start: nil
:hour-start: 22
:minute-start: 0
:year-end: nil
:month-end: nil
:day-end: nil
:hour-end: 23
:minute-end: 0
:diary-sexp: "(diary-float t 4 2)"
#+end_src
**** New term: "syntax node"
To reduce confusion with "element" referring to both "syntax element"
@ -636,7 +720,57 @@ This behaviour has been expanded to store an additional =CUSTOM_ID=
link when storing any type of external link type in an Org file, not
just =id:= links.
*** ~org-ctags~ is not activated by default any more
To follow Emacs [[info:elisp#Coding Conventions][coding conventions]] and to avoid confusion of users
who accidentally get ~org-ctags~ autoloaded due to help completion,
the library does not modify ~org-open-link-functions~ during loading
any more. Run ~org-ctags-enable~ to setup hooks and advices:
#+begin_src emacs-lisp
(with-eval-after-load "org-ctags"
(org-ctags-enable))
#+end_src
** New and changed options
*** New option controlling how Org mode sorts things ~org-sort-function~
Sorting of agenda items, tables, menus, headlines, etc can now be
controlled using a new custom option ~org-sort-function~.
By default, Org mode sorts things according to the operation system
language. However, language sorting rules may or may not produce good
results depending on the use case. For example, multi-language
documents may be sorted weirdly when sorting rules for system language
are applied on the text written using different language. Also, some
operations systems (e.g. MacOS), do not provide accurate string
sorting rules.
Org mode provides 3 possible values for ~org-sort-function~:
1. (default) Sort using system language rules.
2. Sort using string comparison (~compare-strings~), making use of UTF
case conversion. This may work better for mixed-language documents
and on MacOS.
3. Custom function, if the above does not fit the needs.
*** =ob-latex= now uses a new option ~org-babel-latex-process-alist~ to generate png output
Previously, =ob-latex= used ~org-preview-latex-default-process~ from
~org-preview-latex-process-alist~ to produce png output. Now, the
process settings are separated into a new dedicated option
~org-babel-latex-process-alist~.
The default value is pulled from =dvipng= process type from
~org-preview-latex-process-alist~, preserving the existing behavior.
However, the output is now immune to changes in
~org-preview-latex-default-process~ and can be customized
independently of the image preview settings.
*** ~org-babel-lua-multiple-values-separator~
The string that separates the values of multi-valued results returned
from Lua code blocks.
*** =.avif= images are now recognized in ~org-html-inline-image-rules~
In =ox-html=, =.avif= image links are now inlined by default.
@ -999,7 +1133,58 @@ even though it does not have its own ID. By giving files top-level id
properties, links to headlines in the file can also be made more
robust by using the file id instead of the file path.
*** New option ~latex-default-footnote-command~ to customize the LaTeX footnote command
This new option allows you to define the LaTeX command the Org mode
footnotes are converted to (for example ~\sidenote{%s%s}~ instead of
the default ~\footnote{%s%s}~).
The option can be customized either by
1. setting the global variable in the ~org-export-latex~ customization
group or
2. by setting the file local keyword =LATEX_FOOTNOTE_COMMAND=
*** Options for ~#+cite_export: biblatex~ can use the package's option syntax
When using =biblatex= to export bibliographies, you can use the format
as specified in the =biblatex= package documentation as
=key=val,key=val,...=
*** New option ~org-columns-dblock-formatter~
=colview= dynamic blocks now understand a new ~:formatter~ parameter
to use a specific function for formatting and inserting the contents
of the dynamic block. This new option can be used to set the global
default formatting function that will be used for =colview= dynamic
blocks that do not specify any ~:formatter~ parameter. Its default
value (the new function ~org-columns-dblock-write-default~) yields the
previous (fixed) formatting behaviour.
*** New allowed value of ~org-md-headline-style~ to mix ATX and Setext style headlines
Setting ~org-md-headline-style~ to ~'mixed~ will export headline
levels one and two as Setext style headlines, and headline levels
three through six will be exported as ATX style headlines.
** New features
*** =ob-lua=: Support all types and multiple values in results
Lua code blocks can now return values of any type and can also return
multiple values. Previously, values of certain types were incorrectly
converted to the empty string =""=, which broke HTML export for inline
code blocks, and multiple values were incorrectly concatenated, where
~return 1, 2, 3~ was evaluated as =123=.
Multiple values are comma-separated by default, so that they work well
with inline code blocks. To change the string used as the separator,
customize ~org-babel-lua-multiple-values-separator~.
*** ~org-paste-subtree~ now handles =C-u= and =C-u C-u= prefix arguments specially
With =C-u= prefix argument, force inserting a sibling heading below.
With =C-u C-u= prefix argument, force inserting a child heading.
*** =colview= dynamic block now writes column width specifications
When column format contains width specifications, =colview= dynamic
@ -1030,6 +1215,31 @@ Example:
: | PROYECTO EMACS |
: #+END:
*** =colview= dynamic block supports custom formatting function
The =colview= dynamic block understands a new ~:formatter~ parameter,
which specifies a user-supplied function to format and insert the data
in the dynamic block.
A global default formatting function for =colview= dynamic blocks can
be set via the new option ~org-columns-dblock-formatter~ which
defaults to the new function ~org-columns-dblock-write-default~, that
implements the previous (fixed) formatting behaviour. Hence, the
default behaviour is identical to previous versions.
The global default function can be overridden for any given =colview=
dynamic block individually by specifying a custom formatter function
using the new ~:formatter~ parameter on the block's =BEGIN= line.
This new feature replicates the ~:formatter~ option already available
for =clocktable= dynamic blocks.
*** =colview= dynamic block can link to headlines
The =colview= dynamic block understands a new ~:link~ parameter, which
when non-~nil~ causes =ITEM= headlines in the table to be linked to
their origins.
*** =ob-tangle.el=: New flag to remove tangle targets before writing
When ~org-babel-tangle-remove-file-before-write~ is set to ~t~ the

View File

@ -66,17 +66,21 @@
(lambda (pair)
(let ((val (cdr pair)))
(calc-push-list
;; For a vector, Calc follows the format (vec 1 2 3 ...) so
;; a matrix becomes (vec (vec 1 2 3) (vec 4 5 6) ...). See
;; the comments in "Arithmetic routines." section of
;; calc.el.
(list (if (listp val)
(cons 'vec
(if (null (cdr val))
(car val)
(mapcar (lambda (x) (if (listp x) (cons 'vec x) x))
val)))
val))))
(list
(cond
;; For a vector, Calc follows the format (vec 1 2 3 ...) so
;; a matrix becomes (vec (vec 1 2 3) (vec 4 5 6) ...). See
;; the comments in "Arithmetic routines." section of
;; calc.el.
((listp val)
(cons 'vec
(if (null (cdr val))
(car val)
(mapcar (lambda (x) (if (listp x) (cons 'vec x) x))
val))))
((numberp val)
(math-read-number (number-to-string val)))
(t val)))))
(calc-store-into (car pair)))
vars)
(mapc

View File

@ -3136,47 +3136,47 @@ block but are passed literally to the \"example-block\"."
(with-current-buffer parent-buffer
(buffer-chars-modified-tick)))))
(cl-macrolet ((c-wrap
(s)
;; Comment string S, according to LANG mode. Return new
;; string.
`(unless org-babel-tangle-uncomment-comments
(with-temp-buffer
(funcall (org-src-get-lang-mode lang))
(comment-region (point)
(progn (insert ,s) (point)))
(org-trim (buffer-string)))))
(s)
;; Comment string S, according to LANG mode. Return new
;; string.
`(unless org-babel-tangle-uncomment-comments
(with-temp-buffer
(funcall (org-src-get-lang-mode lang))
(comment-region (point)
(progn (insert ,s) (point)))
(org-trim (buffer-string)))))
(expand-body
(i)
;; Expand body of code represented by block info I.
`(let ((b (if (org-babel-noweb-p (nth 2 ,i) :eval)
(org-babel-expand-noweb-references ,i)
(nth 1 ,i))))
(if (not comment) b
(let ((cs (org-babel-tangle-comment-links ,i)))
(concat (c-wrap (car cs)) "\n"
b "\n"
(c-wrap (cadr cs)))))))
(i)
;; Expand body of code represented by block info I.
`(let ((b (if (org-babel-noweb-p (nth 2 ,i) :eval)
(org-babel-expand-noweb-references ,i)
(nth 1 ,i))))
(if (not comment) b
(let ((cs (org-babel-tangle-comment-links ,i)))
(concat (c-wrap (car cs)) "\n"
b "\n"
(c-wrap (cadr cs)) "\n")))))
(expand-references
(ref)
`(pcase (gethash ,ref org-babel-expand-noweb-references--cache)
(`(,last . ,previous)
;; Ignore separator for last block.
(let ((strings (list (expand-body last))))
(dolist (i previous)
(let ((parameters (nth 2 i)))
;; Since we're operating in reverse order, first
;; push separator, then body.
(push (or (cdr (assq :noweb-sep parameters)) "\n")
strings)
(push (expand-body i) strings)))
(mapconcat #'identity strings "")))
;; Raise an error about missing reference, or return the
;; empty string.
((guard (or org-babel-noweb-error-all-langs
(member lang org-babel-noweb-error-langs)))
(error "Cannot resolve %s (see `org-babel-noweb-error-langs')"
(org-babel-noweb-wrap ,ref)))
(_ ""))))
(ref)
`(pcase (gethash ,ref org-babel-expand-noweb-references--cache)
(`(,last . ,previous)
;; Ignore separator for last block.
(let ((strings (list (expand-body last))))
(dolist (i previous)
(let ((parameters (nth 2 i)))
;; Since we're operating in reverse order, first
;; push separator, then body.
(push (or (cdr (assq :noweb-sep parameters)) "\n")
strings)
(push (expand-body i) strings)))
(mapconcat #'identity strings "")))
;; Raise an error about missing reference, or return the
;; empty string.
((guard (or org-babel-noweb-error-all-langs
(member lang org-babel-noweb-error-langs)))
(error "Cannot resolve %s (see `org-babel-noweb-error-langs')"
(org-babel-noweb-wrap ,ref)))
(_ ""))))
(replace-regexp-in-string
noweb-re
(lambda (m)
@ -3360,10 +3360,22 @@ situations in which is it not appropriate."
(string= cell "*this*")))
;; FIXME: Arbitrary code evaluation.
(eval (read cell) t))
((save-match-data
(and (string-match "^[[:space:]]*\"\\(.*\\)\"[[:space:]]*$" cell)
(not (string-match "[^\\]\"" (match-string 1 cell)))))
(read cell))
((let (read-val)
(and (string-match-p
(rx bos (0+ (any space ?\n))
?\" (0+ anychar) ?\"
(0+ (any space ?\n)) eos)
cell)
;; CELL is a single string
(with-temp-buffer
(insert cell)
(goto-char 1)
(when (setq read-val
(ignore-errors
(read (current-buffer))))
(skip-chars-forward "[:space:]")
(eobp)))
read-val)))
(t (org-no-properties cell))))
(defun org-babel--string-to-number (string)
@ -3389,7 +3401,9 @@ SEPARATOR is passed to `org-table-convert-region', which see."
;; If the file was empty, don't bother trying to
;; convert the table.
(when (> pmax 1)
(org-table-convert-region (point-min) pmax separator)
(org-table-convert-region
(point-min) pmax
(or separator 'babel-auto))
(delq nil
(mapcar (lambda (row)
(and (not (eq row 'hline))

View File

@ -238,7 +238,10 @@ this template."
((not (string= replacement
(buffer-substring begin end)))
(delete-region begin end)
(insert replacement))))))
(insert replacement))
;; Replacement is the same as the source
;; block. Continue onwards.
(t (goto-char end))))))
((or `babel-call `inline-babel-call)
(org-babel-exp-do-export
(or (org-babel-lob-get-info element)
@ -367,7 +370,7 @@ The function respects the value of the :exports header argument."
nil))))
(defcustom org-babel-exp-code-template
"#+begin_src %lang%switches%flags\n%body\n#+end_src"
"#+begin_src %lang%switches%flags%header-args\n%body\n#+end_src"
"Template used to export the body of code blocks.
This template may be customized to include additional information
such as the code block name, or the values of particular header
@ -379,6 +382,7 @@ and the following %keys may be used.
body ------ the body of the code block
switches -- the switches associated to the code block
flags ----- the flags passed to the code block
header-args the non-default header arguments of the code block
In addition to the keys mentioned above, every header argument
defined for the code block may be used as a key and will be
@ -388,7 +392,7 @@ replaced with its value."
:package-version '(Org . "9.6"))
(defcustom org-babel-exp-inline-code-template
"src_%lang[%switches%flags]{%body}"
"src_%lang[%switches%flags%header-args]{%body}"
"Template used to export the body of inline code blocks.
This template may be customized to include additional information
such as the code block name, or the values of particular header
@ -400,6 +404,7 @@ and the following %keys may be used.
body ------ the body of the code block
switches -- the switches associated to the code block
flags ----- the flags passed to the code block
header-args the non-default header arguments of the code block
In addition to the keys mentioned above, every header argument
defined for the code block may be used as a key and will be
@ -432,6 +437,41 @@ replaced with its value."
(and (org-string-nw-p f) (concat " " f))))
("flags" . ,(let ((f (assq :flags (nth 2 info))))
(and f (concat " " (cdr f)))))
("header-args"
.
,(let* ((header-args
(mapcar
(lambda (pair)
;; Do no include special parameters, parameters with
;; their values equal to defaults.
(unless (or
;; Special parameters that are not real header
;; arguments.
(memq (car pair)
'( :result-params :result-type
;; This is an obsolete parameter still
;; used in some tests.
:flags))
;; Global defaults.
(equal (cdr pair)
(alist-get
(car pair)
(if (eq type 'inline) org-babel-default-inline-header-args
org-babel-default-header-args)))
;; Per-language defaults.
(let ((lang-headers
(intern
(concat "org-babel-default-header-args:"
(nth 0 info)))))
(and (boundp lang-headers)
(equal (cdr pair)
(alist-get (car pair)
(eval lang-headers t))))))
(format "%s %s" (car pair) (cdr pair))))
(nth 2 info)))
(header-arg-string
(mapconcat #'identity (delq nil header-args) " ")))
(unless (seq-empty-p header-arg-string) (concat " " header-arg-string))))
,@(mapcar (lambda (pair)
(cons (substring (symbol-name (car pair)) 1)
(format "%S" (cdr pair))))

View File

@ -52,6 +52,7 @@
(defvar org-format-latex-options) ; From org.el
(defvar org-latex-default-packages-alist) ; From org.el
(defvar org-latex-packages-alist) ; From org.el
(defvar org-preview-latex-process-alist) ; From org.el
(defvar org-babel-default-header-args:latex
'((:results . "latex") (:exports . "results"))
@ -128,6 +129,18 @@ exporting the literal LaTeX source."
:group 'org-babel
:type '(repeat (string)))
(defcustom org-babel-latex-process-alist
`(,(cons 'png (alist-get 'dvipng org-preview-latex-process-alist)))
"Definitions of external processes for LaTeX result generation.
See `org-preview-latex-process-alist' for more details.
The following process symbols are recognized:
- `png' :: Process used to produce .png output."
:group 'org-babel
:package-version '(Org . "9.7")
:type '(alist :tag "LaTeX to image backends"
:value-type (plist)))
(defun org-babel-expand-body:latex (body params)
"Expand BODY according to PARAMS, return the expanded body."
(mapc (lambda (pair) ;; replace variables
@ -169,9 +182,10 @@ This function is called by `org-babel-execute-src-block'."
((and (string-suffix-p ".png" out-file) (not imagemagick))
(let ((org-format-latex-header
(concat org-format-latex-header "\n"
(mapconcat #'identity headers "\n"))))
(mapconcat #'identity headers "\n")))
(org-preview-latex-process-alist org-babel-latex-process-alist))
(org-create-formula-image
body out-file org-format-latex-options in-buffer)))
body out-file org-format-latex-options in-buffer 'png)))
((string= "svg" extension)
(with-temp-file tex-file
(insert (concat (funcall org-babel-latex-preamble params)

View File

@ -81,6 +81,12 @@ This will typically be `lua-mode'."
:package-version '(Org . "8.3")
:type 'symbol)
(defcustom org-babel-lua-multiple-values-separator ", "
"Separate multiple values with this string."
:group 'org-babel
:package-version '(Org . "9.7")
:type 'string)
(defun org-babel-execute:lua (body params)
"Execute Lua BODY according to PARAMS.
This function is called by `org-babel-execute-src-block'."
@ -251,41 +257,47 @@ function main()
%s
end
fd=io.open(\"%s\", \"w\")
fd:write( main() )
fd:close()")
(defvar org-babel-lua-pp-wrapper-method
"
-- table to string
function t2s(t, indent)
function dump(it, indent)
if indent == nil then
indent = \"\"
indent = ''
end
if type(t) == \"table\" then
ts = \"\"
for k,v in pairs(t) do
if type(v) == \"table\" then
ts = ts .. indent .. t2s(k,indent .. \" \") .. \" = \\n\" ..
t2s(v, indent .. \" \")
else
ts = ts .. indent .. t2s(k,indent .. \" \") .. \" = \" ..
t2s(v, indent .. \" \") .. \"\\n\"
if type(it) == 'table' and %s then
local count = 0
for _ in pairs(it) do
count = count + 1
end
local result = ''
if #indent ~= 0 then
result = result .. '\\n'
end
for key, value in pairs(it) do
result = result
.. indent
.. dump(key)
.. ' = '
.. dump(value, indent .. ' ')
count = count - 1
if count ~= 0 then
result = result .. '\\n'
end
end
return ts
return result
else
return tostring(t)
return tostring(it)
end
end
function main()
%s
function combine(...)
local result = {}
for index = 1, select('#', ...) do
result[index] = dump(select(index, ...))
end
return table.concat(result, '%s')
end
fd=io.open(\"%s\", \"w\")
fd:write(t2s(main()))
fd:close()")
output = io.open('%s', 'w')
output:write(combine(main()))
output:close()")
(defun org-babel-lua-evaluate
(session body &optional result-type result-params preamble)
@ -319,15 +331,17 @@ PREAMBLE string is appended to BODY."
(concat
preamble (and preamble "\n")
(format
(if (member "pp" result-params)
org-babel-lua-pp-wrapper-method
org-babel-lua-wrapper-method)
org-babel-lua-wrapper-method
(mapconcat
(lambda (line) (format "\t%s" line))
(split-string
(org-remove-indentation
(org-trim body))
"[\r\n]") "\n")
"[\r\n]")
"\n")
(if (member "pp" result-params)
"true" "false")
org-babel-lua-multiple-values-separator
(org-babel-process-file-name tmp-file 'noquote))))
(org-babel-eval-read-file tmp-file))))))
(org-babel-result-cond result-params

View File

@ -680,7 +680,7 @@ INFO is the export state as a property list."
INFO is the export state, as a property list."
(and field
(lambda (a b)
(string-collate-lessp
(org-string<
(org-cite-basic--get-field field a info 'raw)
(org-cite-basic--get-field field b info 'raw)
nil t))))

View File

@ -190,20 +190,23 @@ INITIAL is an initial style of comma-separated options, as a string or nil.
STYLE is the style definition as a string or nil.
Return a string."
(let ((options-no-style
(and initial
(let ((re (rx string-start (or "bibstyle" "citestyle" "style"))))
(seq-filter
(lambda (option) (not (string-match re option)))
(split-string (org-unbracket-string "[" "]" initial)
"," t " \t")))))
(style-options
(cond
((null style) nil)
((not (string-match "/" style)) (list (concat "style=" style)))
(t
(list (concat "bibstyle=" (substring style nil (match-beginning 0)))
(concat "citestyle=" (substring style (match-end 0))))))))
(let* ((options-no-style
(and initial
(let ((re (rx string-start (or "bibstyle" "citestyle" "style"))))
(seq-filter
(lambda (option) (not (string-match re option)))
(split-string (org-unbracket-string "[" "]" initial)
"," t " \t")))))
;; Check whether the string is in key=val,...
(biblatex-options-p (and (stringp style) (string-match-p "\\`[^,=]+=[^,]+\\(,[^=]+=[^,]+\\)\\'" style)))
(style-options
(cond
((null style) nil)
;; Assume it is a valid options string for biblatex if it is in key=val,... format
((not (string-match "/" style)) (list (if biblatex-options-p style (concat "style=" style))))
(t
(list (concat "bibstyle=" (substring style nil (match-beginning 0)))
(concat "citestyle=" (substring style (match-end 0))))))))
(if (or options-no-style style-options)
(format "[%s]"
(mapconcat #'identity

View File

@ -134,6 +134,7 @@
(declare-function citeproc-render-bib "ext:citeproc")
(declare-function citeproc-hash-itemgetter-from-any "ext:citeproc")
(declare-function citeproc-add-subbib-filters "ext:citeproc")
(declare-function citeproc-style-cite-superscript-p "ext:citeproc")
(declare-function org-element-interpret-data "org-element" (data))
(declare-function org-element-map "org-element" (data types fun &optional info first-match no-recursion with-affiliated))
@ -435,6 +436,13 @@ INFO is the export state, as a property list."
(citeproc-proc-style
(org-cite-csl--processor info))))
(defun org-cite-csl--style-cite-superscript-p (info)
"Non-nil when bibliography style produces citations in superscript.
INFO is the export state, as a property list."
(citeproc-style-cite-superscript-p
(citeproc-proc-style
(org-cite-csl--processor info))))
(defun org-cite-csl--nocite-p (citation info)
"Non-nil when CITATION object's style is nocite.
INFO is the export state, as a property list."
@ -681,6 +689,9 @@ INFO is the export state, as a property list."
(when (and (not footnote) (org-cite-csl--note-style-p info))
(org-cite-adjust-note citation info)
(setq footnote (org-cite-wrap-citation citation info)))
;; Remove white space before CITATION when it is in superscript.
(when (org-cite-csl--style-cite-superscript-p info)
(org-cite--set-previous-post-blank citation 0 info))
;; Return structure.
(apply #'citeproc-citation-create
`(:note-index

View File

@ -206,7 +206,7 @@ This function is intended to be used as a :set function."
(set symbol value)
(dolist (buf (org-buffer-list))
(with-current-buffer buf
(org-link-descriptive-ensure))))
(org-restart-font-lock))))
(defcustom org-link-descriptive t
"Non-nil means Org displays descriptive links.
@ -590,9 +590,9 @@ taken to make the search successful, another function should be
added to the companion hook `org-execute-file-search-functions',
which see.
A function in this hook may also use `setq' to set the variable
`description' to provide a suggestion for the descriptive text to
be used for this link when it gets inserted into an Org buffer
A function in this hook may also use `org-link-store-props' and set
`:description' property to provide a suggestion for the descriptive
text to be used for this link when it gets inserted into an Org buffer
with \\[org-insert-link].")
(defvar org-execute-file-search-functions nil
@ -649,22 +649,6 @@ exact and fuzzy text search.")
(defvar org-link--search-failed nil
"Non-nil when last link search failed.")
(defvar-local org-link--link-folding-spec '(org-link
(:global t)
(:ellipsis . nil)
(:isearch-open . t)
(:fragile . org-link--reveal-maybe))
"Folding spec used to hide invisible parts of links.")
(defvar-local org-link--description-folding-spec '(org-link-description
(:global t)
(:ellipsis . nil)
(:visible . t)
(:isearch-open . nil)
(:fragile . org-link--reveal-maybe))
"Folding spec used to reveal link description.")
;;; Internal Functions
@ -1134,12 +1118,12 @@ The functions are defined in the `:store' property of
INTERACTIVE? which indicates whether the user has initiated
`org-store-link' interactively.
Each function will be called in turn until one returns a non-nil
value. Each function should check if it is responsible for
creating this link (for example by looking at the major mode).
If not, it must exit and return nil. If yes, it should return
a non-nil value after calling `org-link-store-props' with a list
of properties and values. Special properties are:
Each function will be called in turn with a single argument
INTERACTIVE? - non-nil when user interaction is allowed. Each function
should check if it is responsible for creating this link (for example
by looking at the major mode). If not, it must return nil. If yes,
it should return a non-nil value after calling `org-link-store-props'
with a list of properties and values. Special properties are:
:type The link prefix, like \"http\". This must be given.
:link The link, like \"http://www.astro.uva.nl/~dominik\".
@ -1679,18 +1663,12 @@ If the link is in hidden text, expose it."
(interactive)
(org-next-link t))
(defun org-link-descriptive-ensure ()
"Toggle the literal or descriptive display of links in current buffer if needed."
(org-fold-core-set-folding-spec-property
(car org-link--link-folding-spec)
:visible (not org-link-descriptive)))
;;;###autoload
(defun org-toggle-link-display ()
"Toggle the literal or descriptive display of links in current buffer."
(interactive)
(setq org-link-descriptive (not org-link-descriptive))
(org-link-descriptive-ensure))
(org-restart-font-lock))
;;;###autoload
(defun org-store-link (arg &optional interactive?)
@ -1738,7 +1716,7 @@ NAME."
;; Negate `org-context-in-file-links' when given a single universal arg.
(let ((org-link-context-for-files (org-xor org-link-context-for-files
(equal arg '(4))))
link cpltxt desc search agenda-link) ;; description
link desc search agenda-link) ;; description
(cond
;; Store a link using an external link type, if any function is
;; available, unless external link types are skipped for this
@ -1809,9 +1787,8 @@ NAME."
;; Image mode
((eq major-mode 'image-mode)
(setq cpltxt (concat "file:"
(abbreviate-file-name buffer-file-name))
link cpltxt)
(setq link (concat "file:"
(abbreviate-file-name buffer-file-name)))
(org-link-store-props :type "image" :file buffer-file-name))
;; In dired, store a link to the file of the current line
@ -1822,20 +1799,16 @@ NAME."
(expand-file-name (dired-get-filename nil t)))
;; Otherwise, no file so use current directory.
default-directory))
(setq cpltxt (concat "file:" file)
link cpltxt)))
(setq link (concat "file:" file))))
;; Try `org-create-file-search-functions`. If any are
;; successful, create a file link to the current buffer with
;; the provided search string. (sets `link` and `cpltxt` to
;; the same thing; it looks like the intention originally was
;; that cpltxt was a description, which might have been set by
;; the search-function (removed in switch to lexical binding)).
;; the provided search string.
((setq search (run-hook-with-args-until-success
'org-create-file-search-functions))
(setq link (concat "file:" (abbreviate-file-name buffer-file-name)
"::" search))
(setq cpltxt (or link))) ;; description
"::" search)
desc (plist-get org-store-link-plist :description)))
;; Main logic for storing built-in link types in org-mode
;; buffers
@ -1853,22 +1826,19 @@ NAME."
;; Avoid [[target][file:~/org/test.org::target]]
;; links. Maybe the case of identical target and
;; description should be handled by `org-insert-link'.
cpltxt nil
desc nil))
(t
;; Just link to current headline.
(let ((here (org-link--file-link-to-here)))
(setq cpltxt (car here))
(setq desc (cdr here)))
(setq link cpltxt)))))
(setq link (car here))
(setq desc (cdr here)))))))
;; Buffer linked to file, but not an org-mode buffer.
((buffer-file-name (buffer-base-buffer))
;; Just link to this file here.
(let ((here (org-link--file-link-to-here)))
(setq cpltxt (car here))
(setq desc (cdr here)))
(setq link cpltxt))
(setq link (car here))
(setq desc (cdr here))))
(interactive?
(user-error "No method for storing a link from this buffer"))
@ -1876,8 +1846,7 @@ NAME."
(t (setq link nil)))
;; We're done setting link and desc, clean up
(when (consp link) (setq cpltxt (car link) link (cdr link)))
(setq link (or link cpltxt))
(when (consp link) (setq link (or (cdr link) (car link))))
(cond ((not desc))
((equal desc "NONE") (setq desc nil))
(t (setq desc (org-link-display-format desc))))

View File

@ -2385,8 +2385,7 @@ The following commands are available:
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))
(add-to-invisibility-spec '(org-link))
(easy-menu-change
'("Agenda") "Agenda Files"
(append
@ -5833,7 +5832,7 @@ displayed in agenda view."
(org-encode-time ; DATE bound by calendar
0 0 0 (nth 1 date) (car date) (nth 2 date))))
"\\|\\(<[0-9]+-[0-9]+-[0-9]+[^>\n]+?\\+[0-9]+[hdwmy]>\\)"
"\\|\\(<%%\\(([^>\n]+)\\)>\\)"))
"\\|\\(<%%\\(([^>\n]+)\\)\\([^\n>]*\\)>\\)"))
timestamp-items)
(goto-char (point-min))
(while (re-search-forward regexp nil t)
@ -7491,8 +7490,8 @@ The optional argument TYPE tells the agenda type."
"Compare the string values of categories of strings A and B."
(let ((ca (or (get-text-property (1- (length a)) 'org-category a) ""))
(cb (or (get-text-property (1- (length b)) 'org-category b) "")))
(cond ((string-lessp ca cb) -1)
((string-lessp cb ca) +1))))
(cond ((org-string< ca cb) -1)
((org-string< cb ca) +1))))
(defsubst org-cmp-todo-state (a b)
"Compare the todo states of strings A and B."
@ -7538,8 +7537,8 @@ The optional argument TYPE tells the agenda type."
(cond ((not (or ta tb)) nil)
((not ta) +1)
((not tb) -1)
((string-lessp ta tb) -1)
((string-lessp tb ta) +1))))
((org-string< ta tb) -1)
((org-string< tb ta) +1))))
(defsubst org-cmp-tag (a b)
"Compare the string values of the first tags of A and B."
@ -7548,8 +7547,8 @@ The optional argument TYPE tells the agenda type."
(cond ((not (or ta tb)) nil)
((not ta) +1)
((not tb) -1)
((string-lessp ta tb) -1)
((string-lessp tb ta) +1))))
((funcall (or org-tags-sort-function #'org-string<) ta tb) -1)
((funcall (or org-tags-sort-function #'org-string<) tb ta) +1))))
(defsubst org-cmp-time (a b)
"Compare the time-of-day values of strings A and B."
@ -8595,6 +8594,14 @@ Negative selection means regexp must not match for selection of an entry."
(org-agenda-redo))
(message "Display now includes inactive timestamps as well"))
((eq org-agenda-type 'search)
;; Previous calls to `org-agenda-manipulate-query' could already
;; add trailing text to the query. Prevent duplicating it.
;; Trim the trailing spaces and +/.
(setq org-agenda-query-string
(replace-regexp-in-string
(rx (or (1+ " ") (seq (1+ " ") (any "+-") (opt "{}"))) eos)
""
org-agenda-query-string))
(org-add-to-string
'org-agenda-query-string
(if org-agenda-last-search-view-search-was-boolean
@ -9215,7 +9222,8 @@ When called with a prefix argument, include all archive files as well."
(when (and (markerp m) (marker-buffer m))
(and org-agenda-follow-mode
(if org-agenda-follow-indirect
(org-agenda-tree-to-indirect-buffer nil)
(let ((org-indirect-buffer-display 'other-window))
(org-agenda-tree-to-indirect-buffer nil))
(org-agenda-show)))
(and org-agenda-show-outline-path
(org-with-point-at m (org-display-outline-path org-agenda-show-outline-path))))))
@ -9307,20 +9315,17 @@ Pass ARG, FORCE-ARG, DELETE and BODY to `org-agenda-do-in-region'."
(marker (or (org-get-at-bol 'org-marker)
(org-agenda-error)))
(buffer (marker-buffer marker))
(pos (marker-position marker))
(type (org-get-at-bol 'type))
dbeg dend (n 0))
(org-with-remote-undo buffer
(with-current-buffer buffer
(save-excursion
(goto-char pos)
(if (and (derived-mode-p 'org-mode) (not (member type '("sexp"))))
(setq dbeg (progn (org-back-to-heading t) (point))
dend (org-end-of-subtree t t))
(setq dbeg (line-beginning-position)
dend (min (point-max) (1+ (line-end-position)))))
(goto-char dbeg)
(while (re-search-forward "^[ \t]*\\S-" dend t) (setq n (1+ n)))))
(org-with-point-at marker
(if (and (derived-mode-p 'org-mode) (not (member type '("sexp"))))
(setq dbeg (progn (org-back-to-heading t) (point))
dend (org-end-of-subtree t t))
(setq dbeg (line-beginning-position)
dend (min (point-max) (1+ (line-end-position)))))
(goto-char dbeg)
(while (re-search-forward "^[ \t]*\\S-" dend t) (setq n (1+ n))))
(when (or (eq t org-agenda-confirm-kill)
(and (numberp org-agenda-confirm-kill)
(> n org-agenda-confirm-kill)))
@ -9337,7 +9342,7 @@ Pass ARG, FORCE-ARG, DELETE and BODY to `org-agenda-do-in-region'."
(set-window-configuration win-conf))))
(let ((org-agenda-buffer-name bufname-orig))
(org-remove-subtree-entries-from-agenda buffer dbeg dend))
(with-current-buffer buffer (delete-region dbeg dend))
(org-with-point-at marker (delete-region dbeg dend))
(message "Agenda item and source killed")))))
(defvar org-archive-default-command) ; defined in org-archive.el
@ -9400,26 +9405,26 @@ Pass ARG, FORCE-ARG, DELETE and BODY to `org-agenda-do-in-region'."
The subtree is the one in buffer BUF, starting at BEG and ending at END.
If this information is not given, the function uses the tree at point."
(let ((buf (or buf (current-buffer))) m p)
(save-excursion
(unless (and beg end)
(org-back-to-heading t)
(setq beg (point))
(org-end-of-subtree t)
(setq end (point)))
(set-buffer (get-buffer org-agenda-buffer-name))
(save-excursion
(goto-char (point-max))
(forward-line 0)
(while (not (bobp))
(when (and (setq m (org-get-at-bol 'org-marker))
(equal buf (marker-buffer m))
(setq p (marker-position m))
(>= p beg)
(< p end))
(let ((inhibit-read-only t))
(delete-region (line-beginning-position)
(1+ (line-end-position)))))
(forward-line -1))))))
(org-with-wide-buffer
(unless (and beg end)
(org-back-to-heading t)
(setq beg (point))
(org-end-of-subtree t)
(setq end (point)))
(set-buffer (get-buffer org-agenda-buffer-name))
(save-excursion
(goto-char (point-max))
(forward-line 0)
(while (not (bobp))
(when (and (setq m (org-get-at-bol 'org-marker))
(equal buf (marker-buffer m))
(setq p (marker-position m))
(>= p beg)
(< p end))
(let ((inhibit-read-only t))
(delete-region (line-beginning-position)
(1+ (line-end-position)))))
(forward-line -1))))))
(defun org-agenda-refile (&optional goto rfloc no-update)
"Refile the item at point.
@ -9688,27 +9693,6 @@ With a `\\[universal-argument]' prefix, make a separate frame for this tree, \
i.e. don't use
the dedicated frame."
(interactive "P")
(if current-prefix-arg
(org-agenda-do-tree-to-indirect-buffer arg)
(let ((agenda-buffer (buffer-name))
(agenda-window (selected-window))
(indirect-window
(and org-last-indirect-buffer
(get-buffer-window org-last-indirect-buffer))))
(save-window-excursion (org-agenda-do-tree-to-indirect-buffer arg))
(unless (or (eq org-indirect-buffer-display 'new-frame)
(eq org-indirect-buffer-display 'dedicated-frame))
(unwind-protect
(unless (and indirect-window (window-live-p indirect-window))
(setq indirect-window (split-window agenda-window)))
(and indirect-window (select-window indirect-window))
(switch-to-buffer org-last-indirect-buffer :norecord)
(fit-window-to-buffer indirect-window)))
(select-window (get-buffer-window agenda-buffer))
(setq org-agenda-last-indirect-buffer org-last-indirect-buffer))))
(defun org-agenda-do-tree-to-indirect-buffer (arg)
"Same as `org-agenda-tree-to-indirect-buffer' without saving window."
(org-agenda-check-no-diary)
(let* ((marker (or (org-get-at-bol 'org-marker)
(org-agenda-error)))
@ -9717,7 +9701,8 @@ the dedicated frame."
(with-current-buffer buffer
(save-excursion
(goto-char pos)
(org-tree-to-indirect-buffer arg)))))
(org-tree-to-indirect-buffer arg))))
(setq org-agenda-last-indirect-buffer org-last-indirect-buffer))
(defvar org-last-heading-marker (make-marker)
"Marker pointing to the headline that last changed its TODO state

View File

@ -808,6 +808,7 @@ previous clocking intervals."
60)))
(+ currently-clocked-time (or org-clock-total-time 0))))
;;;###autoload
(defun org-clock-modify-effort-estimate (&optional value)
"Add to or set the effort estimate of the item currently being clocked.
VALUE can be a number of minutes, or a string with format hh:mm or mm.
@ -3111,8 +3112,9 @@ PROPERTIES: The list properties specified in the `:properties' parameter
(let* ((todo (org-get-todo-state))
(tags-list (org-get-tags))
(org-scanner-tags tags-list)
(org-trust-scanner-tags t))
(funcall matcher todo tags-list nil)))))
(org-trust-scanner-tags t)
(level (org-current-level)))
(funcall matcher todo tags-list level)))))
(goto-char (point-min))
(setq st t)
(while (or (and (bobp) (prog1 st (setq st nil))

View File

@ -123,6 +123,12 @@ in `org-columns-summary-types-default', which see."
(function :tag "Summarize")
(function :tag "Collect")))))
(defcustom org-columns-dblock-formatter #'org-columns-dblock-write-default
"Function to format data in column view dynamic blocks.
For more information, see `org-columns-dblock-write-default'."
:group 'org-properties
:package-version '(Org . "9.7")
:type 'function)
;;; Column View
@ -1442,9 +1448,13 @@ that will be excluded from the resulting view. FORMAT is a
format string for columns, or nil. When LOCAL is non-nil, only
capture headings in current subtree.
This function returns a list containing the title row and all
other rows. Each row is a list of fields, as strings, or
`hline'."
This function returns a list containing the title row and all other
rows. Each row is either a list, or the symbol `hline'. The first list
is the heading row as a list of strings with the column titles according
to FORMAT. All subsequent lists each represent a body row as a list
whose first element is an integer indicating the outline level of the
entry, and whose remaining elements are strings with the contents for
the columns according to FORMAT."
(org-columns (not local) format)
(goto-char org-columns-top-level-marker)
(let ((columns (length org-columns-current-fmt-compiled))
@ -1457,11 +1467,10 @@ other rows. Each row is a list of fields, as strings, or
(dotimes (i columns)
(let* ((col (+ (line-beginning-position) i))
(p (get-char-property col 'org-columns-key)))
(push (org-quote-vert
(get-char-property col
(if (string= p "ITEM")
'org-columns-value
'org-columns-value-modified)))
(push (get-char-property col
(if (string= p "ITEM")
'org-columns-value
'org-columns-value-modified))
row)))
(unless (or
(and skip-empty
@ -1493,7 +1502,9 @@ an inline src-block."
'(footnote-reference inline-babel-call inline-src-block target
radio-target statistics-cookie)
#'org-element-extract)
(org-no-properties (org-element-interpret-data data))))
(org-quote-vert
(org-no-properties
(org-element-interpret-data data)))))
;;;###autoload
(defun org-dblock-write:columnview (params)
@ -1545,7 +1556,17 @@ PARAMS is a property list of parameters:
`:vlines'
When non-nil, make each column a column group to enforce
vertical lines."
vertical lines.
`:link'
Link the item headlines in the table to their origins.
`:formatter'
A function to format the data and insert it into the
buffer. Overrides the default formatting function set in
`org-columns-dblock-formatter'."
(let ((table
(let ((id (plist-get params :id))
view-file view-pos)
@ -1573,9 +1594,20 @@ PARAMS is a property list of parameters:
(plist-get params :exclude-tags)
(plist-get params :format)
view-pos)))))
(width-specs
(mapcar (lambda (spec) (nth 2 spec))
org-columns-current-fmt-compiled)))
(formatter (or (plist-get params :formatter)
org-columns-dblock-formatter
#'org-columns-dblock-write-default)))
(funcall formatter (point) table params)))
(defun org-columns-dblock-write-default (ipos table params)
"Write out a columnview table at position IPOS in the current buffer.
TABLE is a table with data as produced by `org-columns--capture-view'.
PARAMS is the parameter property list obtained from the dynamic block
definition."
(let ((link (plist-get params :link))
(width-specs
(mapcar (lambda (spec) (nth 2 spec))
org-columns-current-fmt-compiled)))
(when table
;; Prune level information from the table. Also normalize
;; headings: remove stars, add indentation entities, if
@ -1599,7 +1631,14 @@ PARAMS is a property list of parameters:
(and (numberp hlines) (<= level hlines))))
(push 'hline new-table))
(when item-index
(let ((item (org-columns--clean-item (nth item-index (cdr row)))))
(let* ((raw (nth item-index (cdr row)))
(cleaned (org-columns--clean-item raw))
(item (if (not link) cleaned
(let ((search (org-link-heading-search-string raw)))
(org-link-make-string
(if (not (buffer-file-name)) search
(format "file:%s::%s" (buffer-file-name) search))
cleaned)))))
(setf (nth item-index (cdr row))
(if (and indent (> level 1))
(concat "\\_" (make-string (* 2 (1- level)) ?\s) item)
@ -1616,6 +1655,8 @@ PARAMS is a property list of parameters:
;; to the resulting table, adding alignment field as the first
;; row.
(push (mapcar (lambda (width) (when width (format "<%d>" width))) width-specs) table))
;; now insert the table into the buffer
(goto-char ipos)
(let ((content-lines (org-split-string (plist-get params :content) "\n"))
recalc)
;; Insert affiliated keywords before the table.

View File

@ -649,6 +649,29 @@ Counting starts at 1."
(define-obsolete-variable-alias 'org-plantuml-executable-args 'org-plantuml-args
"Org 9.6")
(defvar org-cached-props nil)
(defvar org-use-property-inheritance)
(declare-function org-entry-get "org" (epom property &optional inherit literal-nil))
(declare-function org-entry-properties "org" (&optional epom which))
(defun org-cached-entry-get (pom property)
(if (or (eq t org-use-property-inheritance)
(and (stringp org-use-property-inheritance)
(let ((case-fold-search t))
(string-match-p org-use-property-inheritance property)))
(and (listp org-use-property-inheritance)
(member-ignore-case property org-use-property-inheritance)))
;; Caching is not possible, check it directly.
(org-entry-get pom property 'inherit)
;; Get all properties, so we can do complicated checks easily.
(cdr (assoc-string property
(or org-cached-props
(setq org-cached-props (org-entry-properties pom)))
t))))
(make-obsolete 'org-cached-entry-get
"Performs badly. Instead use `org-entry-get' with the argument INHERIT set to `selective'"
"9.7")
(defconst org-latex-line-break-safe "\\\\[0pt]"
"Linebreak protecting the following [...].

View File

@ -57,6 +57,12 @@
;; (add-hook 'org-mode-hook
;; (lambda ()
;; (define-key org-mode-map "\C-co" 'org-ctags-find-tag-interactive)))
;; (with-eval-after-load "org-ctags"
;; (org-ctags-enable))
;;
;; To activate the library, you need to call `org-ctags-enable' explicitly.
;; It used to be invoked during library loading, but it was against Emacs
;; policy and caused inconvenience of Org users who do not use `org-ctags'.
;;
;; By default, with org-ctags loaded, org will first try and visit the tag
;; with the same name as the link; then, if unsuccessful, ask the user if
@ -161,6 +167,20 @@ See the ctags documentation for more information.")
:version "24.1"
:type 'file)
(defconst org-ctags--open-link-functions-list
(list
#'org-ctags-find-tag
#'org-ctags-ask-rebuild-tags-file-then-find-tag
#'org-ctags-rebuild-tags-file-then-find-tag
#'org-ctags-ask-append-topic
#'org-ctags-append-topic
#'org-ctags-ask-visit-buffer-or-file
#'org-ctags-visit-buffer-or-file
#'org-ctags-fail-silently)
"Options for `org-open-link-functions'.
Ensure that the user option and `unload-feature'
use the same set of functions.")
(defcustom org-ctags-open-link-functions
'(org-ctags-find-tag
org-ctags-ask-rebuild-tags-file-then-find-tag
@ -168,14 +188,7 @@ See the ctags documentation for more information.")
"List of functions to be prepended to ORG-OPEN-LINK-FUNCTIONS by ORG-CTAGS."
:version "24.1"
:type 'hook
:options '(org-ctags-find-tag
org-ctags-ask-rebuild-tags-file-then-find-tag
org-ctags-rebuild-tags-file-then-find-tag
org-ctags-ask-append-topic
org-ctags-append-topic
org-ctags-ask-visit-buffer-or-file
org-ctags-visit-buffer-or-file
org-ctags-fail-silently))
:options org-ctags--open-link-functions-list)
(defvar org-ctags-tag-list nil
@ -191,21 +204,21 @@ The following patterns are replaced in the string:
:type 'string)
(add-hook 'org-mode-hook
(lambda ()
(when (and org-ctags-enabled-p
(buffer-file-name))
;; Make sure this file's directory is added to default
;; directories in which to search for tags.
(let ((tags-filename
(expand-file-name
(concat (file-name-directory (buffer-file-name))
"/TAGS"))))
(when (file-exists-p tags-filename)
(visit-tags-table tags-filename))))))
(defun org-ctags--visit-tags-table ()
"Load tags for current file.
A function for `org-mode-hook."
(when (and org-ctags-enabled-p
(buffer-file-name))
;; Make sure this file's directory is added to default
;; directories in which to search for tags.
(let ((tags-filename
(expand-file-name
(concat (file-name-directory (buffer-file-name))
"/TAGS"))))
(when (file-exists-p tags-filename)
(visit-tags-table tags-filename)))))
(advice-add 'visit-tags-table :after #'org--ctags-load-tag-list)
(defun org--ctags-load-tag-list (&rest _)
(when (and org-ctags-enabled-p tags-file-name)
(setq-local org-ctags-tag-list
@ -213,12 +226,28 @@ The following patterns are replaced in the string:
(defun org-ctags-enable ()
(add-hook 'org-mode-hook #'org-ctags--visit-tags-table)
(advice-add 'visit-tags-table :after #'org--ctags-load-tag-list)
(advice-add 'xref-find-definitions :before
#'org--ctags-set-org-mark-before-finding-tag)
(put 'org-mode 'find-tag-default-function 'org-ctags-find-tag-at-point)
(setq org-ctags-enabled-p t)
(dolist (fn org-ctags-open-link-functions)
(add-hook 'org-open-link-functions fn t)))
(defun org-ctags-unload-function ()
"Disable `org-ctags' library.
Called by `unload-feature'."
(put 'org-mode 'find-tag-default-function nil)
(advice-remove 'visit-tags-table #'org--ctags-load-tag-list)
(advice-remove 'xref-find-definitions
#'org--ctags-set-org-mark-before-finding-tag)
(dolist (fn org-ctags--open-link-functions-list)
(remove-hook 'org-open-link-functions fn nil)))
;;; General utility functions. ===============================================
;; These work outside org-ctags mode.
@ -294,8 +323,6 @@ The new topic will be titled NAME (or TITLE if supplied)."
;;;; Misc interoperability with etags system =================================
(advice-add 'xref-find-definitions :before
#'org--ctags-set-org-mark-before-finding-tag)
(defun org--ctags-set-org-mark-before-finding-tag (&rest _)
"Before trying to find a tag, save our current position on org mark ring."
(save-excursion
@ -477,18 +504,21 @@ function may take several seconds to finish if the directory or
its subdirectories contain large numbers of taggable files."
(interactive)
(cl-assert (buffer-file-name))
(let ((dir-name (or directory-name
(file-name-directory (buffer-file-name))))
(let ((dir-name (shell-quote-argument
(expand-file-name
(if directory-name
(file-name-as-directory directory-name)
(file-name-directory (buffer-file-name))))))
(exitcode nil))
(save-excursion
(setq exitcode
(shell-command
(format (concat "%s --langdef=orgmode --langmap=orgmode:.org "
"--regex-orgmode=\"%s\" -f \"%s\" -e -R %s")
"--regex-orgmode=%s -f %sTAGS -e -R %s*")
org-ctags-path-to-ctags
org-ctags-tag-regexp
(expand-file-name (concat dir-name "/TAGS"))
(expand-file-name (concat (shell-quote-argument dir-name) "/*")))))
(shell-quote-argument org-ctags-tag-regexp)
dir-name
dir-name)))
(cond
((eql 0 exitcode)
(setq-local org-ctags-tag-list
@ -523,8 +553,6 @@ a new topic."
'org-open-link-functions tag))))))
(org-ctags-enable)
(provide 'org-ctags)
;;; org-ctags.el ends here

View File

@ -4282,7 +4282,7 @@ Assume point is at the target."
"\\|"
"\\(?:<[0-9]+-[0-9]+-[0-9]+[^>\n]+?\\+[0-9]+[dwmy]>\\)"
"\\|"
"\\(?:<%%\\(?:([^>\n]+)\\)>\\)")
"\\(?:<%%\\(?:([^>\n]+)\\)\\([^\n>]*\\)>\\)")
"Regexp matching any timestamp type object.")
(defconst org-element--timestamp-raw-value-regexp
@ -4300,8 +4300,8 @@ containing `:type', `:range-type', `:raw-value', `:year-start',
`:year-end', `:month-end', `:day-end', `:hour-end', `:minute-end',
`:repeater-type', `:repeater-value', `:repeater-unit',
`:repeater-deadline-value', `:repeater-deadline-unit', `:warning-type',
`:warning-value', `:warning-unit', `:begin', `:end' and `:post-blank'
properties. Otherwise, return nil.
`:warning-value', `:warning-unit', `:diary-sexp', `:begin', `:end' and
`:post-blank' properties. Otherwise, return nil.
Assume point is at the beginning of the timestamp."
(when (looking-at-p org-element--timestamp-regexp)
@ -4312,19 +4312,29 @@ Assume point is at the beginning of the timestamp."
(progn
(looking-at org-element--timestamp-raw-value-regexp)
(match-string-no-properties 0)))
(date-start (match-string-no-properties 1))
(date-end (match-string-no-properties 3))
(diaryp (match-beginning 2))
diary-sexp
(date-start (if diaryp
;; Only consider part after sexp for
;; diary timestamps.
(save-match-data
(looking-at org-element--timestamp-regexp)
(setq diary-sexp
(buffer-substring-no-properties
(+ 3 (match-beginning 0))
(match-beginning 2)))
(match-string 2))
(match-string-no-properties 1)))
(date-end (match-string-no-properties 3))
(post-blank (progn (goto-char (match-end 0))
(skip-chars-forward " \t")))
(end (point))
(time-range
(and (not diaryp)
(string-match
"[012]?[0-9]:[0-5][0-9]\\(-\\([012]?[0-9]\\):\\([0-5][0-9]\\)\\)"
date-start)
(cons (string-to-number (match-string 2 date-start))
(string-to-number (match-string 3 date-start)))))
(when (string-match
"[012]?[0-9]:[0-5][0-9]\\(-\\([012]?[0-9]\\):\\([0-5][0-9]\\)\\)"
date-start)
(cons (string-to-number (match-string 2 date-start))
(string-to-number (match-string 3 date-start)))))
(type (cond (diaryp 'diary)
((and activep (or date-end time-range)) 'active-range)
(activep 'active)
@ -4395,6 +4405,17 @@ Assume point is at the beginning of the timestamp."
day-end (or (nth 3 date) day-start)
hour-end (or (nth 2 date) (car time-range) hour-start)
minute-end (or (nth 1 date) (cdr time-range) minute-start))))
;; Diary timestamp with time.
(when (and diaryp
(string-match "\\([012]?[0-9]\\):\\([0-5][0-9]\\)\\(-\\([012]?[0-9]\\):\\([0-5][0-9]\\)\\)?" date-start))
(setq hour-start (match-string 1 date-start)
minute-start (match-string 2 date-start)
hour-end (match-string 4 date-start)
minute-end (match-string 5 date-start))
(when hour-start (setq hour-start (string-to-number hour-start)))
(when minute-start (setq minute-start (string-to-number minute-start)))
(when hour-end (setq hour-end (string-to-number hour-end)))
(when minute-end (setq minute-end (string-to-number minute-end))))
(org-element-create
'timestamp
(nconc (list :type type
@ -4413,137 +4434,144 @@ Assume point is at the beginning of the timestamp."
:begin begin
:end end
:post-blank post-blank)
(and diary-sexp (list :diary-sexp diary-sexp))
repeater-props
warning-props))))))
(defun org-element-timestamp-interpreter (timestamp _)
"Interpret TIMESTAMP object as Org syntax."
(let((type (org-element-property :type timestamp)))
(if (member type '(active inactive inactive-range active-range))
(let ((day-start (org-element-property :day-start timestamp))
(month-start (org-element-property :month-start timestamp))
(year-start (org-element-property :year-start timestamp)))
;; Return nil when start date is not available. Could also
;; throw an error, but the current behavior is historical.
(when (and day-start month-start year-start)
(let* ((repeat-string
(concat
(pcase (org-element-property :repeater-type timestamp)
(`cumulate "+") (`catch-up "++") (`restart ".+"))
(let ((val (org-element-property :repeater-value timestamp)))
(and val (number-to-string val)))
(pcase (org-element-property :repeater-unit timestamp)
(`hour "h") (`day "d") (`week "w") (`month "m") (`year "y"))
(when-let ((repeater-deadline-value
(org-element-property :repeater-deadline-value timestamp))
(repeater-deadline-unit
(org-element-property :repeater-deadline-unit timestamp)))
(concat
"/"
(number-to-string repeater-deadline-value)
(pcase repeater-deadline-unit
(`hour "h") (`day "d") (`week "w") (`month "m") (`year "y"))))))
(range-type (org-element-property :range-type timestamp))
(warning-string
(concat
(pcase (org-element-property :warning-type timestamp)
(`first "--") (`all "-"))
(let ((val (org-element-property :warning-value timestamp)))
(and val (number-to-string val)))
(pcase (org-element-property :warning-unit timestamp)
(`hour "h") (`day "d") (`week "w") (`month "m") (`year "y"))))
(hour-start (org-element-property :hour-start timestamp))
(minute-start (org-element-property :minute-start timestamp))
(brackets
(if (member
type
'(inactive inactive-range))
(cons "[" "]")
(cons "<" ">")))
(timestamp-end
(concat
(and (org-string-nw-p repeat-string) (concat " " repeat-string))
(and (org-string-nw-p warning-string) (concat " " warning-string))
(cdr brackets))))
(concat
;; Opening backet: [ or <
(car brackets)
;; Starting date/time: YYYY-MM-DD DAY[ HH:MM]
(format-time-string
;; `org-time-stamp-formats'.
(org-time-stamp-format
;; Ignore time unless both HH:MM are available.
;; Ignore means (car org-timestamp-formats).
(and minute-start hour-start)
'no-brackets)
(org-encode-time
0 (or minute-start 0) (or hour-start 0)
day-start month-start year-start))
;; Range: -HH:MM or TIMESTAMP-END--[YYYY-MM-DD DAY HH:MM]
(let ((hour-end (org-element-property :hour-end timestamp))
(minute-end (org-element-property :minute-end timestamp)))
(pcase type
((or `active `inactive)
;; `org-element-timestamp-parser' uses this type
;; when no time/date range is provided. So,
;; should normally return nil in this clause.
(pcase range-type
(`nil
;; `org-element-timestamp-parser' assigns end
;; times for `active'/`inactive' TYPE if start
;; time is not nil. But manually built
;; timestamps may not contain end times, so
;; check for end times anyway.
(when (and hour-start hour-end minute-start minute-end
(or (/= hour-start hour-end)
(/= minute-start minute-end)))
;; Could also throw an error. Return range
;; timestamp nevertheless to preserve
;; historical behavior.
(format "-%02d:%02d" hour-end minute-end)))
((or `timerange `daterange)
(error "`:range-type' must be `nil' for `active'/`inactive' type"))))
;; Range must be present.
((or `active-range `inactive-range)
(pcase range-type
;; End time: -HH:MM.
;; Fall back to start time if end time is not defined (arbitrary historical choice).
;; Error will be thrown if both end and begin time is not defined.
(`timerange (format "-%02d:%02d" (or hour-end hour-start) (or minute-end minute-start)))
;; End date: TIMESTAMP-END--[YYYY-MM-DD DAY HH:MM
((or `daterange
;; Should never happen in the output of `org-element-timestamp-parser'.
;; Treat as an equivalent of `daterange' arbitrarily.
`nil)
(concat
;; repeater + warning + closing > or ]
;; This info is duplicated in date ranges.
timestamp-end
"--" (car brackets)
(format-time-string
;; `org-time-stamp-formats'.
(org-time-stamp-format
;; Ignore time unless both HH:MM are available.
;; Ignore means (car org-timestamp-formats).
(and minute-end hour-end)
'no-brackets)
(org-encode-time
;; Closing HH:MM missing is a valid scenario.
0 (or minute-end 0) (or hour-end 0)
;; YEAR/MONTH/DAY-END will always be present
;; for `daterange' range-type, as parsed by
;; `org-element-timestamp-parser'.
;; For manually constructed timestamp
;; object, arbitrarily fall back to starting
;; date.
(or (org-element-property :day-end timestamp) day-start)
(or (org-element-property :month-end timestamp) month-start)
(or (org-element-property :year-end timestamp) year-start)))))))))
;; repeater + warning + closing > or ]
;; This info is duplicated in date ranges.
timestamp-end))))
;; diary type.
(org-element-property :raw-value timestamp))))
(let ((day-start (org-element-property :day-start timestamp))
(month-start (org-element-property :month-start timestamp))
(year-start (org-element-property :year-start timestamp)))
;; Return nil when start date is not available. Could also
;; throw an error, but the current behavior is historical.
(when (or (and day-start month-start year-start)
(eq type 'diary))
(let* ((repeat-string
(concat
(pcase (org-element-property :repeater-type timestamp)
(`cumulate "+") (`catch-up "++") (`restart ".+"))
(let ((val (org-element-property :repeater-value timestamp)))
(and val (number-to-string val)))
(pcase (org-element-property :repeater-unit timestamp)
(`hour "h") (`day "d") (`week "w") (`month "m") (`year "y"))
(when-let ((repeater-deadline-value
(org-element-property :repeater-deadline-value timestamp))
(repeater-deadline-unit
(org-element-property :repeater-deadline-unit timestamp)))
(concat
"/"
(number-to-string repeater-deadline-value)
(pcase repeater-deadline-unit
(`hour "h") (`day "d") (`week "w") (`month "m") (`year "y"))))))
(range-type (org-element-property :range-type timestamp))
(warning-string
(concat
(pcase (org-element-property :warning-type timestamp)
(`first "--") (`all "-"))
(let ((val (org-element-property :warning-value timestamp)))
(and val (number-to-string val)))
(pcase (org-element-property :warning-unit timestamp)
(`hour "h") (`day "d") (`week "w") (`month "m") (`year "y"))))
(hour-start (org-element-property :hour-start timestamp))
(minute-start (org-element-property :minute-start timestamp))
(brackets
(if (member
type
'(inactive inactive-range))
(cons "[" "]")
;; diary as well
(cons "<" ">")))
(timestamp-end
(concat
(and (org-string-nw-p repeat-string) (concat " " repeat-string))
(and (org-string-nw-p warning-string) (concat " " warning-string))
(cdr brackets))))
(concat
;; Opening backet: [ or <
(car brackets)
;; Starting date/time: YYYY-MM-DD DAY[ HH:MM]
(if (eq type 'diary)
(concat
"%%"
(org-element-property :diary-sexp timestamp)
(when (and minute-start hour-start)
(format " %02d:%02d" hour-start minute-start)))
(format-time-string
;; `org-time-stamp-formats'.
(org-time-stamp-format
;; Ignore time unless both HH:MM are available.
;; Ignore means (car org-timestamp-formats).
(and minute-start hour-start)
'no-brackets)
(org-encode-time
0 (or minute-start 0) (or hour-start 0)
day-start month-start year-start)))
;; Range: -HH:MM or TIMESTAMP-END--[YYYY-MM-DD DAY HH:MM]
(let ((hour-end (org-element-property :hour-end timestamp))
(minute-end (org-element-property :minute-end timestamp)))
(pcase type
((or `active `inactive)
;; `org-element-timestamp-parser' uses this type
;; when no time/date range is provided. So,
;; should normally return nil in this clause.
(pcase range-type
(`nil
;; `org-element-timestamp-parser' assigns end
;; times for `active'/`inactive' TYPE if start
;; time is not nil. But manually built
;; timestamps may not contain end times, so
;; check for end times anyway.
(when (and hour-start hour-end minute-start minute-end
(or (/= hour-start hour-end)
(/= minute-start minute-end)))
;; Could also throw an error. Return range
;; timestamp nevertheless to preserve
;; historical behavior.
(format "-%02d:%02d" hour-end minute-end)))
((or `timerange `daterange)
(error "`:range-type' must be `nil' for `active'/`inactive' type"))))
;; Range must be present.
((or `active-range `inactive-range
(and `diary (guard (eq 'timerange range-type))))
(pcase range-type
;; End time: -HH:MM.
;; Fall back to start time if end time is not defined (arbitrary historical choice).
;; Error will be thrown if both end and begin time is not defined.
(`timerange (format "-%02d:%02d" (or hour-end hour-start) (or minute-end minute-start)))
;; End date: TIMESTAMP-END--[YYYY-MM-DD DAY HH:MM
((or `daterange
;; Should never happen in the output of `org-element-timestamp-parser'.
;; Treat as an equivalent of `daterange' arbitrarily.
`nil)
(concat
;; repeater + warning + closing > or ]
;; This info is duplicated in date ranges.
timestamp-end
"--" (car brackets)
(format-time-string
;; `org-time-stamp-formats'.
(org-time-stamp-format
;; Ignore time unless both HH:MM are available.
;; Ignore means (car org-timestamp-formats).
(and minute-end hour-end)
'no-brackets)
(org-encode-time
;; Closing HH:MM missing is a valid scenario.
0 (or minute-end 0) (or hour-end 0)
;; YEAR/MONTH/DAY-END will always be present
;; for `daterange' range-type, as parsed by
;; `org-element-timestamp-parser'.
;; For manually constructed timestamp
;; object, arbitrarily fall back to starting
;; date.
(or (org-element-property :day-end timestamp) day-start)
(or (org-element-property :month-end timestamp) month-start)
(or (org-element-property :year-end timestamp) year-start)))))))))
;; repeater + warning + closing > or ]
;; This info is duplicated in date ranges.
timestamp-end))))))
;;;; Underline
(defun org-element-underline-parser ()
@ -8292,8 +8320,11 @@ the cache."
;; Reached LIMIT-COUNT. Abort.
(when (and limit-count
(>= count-predicate-calls-match
limit-count))
(cache-walk-abort)))
limit-count))
(cache-walk-abort))
;; Make sure that we have a cached
;; element at the new STAR.
(when start (element-match-at-point)))
;; Check if the buffer or cache has been modified.
(unless (org-with-base-buffer nil
(and (eq modified-tic org-element--cache-change-tic)

View File

@ -705,7 +705,7 @@ The folding spec properties will be set to PROPERTIES (see
(let* ((full-properties (mapcar (lambda (prop) (cons prop (cdr (assq prop properties))))
'( :visible :ellipsis :isearch-ignore
:global :isearch-open :front-sticky
:rear-sticky :fragile :alias)))
:rear-sticky :fragile :alias :font-lock)))
(full-spec (cons spec full-properties)))
(add-to-list 'org-fold-core--specs full-spec append)
(mapc (lambda (prop-cons) (org-fold-core-set-folding-spec-property spec (car prop-cons) (cdr prop-cons) 'force)) full-properties)
@ -1094,8 +1094,7 @@ If SPEC-OR-ALIAS is omitted and FLAG is nil, unfold everything in the region."
(overlay-put o 'invisible spec)
;; Preserve priority.
(overlay-put o 'priority (length (member spec (org-fold-core-folding-spec-list))))
(overlay-put o 'isearch-open-invisible #'org-fold-core--isearch-show)
(overlay-put o 'isearch-open-invisible-temporary #'org-fold-core--isearch-show-temporary))
(overlay-put o 'isearch-open-invisible #'org-fold-core--isearch-show))
(put-text-property from to (org-fold-core--property-symbol-get-create spec) spec)
(put-text-property from to 'isearch-open-invisible #'org-fold-core--isearch-show)
(put-text-property from to 'isearch-open-invisible-temporary #'org-fold-core--isearch-show-temporary)
@ -1246,7 +1245,9 @@ This function is intended to be used as `isearch-filter-predicate'."
;; FIXME: Reveal the match (usually point, but may sometimes go beyond the region).
(when (< beg (point) end)
(funcall org-fold-core-isearch-open-function (point)))
(org-fold-core-region beg end nil)))
(if (overlayp overlay-or-region)
(delete-overlay overlay-or-region)
(org-fold-core-region beg end nil))))
(defun org-fold-core--isearch-show-temporary (region hide-p)
"Temporarily reveal text in REGION.

View File

@ -49,8 +49,6 @@
(require 'org-fold-core)
(defvar org-inlinetask-min-level)
(defvar org-link--link-folding-spec)
(defvar org-link--description-folding-spec)
(defvar org-odd-levels-only)
(defvar org-drawer-regexp)
(defvar org-property-end-re)
@ -280,9 +278,7 @@ Also, see `org-fold-catch-invisible-edits'."
(:isearch-open . t)
(:font-lock . t)
(:front-sticky . t)
(:alias . (drawer property-drawer)))
,org-link--description-folding-spec
,org-link--link-folding-spec)))
(:alias . (drawer property-drawer))))))
;;;; Searching and examining folded text
@ -679,19 +675,12 @@ DETAIL is either nil, `minimal', `local', `ancestors',
(org-with-point-at (car region)
(forward-line 0)
(let (font-lock-extend-region-functions)
(font-lock-fontify-region (max (point-min) (1- (car region))) (cdr region))))))
;; Unfold links.
(let (region)
(dolist (spec '(org-link org-link-description))
(setq region (org-fold-get-region-at-point spec))
(when region (org-fold-region (car region) (cdr region) nil spec)))))
(font-lock-fontify-region (max (point-min) (1- (car region))) (cdr region)))))))
(let (region)
(dolist (spec (org-fold-core-folding-spec-list))
;; Links are taken care by above.
(unless (memq spec '(org-link org-link-description))
(setq region (org-fold-get-region-at-point spec))
(when region
(org-fold-region (car region) (cdr region) nil spec))))))
(setq region (org-fold-get-region-at-point spec))
(when region
(org-fold-region (car region) (cdr region) nil spec)))))
(unless (org-before-first-heading-p)
(org-with-limited-levels
(cl-case detail

View File

@ -2979,7 +2979,7 @@ function is being called interactively."
(error "Missing key extractor"))))
(sort-func
(cond
((= dcst ?a) #'string-collate-lessp)
((= dcst ?a) #'org-string<)
((= dcst ?f)
(or compare-func
(and interactive?

View File

@ -113,7 +113,6 @@ Version mismatch is commonly encountered in the following situations:
(declare-function org-fold-next-visibility-change "org-fold" (&optional pos limit ignore-hidden-p previous-p))
(declare-function org-fold-core-with-forced-fontification "org-fold" (&rest body))
(declare-function org-fold-folded-p "org-fold" (&optional pos limit ignore-hidden-p previous-p))
(declare-function string-collate-lessp "org-compat" (s1 s2 &optional locale ignore-case))
(declare-function org-time-convert-to-list "org-compat" (time))
(declare-function org-buffer-text-pixel-width "org-compat" ())
@ -982,20 +981,67 @@ return nil."
;;; String manipulation
(defun org-string< (a b)
(string-collate-lessp a b))
(defcustom org-sort-function #'string-collate-lessp
"Function used to compare strings when sorting.
This function affects how Org mode sorts headlines, agenda items,
table lines, etc.
(defun org-string<= (a b)
(or (string= a b) (string-collate-lessp a b)))
The function must accept either 2 or 4 arguments: strings to compare
and, optionally, LOCALE and IGNORE-CASE - locale name and flag to make
comparison case-insensitive.
(defun org-string>= (a b)
(not (string-collate-lessp a b)))
The default value uses sorting rules according to OS language. Users
who want to make sorting language-independent, may customize the value
to `org-sort-function-fallback'.
(defun org-string> (a b)
Note that some string sorting rules are known to be not accurate on
MacOS. See https://debbugs.gnu.org/cgi/bugreport.cgi?bug=59275.
MacOS users may customize the value to
`org-sort-function-fallback'."
:group 'org
:package-version '(Org . "9.7")
:type '(choice
(const :tag "According to OS language" string-collate-lessp)
(const :tag "Using string comparison" org-sort-function-fallback)
(function :tag "Custom function")))
(defun org-sort-function-fallback (a b &optional _ ignore-case)
"Return non-nil when downcased string A < string B.
Use `compare-strings' for comparison. Honor IGNORE-CASE."
(let ((ans (compare-strings a nil nil b nil nil ignore-case)))
(cond
((and (numberp ans) (< ans 0)) t)
(t nil))))
(defun org-string< (a b &optional locale ignore-case)
"Return non-nil when string A < string B.
LOCALE is the locale name. IGNORE-CASE, when non-nil, makes comparison
ignore case."
(if (= 4 (cdr (func-arity org-sort-function)))
(funcall org-sort-function a b locale ignore-case)
(funcall org-sort-function a b)))
(defun org-string<= (a b &optional locale ignore-case)
"Return non-nil when string A <= string B.
LOCALE is the locale name. IGNORE-CASE, when non-nil, makes comparison
ignore case."
(or (string= a b) (org-string< a b locale ignore-case)))
(defun org-string>= (a b &optional locale ignore-case)
"Return non-nil when string A >= string B.
LOCALE is the locale name. IGNORE-CASE, when non-nil, makes comparison
ignore case."
(not (org-string< a b locale ignore-case)))
(defun org-string> (a b &optional locale ignore-case)
"Return non-nil when string A > string B.
LOCALE is the locale name. IGNORE-CASE, when non-nil, makes comparison
ignore case."
(and (not (string= a b))
(not (string-collate-lessp a b))))
(not (org-string< a b locale ignore-case))))
(defun org-string<> (a b)
"Return non-nil when string A and string B are not equal."
(not (string= a b)))
(defsubst org-trim (s &optional keep-lead)
@ -1744,6 +1790,23 @@ indirectly called by the latter."
(prog1 nil
(set-window-configuration window-configuration)))))
(defun org-display-buffer-in-window (buffer alist)
"Display BUFFER in specific window.
The window is defined according to the `window' slot in the ALIST.
Then `same-frame' slot in the ALIST is set, only display buffer when
window is present in the current frame.
This is an action function for buffer display, see Info
node `(elisp) Buffer Display Action Functions'. It should be
called only by `display-buffer' or a function directly or
indirectly called by the latter."
(let ((window (alist-get 'window alist)))
(when (and window
(window-live-p window)
(or (not (alist-get 'same-frame alist))
(eq (window-frame) (window-frame window))))
(window--display-buffer buffer window 'reuse alist))))
(provide 'org-macs)
;; Local variables:

View File

@ -1057,7 +1057,7 @@ be returned that indicates what went wrong."
(goto-char (match-beginning 4))
(insert new)
(delete-region (point) (+ (point) (length current)))
(org-align-tags))
(when org-auto-align-tags (org-align-tags)))
(t
(error
"Heading changed in the mobile device and on the computer")))))))

View File

@ -426,13 +426,14 @@ SCHEDULED: or DEADLINE: or ANYTHINGLIKETHIS:"
(append
(let ((tags (org-get-tags nil t)))
(org-mouse-keyword-menu
(sort (mapcar #'car (org-get-buffer-tags)) #'string-lessp)
(sort (mapcar #'car (org-get-buffer-tags))
(or org-tags-sort-function #'org-string<))
(lambda (tag)
(org-mouse-set-tags
(sort (if (member tag tags)
(delete tag tags)
(cons tag tags))
#'string-lessp)))
(or org-tags-sort-function #'org-string<))))
(lambda (tag) (member tag tags))
))
'("--"
@ -473,7 +474,7 @@ SCHEDULED: or DEADLINE: or ANYTHINGLIKETHIS:"
(sort (if (member ',name ',options)
(delete ',name ',options)
(cons ',name ',options))
'string-lessp)
#'org-string<)
" ")
nil nil nil 1)
(when (functionp ',function) (funcall ',function)))
@ -502,7 +503,8 @@ SCHEDULED: or DEADLINE: or ANYTHINGLIKETHIS:"
["Check TODOs" org-show-todo-tree t]
("Check Tags"
,@(org-mouse-keyword-menu
(sort (mapcar #'car (org-get-buffer-tags)) #'string-lessp)
(sort (mapcar #'car (org-get-buffer-tags))
(or org-tags-sort-function #'org-string<))
(lambda (tag) (org-tags-sparse-tree nil tag)))
"--"
["Custom Tag ..." org-tags-sparse-tree t])
@ -512,7 +514,8 @@ SCHEDULED: or DEADLINE: or ANYTHINGLIKETHIS:"
["Display TODO List" org-todo-list t]
("Display Tags"
,@(org-mouse-keyword-menu
(sort (mapcar #'car (org-get-buffer-tags)) #'string-lessp)
(sort (mapcar #'car (org-get-buffer-tags))
(or org-tags-sort-function #'org-string<))
(lambda (tag) (org-tags-view nil tag)))
"--"
["Custom Tag ..." org-tags-view t])

View File

@ -754,8 +754,6 @@ as `org-src-fontify-natively' is non-nil."
(s (and b (make-string (* (- e b) native-tab-width) ? ))))
(when (and b (< b e)) (add-text-properties b e `(display ,s)))
(forward-char)))))
;; Clear abbreviated link folding.
(org-fold-region start end nil 'org-link)
(add-text-properties
start end
'(font-lock-fontified t fontified t font-lock-multiline t))

View File

@ -892,7 +892,10 @@ nil When nil, the command tries to be smart and figure out the
separator in the following way:
- when each line contains a TAB, assume TAB-separated material
- when each line contains a comma, assume CSV material
- else, assume one or more SPACE characters as separator."
- else, assume one or more SPACE characters as separator.
`babel-auto'
Use the same rules as nil, but do not try any separator when
the region contains a single line and has no commas or tabs."
(interactive "r\nP")
(let* ((beg (min beg0 end0))
(end (max beg0 end0))
@ -909,12 +912,15 @@ nil When nil, the command tries to be smart and figure out the
(if (bolp) (backward-char 1) (end-of-line 1))
(setq end (point-marker))
;; Get the right field separator
(unless separator
(when (or (not separator) (eq separator 'babel-auto))
(goto-char beg)
(setq separator
(cond
((not (re-search-forward "^[^\n\t]+$" end t)) '(16))
((not (re-search-forward "^[^\n,]+$" end t)) '(4))
((not (save-excursion (re-search-forward "^[^\n\t]+$" end t))) '(16))
((not (save-excursion (re-search-forward "^[^\n,]+$" end t))) '(4))
((and (eq separator 'babel-auto)
(= 1 (count-lines beg end)))
(rx unmatchable))
(t 1))))
(goto-char beg)
(if (equal separator '(4))
@ -2881,15 +2887,15 @@ list, `literal' is for the format specifier L."
(if lispp
(if (eq lispp 'literal)
elements
(if (and (eq elements "") (not keep-empty))
;; FIXME: This branch of `if' is never used because
;; strings are never `eq' here. But changing to
;; `equal' breaks tests.
;; See
;; https://list.orgmode.org/orgmode/20230827214320.46754-1-salutis@me.com/
""
(prin1-to-string
(if numbers (string-to-number elements) elements))))
;; Ignore KEEP-EMPTY here.
;; When ELEMENTS="" and NUMBERS=t, (string-to-number "")
;; returns 0 - consistent with (0) for Calc branch.
;; When ELEMENTS="" and NUMBERS=nil, `prin1-to-string' will
;; return "\"\"" - historical behavior that also does not
;; leave missing arguments in formulas like (string< $1 $2)
;; when $2 cell is empty.
(prin1-to-string
(if numbers (string-to-number elements) elements)))
(if (string-match "\\S-" elements)
(progn
(when numbers (setq elements (number-to-string
@ -4631,8 +4637,8 @@ function is being called interactively."
(predicate
(cl-case sorting-type
((?n ?N ?t ?T) #'<)
((?a ?A) (if with-case #'string-collate-lessp
(lambda (s1 s2) (string-collate-lessp s1 s2 nil t))))
((?a ?A) (if with-case #'org-string<
(lambda (s1 s2) (org-string< s1 s2 nil t))))
((?f ?F)
(or compare-func
(and interactive?

View File

@ -1107,19 +1107,26 @@ will be parsed as single sub- or superscripts:
10^-12 or 10^-tau a leading sign with digits or a word
x^2-y^3 will be read as x^2 - y^3, because items are
terminated by almost any nonword/nondigit char.
x_{i^2} or x^(2-i) braces or parenthesis do grouping.
x^(2 - i) expression inside round braces, including the
braces is read as a sub/superscript.
x_{i^2} curly braces do grouping; braces are not
considered a part of the sub/superscript.
Still, ambiguity is possible. So when in doubt, use {} to enclose
the sub/superscript. If you set this variable to the symbol `{}',
the braces are *required* in order to trigger interpretations as
the curly braces are *required* in order to trigger interpretations as
sub/superscript. This can be helpful in documents that need \"_\"
frequently in plain text."
frequently in plain text.
Setting this variable does not change Org mode markup. Org mode will
still parse the matching text as sub/superscript internally. It is
only the visual appearance that will be changed."
:group 'org-startup
:version "24.4"
:package-version '(Org . "8.0")
:type '(choice
(const :tag "Always interpret" t)
(const :tag "Only with braces" {})
(const :tag "Only with curly braces" {})
(const :tag "Never interpret" nil)))
(defcustom org-startup-with-beamer-mode nil
@ -2937,8 +2944,8 @@ is better to limit inheritance to certain tags using the variables
:group 'org-tags
:type '(choice
(const :tag "No sorting" nil)
(const :tag "Alphabetical" string-collate-lessp)
(const :tag "Reverse alphabetical" org-string-collate-greaterp)
(const :tag "Alphabetical" org-string<)
(const :tag "Reverse alphabetical" org-string>)
(function :tag "Custom function" nil)))
(defvar org-tags-history nil
@ -4945,16 +4952,11 @@ The following commands are available:
(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)))
(add-to-invisibility-spec '(org-link))
(org-fold-initialize (or (and (stringp org-ellipsis) (not (equal "" org-ellipsis)) org-ellipsis)
"..."))
(make-local-variable 'org-link-descriptive)
(when (eq org-fold-core-style 'overlays) (add-to-invisibility-spec '(org-hide-block . t)))
(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))
(when (and (stringp org-ellipsis) (not (equal "" org-ellipsis)))
(unless org-display-table
(setq org-display-table (make-display-table)))
@ -5236,10 +5238,6 @@ stacked delimiters is N. Escaping delimiters is not possible."
(when verbatim?
(org-remove-flyspell-overlays-in
(match-beginning 0) (match-end 0))
(when (and (org-fold-core-folding-spec-p 'org-link)
(org-fold-core-folding-spec-p 'org-link-description))
(org-fold-region (match-beginning 0) (match-end 0) nil 'org-link)
(org-fold-region (match-beginning 0) (match-end 0) nil 'org-link-description))
(remove-text-properties (match-beginning 2) (match-end 2)
'(display t invisible t intangible t)))
(add-text-properties (match-beginning 2) (match-end 2)
@ -5307,7 +5305,7 @@ prompted for."
(insert string)
(and move (backward-char 1))))
(defun org-activate-links--overlays (limit)
(defun org-activate-links (limit)
"Add link properties to links.
This includes angle, plain, and bracket links."
(catch :exit
@ -5363,10 +5361,12 @@ This includes angle, plain, and bracket links."
;; Handle invisible parts in bracket links.
(remove-text-properties start end '(invisible nil))
(let ((hidden
(append `(invisible
,(or (org-link-get-parameter type :display)
'org-link))
properties)))
(if org-link-descriptive
(append `(invisible
,(or (org-link-get-parameter type :display)
'org-link))
properties)
properties)))
(add-text-properties start visible-start hidden)
(add-face-text-property start end face-property)
(add-text-properties visible-start visible-end properties)
@ -5378,99 +5378,6 @@ This includes angle, plain, and bracket links."
(funcall f start end path (eq style 'bracket))))
(throw :exit t))))) ;signal success
nil))
(defun org-activate-links--text-properties (limit)
"Add link properties to links.
This includes angle, plain, and bracket links."
(catch :exit
(while (re-search-forward org-link-any-re limit t)
(let* ((start (match-beginning 0))
(end (match-end 0))
(visible-start (or (match-beginning 3) (match-beginning 2)))
(visible-end (or (match-end 3) (match-end 2)))
(style (cond ((eq ?< (char-after start)) 'angle)
((eq ?\[ (char-after (1+ start))) 'bracket)
(t 'plain))))
(when (and (memq style org-highlight-links)
;; Do not span over paragraph boundaries.
(not (string-match-p org-element-paragraph-separate
(match-string 0)))
;; Do not confuse plain links with tags.
(not (and (eq style 'plain)
(let ((face (get-text-property
(max (1- start) (point-min)) 'face)))
(if (consp face) (memq 'org-tag face)
(eq 'org-tag face))))))
(let* ((link-object (save-excursion
(goto-char start)
(save-match-data (org-element-link-parser))))
(link (org-element-property :raw-link link-object))
(type (org-element-property :type link-object))
(path (org-element-property :path link-object))
(face-property (pcase (org-link-get-parameter type :face)
((and (pred functionp) face) (funcall face path))
((and (pred facep) face) face)
((and (pred consp) face) face) ;anonymous
(_ 'org-link)))
(properties ;for link's visible part
(list 'mouse-face (or (org-link-get-parameter type :mouse-face)
'highlight)
'keymap (or (org-link-get-parameter type :keymap)
org-mouse-map)
'help-echo (pcase (org-link-get-parameter type :help-echo)
((and (pred stringp) echo) echo)
((and (pred functionp) echo) echo)
(_ (concat "LINK: " link)))
'htmlize-link (pcase (org-link-get-parameter type
:htmlize-link)
((and (pred functionp) f) (funcall f))
(_ `(:uri ,link)))
'font-lock-multiline t)))
(org-remove-flyspell-overlays-in start end)
(org-rear-nonsticky-at end)
(if (not (eq 'bracket style))
(progn
(add-face-text-property start end face-property)
(add-text-properties start end properties))
;; Initialize folding when used outside org-mode.
(unless (or (derived-mode-p 'org-mode)
(and (org-fold-folding-spec-p 'org-link-description)
(org-fold-folding-spec-p 'org-link)))
(org-fold-initialize (or (and (stringp org-ellipsis) (not (equal "" org-ellipsis)) org-ellipsis)
"...")))
;; Handle invisible parts in bracket links.
(let ((spec (or (org-link-get-parameter type :display)
'org-link)))
(unless (org-fold-folding-spec-p spec)
(org-fold-add-folding-spec spec
(cdr org-link--link-folding-spec)
nil
'append)
(org-fold-core-set-folding-spec-property spec :visible t))
(org-fold-region start end nil 'org-link)
(org-fold-region start end nil 'org-link-description)
;; We are folding the whole emphasized text with SPEC
;; first. It makes everything invisible (or whatever
;; the user wants).
(org-fold-region start end t spec)
;; The visible part of the text is folded using
;; 'org-link-description, which is forcing this part of
;; the text to be visible.
(org-fold-region visible-start visible-end t 'org-link-description)
(add-text-properties start end properties)
(add-face-text-property start end face-property)
(org-rear-nonsticky-at visible-start)
(org-rear-nonsticky-at visible-end)))
(let ((f (org-link-get-parameter type :activate-func)))
(when (functionp f)
(funcall f start end path (eq style 'bracket))))
(throw :exit t))))) ;signal success
nil))
(defsubst org-activate-links (limit)
"Add link properties to links.
This includes angle, plain, and bracket links."
(if (eq org-fold-core-style 'text-properties)
(org-activate-links--text-properties limit)
(org-activate-links--overlays limit)))
(defun org-activate-code (limit)
(when (re-search-forward "^[ \t]*\\(:\\(?: .*\\|$\\)\n?\\)" limit t)
@ -5849,8 +5756,7 @@ highlighting was done, nil otherwise."
(when next-unfolded-newline
(org-with-wide-buffer
(when (and (> (match-beginning 0) (point-min))
(org-fold-folded-p (1- (match-beginning 0)))
(not (org-fold-folded-p (1- (match-beginning 0)) 'org-link)))
(org-fold-folded-p (1- (match-beginning 0))))
(put-text-property
(match-beginning 0) (match-end 0)
'face
@ -6230,8 +6136,6 @@ If TAG is a number, get the corresponding match group."
'(mouse-face t keymap t org-linked-text t
invisible t intangible t
org-emphasis t))
(org-fold-region beg end nil 'org-link)
(org-fold-region beg end nil 'org-link-description)
(org-fold-core-update-optimisation beg end)
(org-remove-font-lock-display-properties beg end)))
@ -6372,7 +6276,10 @@ frame is not changed."
(let ((cbuf (current-buffer))
(cwin (selected-window))
(pos (point))
beg end level heading ibuf)
beg end level heading ibuf
(last-indirect-window
(and org-last-indirect-buffer
(get-buffer-window org-last-indirect-buffer))))
(save-excursion
(org-back-to-heading t)
(when (numberp arg)
@ -6408,7 +6315,10 @@ frame is not changed."
((eq org-indirect-buffer-display 'current-window)
(pop-to-buffer-same-window ibuf))
((eq org-indirect-buffer-display 'other-window)
(pop-to-buffer ibuf))
(pop-to-buffer
ibuf
`(org-display-buffer-in-window (window . ,last-indirect-window)
(same-frame . t))))
(t (error "Invalid value")))
(narrow-to-region beg end)
(org-fold-show-all '(headings drawers blocks))
@ -6505,7 +6415,17 @@ but not a number, insert a level-1 heading."
current-level
;; This `1' is for when before first headline
1))
(stars (make-string num-stars ?*)))
(stars (make-string num-stars ?*))
(maybe-add-blank-after
(lambda (blank?)
"Add a blank line before next heading when BLANK? is non-nil.
Assume that point is on the inserted heading."
(save-excursion
(end-of-line)
(unless (eobp)
(forward-char)
(when (and blank? (org-at-heading-p))
(insert "\n")))))))
(cond
((or org-insert-heading-respect-content
(member arg '((4) (16)))
@ -6535,6 +6455,8 @@ but not a number, insert a level-1 heading."
(insert stars " " "\n")
;; Move point after stars.
(backward-char)
;; Retain blank lines before next heading.
(funcall maybe-add-blank-after blank?)
;; When INVISIBLE-OK is non-nil, ensure newly created headline
;; is visible.
(unless invisible-ok
@ -6565,27 +6487,35 @@ but not a number, insert a level-1 heading."
;; Preserve tags.
(let ((split (delete-and-extract-region (point) (match-end 4))))
(if (looking-at "[ \t]*$") (replace-match "")
(org-align-tags))
(when org-auto-align-tags (org-align-tags)))
(end-of-line)
(when blank? (insert "\n"))
(insert "\n" stars " ")
;; Retain blank lines before next heading.
(funcall maybe-add-blank-after blank?)
(when (org-string-nw-p split) (insert split))))
(t
(end-of-line)
(when blank? (insert "\n"))
(insert "\n" stars " "))))
(insert "\n" stars " ")
;; Retain blank lines before next heading.
(funcall maybe-add-blank-after blank?))))
;; On regular text, turn line into a headline or split, if
;; appropriate.
((bolp)
(insert stars " ")
(unless (and blank? (org-previous-line-empty-p))
(org-N-empty-lines-before-current (if blank? 1 0))))
(org-N-empty-lines-before-current (if blank? 1 0)))
;; Retain blank lines before next heading.
(funcall maybe-add-blank-after blank?))
(t
(unless (org-get-alist-option org-M-RET-may-split-line 'headline)
(end-of-line))
(insert "\n" stars " ")
(unless (and blank? (org-previous-line-empty-p))
(org-N-empty-lines-before-current (if blank? 1 0))))))
(org-N-empty-lines-before-current (if blank? 1 0)))
;; Retain blank lines before next heading.
(funcall maybe-add-blank-after blank?))))
(run-hooks 'org-insert-heading-hook))
(defun org-N-empty-lines-before-current (n)
@ -6677,7 +6607,7 @@ Set it to HEADING when provided."
(if old (replace-match new t t nil 4)
(goto-char (or (match-end 3) (match-end 2) (match-end 1)))
(insert " " new))
(org-align-tags)
(when org-auto-align-tags (org-align-tags))
(when (looking-at "[ \t]*$") (replace-match ""))))))))
(defun org-insert-heading-after-current ()
@ -7287,7 +7217,13 @@ The entire subtree is promoted or demoted in order to match a new headline
level.
If the cursor is at the beginning of a headline, the same level as
that headline is used to paste the tree.
that headline is used to paste the tree before current headline.
With `\\[universal-argument]' prefix, force inserting at the same level
as current headline, after subtree at point.
With `\\[universal-argument]' `\\[universal-argument]' prefix, force
inserting as a child headline, as the first child.
If not, the new level is derived from the *visible* headings
before and after the insertion point, and taken to be the inferior headline
@ -7323,23 +7259,30 @@ When REMOVE is non-nil, remove the subtree from the clipboard."
level-indicator?
(force-level
(cond
(level (prefix-numeric-value level))
;; When point is after the stars in an otherwise empty
;; headline, use the number of stars as the forced level.
((and (org-match-line "^\\*+[ \t]*$")
((and (or (not level) (member level '((4) (16))))
(org-match-line "^\\*+[ \t]*$")
(not (eq ?* (char-after))))
(setq level-indicator? (org-outline-level)))
((equal level '(4)) (org-outline-level))
((equal level '(16)) nil) ; handle later
(level (prefix-numeric-value level))
((looking-at-p org-outline-regexp-bol) (org-outline-level))))
(previous-level
(save-excursion
(org-previous-visible-heading 1)
(unless (org-at-heading-p) (org-previous-visible-heading 1))
(if (org-at-heading-p) (org-outline-level) 1)))
(next-level
(save-excursion
(if (org-at-heading-p) (org-outline-level)
(org-next-visible-heading 1)
(if (org-at-heading-p) (org-outline-level) 1))))
(new-level (or force-level (max previous-level next-level)))
(org-next-visible-heading 1)
(if (org-at-heading-p) (org-outline-level) 1)))
(new-level (or force-level
(max
;; C-u C-u forces child.
(if (equal level '(16)) (1+ previous-level) 0)
previous-level
next-level)))
(shift (if (or (= old-level -1)
(= new-level -1)
(= old-level new-level))
@ -7354,7 +7297,8 @@ When REMOVE is non-nil, remove the subtree from the clipboard."
(delete-region (line-beginning-position) (line-beginning-position 2)))
;; Paste before the next visible heading or at end of buffer,
;; unless point is at the beginning of a headline.
(unless (and (bolp) (org-at-heading-p))
(unless (and (bolp) (org-at-heading-p) (not (member level '((4) (16)))))
(when (equal level '(4)) (org-end-of-subtree t))
(org-next-visible-heading 1)
(unless (bolp) (insert "\n")))
(setq beg (point))
@ -8037,7 +7981,7 @@ function is being called interactively."
(t (error "Invalid sorting type `%c'" sorting-type))))
nil
(cond
((= dcst ?a) 'string-collate-lessp)
((= dcst ?a) #'org-string<)
((= dcst ?f)
(or compare-func
(and interactive?
@ -9130,7 +9074,7 @@ keywords relative to each registered export backend."
'("ARCHIVE:" "AUTHOR:" "BIBLIOGRAPHY:" "BIND:" "CATEGORY:" "CITE_EXPORT:"
"COLUMNS:" "CREATOR:" "DATE:" "DESCRIPTION:" "DRAWERS:" "EMAIL:"
"EXCLUDE_TAGS:" "FILETAGS:" "INCLUDE:" "INDEX:" "KEYWORDS:" "LANGUAGE:"
"MACRO:" "OPTIONS:" "PROPERTY:" "PRINT_BIBLIOGRAPHY" "PRIORITIES:"
"MACRO:" "OPTIONS:" "PROPERTY:" "PRINT_BIBLIOGRAPHY:" "PRIORITIES:"
"SELECT_TAGS:" "SEQ_TODO:" "SETUPFILE:" "STARTUP:" "TAGS:" "TITLE:" "TODO:"
"TYP_TODO:" "SELECT_TAGS:" "EXCLUDE_TAGS:" "EXPORT_FILE_NAME:"))
@ -11215,7 +11159,7 @@ or a character."
(insert " [#" news "]"))
(goto-char (match-beginning 3))
(insert "[#" news "] "))))
(org-align-tags))
(when org-auto-align-tags (org-align-tags)))
(if remove
(message "Priority removed")
(message "Priority of current item set to %s" news)))))
@ -11459,22 +11403,6 @@ are also TODO tasks."
(defalias 'org-tags-sparse-tree 'org-match-sparse-tree)
(defvar org-cached-props nil)
(defun org-cached-entry-get (pom property)
(if (or (eq t org-use-property-inheritance)
(and (stringp org-use-property-inheritance)
(let ((case-fold-search t))
(string-match-p org-use-property-inheritance property)))
(and (listp org-use-property-inheritance)
(member-ignore-case property org-use-property-inheritance)))
;; Caching is not possible, check it directly.
(org-entry-get pom property 'inherit)
;; Get all properties, so we can do complicated checks easily.
(cdr (assoc-string property
(or org-cached-props
(setq org-cached-props (org-entry-properties pom)))
t))))
(defun org-global-tags-completion-table (&optional files)
"Return the list of all tags in all agenda buffer/files.
Optional FILES argument is a list of files which can be used
@ -11649,7 +11577,7 @@ See also `org-scan-tags'."
("CATEGORY"
'(org-get-category (point)))
("TODO" 'todo)
(p `(org-cached-entry-get nil ,p))))
(p `(org-entry-get (point) ,p 'selective))))
;; Determine operand (aka. property
;; value).
(pv (match-string 8 term))
@ -11686,7 +11614,7 @@ See also `org-scan-tags'."
(setq term rest)))
(push `(and ,@tagsmatcher) orlist)
(setq tagsmatcher nil))
(setq tagsmatcher `(progn (setq org-cached-props nil) (or ,@orlist)))))
(setq tagsmatcher `(or ,@orlist))))
;; Make the TODO matcher.
(when (org-string-nw-p todomatch)
@ -11716,7 +11644,12 @@ See also `org-scan-tags'."
(or tagsmatcher todomatcher t))))
(when org--matcher-tags-todo-only
(setq matcher `(and (member todo org-not-done-keywords) ,matcher)))
(cons match0 `(lambda (todo tags-list level) ,matcher)))))
(cons match0
(byte-compile
`(lambda (todo tags-list level)
;; Pacify byte-compiler.
(ignore todo) (ignore tags-list) (ignore level)
,matcher))))))
(defun org--tags-expand-group (group tag-groups expanded)
"Recursively expand all tags in GROUP, according to TAG-GROUPS.
@ -12021,7 +11954,7 @@ This function assumes point is on a headline."
(unless (org-invisible-p (line-beginning-position))
(org-fold-region (point) (line-end-position) nil 'outline))))
;; Align tags, if any.
(when tags (org-align-tags))
(when (and tags org-auto-align-tags) (org-align-tags))
(when tags-change? (run-hooks 'org-after-tags-change-hook))))))
(defun org-change-tag-in-region (beg end tag off)
@ -13261,10 +13194,10 @@ decreases scheduled or deadline date by one day."
((not (member value org-todo-keywords-1))
(user-error "\"%s\" is not a valid TODO state" value)))
(org-todo value)
(org-align-tags))
(when org-auto-align-tags (org-align-tags)))
((equal property "PRIORITY")
(org-priority (if (org-string-nw-p value) (string-to-char value) ?\s))
(org-align-tags))
(when org-auto-align-tags (org-align-tags)))
((equal property "SCHEDULED")
(forward-line)
(if (and (looking-at-p org-planning-line-re)
@ -15539,10 +15472,29 @@ When set to a number in a list, try to get the width from any
and fall back on that number if none is found.
When set to nil, try to get the width from an #+ATTR.* keyword
and fall back on the original width if none is found.
When set to nil, first try to get the width from #+ATTR_ORG. If
that is not found, use the first #+ATTR_xxx :width specification.
If that is also not found, fall back on the original image width.
When set to any other non-nil value, always use the image width.
Finally, Org mode is quite flexible in the width specifications it
supports and intelligently interprets width specifications for other
backends when rendering an image in an org buffer. This behavior is
described presently.
1. A floating point value between 0 and 2 is interpreted as the
percentage of the text area that should be taken up by the image.
2. A number followed by a percent sign is divided by 100 and then
interpreted as a floating point value.
3. If a number is followed by other text, extract the number and
discard the remaining text. That number is then interpreted as a
floating-point value. For example,
#+ATTR_LATEX: :width 0.7\\linewidth
would be interpreted as 70% of the text width.
4. If t is provided the original image width is used. This is useful
when you want to specify a width for a backend, but still want to
use the original image width in the org buffer.
This requires Emacs >= 24.1, built with imagemagick support."
:group 'org-appearance
@ -16874,18 +16826,22 @@ buffer boundaries with possible narrowing."
("right" `(space :align-to (- right ,image)))))))
(push ov org-inline-image-overlays))))))))))))))))
(declare-function org-export-read-attribute "ox"
(attribute element &optional property))
(defvar visual-fill-column-width) ; Silence compiler warning
(defun org-display-inline-image--width (link)
"Determine the display width of the image LINK, in pixels.
- When `org-image-actual-width' is t, the image's pixel width is used.
- When `org-image-actual-width' is a number, that value will is used.
- When `org-image-actual-width' is nil or a list, the first :width attribute
set (if it exists) is used to set the image width. A width of X% is
divided by 100.
If no :width attribute is given and `org-image-actual-width' is a list with
a number as the car, then that number is used as the default value.
If the value is a float between 0 and 2, it interpreted as that proportion
of the text width in the buffer."
- When `org-image-actual-width' is nil or a list, :width attribute of
#+attr_org or the first #+attr_... (if it exists) is used to set the
image width. A width of X% is divided by 100. If the value is a
float between 0 and 2, it interpreted as that proportion of the text
width in the buffer.
If no :width attribute is given and `org-image-actual-width' is a
list with a number as the car, then that number is used as the
default value."
;; Apply `org-image-actual-width' specifications.
;; Support subtree-level property "ORG-IMAGE-ACTUAL-WIDTH" specified
;; width.
@ -16893,26 +16849,46 @@ buffer boundaries with possible narrowing."
(cond
((eq org-image-actual-width t) nil)
((listp org-image-actual-width)
(let* ((case-fold-search t)
(par (org-element-lineage link 'paragraph))
(attr-re "^[ \t]*#\\+attr_.*?: +.*?:width +\\(\\S-+\\)")
(par-end (org-element-post-affiliated par))
(require 'ox)
(let* ((par (org-element-lineage link 'paragraph))
;; Try to find an attribute providing a :width.
;; #+ATTR_ORG: :width ...
(attr-width (org-export-read-attribute :attr_org par :width))
(width-unreadable?
(lambda (value)
(or (not (stringp value))
(unless (string= value "t")
(or (not (string-match-p
(rx bos (opt "+") (opt ".") (in "0-9"))
value))
(let ((number (string-to-number value)))
(and (floatp number) (not (<= 0.0 number 2.0)))))))))
;; #+ATTR_BACKEND: :width ...
(attr-other
(catch :found
(org-element-properties-map
(lambda (prop _)
(when (and
(not (eq prop :attr_org))
(string-match-p "^:attr_" (symbol-name prop))
(not (funcall width-unreadable? (org-export-read-attribute prop par :width))))
(throw :found prop)))
par)))
(attr-width
(when (and par (org-with-point-at
(org-element-begin par)
(re-search-forward attr-re par-end t)))
(match-string 1)))
(if (not (funcall width-unreadable? attr-width))
attr-width
;; When #+attr_org: does not have readable :width
(and attr-other
(org-export-read-attribute attr-other par :width))))
(width
(cond
;; Treat :width t as if `org-image-actual-width' were t.
((string= attr-width "t") nil)
;; Fallback to `org-image-actual-width' if no interprable width is given.
((or (null attr-width)
(string-match-p "\\`[^0-9]" attr-width))
((funcall width-unreadable? attr-width)
(car org-image-actual-width))
;; Convert numeric widths to numbers, converting percentages.
((string-match-p "\\`[0-9.]+%" attr-width)
((string-match-p "\\`[[+]?[0-9.]+%" attr-width)
(/ (string-to-number attr-width) 100.0))
(t (string-to-number attr-width)))))
(if (and (floatp width) (<= 0.0 width 2.0))
@ -17088,7 +17064,7 @@ overwritten, and the table is not marked as requiring realignment."
;; Interactively, point should never be inside invisible regions
(org-fold-core-suppress-folding-fix
(self-insert-command N)
(org-fix-tags-on-the-fly))
(when org-auto-align-tags (org-fix-tags-on-the-fly)))
(when org-self-insert-cluster-for-undo
(if (not (eq last-command 'org-self-insert-command))
(setq org-self-insert-command-undo-counter 1)
@ -17118,7 +17094,7 @@ because, in this case the deletion might narrow the column."
(org-at-table-p))
(progn (forward-char -1) (org-delete-char 1))
(funcall-interactively #'backward-delete-char N)
(org-fix-tags-on-the-fly))))
(when org-auto-align-tags (org-fix-tags-on-the-fly)))))
(defun org-delete-char (N)
"Like `delete-char', but insert whitespace at field end in tables.
@ -17134,7 +17110,7 @@ because, in this case the deletion might narrow the column."
(save-excursion (skip-chars-backward " \t") (bolp))
(not (org-at-table-p)))
(delete-char N)
(org-fix-tags-on-the-fly))
(when org-auto-align-tags (org-fix-tags-on-the-fly)))
((looking-at ".\\(.*?\\)|")
(let* ((update? org-table-may-need-update)
(noalign (looking-at-p ".*? |")))
@ -19758,7 +19734,8 @@ Also align node properties according to `org-property-format'."
(org-with-point-at (org-element-property :begin element)
(+ (org-current-text-indentation)
org-edit-src-content-indentation)))))
(org-babel-do-key-sequence-in-edit-buffer (kbd "TAB"))
(ignore-errors ; do not err when there is no proper major mode
(org-babel-do-in-edit-buffer (funcall indent-line-function)))
(when (and block-content-ind (looking-at-p "^$"))
(indent-line-to block-content-ind))))
(t
@ -20376,11 +20353,12 @@ Optional arguments START and END can be used to limit the range."
(end (or end (point-max))))
(save-excursion
(goto-char start)
(while (and (< (point) end) (re-search-forward org-block-regexp end t))
(while (and (< (point) end) (re-search-forward "^[ \t]*#\\+begin" end t))
(save-excursion
(save-match-data
(goto-char (match-beginning 0))
(funcall function)))))))
(when (org-at-block-p)
(funcall function))))))))
(defun org-next-block (arg &optional backward block-regexp)
"Jump to the next block.
@ -21175,7 +21153,7 @@ see)."
(kill-region (point) (line-end-position))
(kill-region (point) end)))
;; Only align tags when we are still on a heading:
(if (org-at-heading-p) (org-align-tags)))
(if (and (org-at-heading-p) org-auto-align-tags) (org-align-tags)))
(t (kill-region (point) (line-end-position)))))
(defun org-yank (&optional arg)

View File

@ -954,14 +954,15 @@ channel."
;; Only links with a description need an entry. Other are
;; already handled in `org-ascii-link'.
(when description
(let ((dest (if (equal type "fuzzy")
(org-export-resolve-fuzzy-link link info)
;; Ignore broken links. On broken link,
;; `org-export-resolve-id-link' will throw an
;; error and we will return nil.
(condition-case nil
(org-export-resolve-id-link link info)
(org-link-broken nil)))))
(let ((dest
;; Ignore broken links. On broken link,
;; `org-export-resolve-id-link' will throw an
;; error and we will return nil.
(condition-case nil
(if (equal type "fuzzy")
(org-export-resolve-fuzzy-link link info)
(org-export-resolve-id-link link info))
(org-link-broken nil))))
(when dest
(concat
(org-ascii--fill-string

View File

@ -1873,36 +1873,43 @@ INFO is a plist used as a communication channel."
(pcase (org-export-collect-footnote-definitions info)
(`nil nil)
(definitions
(format
(plist-get info :html-footnotes-section)
(org-html--translate "Footnotes" info)
(format
(plist-get info :html-footnotes-section)
(org-html--translate "Footnotes" info)
(format
"\n%s\n"
(mapconcat
(lambda (definition)
(pcase definition
(`(,n ,_ ,def)
;; `org-export-collect-footnote-definitions' can return
;; two kinds of footnote definitions: inline and blocks.
;; Since this should not make any difference in the HTML
;; output, we wrap the inline definitions within
;; a "footpara" class paragraph.
(let ((inline? (not (org-element-map def org-element-all-elements
#'identity nil t)))
(anchor (org-html--anchor
(format "fn.%d" n)
n
(format " class=\"footnum\" href=\"#fnr.%d\" role=\"doc-backlink\"" n)
info))
(contents (org-trim (org-export-data def info))))
(format "<div class=\"footdef\">%s %s</div>\n"
(format (plist-get info :html-footnote-format) anchor)
(format "<div class=\"footpara\" role=\"doc-footnote\">%s</div>"
(if (not inline?) contents
(format "<p class=\"footpara\">%s</p>"
contents))))))))
definitions
"\n"))))))
"\n%s\n"
(mapconcat
(lambda (definition)
(pcase definition
(`(,n ,label ,def)
;; Do not assign number labels as they appear in Org mode
;; - the footnotes are re-numbered by
;; `org-export-get-footnote-number'. If the label is not
;; a number, keep it.
(when (and (stringp label)
(equal label (number-to-string (string-to-number label))))
(setq label nil))
;; `org-export-collect-footnote-definitions' can return
;; two kinds of footnote definitions: inline and blocks.
;; Since this should not make any difference in the HTML
;; output, we wrap the inline definitions within
;; a "footpara" class paragraph.
(let ((inline? (not (org-element-map def org-element-all-elements
#'identity nil t)))
(anchor (org-html--anchor
(format "fn.%s" (or label n))
n
(format " class=\"footnum\" href=\"#fnr.%s\" role=\"doc-backlink\"" (or label n))
info))
(contents (org-trim (org-export-data def info))))
(format "<div class=\"footdef\">%s %s</div>\n"
(format (plist-get info :html-footnote-format) anchor)
(format "<div class=\"footpara\" role=\"doc-footnote\">%s</div>"
(if (not inline?) contents
(format "<p class=\"footpara\">%s</p>"
contents))))))))
definitions
"\n"))))))
;;; Template
@ -2741,16 +2748,33 @@ CONTENTS is nil. INFO is a plist holding contextual information."
(when (org-element-type-p prev 'footnote-reference)
(plist-get info :html-footnote-separator)))
(let* ((n (org-export-get-footnote-number footnote-reference info))
(id (format "fnr.%d%s"
n
(label (org-element-property :label footnote-reference))
;; Do not assign number labels as they appear in Org mode -
;; the footnotes are re-numbered by
;; `org-export-get-footnote-number'. If the label is not a
;; number, keep it.
(label (if (and (stringp label)
(equal label (number-to-string (string-to-number label))))
nil
label))
(id (format "fnr.%s%s"
(or label n)
(if (org-export-footnote-first-reference-p
footnote-reference info)
""
".100"))))
(let ((label (org-element-property :label footnote-reference)))
(format
".%d"
(org-export-get-ordinal
footnote-reference info '(footnote-reference)
`(lambda (ref _)
(if ,label
(equal (org-element-property :label ref) ,label)
(not (org-element-property :label ref)))))))))))
(format
(plist-get info :html-footnote-format)
(org-html--anchor
id n (format " class=\"footref\" href=\"#fn.%d\" role=\"doc-backlink\"" n) info)))))
id n (format " class=\"footref\" href=\"#fn.%s\" role=\"doc-backlink\"" (or label n)) info)))))
;;;; Headline
@ -2897,7 +2921,7 @@ INFO arguments."
(org-html-format-headline-default-function
todo todo-type priority text tags info)
(org-html-close-tag "br" nil info)
contents))
(or contents "")))
;;;; Italic
@ -3943,7 +3967,7 @@ contextual information."
CONTENTS is the exported HTML code. INFO is the info plist."
(with-temp-buffer
(insert contents)
(set-auto-mode t)
(delay-mode-hooks (set-auto-mode t))
(when (plist-get info :html-indent)
(indent-region (point-min) (point-max)))
(buffer-substring-no-properties (point-min) (point-max))))

View File

@ -1142,7 +1142,13 @@ external process."
(catch 'nextfile
(org-check-agenda-file file)
(with-current-buffer (org-get-agenda-file-buffer file)
(org-icalendar-export-to-ics))))
(condition-case err
(org-icalendar-export-to-ics)
(error
(warn "Exporting %s to icalendar failed: %s"
file
(error-message-string err))
(signal (car err) (cdr err)))))))
(org-release-buffers org-agenda-new-buffers)))))
;;;###autoload

View File

@ -135,6 +135,7 @@
(:latex-default-table-environment nil nil org-latex-default-table-environment)
(:latex-default-quote-environment nil nil org-latex-default-quote-environment)
(:latex-default-table-mode nil nil org-latex-default-table-mode)
(:latex-default-footnote-command "LATEX_FOOTNOTE_COMMAND" nil org-latex-default-footnote-command)
(:latex-diary-timestamp-format nil nil org-latex-diary-timestamp-format)
(:latex-engraved-options nil nil org-latex-engraved-options)
(:latex-engraved-preamble nil nil org-latex-engraved-preamble)
@ -667,6 +668,17 @@ The function result will be used in the section format string."
;;;; Footnotes
(defcustom org-latex-default-footnote-command "\\footnote{%s%s}"
"Default command used to insert footnotes.
Customize this command if the LaTeX class provides a different
command like \"\\sidenote{%s%s}\" that you want to use.
The value will be passed as an argument to `format' as the following
(format org-latex-default-footnote-command
footnote-description footnote-label)"
:group 'org-export-latex
:package-version '(Org . "9.7")
:type 'string)
(defcustom org-latex-footnote-separator "\\textsuperscript{,}\\,"
"Text used to separate footnotes."
:group 'org-export-latex
@ -780,7 +792,6 @@ default we use here encompasses both."
:group 'org-export-latex
:type 'string)
;;;; Tables
(defcustom org-latex-default-table-environment "tabular"
@ -2239,7 +2250,7 @@ CONTENTS is nil. INFO is a plist holding contextual information."
(t
(let ((def (org-export-get-footnote-definition footnote-reference info)))
(concat
(format "\\footnote{%s%s}" (org-trim (org-export-data def info))
(format (plist-get info :latex-default-footnote-command) (org-trim (org-export-data def info))
;; Only insert a \label if there exist another
;; reference to def.
(cond ((not label) "")

View File

@ -293,6 +293,13 @@ This function shouldn't be used for floats. See
"Protect minus and backslash characters in string TEXT."
(replace-regexp-in-string "-" "\\-" text nil t))
(defun org-man--protect-example (text)
"Escape necessary characters for verbatim TEXT."
;; See man groff_man_style; \e must be used to render backslash.
;; Note that groff's .eo (disable backslash) and .ec (re-enable
;; backslash) cannot be used as per the same man page.
(replace-regexp-in-string "\\\\" "\\e" text nil t))
;;; Template
@ -400,7 +407,7 @@ information."
(org-man--wrap-label
example-block
(format ".RS\n.nf\n%s\n.fi\n.RE"
(org-export-format-code-default example-block info))))
(org-man--protect-example (org-export-format-code-default example-block info)))))
;;; Export Block
@ -529,11 +536,11 @@ contextual information."
(delete-file out-file)
code-block)
(format ".RS\n.nf\n\\fC\\m[black]%s\\m[]\\fP\n.fi\n.RE\n"
code))))
(org-man--protect-example code)))))
;; Do not use a special package: transcode it verbatim.
(t
(concat ".RS\n.nf\n" "\\fC" "\n" code "\n"
(concat ".RS\n.nf\n" "\\fC" "\n" (org-man--protect-example code) "\n"
"\\fP\n.fi\n.RE\n")))))
@ -749,7 +756,7 @@ CONTENTS holds the contents of the item. INFO is a plist holding
contextual information."
(if (not (plist-get info :man-source-highlight))
(format ".RS\n.nf\n\\fC%s\\fP\n.fi\n.RE\n\n"
(org-export-format-code-default src-block info))
(org-man--protect-example (org-export-format-code-default src-block info)))
(let* ((tmpdir temporary-file-directory)
(in-file (make-temp-name (expand-file-name "srchilite" tmpdir)))
(out-file (make-temp-name (expand-file-name "reshilite" tmpdir)))
@ -772,7 +779,7 @@ contextual information."
(delete-file in-file)
(delete-file out-file)
code-block)
(format ".RS\n.nf\n\\fC\\m[black]%s\\m[]\\fP\n.fi\n.RE" code)))))
(format ".RS\n.nf\n\\fC\\m[black]%s\\m[]\\fP\n.fi\n.RE" (org-man--protect-example code))))))
;;; Statistics Cookie
@ -836,9 +843,10 @@ contextual information."
(format ".nf\n\\fC%s\\fP\n.fi"
;; Re-create table, without affiliated keywords.
(org-trim
(org-element-interpret-data
`(table nil ,@(org-element-contents table))))))
(org-man--protect-example
(org-trim
(org-element-interpret-data
`(table nil ,@(org-element-contents table)))))))
;; Case 2: Standard table.
(t (org-man-table--org-table table contents info))))

View File

@ -47,11 +47,15 @@
(defcustom org-md-headline-style 'atx
"Style used to format headlines.
This variable can be set to either `atx' or `setext'."
This variable can be set to either `atx', `setext', or `mixed'.
Mixed style uses Setext style markup for the first two headline levels
and uses ATX style markup for the remaining four levels."
:group 'org-export-md
:type '(choice
(const :tag "Use \"atx\" style" atx)
(const :tag "Use \"Setext\" style" setext)))
(const :tag "Use \"Setext\" style" setext)
(const :tag "Use \"mixed\" style" mixed)))
;;;; Footnotes
@ -232,7 +236,7 @@ anchor tag for the section as a string. TAGS are the tags set on
the section."
(let ((anchor-lines (and anchor (concat anchor "\n\n"))))
;; Use "Setext" style
(if (and (eq style 'setext) (< level 3))
(if (and (memq style '(setext mixed)) (< level 3))
(let* ((underline-char (if (= level 1) ?= ?-))
(underline (concat (make-string (length title) underline-char)
"\n")))
@ -397,9 +401,10 @@ a communication channel."
(cond
;; Cannot create a headline. Fall-back to a list.
((or (org-export-low-level-p headline info)
(not (memq style '(atx setext)))
(not (memq style '(atx mixed setext)))
(and (eq style 'atx) (> level 6))
(and (eq style 'setext) (> level 2)))
(and (eq style 'setext) (> level 2))
(and (eq style 'mixed) (> level 6)))
(let ((bullet
(if (not (org-export-numbered-headline-p headline info)) "-"
(concat (number-to-string
@ -452,7 +457,7 @@ a communication channel."
(org-list-parents-alist struct)))))
"."))))
(concat bullet
(make-string (- 4 (length bullet)) ? )
(make-string (max 1 (- 4 (length bullet))) ? )
(pcase (org-element-property :checkbox item)
(`on "[X] ")
(`trans "[-] ")

View File

@ -2253,11 +2253,11 @@ SHORT-CAPTION are strings."
LINK is the link pointing to the inline image. INFO is a plist
used as a communication channel."
(cl-assert (org-element-type-p element 'link))
(let* ((src (let* ((type (org-element-property :type element))
(raw-path (org-element-property :path element)))
(cl-assert (equal "file" (org-element-property :type element)))
(let* ((src (let ((raw-path (org-element-property :path element)))
(cond ((file-name-absolute-p raw-path)
(expand-file-name raw-path))
(t (concat type ":" raw-path)))))
(t raw-path))))
(src-expanded (if (file-name-absolute-p src) src
(expand-file-name src (file-name-directory
(plist-get info :input-file)))))
@ -2682,8 +2682,6 @@ INFO is a plist holding contextual information. See
(imagep (org-export-inline-image-p
link (plist-get info :odt-inline-image-rules)))
(path (cond
((member type '("http" "https" "ftp" "mailto"))
(concat type ":" raw-path))
((string= type "file")
(let ((path-uri (org-export-file-uri raw-path)))
(if (string-prefix-p "file://" path-uri)
@ -2693,9 +2691,10 @@ INFO is a plist holding contextual information. See
;; archive. The directory containing the odt file
;; is "../".
(concat "../" path-uri))))
(t raw-path)))
(t (concat type ":" raw-path))))
;; Convert & to &amp; for correct XML representation
(path (replace-regexp-in-string "&" "&amp;" path)))
(path (replace-regexp-in-string "&" "&amp;" path))
(raw-path (replace-regexp-in-string "&" "&amp;" raw-path)))
(cond
;; Link type is handled by a special function.
((org-export-custom-protocol-maybe link desc 'odt info))
@ -2774,10 +2773,10 @@ INFO is a plist holding contextual information. See
;; Coderef: replace link with the reference name or the
;; equivalent line number.
((string= type "coderef")
(let* ((line-no (format "%d" (org-export-resolve-coderef path info)))
(href (concat "coderef-" path)))
(let* ((line-no (format "%d" (org-export-resolve-coderef raw-path info)))
(href (concat "coderef-" raw-path)))
(format
(org-export-get-coderef-format path desc)
(org-export-get-coderef-format raw-path desc)
(format
"<text:bookmark-ref text:reference-format=\"number\" text:ref-name=\"OrgXref.%s\">%s</text:bookmark-ref>"
href line-no))))

View File

@ -56,6 +56,9 @@
"This will cache timestamps and titles for files in publishing projects.
Blocks could hash sha1 values here.")
(defvar org-publish-transient-cache nil
"This will cache information during publishing process.")
(defvar org-publish-after-publishing-hook nil
"Hook run each time a file is published.
Every function in this hook will be called with two arguments:
@ -791,17 +794,14 @@ Default for SITEMAP-FILENAME is `sitemap.org'."
(concat (file-name-directory b)
(org-publish-find-title b project))
b)))
(setq retval
(if ignore-case
(not (string-lessp (upcase B) (upcase A)))
(not (string-lessp B A))))))
(setq retval (org-string<= A B nil ignore-case))))
((or `anti-chronologically `chronologically)
(let* ((adate (org-publish-find-date a project))
(bdate (org-publish-find-date b project)))
(setq retval
(not (if (eq sort-files 'chronologically)
(time-less-p bdate adate)
(time-less-p adate bdate))))))
(time-less-p bdate adate)
(time-less-p adate bdate))))))
(`nil nil)
(_ (user-error "Invalid sort value %s" sort-files)))
;; Directory-wise wins:
@ -867,7 +867,7 @@ PROPERTY, i.e. \"behavior\" parameter from `org-export-options-alist'."
(org-no-properties
(org-element-interpret-data parsed-title))
(file-name-nondirectory (file-name-sans-extension file)))))
(org-publish-cache-set-file-property file :title title)))))
(org-publish-cache-set-file-property file :title title nil 'transient)))))
(defun org-publish-find-date (file project)
"Find the date of FILE in PROJECT.
@ -892,7 +892,8 @@ time in `current-time' format."
(org-time-string-to-time value))))))
((file-exists-p file)
(file-attribute-modification-time (file-attributes file)))
(t (error "No such file: \"%s\"" file)))))))))
(t (error "No such file: \"%s\"" file)))))
nil 'transient))))
(defun org-publish-sitemap-default-entry (entry style project)
"Default format for site map ENTRY, as a string.
@ -1048,7 +1049,8 @@ its CDR is a string."
(replace-regexp-in-string
"\\[[0-9]+%\\]\\|\\[[0-9]+/[0-9]+\\]" ""
(org-element-property :raw-value parent)))))))))
info))))
info))
nil 'transient))
;; Return output unchanged.
output)
@ -1251,6 +1253,9 @@ If FREE-CACHE, empty the cache."
(error "Org publish timestamp: %s is not a directory"
org-publish-timestamp-directory))
(unless org-publish-transient-cache
(setq org-publish-transient-cache (make-hash-table :test #'equal)))
(unless (and org-publish-cache
(string= (org-publish-cache-get ":project:") project-name))
(let* ((cache-file
@ -1274,6 +1279,8 @@ If FREE-CACHE, empty the cache."
(message "%s" "Resetting org-publish-cache")
(when (hash-table-p org-publish-cache)
(clrhash org-publish-cache))
(when (hash-table-p org-publish-transient-cache)
(clrhash org-publish-transient-cache))
(setq org-publish-cache nil))
(defun org-publish-cache-file-needs-publishing
@ -1319,16 +1326,22 @@ the file including them will be republished as well."
included-files-mtime))))))
(defun org-publish-cache-set-file-property
(filename property value &optional project-name)
(filename property value &optional project-name transient)
"Set the VALUE for a PROPERTY of file FILENAME in publishing cache to VALUE.
Use cache file of PROJECT-NAME. If the entry does not exist, it
will be created. Return VALUE."
will be created. Return VALUE.
When TRANSIENT is non-nil, store value in transient cache that is only
maintained during the current publish process."
;; Evtl. load the requested cache file:
(when project-name (org-publish-initialize-cache project-name))
(let ((pl (org-publish-cache-get filename)))
(if pl (progn (plist-put pl property value) value)
(org-publish-cache-get-file-property
filename property value nil project-name))))
(if transient
(puthash (cons filename property) value
org-publish-transient-cache)
(let ((pl (org-publish-cache-get filename)))
(if pl (progn (plist-put pl property value) value)
(org-publish-cache-get-file-property
filename property value nil project-name)))))
(defun org-publish-cache-get-file-property
(filename property &optional default no-create project-name)
@ -1337,13 +1350,14 @@ Use cache file of PROJECT-NAME. Return the value of that PROPERTY,
or DEFAULT, if the value does not yet exist. Create the entry,
if necessary, unless NO-CREATE is non-nil."
(when project-name (org-publish-initialize-cache project-name))
(let ((properties (org-publish-cache-get filename)))
(cond ((null properties)
(unless no-create
(org-publish-cache-set filename (list property default)))
default)
((plist-member properties property) (plist-get properties property))
(t default))))
(or (gethash (cons filename property) org-publish-transient-cache)
(let ((properties (org-publish-cache-get filename)))
(cond ((null properties)
(unless no-create
(org-publish-cache-set filename (list property default)))
default)
((plist-member properties property) (plist-get properties property))
(t default)))))
(defun org-publish-cache-get (key)
"Return the value stored in `org-publish-cache' for key KEY.

View File

@ -684,31 +684,14 @@ e.g. \"stat:nil\""
"Non-nil means interpret \"_\" and \"^\" for export.
If you want to control how Org displays those characters, see
`org-use-sub-superscripts'. `org-export-with-sub-superscripts'
used to be an alias for `org-use-sub-superscripts' in Org <8.0,
it is not anymore.
`org-use-sub-superscripts'.
When this option is turned on, you can use TeX-like syntax for
sub- and superscripts and see them exported correctly.
You can also set the option with #+OPTIONS: ^:t
Several characters after \"_\" or \"^\" will be considered as a
single item - so grouping with {} is normally not needed. For
example, the following things will be parsed as single sub- or
superscripts:
10^24 or 10^tau several digits will be considered 1 item.
10^-12 or 10^-tau a leading sign with digits or a word
x^2-y^3 will be read as x^2 - y^3, because items are
terminated by almost any nonword/nondigit char.
x_{i^2} or x^(2-i) braces or parenthesis do grouping.
Still, ambiguity is possible. So when in doubt, use {} to enclose
the sub/superscript. If you set this variable to the symbol `{}',
the braces are *required* in order to trigger interpretations as
sub/superscript. This can be helpful in documents that need \"_\"
frequently in plain text."
See `org-use-sub-superscripts' docstring for more details."
:group 'org-export-general
:version "24.4"
:package-version '(Org . "8.0")
@ -1917,7 +1900,7 @@ Return a string."
(progn ,@body)
(org-link-broken
(pcase (plist-get info :with-broken-links)
(`nil (user-error "Unable to resolve link: %S" (nth 1 err)))
(`nil (user-error "Org export aborted. Unable to resolve link: %S\nSee `org-export-with-broken-links'." (nth 1 err)))
(`mark (org-export-data
(format "[BROKEN LINK: %s]" (nth 1 err)) info))
(_ nil))))))

View File

@ -39,6 +39,14 @@
#+END_SRC"
(should (equal "27" (org-babel-execute-src-block)))))
(ert-deftest ob-calc/float-var ()
"Test of floating variable."
(org-test-with-temp-text "\
#+BEGIN_SRC calc :results silent :var x=2.0
1/x
#+END_SRC"
(should (equal "0.5" (org-babel-execute-src-block)))))
(ert-deftest ob-calc/simple-program-symbolic ()
"Test of simple symbolic algebra."
(org-test-with-temp-text "\
@ -59,7 +67,14 @@
inv(a)
#+END_SRC "
(should (equal "[[-1, 0.625, -0.125], [0.25, -0.5, 0.25], [0.5, 0.125, -0.125]]"
(org-babel-execute-src-block)))))
(let ((calc-float-format '(float 0)))
;; ;; Make sure that older Calc buffers are not present.
(save-current-buffer
(when (ignore-errors (calc-select-buffer))
(kill-buffer)))
;; Now, let-bound `calc-float-format' will take
;; effect.
(org-babel-execute-src-block))))))
(ert-deftest ob-calc/matrix-algebra ()
"Test of simple matrix algebra."

View File

@ -205,14 +205,14 @@ Here is one at the end of a line. {{{results(=2=)}}}
(ert-deftest ob-exp/exports-inline-code ()
(should
(equal "src_emacs-lisp[]{(+ 1 1)}"
(equal "src_emacs-lisp[ :exports code]{(+ 1 1)}"
(org-test-with-temp-text "src_emacs-lisp[:exports code]{(+ 1 1)}"
(let ((org-babel-inline-result-wrap "=%s=")
(org-export-use-babel t))
(org-babel-exp-process-buffer))
(buffer-string))))
(should
(equal "src_emacs-lisp[]{(+ 1 1)}"
(equal "src_emacs-lisp[ :exports code]{(+ 1 1)}"
(org-test-with-temp-text "src_emacs-lisp[ :exports code ]{(+ 1 1)}"
(let ((org-babel-inline-result-wrap "=%s=")
(org-export-use-babel t))
@ -220,14 +220,14 @@ Here is one at the end of a line. {{{results(=2=)}}}
(buffer-string))))
;; Do not escape characters in inline source blocks.
(should
(equal "src_c[]{*a}"
(equal "src_c[ :exports code]{*a}"
(org-test-with-temp-text "src_c[ :exports code ]{*a}"
(let ((org-babel-inline-result-wrap "=%s=")
(org-export-use-babel t))
(org-babel-exp-process-buffer))
(buffer-string))))
(should
(equal "src_emacs-lisp[]{(+ 1 1)} {{{results(=2=)}}}"
(equal "src_emacs-lisp[ :exports both]{(+ 1 1)} {{{results(=2=)}}}"
(org-test-with-temp-text "src_emacs-lisp[:exports both]{(+ 1 1)}"
(let ((org-babel-inline-result-wrap "=%s=")
(org-export-use-babel t))
@ -262,10 +262,10 @@ Here is one at the end of a line. {{{results(=2=)}}}
(string-match
(replace-regexp-in-string
"\\\\\\[]{" "\\(?:\\[]\\)?{" ;accept both src_sh[]{...} or src_sh{...}
(regexp-quote "Here is one in the middle src_sh[]{echo 1} of a line.
Here is one at the end of a line. src_sh[]{echo 2}
src_sh[]{echo 3} Here is one at the beginning of a line.
Here is one that is also evaluated: src_sh[]{echo 4} {{{results(=4=)}}}")
(regexp-quote "Here is one in the middle src_sh[ :exports code]{echo 1} of a line.
Here is one at the end of a line. src_sh[ :exports code]{echo 2}
src_sh[ :exports code]{echo 3} Here is one at the beginning of a line.
Here is one that is also evaluated: src_sh[ :exports both]{echo 4} {{{results(=4=)}}}")
nil t)
(org-test-at-id "cd54fc88-1b6b-45b6-8511-4d8fa7fc8076"
(org-narrow-to-subtree)
@ -301,7 +301,7 @@ be evaluated."
(ert-deftest ob-exp/exports-inline-code-double-eval-exports-both ()
(let ((org-export-use-babel t))
(should
(string-match (concat "\\`src_emacs-lisp\\(?:\\[]\\)?{(\\+ 1 1)} "
(string-match (concat "\\`src_emacs-lisp\\(?:\\[.+?]\\)?{(\\+ 1 1)} "
"{{{results(src_emacs-lisp\\[ :exports code\\]{2})}}}$")
(org-test-with-temp-text
(concat "src_emacs-lisp[:exports both :results code "
@ -403,7 +403,7 @@ be evaluated."
: 2
#+NAME: src1
#+begin_src emacs-lisp
#+begin_src emacs-lisp :exports both
\(+ 1 1)
#+end_src"
(org-test-with-temp-text

View File

@ -77,9 +77,9 @@ return x[1]
(ert-deftest test-ob-lua/colnames-yes-header-argument-pp ()
"Test table passing with `colnames' header and pp option."
"Test table passing with `colnames' header and `pp' option."
(should
(equal "a = 12\nb = 13\n"
(equal "a = 12\nb = 13"
(org-test-with-temp-text
"#+name: eg
| col | val |
@ -99,7 +99,7 @@ return x
(ert-deftest test-ob-lua/colnames-nil-header-argument ()
"Test table with `colnames' set to `nil'."
(should
(equal "1 = a\n2 = b\n"
(equal "1 = a\n2 = b"
(org-test-with-temp-text
"#+name: eg
| col |
@ -119,7 +119,7 @@ return x
(ert-deftest test-ob-lua/colnames-no-header-argument ()
"Test table passing without `colnames'."
(should
(equal "1 = col\n2 = a\n3 = b\n"
(equal "1 = col\n2 = a\n3 = b"
(org-test-with-temp-text
"#+name: eg
| col |
@ -136,6 +136,46 @@ return x
(org-babel-next-src-block)
(org-babel-execute-src-block)))))
(ert-deftest test-ob-lua/types ()
"Test returning different types."
(should
(equal "nil"
(org-test-with-temp-text "src_lua{return nil}"
(org-babel-execute-src-block))))
(should
(equal "true"
(org-test-with-temp-text "src_lua{return true}"
(org-babel-execute-src-block))))
(should
(equal "false"
(org-test-with-temp-text "src_lua{return false}"
(org-babel-execute-src-block))))
(should
(equal 1
(org-test-with-temp-text "src_lua{return 1}"
(org-babel-execute-src-block))))
(should
(equal "hello world"
(org-test-with-temp-text "src_lua{return 'hello world'}"
(org-babel-execute-src-block))))
(should
(equal 0
(string-match "table: 0x[0-9A-F]+"
(org-test-with-temp-text "src_lua{return {}}"
(org-babel-execute-src-block))))))
(ert-deftest test-ob-lua/multiple-values ()
"Test returning multiple values."
(should
(equal "1, 2, 3"
(org-test-with-temp-text "src_lua{return 1, 2, 3}"
(org-babel-execute-src-block))))
(should
(equal "1|2|3"
(let ((org-babel-lua-multiple-values-separator "|"))
(org-test-with-temp-text "src_lua{return 1, 2, 3}"
(org-babel-execute-src-block))))))
(provide 'test-ob-lua)
;;; test-ob-lua.el ends here

View File

@ -183,6 +183,7 @@ that will return all elements of the array as a single string."
echo ${array}
<point>
#+end_src"
(skip-unless (executable-find "bash"))
(should (equal "one" (org-trim (org-babel-execute-src-block))))))
(ert-deftest test-ob-shell/generic-uses-no-assoc-arrays-simple-map ()
@ -229,6 +230,10 @@ echo ${table}
Bash will see a table that contains the first column as the
'index' of the associative array, and the second column as the
value. "
(skip-unless
;; Old GPLv2 BASH in macOSX does not support associative arrays.
(if-let ((bash (executable-find "bash")))
(eq 0 (process-file bash nil nil nil "-c" "declare -A assoc_array"))))
(org-test-with-temp-text
"#+NAME: sample_mapping_table
| first | one |
@ -248,6 +253,10 @@ echo ${table[second]}
Bash will see an associative array that contains each row as a single
string. Bash cannot handle lists in associative arrays."
(skip-unless
;; Old GPLv2 BASH in macOSX does not support associative arrays.
(if-let ((bash (executable-find "bash")))
(eq 0 (process-file bash nil nil nil "-c" "declare -A assoc_array"))))
(org-test-with-temp-text
"#+NAME: sample_big_table
| bread | 2 | kg |

View File

@ -191,20 +191,20 @@ echo 1
* Main
#+header: :tangle \"test-ob-tangle.el\" :comments noweb :noweb yes
#+begin_src emacs-lisp
1
<<inner>>
'(1
<<inner>>)
#+end_src"
(unwind-protect
(let ((org-babel-tangle-use-relative-file-links t))
(org-babel-tangle)
(with-temp-buffer
(insert-file-contents "test-ob-tangle.el")
(buffer-string)
(goto-char (point-min))
(and
(search-forward (concat ";; [[file:" (file-name-nondirectory file) "::inner") nil t)
(search-forward ";; inner ends here" nil t))))
(delete-file "test-ob-tangle.el")))))
(unwind-protect
(let ((org-babel-tangle-use-relative-file-links t))
(org-babel-tangle)
(with-temp-buffer
(insert-file-contents "test-ob-tangle.el")
(buffer-string)
(goto-char (point-min))
(and
(search-forward (concat ";; [[file:" (file-name-nondirectory file) "::inner") nil t)
(search-forward ";; inner ends here\n" nil t))))
(delete-file "test-ob-tangle.el")))))
(ert-deftest ob-tangle/comment-noweb-absolute ()
"Test :comments noweb tangling with absolute file path."

View File

@ -2545,6 +2545,70 @@ abc
(lambda (&rest _) (error "No warnings should occur"))))
(org-babel-import-elisp-from-file (buffer-file-name))))))
(ert-deftest test-ob/org-babel-read ()
"Test `org-babel-read' specifications."
(dolist (inhibit '(t nil))
;; A number
(should (equal 1 (org-babel-read "1" inhibit)))
(should (equal -1 (org-babel-read "-1" inhibit)))
(should (equal 1.2 (org-babel-read "1.2" inhibit)))
;; Allow whitespace
(should (equal 1 (org-babel-read " 1 " inhibit)))
(should (equal 1 (org-babel-read " 1\n" inhibit)))
;; Not a number
(should-not (equal 1 (org-babel-read "1foo" inhibit)))
;; Empty string
(should (equal "" (org-babel-read "" inhibit)))
(should (equal " " (org-babel-read " " inhibit)))
;; Elisp function call
(should
(equal (if inhibit
;; Verbatim string, with spaces
"(+ 1 2) "
;; Result of evaluation
3)
(org-babel-read "(+ 1 2) " inhibit)))
;; Elisp function call must start from (
(should-not (equal 3 (org-babel-read " (+ 1 2)" nil)))
(should
(equal (if inhibit
"'(1 2)"
;; Result of evaluation
'(1 2))
(org-babel-read "'(1 2)" inhibit)))
;; `(...)
(should
(equal (if inhibit
"`(1 ,(+ 1 2))"
;; Result of evaluation
'(1 3))
(org-babel-read "`(1 ,(+ 1 2))" inhibit)))
;; [...]
(should
(equal (if inhibit
"[1 2 (foo)]"
;; Result of evaluation
[1 2 (foo)])
(org-babel-read "[1 2 (foo)]" inhibit)))
;; Special case: *this* literal is evaluated
(defvar *this* nil)
(let ((*this* 100))
(should
(equal
(if inhibit "*this*" 100)
(org-babel-read "*this*" inhibit))))
;; Special case: data inside quotes
(should (equal "foo" (org-babel-read " \"foo\" " inhibit)))
(should (equal "foo" (org-babel-read " \"foo\"\n" inhibit)))
(should (equal "foo with\" inside" (org-babel-read " \"foo with\\\" inside\" " inhibit)))
(should (equal "abc\nsdf" (org-babel-read "\"abc\nsdf\"" inhibit)))
(should (equal "foo" (org-babel-read "\"foo\"" inhibit)))
(should (equal "\"foo\"(\"bar\"" (org-babel-read "\"foo\"(\"bar\"" inhibit)))
;; Unpaired quotes
(should (equal "\"foo\"\"bar\"" (org-babel-read "\"foo\"\"bar\"" inhibit)))
;; Recover from `read' parsing errors.
(org-babel-read "\"Quoted closing quote:\\\"" inhibit)))
(ert-deftest test-ob/demarcate-block-split-duplication ()
"Test duplication of language, body, switches, and headers in splitting."
(let ((caption "#+caption: caption.")

View File

@ -61,6 +61,7 @@ See https://github.com/yantar92/org/issues/4."
(org-test-with-temp-text "* Org link test
[[https://example.com][A link to a site]]"
(dotimes (_ 2)
(font-lock-ensure)
(goto-char 1)
(re-search-forward "\\[")
(should-not (org-xor org-link-descriptive (org-invisible-p)))

View File

@ -690,43 +690,65 @@ Sunday 7 January 2024
(ert-deftest test-org-agenda/skip-deadline-prewarning-if-scheduled ()
"Test `org-agenda-skip-deadline-prewarning-if-scheduled'."
(org-test-at-time
"2024-01-15"
(let ((org-agenda-skip-deadline-prewarning-if-scheduled t))
(org-test-agenda-with-agenda
"* TODO foo\nDEADLINE: <2024-01-20 Sat> SCHEDULED: <2024-01-19 Fri>"
"2024-01-15"
(let ((org-agenda-skip-deadline-prewarning-if-scheduled t))
(org-test-agenda-with-agenda
"* TODO foo\nDEADLINE: <2024-01-20 Sat> SCHEDULED: <2024-01-19 Fri>"
(org-agenda-list nil nil 1)
(should-not (search-forward "In " nil t))))
(let ((org-agenda-skip-deadline-prewarning-if-scheduled 10))
(org-test-agenda-with-agenda
"* TODO foo\nDEADLINE: <2024-01-20 Sat> SCHEDULED: <2024-01-19 Fri>"
(org-agenda-list nil nil 1)
(should (search-forward "In " nil t))))
;; Custom prewarning cookie "-3d", so there should be no warning anyway.
(let ((org-agenda-skip-deadline-prewarning-if-scheduled 10))
(org-test-agenda-with-agenda
"* TODO foo\nDEADLINE: <2024-01-20 Sat -3d> SCHEDULED: <2024-01-19 Fri>"
(org-agenda-list nil nil 1)
(should-not (search-forward "In " nil t))))
(let ((org-agenda-skip-deadline-prewarning-if-scheduled 3))
(org-test-agenda-with-agenda
"* TODO foo\nDEADLINE: <2024-01-20 Sat> SCHEDULED: <2024-01-19 Fri>"
(org-agenda-list nil nil 1)
(should-not (search-forward "In " nil t))))
(let ((org-agenda-skip-deadline-prewarning-if-scheduled nil))
(org-test-agenda-with-agenda
"* TODO foo\nDEADLINE: <2024-01-20 Sat> SCHEDULED: <2024-01-19 Fri>"
(org-agenda-list nil nil 1)
(should (search-forward "In " nil t))))
(let ((org-agenda-skip-deadline-prewarning-if-scheduled 'pre-scheduled))
(org-test-agenda-with-agenda
"* TODO foo\nDEADLINE: <2024-01-20 Sat> SCHEDULED: <2024-01-16 Tue>"
(org-agenda-list nil nil 1)
(should-not (search-forward "In " nil t))))
(let ((org-agenda-skip-deadline-prewarning-if-scheduled 'pre-scheduled))
(org-test-agenda-with-agenda
"* TODO foo\nDEADLINE: <2024-01-20 Sat> SCHEDULED: <2024-01-15 Mon>"
(org-agenda-list nil nil 1)
(should (search-forward "In " nil t))))))
(ert-deftest test-org-agenda/diary-timestamp ()
"Test diary timestamp handling."
(org-test-at-time
"2024-01-15"
(org-test-agenda-with-agenda
"* TODO foo\n<%%(diary-date 01 15 2024)>"
(org-agenda-list nil nil 1)
(should-not (search-forward "In " nil t))))
(let ((org-agenda-skip-deadline-prewarning-if-scheduled 10))
(org-test-agenda-with-agenda
"* TODO foo\nDEADLINE: <2024-01-20 Sat> SCHEDULED: <2024-01-19 Fri>"
(should (search-forward "foo" nil t)))
(org-test-agenda-with-agenda
"* TODO foo\n<%%(diary-date 02 15 2024)>"
(org-agenda-list nil nil 1)
(should (search-forward "In " nil t))))
;; Custom prewarning cookie "-3d", so there should be no warning anyway.
(let ((org-agenda-skip-deadline-prewarning-if-scheduled 10))
(org-test-agenda-with-agenda
"* TODO foo\nDEADLINE: <2024-01-20 Sat -3d> SCHEDULED: <2024-01-19 Fri>"
(should-not (search-forward "foo" nil t)))
;; Test time and time ranges in diary timestamps.
(org-test-agenda-with-agenda
"* TODO foo\n<%%(diary-date 01 15 2024) 12:00>"
(org-agenda-list nil nil 1)
(should-not (search-forward "In " nil t))))
(let ((org-agenda-skip-deadline-prewarning-if-scheduled 3))
(org-test-agenda-with-agenda
"* TODO foo\nDEADLINE: <2024-01-20 Sat> SCHEDULED: <2024-01-19 Fri>"
(should (search-forward "12:00" nil t)))
(org-test-agenda-with-agenda
"* TODO foo\n<%%(diary-date 01 15 2024) 12:00-14:00>"
(org-agenda-list nil nil 1)
(should-not (search-forward "In " nil t))))
(let ((org-agenda-skip-deadline-prewarning-if-scheduled nil))
(org-test-agenda-with-agenda
"* TODO foo\nDEADLINE: <2024-01-20 Sat> SCHEDULED: <2024-01-19 Fri>"
(org-agenda-list nil nil 1)
(should (search-forward "In " nil t))))
(let ((org-agenda-skip-deadline-prewarning-if-scheduled 'pre-scheduled))
(org-test-agenda-with-agenda
"* TODO foo\nDEADLINE: <2024-01-20 Sat> SCHEDULED: <2024-01-16 Tue>"
(org-agenda-list nil nil 1)
(should-not (search-forward "In " nil t))))
(let ((org-agenda-skip-deadline-prewarning-if-scheduled 'pre-scheduled))
(org-test-agenda-with-agenda
"* TODO foo\nDEADLINE: <2024-01-20 Sat> SCHEDULED: <2024-01-15 Mon>"
(org-agenda-list nil nil 1)
(should (search-forward "In " nil t))))))
(should (search-forward "12:00-14:00" nil t)))))
;; agenda redo

View File

@ -1398,6 +1398,13 @@
;;; Dynamic block
(defun test-org-colview/dblock-formatter (ipos table params)
"User-defined columnview dblock formatting function."
(goto-char ipos)
(insert-before-markers "Hello columnview!" "\n")
(insert-before-markers (format "table has %d rows" (length table)) "\n")
(insert-before-markers (format "there are %d parameters" (/ (length params) 2))))
(ert-deftest test-org-colview/dblock ()
"Test the column view table."
(should
@ -1703,6 +1710,31 @@ SCHEDULED: <2020-05-11 Mon> DEADLINE: <2020-05-14 Thu>
(let ((org-columns-default-format
"%ITEM %DEADLINE(d) %SCHEDULED(s) %TIMESTAMP(t)"))
(org-update-dblock))
(buffer-substring-no-properties (point) (point-max)))))
;; custom formatting function
(should
(equal
"#+BEGIN: columnview :formatter test-org-colview/dblock-formatter
Hello columnview!
table has 3 rows
there are 4 parameters
#+END:"
(org-test-with-temp-text
"* H\n<point>#+BEGIN: columnview :formatter test-org-colview/dblock-formatter\n#+END:"
(let ((org-columns-default-format "%ITEM"))
(org-update-dblock))
(buffer-substring-no-properties (point) (point-max)))))
;; test headline linkification
(should
(equal
"#+BEGIN: columnview :link t
| ITEM |
|------|
| [[*H][H]] |
#+END:"
(org-test-with-temp-text
"* H\n<point>#+BEGIN: columnview :link t\n#+END:"
(let ((org-columns-default-format "%ITEM")) (org-update-dblock))
(buffer-substring-no-properties (point) (point-max))))))
(provide 'test-org-colview)

View File

@ -0,0 +1,192 @@
;;; test-org-ctags.el --- tests for org-ctags.el -*- lexical-binding: t -*-
;; Copyright (C) 2024 Max Nikulin
;; Authors: Max Nikulin
;; This file is not part of GNU Emacs.
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
;;; Code:
;; Alternative implementation for `test-org-ctags/mock-command'
;; is required for cmd.exe.
(unless (string-equal "-c" shell-command-switch)
(signal 'missing-test-dependency "POSIX shell"))
(require 'org-ctags)
;;;; Helpers:
(defun test-org-ctags/mock-command (temp-file command-name)
"Define shell function COMMAND-NAME wrining arguments to TEMP-FILE."
;; Failure exit code is used to prevent further `org-ctags' actions.
(format "%s() { printf '%%s\\n' %s \"$@\" >%s 2>&1 ; false ; } ; %s"
command-name command-name
(shell-quote-argument temp-file)
command-name))
(defun test-org-ctags/get-args (temp-file base magic)
"Read list of strings from TEMP-FILE.
If TEMP-FILE does not start from MAGIC then return
its content as a string. Otherwise strip first line
and trailing newline, replace BASE with \"TMPDIR\" string,
return list of lines."
(let* ((case-fold-search nil)
(content
(and
(file-exists-p temp-file)
(with-temp-buffer
(insert-file-contents temp-file)
(goto-char (point-min))
(when (looking-at magic)
(while (search-forward base nil 'noerror)
(replace-match "TMPDIR" 'fixedcase 'literal)))
(goto-char (point-max))
(when (and (bolp) (> (point) 1))
(delete-char -1))
(buffer-string)))))
(if (and content (string-prefix-p magic content))
(cdr (split-string content "\n"))
content)))
(defmacro test-org-ctags/with-fake-ctags
(temp-dir subdir &rest body)
"Run BODY with `org-ctags-path-to-ctags' set to a test function.
Create a buffer backed by a file in the TEMP-DIR/SUBDIR directory."
(declare (indent 2))
(let ((buffer (gensym "buffer"))
(base (gensym "base"))
(dir (gensym "dir"))
(temp-file (gensym "temp-file")))
`(let* ((,base ,temp-dir)
(,dir (concat ,base "/" ,subdir))
(,temp-file (concat ,dir "/ctags.txt"))
(org-ctags-path-to-ctags
(test-org-ctags/mock-command ,temp-file "ctags_mock"))
,buffer)
(make-directory ,dir)
(unwind-protect
;; `org-ctags' commands call `buffer-file-name'.
(with-current-buffer
(setq ,buffer (find-file-noselect ,temp-file))
(insert "Should be overwritten by org-ctags mock script")
(save-buffer)
,@body
(test-org-ctags/get-args ,temp-file ,base "ctags_mock\n"))
(kill-buffer ,buffer)
(delete-file ,temp-file)
(delete-directory ,dir)))))
;;;; Comparator to have informative failures:
(defun test-org-ctags/list-elements (lst &optional indicies)
"Select INDICIES elements from LST list.
INDICIES should be sorted in growing order."
(if (not (and indicies (listp lst)))
lst
(let (selected
(prev 0))
(dolist (i indicies (nreverse selected))
(setq lst (nthcdr (- i prev) lst))
(setq prev i)
(push (car lst) selected)))))
(defun test-org-ctags/list-elements-equal-p
(expect actual indicies &rest _comments)
"Call `equal' for lists EXPECT and INDICIES elements from ACTUAL.
_COMMENTS should appear in failure message."
(equal expect
(test-org-ctags/list-elements actual indicies)))
(defun test-org-ctags/list-elements-equal-explain
(expect actual indicies &rest _comments)
"`ert-eplainer' for `test-org-ctags/list-elements-equal-p'."
(if (listp actual)
(list
'selected-elements
(test-org-ctags/list-elements actual indicies))
"Shell command failed"))
(put 'test-org-ctags/list-elements-equal-p
'ert-explainer
'test-org-ctags/list-elements-equal-explain)
;;;; Tests:
(ert-deftest test-org-ctags/create-tags-escape ()
"Test that `org-ctags-create-tags' escapes shell arguments."
(let ((temp-dir (make-temp-file "test-org-ctags-" 'dir)))
(unwind-protect
(progn
(should
(test-org-ctags/list-elements-equal-p
(list (format "--regex-orgmode=%s" org-ctags-tag-regexp))
(test-org-ctags/with-fake-ctags temp-dir "regexp"
(org-ctags-create-tags))
'(2)
"Regexp should be escaped."))
(should
(test-org-ctags/list-elements-equal-p
'("TMPDIR/regular/ctags.txt")
(test-org-ctags/with-fake-ctags temp-dir "regular"
(org-ctags-create-tags (concat temp-dir "/regular")))
'(7)
"Wildcard should be expanded."
"Directory passed as an argument."))
(should
(test-org-ctags/list-elements-equal-p
'("TMPDIR/space char/TAGS" "TMPDIR/space char/ctags.txt")
(test-org-ctags/with-fake-ctags temp-dir "space char"
(org-ctags-create-tags (concat temp-dir "/space char")))
'(4 7)
"Space characters should not split arguments."
"Directory passed as an argument."))
(should
(test-org-ctags/list-elements-equal-p
'("TMPDIR/apostrophe' sep '/TAGS" "TMPDIR/apostrophe' sep '/ctags.txt")
(test-org-ctags/with-fake-ctags temp-dir "apostrophe' sep '"
(org-ctags-create-tags))
'(4 7)
"Apostrophes should be regular characters."
"Path is derived from `default-directory'."))
(should
(test-org-ctags/list-elements-equal-p
'("TMPDIR/def-dir.$HOME/TAGS" "TMPDIR/def-dir.$HOME/ctags.txt")
(test-org-ctags/with-fake-ctags temp-dir "def-dir.$HOME"
(org-ctags-create-tags))
'(4 7)
"$VARIABLES should not be expanded in directory names."
"Path is derived from `default-directory'."))
(should
(test-org-ctags/list-elements-equal-p
'("TMPDIR/arg.$HOME/TAGS" "TMPDIR/arg.$HOME/ctags.txt")
(test-org-ctags/with-fake-ctags temp-dir "arg.$HOME"
(org-ctags-create-tags (concat temp-dir "/arg.$HOME")))
'(4 7)
"$VARIABLES should not be expanded in directory names."
"Directory passed as an argument")))
(delete-directory temp-dir))))
(provide 'test-org-ctags)
;;; test-org.el ends here

View File

@ -3989,8 +3989,31 @@ DEADLINE: <2012-03-29 thu.> SCHEDULED: <2012-03-29 thu.> CLOSED: [2012-03-29 thu
(org-test-parse-and-interpret
"<2012-03-29 thu. 16:40-16:41>")))
;; Diary.
(should (equal (org-test-parse-and-interpret "<%%diary-float t 4 2>")
"<%%diary-float t 4 2>\n"))
(should (equal (org-test-parse-and-interpret "<%%(diary-float t 4 2)>")
"<%%(diary-float t 4 2)>\n"))
;; Diary with time.
(should (equal (org-test-parse-and-interpret "<%%(diary-float t 4 2) 12:00>")
"<%%(diary-float t 4 2) 12:00>\n"))
(should (equal (org-test-parse-and-interpret "<%%(diary-cyclic 1 1 1 2020) 12:00-14:00>")
"<%%(diary-cyclic 1 1 1 2020) 12:00-14:00>\n"))
(org-test-with-temp-text "<%%(diary-float t 4 2) 12:00>"
(let ((ts (org-element-context)))
(should (org-element-type-p ts 'timestamp))
(should (eq 'diary (org-element-property :type ts)))
(should (eq nil (org-element-property :range-type ts)))
(should (equal 12 (org-element-property :hour-start ts)))
(should (equal 0 (org-element-property :minute-start ts)))
(should-not (org-element-property :hour-end ts))
(should-not (org-element-property :minute-end ts))))
(org-test-with-temp-text "<%%(diary-float t 4 2) 12:00-14:01>"
(let ((ts (org-element-context)))
(should (org-element-type-p ts 'timestamp))
(should (eq 'diary (org-element-property :type ts)))
(should (eq 'timerange (org-element-property :range-type ts)))
(should (equal 12 (org-element-property :hour-start ts)))
(should (equal 0 (org-element-property :minute-start ts)))
(should (equal 14 (org-element-property :hour-end ts)))
(should (equal 1 (org-element-property :minute-end ts)))))
;; Timestamp with repeater interval, repeater deadline, with delay, with combinations.
(should
(string-match "<2012-03-29 .* \\+1y>"
@ -4983,6 +5006,18 @@ Text
;;; Test Cache.
(ert-deftest test-org-element/cache-map ()
"Test `org-element-cache-map'."
(org-test-with-temp-text "* headline\n:DRAWER:\nparagraph\n:END:\n* headline 2"
(should
(equal
'(org-data headline section drawer paragraph headline)
(org-element-cache-map #'car :granularity 'element))))
(should
(equal
'(org-data headline section drawer paragraph)
(org-test-with-temp-text "* headline\n:DRAWER:\nparagraph\n:END:"
(org-element-cache-map #'car :granularity 'element)))))
(ert-deftest test-org-element/cache ()
"Test basic expectations and common pitfalls for cache."

View File

@ -22,6 +22,21 @@
;;; Macros
(ert-deftest test-org-macro/initialize-templates ()
"Test `org-macro-initialize-templates'."
;; No code is executed during loading of Org mode files."
(should
(org-test-with-temp-text
"#+MACRO: title (eval (eval-and-compile (error \"CVE-2024-30202\")))"
(progn
(org-macro-initialize-templates)
t)))
(org-test-with-temp-text
"#+MACRO: title (eval (eval-and-compile (error \"CVE-2024-30202\")))"
(progn
(org-mode)
t)))
(ert-deftest test-org/macro-replace-all ()
"Test `org-macro-replace-all' specifications."
;; Standard test.

View File

@ -938,7 +938,7 @@ See also URL `https://orgmode.org/worg/org-tutorials/org-lookups.html'."
;; For Lisp formula
(should (equal "\"0\"" (org-table-make-reference "0" nil nil t)))
(should (equal "\"z\"" (org-table-make-reference "z" nil nil t)))
(should (equal "" (org-table-make-reference "" nil nil t)))
(should (equal "\"\"" (org-table-make-reference "" nil nil t)))
(should (equal "\"0\" \"1\"" (org-table-make-reference '("0" "1") nil nil t)))
(should (equal "\"z\" \"1\"" (org-table-make-reference '("z" "1") nil nil t)))
(should (equal "\"1\"" (org-table-make-reference '("" "1") nil nil t)))
@ -965,7 +965,7 @@ See also URL `https://orgmode.org/worg/org-tutorials/org-lookups.html'."
;; For Lisp formula
(should (equal "0" (org-table-make-reference "0" nil t t)))
(should (equal "0" (org-table-make-reference "z" nil t t)))
(should (equal "" (org-table-make-reference "" nil t t)))
(should (equal "0" (org-table-make-reference "" nil t t)))
(should (equal "0 1" (org-table-make-reference '("0" "1") nil t t)))
(should (equal "0 1" (org-table-make-reference '("z" "1") nil t t)))
(should (equal "1" (org-table-make-reference '("" "1") nil t t)))

View File

@ -9356,6 +9356,18 @@ CLOSED: %s
(org-test-with-temp-text "* H1\n<point>Paragraph\n* H2"
(org-paste-subtree nil "* Text")
(buffer-string))))
;; With prefix argument, move to the end of subtree.
(should
(equal "* H1\nParagraph\n** H1.1\n* Text\n* H2"
(org-test-with-temp-text "* H1\n<point>Paragraph\n** H1.1\n* H2"
(org-paste-subtree '(4) "* Text")
(buffer-string))))
;; With double prefix argument, move to first sibling
(should
(equal "* H1\nParagraph\n** Text\n** H1.1\n* H2"
(org-test-with-temp-text "* H1\n<point>Paragraph\n** H1.1\n* H2"
(org-paste-subtree '(16) "* Text")
(buffer-string))))
;; If point is between two headings, use the deepest level.
(should
(equal "* H1\n\n* Text\n* H2"
@ -9372,6 +9384,30 @@ CLOSED: %s
(org-test-with-temp-text "* H1\n<point>\n** H2"
(org-paste-subtree nil "* Text")
(buffer-string))))
;; When point is on heading at bol, insert before
(should
(equal "* Text\n* H1\n** H2"
(org-test-with-temp-text "<point>* H1\n** H2"
(org-paste-subtree nil "*** Text")
(buffer-string))))
;; With prefix argument, ignore that we are at bol
(should
(equal "* H1\n** H2\n* Text\n"
(org-test-with-temp-text "<point>* H1\n** H2"
(org-paste-subtree '(4) "*** Text")
(buffer-string))))
;; When point is on heading but not at bol, use smallest level among
;; current heading and next, inserting before the next heading.
(should
(equal "* H1\ncontents\n** Text\n** H2"
(org-test-with-temp-text "* H1<point>\ncontents\n** H2"
(org-paste-subtree nil "*** Text")
(buffer-string))))
(should
(equal "*** H1\ncontents\n*** Text\n* H2"
(org-test-with-temp-text "*** H1<point>\ncontents\n* H2"
(org-paste-subtree nil "* Text")
(buffer-string))))
;; When on an empty heading, after the stars, deduce the new level
;; from the number of stars.
(should

View File

@ -39,5 +39,67 @@
(goto-char (point-min))
(should (search-forward "#### Footnotes"))))))
(ert-deftest ox-md/headline-style ()
"Test `org-md-headline-style' being honored."
(dolist (org-md-headline-style '(atx setext mixed))
(let ((export-buffer "*Test MD Export*")
(org-export-show-temporary-export-buffer nil))
(org-test-with-temp-text "#+options: toc:nil h:10
* level 1
** level 2
*** level 3
**** level 4
***** level 5
****** level 6
******* level 7
"
(org-export-to-buffer 'md export-buffer)
(with-current-buffer export-buffer
(goto-char (point-min))
(pcase org-md-headline-style
(`atx
(should (search-forward "# level 1"))
(should (search-forward "## level 2"))
(should (search-forward "### level 3"))
(should (search-forward "#### level 4"))
(should (search-forward "##### level 5"))
(should (search-forward "###### level 6"))
(should (search-forward "1. level 7")))
(`setext
(should (search-forward "level 1\n======="))
(should (search-forward "level 2\n------"))
(should (search-forward "1. level 3"))
(should (search-forward "1. level 4"))
(should (search-forward "1. level 5"))
(should (search-forward "1. level 6"))
(should (search-forward "1. level 7")))
(`mixed
(should (search-forward "level 1\n======="))
(should (search-forward "level 2\n------"))
(should (search-forward "### level 3"))
(should (search-forward "#### level 4"))
(should (search-forward "##### level 5"))
(should (search-forward "###### level 6"))
(should (search-forward "1. level 7")))))))))
(ert-deftest ox-md/item ()
"Test `org-md-item'."
;; Align items at column 4.
;; Columns >=100 not aligned.
(org-test-with-temp-text
(mapconcat
#'identity
(cl-loop for n from 1 to 105
collect (format "%d. item" n))
"\n")
(let ((export-buffer "*Test MD Export*")
(org-export-show-temporary-export-buffer nil))
(org-export-to-buffer 'md export-buffer)
(with-current-buffer export-buffer
(goto-char (point-min))
(should (search-forward "1. item"))
(should (search-forward "10. item"))
(should (search-forward "101. item"))))))
(provide 'test-ox-md)
;;; test-ox-md.el ends here