Compare commits

...

227 Commits
dev ... main

Author SHA1 Message Date
Ihor Radchenko 959534ba11
ob-sql: Quote all the shell arguments originating from Org buffer
* lisp/ob-sql.el (org-babel-sql-dbstring-mysql):
(org-babel-sql-dbstring-postgresql):
(org-babel-sql-dbstring-oracle):
(org-babel-sql-dbstring-mssql):
(org-babel-sql-dbstring-sqsh):
(org-babel-sql-dbstring-vertica):
(org-babel-sql-dbstring-saphana):
(org-babel-execute:sql): Quote all the shell arguments to avoid
unexpect shell expansion.  Do not quote port as it is a number; make
sure that port is really demanded a number in the format strings.

Reported-by: Andrea <andrea-dev@hotmail.com>
Link: https://orgmode.org/list/DU2P193MB24225F623DBF8B3D254D3C0E88FA2@DU2P193MB2422.EURP193.PROD.OUTLOOK.COM
2024-06-12 15:40:31 +02:00
Ihor Radchenko 3232cc1619
Merge branch 'bugfix' 2024-06-12 15:33:01 +02:00
Ihor Radchenko 84945f9de0
orgtbl-gather-send-defs: Fix infinite loop when table is at bob
* lisp/org-table.el (orgtbl-gather-send-defs): Avoid infinite loop
when table is at the beginning of buffer.

Reported-by: Rustom Mody <rustompmody@gmail.com>
Link: https://orgmode.org/list/CAJ+Teoehk30LKVCTwMy0uREBHkNVBvrOLDZYboUQ4wBV6Fnwzw@mail.gmail.com
2024-06-12 15:31:45 +02:00
Ihor Radchenko a0950e9432
org-babel-execute-src-block: Handle code block moving point
* lisp/ob-core.el (org-babel-execute-src-block): Make sure that point
remain on src block after evaluation.  The function logic later
implicitly assumes that the point is on the block that has been
evaluated.
2024-06-12 12:47:48 +02:00
Ihor Radchenko e24c2408e7
Merge branch 'bugfix' 2024-06-11 12:46:49 +02:00
Ihor Radchenko 3e4c89e556
org-image--align: Fix image alignment when image is not inside paragraph
* lisp/org.el (org-image--align): Improve docstring.  Do not try to
align when image is not inside a paragraph.

Reported-by: Lin Sun <sunlin7.mail@gmail.com>
Link: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=71484
2024-06-11 12:44:57 +02:00
Ihor Radchenko 331086ebec
org-capture-fill-template: Allow recursive capture while expanding template
* lisp/org-capture.el (org-capture-fill-template): Do not fix the
temporary *Capture* buffer name to be used for template expansion.
Instead, generate a throwaway buffer every time a new capture is
requested.  This way, we can nest multiple captures even when a new
capture is requested while querying a %^{prompt}.  Clear the buffer
upon completing/failing the template expansion.
(org-capture): Do not clear *Capture* buffer.
`org-capture-fill-template' not does it by itself.

Reported-by: Cletip Cletip <clement020302@gmail.com>
Link: https://orgmode.org/list/CAD6d+LUJ7St5_muvwqzE80EfHSoiMmZD+qDTAojeN0L7v+zsCQ@mail.gmail.com
2024-06-11 12:27:11 +02:00
Ihor Radchenko ea4a690c1a
org--confirm-resource-safe: Throw an error when non-interactive
* lisp/org.el (org--confirm-resource-safe): When asking about resource
safety in non-interactive mode throw an error rather than silently not
downloading the resource.  The previous behavior may remote
 #+include's seemingly being ignored.
* etc/ORG-NEWS (Org mode may throw an error when attempting to include
remote unsafe resource): Announce the change.
2024-06-11 12:09:38 +02:00
Kyle Meyer 9419dad48a Merge branch 'km/from-emacs-master' into bugfix 2024-06-10 18:34:04 -04:00
Stefan Monnier 008e6030ac Backport commit d3524560e from Emacs
* lisp/ox.el (org-export-filters-alist): Don't define as constant.

d3524560ee3cb075125f0af158d4af01cb2ab546
Stefan Monnier
Mon Jun 10 10:58:46 2024 -0400
2024-06-10 18:30:27 -04:00
Mattias Engdegård 6eab01c580 Backport commit 331573e40 from Emacs
* lisp/org-element.el (org-element-copy-buffer):
Repair incorrect escaping.
* lisp/org-macs.el (org--line-empty-p): Fix broken skip-set.
* lisp/org.el (org-setup-yank-dnd-handlers): Fix broken regexp.

Org: fix mistakes in regexp, skip set and doc string
331573e40731d6635acd366694493c26b480c230
Mattias Engdegård
Mon Jun 10 14:07:07 2024 +0200
2024-06-10 18:29:36 -04:00
Kyle Meyer ce350490ca ob-core: Fix indentation
* lisp/ob-core.el (org-babel-execute-src-block): Fix indentation of
line.

Emacs's bd80717d8e7 (Re-enable TTY glyph production for batch mode
frames on Android, 2024-06-10) reverted all changes from 8d1d9798f77
(Fix bootstrap of org.texi, 2024-06-10) aside from an indentation fix.
Apply the indentation fix to avoid overwriting it on sync.
2024-06-10 18:28:27 -04:00
Ihor Radchenko 9447518c75
Merge branch 'bugfix' 2024-06-10 11:16:18 +02:00
Ihor Radchenko 4d4d59874c
Fix indirect buffer tracking
* lisp/org-fold-core.el
(org-fold-core-decouple-indirect-buffer-folds): Actually, add newly
created indirect buffer to the tracked list.
2024-06-10 11:16:00 +02:00
Kyle Meyer bb3800f904 Merge branch 'km/from-emacs-master' into bugfix 2024-06-09 20:52:14 -04:00
Stefan Kangas 2a6a0480d3 Backport commit 77d0eed74 from Emacs
; Fix typos
77d0eed74e1d934e28f364cb3adb06365e71335e
Stefan Kangas
Mon Jun 10 00:40:26 2024 +0200
2024-06-09 20:50:50 -04:00
Ihor Radchenko dc2f270ac4
org-agenda: Fix multi-day ranges with non-nil `org-agenda-default-appointment-duration'
* lisp/org-agenda.el (org-agenda-get-blocks): Force
`org-agenda-default-appointment-duration' to be nil for time blocks -
they already have begin/end time, even if during different days.
* testing/examples/agenda-file2.org (five):
* testing/lisp/test-org-agenda.el (test-org-agenda/time-grid): New
test.

Reported-by: hrdl <git@hrdl.eu>
Link: https://orgmode.org/list/ZldNYYtvvQp0dILB@t490.localdomain
2024-06-09 14:25:58 +02:00
Ihor Radchenko 9427bdedcc
Merge branch 'bugfix' 2024-06-09 11:23:12 +02:00
Ihor Radchenko 0c06694666
etc/ORG-NEWS: Announce removal of searching inside hidden parts of links 2024-06-09 11:21:48 +02:00
Ihor Radchenko 1cea4094fc
Merge branch 'bugfix' 2024-06-08 21:08:01 +02:00
Ihor Radchenko 915e883645
org-lint-misplaced-heading: Reduce false-positive rate
* lisp/org-lint.el (org-lint-misplaced-heading): Be more strict
matching potential misplaced headings - only do it on another heading
and inside paragraphs.

Link: https://orgmode.org/list/87a5jv77qs.fsf@gmail.com
2024-06-08 21:02:40 +02:00
Ihor Radchenko 212237bdbd
Merge branch 'bugfix' 2024-06-07 16:54:13 +02:00
Ihor Radchenko 6c862699a6
org-lint: Fix heuristics introduced in 51aea4946
* lisp/org-lint.el (org-lint-misplaced-heading): Use parser to query
whether we are inside a verbatim block.  `org-at-block-p' only
triggers on the begin line of blocks.
2024-06-07 16:53:29 +02:00
Suhail 96eb9f0b4a
org-lint: Add function to remove checker(s)
* lisp/org-lint.el (org-lint-remove-checker): Remove one or more
checkers from `org-lint--checkers'.

TINYCHANGE
2024-06-06 17:30:53 +02:00
Ihor Radchenko 453cb0883a
Merge branch 'bugfix' 2024-06-06 17:23:11 +02:00
Ihor Radchenko 266bd1c4a0
org-capture-templates: New placeholder to refer to %^{prompt}X answers
* lisp/org-capture.el (org-capture-fill-template): Support new
placeholder %\*N to insert answers to all prompts - %^{prompt} and
%^{prompt}X.
(org-capture-templates):
* etc/ORG-NEWS (New =%\*N= placeholder in ~org-capture-templates~):
* doc/org-manual.org (Template expansion): Document the new
placeholder.

Link: https://orgmode.org/list/87le40puvb.fsf@gmail.com
2024-06-06 17:17:38 +02:00
Ihor Radchenko 2f184485bf
Update version number for the 9.7.3 release 2024-06-06 16:49:56 +02:00
Ihor Radchenko 5eb929a27c
lisp/ol.el (org-link--store-shortdoc): Fix typo 2024-06-06 14:50:30 +02:00
Ihor Radchenko e6c5f25c13
org-babel-exp-code: Fix exporting src blocks with :var arguments
* lisp/ob-exp.el (org-babel-exp-code): Do not use resolved argument
values when formatting the code block.  Resolved argument values may
contain awkward data like full (long) table contents, various Elisp
data (including non-printable), etc.  Simply using verbatim src block
parameters as they appear in the original buffer is more reliable.
(org-babel-exp-inline-code-template):
(org-babel-exp-code-template): Update docstrings, drop %flags
placeholder, which is no longer supported using the current src block
syntax.
* etc/ORG-NEWS (=ox-org= preserves header arguments in src blocks):
Drop "non-default" when explaining how header arguments are formatted.
We cannot know which values are default and which not without
resolving the values - something we cannot do as it turned out.
* testing/lisp/test-ob-exp.el (ob-exp/exports-inline-code):
(ob-export/export-src-block-with-flags):
(ob-export/body-with-coderef): Update the tests.
2024-06-06 14:44:01 +02:00
bruno 55e8068d69
ol: Add support for shortdoc link type
* lisp/ol.el (org-link--open-shortdoc org-link--store-shortdoc)
(org-link--complete-shortdoc): Add support for storing and inserting links
to `shortdoc' documentation groups for Emacs Lisp functions.
* doc/org-manual.org (External Links): Add shortdoc link type
documentation.
* etc/ORG-NEWS (=ol.el=: Support for =shortdoc= link type): Document
the new feature.
2024-06-06 13:50:27 +02:00
Ihor Radchenko bb633b6740
Merge branch 'bugfix' 2024-06-05 17:11:10 +02:00
Ihor Radchenko 51aea49462
org-lint: Improve heuristics for unknown src block language
* lisp/org-lint.el (org-lint-suspicious-language-in-src-block): Do not
complain about src block languages without execute function if there
is <lang>-mode major mode available.

Reported-by: Suhail Singh <suhailsingh247@gmail.com>
Link: https://orgmode.org/list/874ja7ik7h.fsf@gmail.com
2024-06-05 17:08:50 +02:00
Ihor Radchenko d08a5abb90
Merge branch 'bugfix' 2024-06-05 16:54:29 +02:00
Ihor Radchenko 04d56f757f
mk/targets.mk (GITVERSION): Fix version string for ELPA build
* mk/targets.mk (GITVERSION): Use previous convention for the Org
version string on ELPA, where Org release tags are not available.
Instead of the new release_N/A-N/A prefix, use the Org version from
org.el file headers, as we did in Org 9.6.

Reported-by: Sharon Kimble <boudiccas@skimble09.plus.com>
Link: https://orgmode.org/list/87ikynyggt.fsf@skimble09.plus.com
2024-06-05 16:51:28 +02:00
Ihor Radchenko e804de88e4
Merge branch 'bugfix' 2024-06-05 16:08:55 +02:00
Ihor Radchenko 223cc31ec7
org-log-beginning: Fix regression in c0b66bf
* lisp/org.el (org-log-beginning): Re-implement the bugfix attempted
in c0b66bf differently to avoid slurping blank lines when creating a
new logbook drawer.  Add more commentary to the function.

Reported-by: Christopher M. Miles <numbchild@gmail.com>

The reproducer:

* headline1
(point here)
* headline 2

(setq org-log-into-drawer t)

Press [C-c C-z] become bellowing content:

* headline1
:LOGBOOK:
- Note taken on [2024-06-05 Wed 12:49] \\
  kkk
:END:(point here)
* headline 2
2024-06-05 16:08:35 +02:00
Ihor Radchenko 589e1f38c1
Revert "org-log-beginning: Fix error creating LOGBOOK drawer at end of buffer"
This reverts commit c0b66bf9c1.

This itself caused a regression when inserting a new logbook drawer -
blank line is slurped.
2024-06-05 16:07:31 +02:00
Ihor Radchenko 9d70929fd7
Merge branch 'bugfix' 2024-06-05 15:14:03 +02:00
Ihor Radchenko b8497aa7fe
org-lint: Do not warn about trailing *** lines inside blocks
* lisp/org-lint.el (org-lint-misplaced-heading): The chances that
there is a heading between #+begin... #+end lines is generally low.
So *** text instances are likely intended.

Reported-by: Suhail Singh <suhailsingh247@gmail.com>
Link: https://orgmode.org/list/87r0dc35ya.fsf@gmail.com
2024-06-05 15:13:44 +02:00
Ihor Radchenko 466c180a47
Merge branch 'bugfix' 2024-06-05 14:37:09 +02:00
Ihor Radchenko ac1d58477a
org-element-cache: Fix indirect buffer tracking
* lisp/org-element.el (org-element--cache-setup-change-functions):
Make sure that indirect buffers are registered to be traversed in
`org-fold-core-cycle-over-indirect-buffers' in
`org-element--cache-active-p'.
`org-fold-core-decouple-indirect-buffer-folds' may not be called in
some scenarios when Org mode is active.

The reproducer that revealed the problem is in
https://orgmode.org/list/CAD6d+LUJ7St5_muvwqzE80EfHSoiMmZD+qDTAojeN0L7v+zsCQ@mail.gmail.com
2024-06-05 14:34:46 +02:00
Ihor Radchenko 654a68dc51
org-agenda-format-item: Refactor, adding readable variable names
* lisp/org-agenda.el (org-agenda-format-item): Rename internal
variables to clarify their meaning.
2024-06-05 13:51:43 +02:00
Rens Oliemans a62f75c841
org-capture: Allow table-line entry to start without |
* lisp/org-capture.el (org-capture-place-table-line): Prepend
table-line begin ('|') if the template does not start with it.

* testing/lisp/test-org-capture.el (test-org-capture/table-line):
Verify that a template gets prepended with a '|' if it does not start
with it.
2024-06-04 15:17:12 +02:00
Rens Oliemans 0c8fba93fe
org-capture: Allow entry template to start without heading
* lisp/org-capture.el (org-capture-place-entry): Prepend heading to
template if the template does not yet start with a heading.

* testing/lisp/test-org-capture.el (test-org-capture/entry): Add two
tests: no error is raised when org-capture is called with a template
that does not start with a heading; and org-capture should error with
a template with a lower heading after a higher heading.

Link: https://list.orgmode.org/877chnc0lr.fsf@localhost/
2024-06-04 15:17:11 +02:00
Ihor Radchenko 8c7577817c
Merge branch 'bugfix' 2024-06-04 15:03:32 +02:00
Kyle Meyer de0df5b925
org-test: Fix zone-dependent miscalculation of days of week
* testing/org-test.el (org-test-day-of-weeks-seconds): Specify seconds
for formatting with UTC as time zone.
(org-test-day-of-weeks-abbrev):
(org-test-day-of-weeks-full): Use UTC as time zone when formatting
input.

Avoid calling format-time-string with the local time zone because that
gives the wrong result in some cases.  For example, 2222222 is
supposed to produce the locale's name for "Tuesday" but, when the
local time zone is +0000, (format-time-string "%A" 2222222) returns
the locale's name for "Monday".
2024-06-04 15:01:31 +02:00
Ihor Radchenko 9f6dbd8d2e
org-agenda-get-blocks: Refactor, adding readable variable names
* lisp/org-agenda.el (org-agenda-get-blocks): Add comments.  Rename
internal variables to clarify their meaning.
2024-06-04 14:53:26 +02:00
Ihor Radchenko c426f49364
org-babel-latex-process-alist: Use latemk or run latex trice
* lisp/ob-latex.el (org-babel-latex-process-alist): Change the default
value to using latexmk/latex x 3, so that references are resolved.
* etc/ORG-NEWS (The default value of
~org-babel-latex-process-alist~...): Announce the change.

Link: https://list.orgmode.org/orgmode/87cyretut7.fsf@localhost/
2024-06-03 16:32:02 +02:00
Ihor Radchenko 4ee373cb75
Merge branch 'bugfix' 2024-06-03 11:22:32 +02:00
Ihor Radchenko 2ee94bb065
Reapply "lisp/ox-html.el: Restore org-svg class."
This reverts commit 895a367a67.
2024-06-03 11:16:15 +02:00
Ihor Radchenko 77e77f051c
Reapply "ox-html: Use <img> tags for svgs, not <object>"
This reverts commit 302bc6393a.

It turns out that <object ...> tags with data pointing outside the
website are not rendered by the modern
qtwebengine (linked svgs in https://orgmode.org/tools.html are not
rendered). Even though Firefox does render the same page, it no longer
appears safe to use <object ...> for svg.  So, we have to use <img...>
with its limitations.
2024-06-03 11:14:41 +02:00
Ihor Radchenko 8e8e635eba
Revert "lisp/ox-html.el: Convert :alt to :aria-label attribute in svg images"
This reverts commit 0e5ac43324.
2024-06-03 11:14:31 +02:00
Ihor Radchenko 71077dedc8
Merge branch 'bugfix' 2024-06-03 11:11:13 +02:00
Ihor Radchenko 5f050580d8
lisp/org.el (org--dnd-attach-file): Load org-attach
This is necessary to make sure that `org-attach-method' variable is
available.
2024-06-03 11:10:07 +02:00
Ihor Radchenko 0477df8aab
org-setup-yank-dnd-handlers: Support MacOS dnd URIs
* lisp/org.el (org-setup-yank-dnd-handlers): MacOS uses
"file:/Users/juergenfenn/Desktop/test-file.jpeg" instead of file:///
stype URIs in DND data.  Handle this URI style.

We do not need to worry about converting the URI -
`org--dnd-local-file-handler' uses `dnd-get-local-file-name' that
takes care about URI-to-path conversion.

Reported-by: Juergen Fenn <jfenn@gmx.net>
Link: https://orgmode.org/list/875xur1aql.fsf@localhost
2024-06-03 11:10:06 +02:00
Kyle Meyer 671ca44df0 test-org-clock: Fix typo in test name 2024-06-01 17:10:58 -04:00
Ihor Radchenko 9ad3360d76
etc/ORG-NEWS: Fix unintentional list markup
* etc/ORG-NEWS (Images and files in clipboard can be pasted): More
"29." away from beginning of line.  It was parsed as list.
2024-06-01 20:31:17 +02:00
Ihor Radchenko 88dd2cea35
Update version number for the 9.7.2 release 2024-06-01 14:49:45 +02:00
Ihor Radchenko 5b8159228a
etc/ORG-NEWS: Move user-facing changes near the top 2024-06-01 14:49:18 +02:00
Ihor Radchenko 0ea4dc166c
org-html-latex-environment: Fix error when environment is non-math
* lisp/ox-html.el (org-html-latex-environment): Do not try to compute
caption for non-math environments.
2024-06-01 14:47:43 +02:00
Ihor Radchenko 0fd4f2e272
etc/ORG-NEWS: Add outline for future Org 9.8 news 2024-06-01 11:16:36 +02:00
Ihor Radchenko a22c8b7e09
Merge branch 'bugfix' 2024-06-01 11:15:34 +02:00
Ihor Radchenko f737e7213d
Update version number for the 9.7.1 release 2024-06-01 11:14:24 +02:00
Ihor Radchenko 9189ccacd5
etc/ORG-NEWS: Remove "unreleased" from Version 9.7 2024-06-01 11:12:30 +02:00
Ihor Radchenko b3aff71a65
lisp/org.el: Bump development version of Org mode to 9.8-pre 2024-06-01 11:10:43 +02:00
Ihor Radchenko 5fe70f2d66
Update version number for the 9.7 release 2024-06-01 10:59:57 +02:00
Ihor Radchenko eec8ba4087
Merge branch 'bugfix' 2024-06-01 10:58:39 +02:00
Ihor Radchenko dc485a6590
lisp/org-persist.el: Ignore lock files when writing cache
* lisp/org-persist.el (org-persist--write-elisp-file): Ignore locks.

Reported-by: Greg Minshall <minshall@umich.edu>
Link: https://orgmode.org/list/574109.1715751441@archlinux
2024-05-30 15:31:20 +02:00
Kyle Meyer 64bb80b982 Update customize-package-emacs-version-alist
* lisp/org.el (customize-package-emacs-version-alist): Map Org 9.7 to
Emacs 30.1.
2024-05-28 23:43:46 -04:00
Kyle Meyer 53c39a494f org-ctags: Don't assume ctags-program-name is bound
* lisp/org-ctags.el (org-ctags-path-to-ctags): Fall back to "ctags" if
ctags-program-name isn't bound because that wasn't introduced until
Emacs 30.

This is a follow-up commit to the port of Emacs's 9082b4e6e.
2024-05-28 23:23:39 -04:00
Kyle Meyer 377addb5b2 Merge branch 'km/from-emacs-master' 2024-05-28 23:01:23 -04:00
Tim Landscheidt d12f8b8624 Backport commit 6d1c1fca0 from Emacs
* lisp/ob-calc.el: (org-babel-execute:calc):
* lisp/org-agenda.el (org-agenda-use-sticky-p):
Replace (with-current-buffer (get-buffer ...) ...) with
(with-current-buffer ...).

; Simplify (with-current-buffer (get-buffer ...) ...)
6d1c1fca0aa7c5a1ff0254af3f89a34d5309ea0d
Tim Landscheidt
Thu Mar 14 12:40:26 2024 +0200
2024-05-28 22:58:43 -04:00
Basil L. Contovounesios 014f85f55f Backport commit 6dacb60bb from Emacs
; Fix last major-mode-remap-defaults change.
6dacb60bb135dbb002c2ce1c70f70430c5d1bbff
Basil L. Contovounesios
Mon Mar 4 07:19:22 2024 +0100
2024-05-28 22:58:43 -04:00
Stefan Monnier ab62bdd79f Backport commit 2b5d43081 from Emacs
* lisp/ox.el (org-export-to-buffer): Modernize docstring accordingly.
* lisp/ox-latex.el (org-latex-export-as-latex):
* lisp/ox-koma-letter.el (org-koma-letter-export-as-latex):
* lisp/ox-beamer.el (org-beamer-export-as-latex):
Use `major-mode-remap` when available.

(major-mode-remap(-defaults)): New var and function (bug#69191)
2b5d43081a30f816dd38a16c7b5bfbad712a779b
Stefan Monnier
Sun Mar 3 23:58:18 2024 -0500
2024-05-28 22:58:43 -04:00
Stefan Monnier e8fe9642b0 Backport commit 445f376e4 from Emacs
Revert "ox-texinfo:: Require only TEXINFO_DIR_CATEGORY"
445f376e4e613ebee94d2844926269bfa8793858
Stefan Monnier
Sun Mar 3 22:09:24 2024 -0500
2024-05-28 22:58:43 -04:00
Stefan Monnier 5dc2b6ee75 Backport commit 1a37fe3a6 from Emacs
Revert "Set org-macro-templates more lazily"
1a37fe3a66930bb8151a29c722dbe3bebc20d033
Stefan Monnier
Sun Mar 3 22:09:19 2024 -0500
2024-05-28 22:58:43 -04:00
Stefan Monnier fb4d2b96dc Backport commit 99483e214 from Emacs
Set org-macro-templates more lazily
99483e214fdafa76e8001c7009dff13a76c33f32
Stefan Monnier
Sun Mar 3 16:57:56 2024 -0500
2024-05-28 22:58:43 -04:00
Stefan Monnier 338ff105c5 Backport commit 5254c582e from Emacs
* lisp/ox-texinfo.el: Remove redundant `:group` arguments.
Prefer #' to quote function names.
(org-texinfo-template): Use sane defaults for `@direntry`.

* doc/org.org (Texinfo specific export settings): Adjust accordingly.

ox-texinfo:: Require only TEXINFO_DIR_CATEGORY
5254c582efb3e7171e955dde653e7530d2d3ffef
Stefan Monnier
Sun Mar 3 16:57:56 2024 -0500
2024-05-28 22:58:43 -04:00
Robert Pluim 5a176d76ad Backport commit 862dfef88 from Emacs
* lisp/org-macs.el (org-split-string): Escape control chars.
* lisp/ox-latex.el (org-latex-guess-babel-language): And here.

Pacify more docstring control char warnings
862dfef88d8e62d12bac3ca2e44e035a2ff5b298
Robert Pluim
Thu Feb 29 09:31:41 2024 +0100
2024-05-28 22:58:43 -04:00
Stefan Kangas 6c34fd374c Backport commit 9364c2895 from Emacs
; Fix typos in symbol names
9364c28959a5b00e8ffd5d0d283ff0c0042f1bb0
Stefan Kangas
Sun Jan 21 15:28:06 2024 +0100
2024-05-28 22:58:43 -04:00
Stefan Kangas 7564dfd968 Backport commit 0f3be9596 from Emacs
; Prefer finder keyword "text" to deprecated keyword "wp"
0f3be9596fb3cf2f5e8f10fe2b3ef59546de98bb
Stefan Kangas
Sat Dec 30 18:14:40 2023 +0100
2024-05-28 22:58:43 -04:00
Stefan Monnier 68f9abe0cd Backport commit 40dafa9af from Emacs
* lisp/org-src.el (org-src-font-lock-fontify-block): Fix point-min /= 1
40dafa9af0ae3b1826409ebed80cb65f56591ffb
Stefan Monnier
Wed Dec 20 17:50:09 2023 -0500
2024-05-28 22:58:43 -04:00
Mattias Engdegård 1bff87bdb7 Backport commit 67977ae59 from Emacs
* lisp/org/org.el (org-make-tags-matcher):
Apply the transform (A+B*)+ -> A(A|B)*

Eliminate some nested repetitions in regexps
67977ae5974e54d34034aa7990cf22dd162c179b
Mattias Engdegård
Sun Oct 29 17:40:36 2023 +0100
2024-05-28 22:58:43 -04:00
Stefan Kangas 5e9a60aaae Backport commit 2e19e1163 from Emacs
* lisp/ob-lua.el (org-babel-lua-evaluate-session):
* lisp/ob-python.el (org-babel-python-initiate-session-by-key):
(org-babel-python-evaluate-session): Don't use obsolete 'sleep-for'
argument.
2024-05-28 22:58:43 -04:00
Stefan Kangas 53d3fcfbe9 Backport commit 6b2219cd2 from Emacs
* lisp/org.el (org-read-date-analyze):
* lisp/ox-html.el (org-html-latex-fragment):
Add several "duplicate value in `cond`" FIXMEs.
Found by Mattias Engdegård <mattias.engdegard@gmail.com>.
Ref: https://debbugs.gnu.org/51368#51

; Add several "duplicate value in `cond`" FIXMEs
6b2219cd2744c711580cc7226554e69c8cec8247
Stefan Kangas
Sun Oct 1 19:00:26 2023 +0200
2024-05-28 22:58:43 -04:00
Stefan Kangas d7ee5691cb Backport commit e0070fc57 from Emacs
* lisp/ob-eshell.el (org-babel-execute:eshell): Improve docstring.

Improve org-babel-execute:eshell docstring
e0070fc574a8621b2fbb1aaca678b974a3dc5fd5
Stefan Kangas
Sun Sep 17 16:57:25 2023 +0200
2024-05-28 22:58:43 -04:00
Stefan Kangas c49b8f68ca Backport commit 1e270e580 from Emacs
; Grammar fixes ("allow to" et al)
1e270e580d3bb9ca1b3766a296611f76ec13f6f1
Stefan Kangas
Sun Sep 17 16:49:21 2023 +0200
2024-05-28 22:58:43 -04:00
Stefan Monnier b2b9a96192 Backport commit ff87aecf8 from Emacs
* lisp/org.el: Remove dead-code.

Address "Useless clause following default cond clause" warnings
ff87aecf8554042b043467a7aaff1a758df0bbae
Stefan Monnier
Tue Sep 12 12:59:03 2023 -0400
2024-05-28 22:58:43 -04:00
Po Lu 88ac4758a7 Backport commit c0400151f from Emacs
* lisp/org.el (org-startup-truncated, org-file-apps):
The construct ``allows to <infinitive>'' is not English inasmuch as no
direct object to ``allows'' is provided.  Correct and rephrase each
instance of such a construct within our documentation and commentary.

Correct many instances of ``allows to''
c0400151f8880862d460f0e47be287237a6182ad
Po Lu
Sun Sep 10 09:33:50 2023 +0800
2024-05-28 22:58:43 -04:00
Stefan Kangas 0e345ecda8 Backport commit 642691251 from Emacs
; Delete redundant defvars; font-lock is preloaded
64269125156836060eb95b28b01b877c74e800d8
Stefan Kangas
Fri Aug 25 23:54:51 2023 +0200
2024-05-28 22:58:43 -04:00
Stefan Kangas bb7473f3d3 Backport commit 2b311a47d from Emacs
* lisp/ox-beamer.el (org-mode): Assume that font-lock is preloaded,
which it has been since Emacs 22.1.

Assume that font-lock is preloaded
2b311a47dd0cde82fb9d32c303f13700cae4f0b3
Stefan Kangas
Fri Aug 25 20:35:38 2023 +0200
2024-05-28 22:58:43 -04:00
Po Lu 860d4fd169 Backport commit 73b24a414 from Emacs
* lisp/org-mouse.el (org-mouse-down-mouse): Characterize as an
`ignored-mouse-command'.

Make org-mouse compatible with touch screen event emulation
73b24a41412eb97a9451a8310da0ebab379f7534
Po Lu
Wed Aug 23 09:56:35 2023 +0800
2024-05-28 22:58:43 -04:00
Po Lu a7c8c9d8c2 Backport commit 4f714dc08 from Emacs
* lisp/org-clock.el (haiku-notifications-notify): Correct file name in
function declaration.
(android-notifications-notify): New declaration.
(org-show-notification): Use `android-notifications-notify'.

Support desktop notifications on Android
4f714dc08137d36d0d1e886814008f2abe5712c0
Po Lu
Sun Aug 20 20:25:53 2023 +0800
2024-05-28 22:58:43 -04:00
Po Lu d5925e3e70 Backport commit 5856ea5e4 from Emacs
* lisp/org-clock.el (haiku-notifications-notify): New declaration.
(org-show-notification): Employ that function.

Introduce support for Desktop Notifications on Haiku
5856ea5e4e897f4cb5cd1c3c28d14b335fe5cf54
Po Lu
Thu Aug 17 08:34:32 2023 +0000
2024-05-28 22:58:43 -04:00
Mattias Engdegård cd8017e68f Backport commit 1ad318cf2 from Emacs
* lisp/ob-tangle.el (org-babel-interpret-file-mode): Repair parts of
regexp that should only match +, - and =.

ob-tangle.el: fix unintended range in regexp
1ad318cf2ae22d945f8bfcd61981d619467a36da
Mattias Engdegård
Wed Aug 16 16:55:38 2023 +0200
2024-05-28 22:58:43 -04:00
Po Lu 525df5272d Backport commit 9082b4e6e from Emacs
* lisp/org-ctags.el (org-ctags-path-to-ctags): Use new variables.

Make binaries distributed with Emacs work on Android
9082b4e6ee27b995cbb61668cb437d7b91c7f5f8
Po Lu
Tue Jan 24 21:37:22 2023 +0800

[km] A follow-up commit will adjust this to be compatible with Emacs <
     30.
2024-05-28 22:58:43 -04:00
Stefan Kangas 4bd1c59d83 Backport commit c75c79971 from Emacs
* doc/org.org (External Links): Change an HTTPS link back to
HTTP, as it's used as an example to show the supported protocols.
Ref: https://lists.gnu.org/r/emacs-devel/2023-08/msg00018.html

; Fix http/https thinko in org manual
c75c7997197502189023c9f47140474fa7fd719e
Stefan Kangas
Fri Aug 4 09:57:27 2023 +0200
2024-05-28 22:58:43 -04:00
Stefan Kangas d2eba8b77f Backport commit 0910230be from Emacs
; Prefer HTTPS to HTTP in more links
0910230be6ee858d8d8849a1fc9559bfd163dc38
Stefan Kangas
Wed Aug 2 23:32:28 2023 +0200

[km] The http example should remain http.  That's reverted in the next
     commit.
2024-05-28 22:58:43 -04:00
Jakub Ječmínek 6eb4aa3e35 Backport commit 4c01b0dee from Emacs
* lisp/org-table.el (orgtbl-to-table.el): Perform character
replacement in the temp buffer and fix missing cell border.
(Bug#64205)

Fix orgtbl-to-table.el function to include last cell border
4c01b0deee13808605b05a89e927e67eaf67edbd
Jakub Ječmínek
Thu Jun 22 17:38:56 2023 +0200
2024-05-28 22:58:43 -04:00
Mattias Engdegård f0c0dee11c Backport commit ace9f6775 from Emacs
* lisp/org.el (org-fontify-meta-lines-and-blocks-1): Replace uses of
`any` with `nonl`.

Avoid using rx `any` for `not-newline`
ace9f6775580459c35254607d866f3bb22a8c45b
Mattias Engdegård
Tue May 30 17:44:53 2023 +0200
2024-05-28 22:58:43 -04:00
Mattias Engdegård d0c29cfdf9 Backport commit af4791b57 from Emacs
* lisp/org.el (org-display-inline-remove-overlay):
Update the base variable after performing a destructive deletion,
where it was obvious that this was intended.

Fix apparently wrong `delete` and `delq` value discards (bug#61730)
af4791b5706f494d73fd00c391ff867fb2c5a06d
Mattias Engdegård
Wed May 24 23:01:10 2023 +0200
2024-05-28 22:58:43 -04:00
Stefan Monnier d8e47abb75 Backport commit 54d40577c from Emacs
* lisp/org-table.el (org-table-make-reference): Don't use `eq` to
compare against literal strings.

(org-table-make-reference): Fix compiler warning
54d40577c4bb64d25db030b7d11ab553364e375d
Stefan Monnier
Mon Apr 10 21:33:56 2023 -0400
2024-05-28 22:58:42 -04:00
Kyle Meyer 898b5c4da5 org-macs: Autoload org-element-with-disabled-cache
* lisp/org-macs.el (org-element-with-disabled-cache): Autoload.

Otherwise compiling lisp/org/org-loaddefs.el in the Emacs tree will
warn that org-element-with-disabled-cache is not known to be defined.
2024-05-27 22:55:14 -04:00
Kyle Meyer 464d668ead Clean up spacing to pass Emacs's pre-commit check
Avoid trailing spaces and spaces before tabs.
2024-05-27 21:18:59 -04:00
Ihor Radchenko 0450cf0e85
Fix test failures for thingatpt support on Emacs 27
* testing/lisp/test-org.el (test-org/thing-at-point/url): Disable test
in old Emacs that do not yet support custom
`thing-at-point-provider-alist'.
* etc/ORG-NEWS (Org links now support ~thing-at-point~): Clarify Emacs
versions where the new feature is supported.
2024-05-27 14:27:35 +02:00
Ihor Radchenko 6f152d8914
lisp/org.el (org-mode): Fix thingatpt support for Emacs 27 2024-05-26 17:53:57 +02:00
Jim Porter 66cb45658d
Add support for 'thing-at-point' to get URL at point
* lisp/org.el (thingatpt): Require.
(org--link-at-point, org--bounds-of-link-at-point): New functions...
(org-mode): ... add to 'thing-at-point-provider-alist' and friends.

* testing/lisp/test-org.el (test-org/thing-at-point/url): New test.

* etc/ORG-NEWS: Announce this change.
2024-05-26 14:51:31 +02:00
Ihor Radchenko 09f339c9dd
org-element-cache: Fix tracking changes in indirect buffers for overlay folding
* lisp/org-fold-core.el (org-fold-core-decouple-indirect-buffer-folds):
(org-fold-core--property-symbol-get-create): Make
`org-fold-core-cycle-over-indirect-buffers' track indirect buffers
even with `org-fold-core-style' = 'overlays.  This is necessary to
keep org-element-cache working.
* lisp/org-element.el: Add FIXME - we should eventually pull out
`org-fold-core-cycle-over-indirect-buffers' as it is used out of scope
of folding.
2024-05-25 14:22:17 +02:00
Morgan Smith a3c1a85021
Fix typos surrounding `org-agenda-skip-scheduled-repeats-after-deadline'
* etc/ORG-NEWS: Fix typos.
* testing/lisp/test-org-agenda.el: Fix typos.
2024-05-24 19:56:07 +02:00
Ihor Radchenko 1c5492263f
etc/ORG-NEWS: Re-organize and document news sections
* etc/ORG-NEWS: Add comments explaining the purpose of each of the
sections in the NEWS.  Refile the news entries accordingly.
2024-05-22 15:11:59 +02:00
Ihor Radchenko 0e5ac43324
lisp/ox-html.el: Convert :alt to :aria-label attribute in svg images
* lisp/ox-html.el (org-html--svg-image): When svg image has :alt
attribute, convert it to :aria-label instead.
(org-html--format-image): Pass default :alt attribute based on the
file name to `org-html--svg-image'.
2024-05-22 11:23:47 +02:00
Ihor Radchenko 302bc6393a
Revert "ox-html: Use <img> tags for svgs, not <object>"
This reverts commit d96e897579.

See https://orgmode.org/list/87r0dy3u91.fsf@localhost
2024-05-22 11:01:05 +02:00
Ihor Radchenko 895a367a67
Revert "lisp/ox-html.el: Restore org-svg class."
This reverts commit 9364b2d894.
2024-05-22 11:00:49 +02:00
Ihor Radchenko b2520ec52f
ob-haskell: Remove FIXME
* lisp/ob-haskell.el (org-babel-haskell-export-to-lhs): The answer to
question asked in FIXME is that -i flag is handled later, in regex
search.  There is nothing to fix.
2024-05-21 15:58:40 +02:00
Ihor Radchenko b26337c255
oc-csl: Use `org-require-package' instead of `org-cite-csl--barf-without-citeproc'
* lisp/oc-csl.el (org-cite-csl--barf-without-citeproc): Remove.
(org-cite-csl-render-citation):
(org-cite-csl-render-bibliography):
(org-cite-csl-finalizer): Use `org-require-package'.
2024-05-21 15:57:15 +02:00
Ihor Radchenko 5fcd1d9def
org-save-markers-in-region: Store log note marker
* lisp/org.el (org-save-markers-in-region): Store
`org-log-note-marker' when storing and reinstalling Org markers.

This change automatically handles note taken after refiling/archiving
without trying to place the note in place of the moved
subtree/heading.

Link: https://orgmode.org/list/m2plyjid8q.fsf@kyon.home
2024-05-21 13:36:39 +02:00
Ihor Radchenko 41c2e7af10
Add missing :package-version keywords to new and changed `defcustom'
* lisp/ob-comint.el (org-babel-comint-fallback-regexp-threshold):
* lisp/ob-exp.el (org-babel-exp-code-template):
(org-babel-exp-inline-code-template):
* lisp/org-agenda.el (org-agenda-skip-scheduled-if-deadline-is-shown):
(org-agenda-sorting-strategy):
* lisp/org-attach.el (org-attach-store-link-p):
* lisp/org-capture.el (org-capture-templates):
* lisp/org-fold-core.el (org-fold-core-style):
* lisp/org-footnote.el (org-footnote-auto-label):
* lisp/org.el (org-latex-to-mathml-convert-command):
(org-latex-to-html-convert-command):
(org-latex-default-packages-alist):
(org-display-remote-inline-images):
* lisp/ox-beamer.el (org-beamer-environments-extra):
* lisp/ox-latex.el (org-latex-known-warnings):
2024-05-21 13:15:12 +02:00
Ihor Radchenko 8d43ab9ca9
orgtbl-setup: Resolve FIXME
* lisp/org-table.el (orgtbl-setup): Move setting up keymap to top
level instead of awkward re-`defun' used previously to ensure that
setup is evaluated once.  Make it possible to honor the value of
`orgtbl-optimized' during runtime, if it is changed.
(orgtbl-mode): Remove re-`defun'.
2024-05-21 12:21:29 +02:00
Ihor Radchenko e6c7b0f15e
testing/lisp/test-org.el (test-org/org-todo-prefix): Add test case 2024-05-21 12:12:11 +02:00
Ihor Radchenko b34b5baffc
lisp/org-keys.el: Remove support of obsolete `org-speed-commands-user'
* lisp/org-keys.el (org--print-speed-command): Update the docstring.
(org-speed-command-help):
(org-speed-command-activate): Remove code supporting
`org-speed-commands-user'.
2024-05-21 11:50:29 +02:00
Ihor Radchenko 81f84ae679
testing/lisp/test-org.el (test-org/org-ctrl-c-ctrl-c): Add test case 2024-05-21 11:47:26 +02:00
Ihor Radchenko 102f0a24c9
Do no assume that todo keywords are full words
* lisp/org-agenda.el (org-agenda):
(org-agenda-list-stuck-projects):
* lisp/org-clock.el (org-clock-in):
(org-clock-out):
* lisp/org.el (org-show-todo-tree): Do not enforce that word boundary
always matches after todo keyword \>.  Instead use a more accurate
match - space or eol.  Also, regexp-quote the todo keywords when
searching them.

Reported-by: Kepa <gnu.cognition199@slmails.com>
Link: https://orgmode.org/list/171620796695.7.14337986338068154257.334928503@slmails.com
2024-05-21 11:40:36 +02:00
Ihor Radchenko 6799350a85
org-manual: Explain how to handle ; inside formulas
* doc/org-manual.org (Emacs Lisp forms as formulas): Show an example
how to resolve ambiguity when the formula contains ;.

Reported-by: Nick Dokos <ndokos@gmail.com>
Link: https://orgmode.org/list/87ply5v1gj.fsf@localhost
2024-05-21 11:24:39 +02:00
Ihor Radchenko bae1b1fe70
Revert "org-table-eval-formula: Fix parsing of mode string when formula has ;"
This reverts commit 5af0625113.

The commit broken handling custom `format' spec for formula results:

Reported-by: Daniel Clemente <n142857@gmail.com>
Link: https://orgmode.org/list/CAJKAhPDFrgZY6sgefxu85qjEXnE2_HkPCHzbDOLsAD4Je57z7w@mail.gmail.com
2024-05-21 11:09:46 +02:00
Ihor Radchenko 3f539bc3d6
org-manual: Add better opening description to "Citation handling" section
* doc/org-manual.org (Citation handling): Rewrite the opening
paragraphs describing citations using less technical description.  The
new version aims to ordinary Org mode users and avoids talking about
Elisp libraries.
(Citations): Unify markup for citation processor names (use verbatim).
Mention that at least one #+PRINT_BIBLIOGRAPHY is mandatory to render
output.  Indicate that default citation style is "nil".
2024-05-20 15:24:13 +02:00
Ihor Radchenko 4049742044
lisp/ox-html.el (org-html-template): Remove Emacs 22 compatibility
Emacs 22 support is long-dropped.  We no longer need to be backwards
compatible with it.  Also, Org mode no longer works with Emacs 22, so
there is no point keeping this code.
2024-05-20 15:11:11 +02:00
Ihor Radchenko 9a02750501
lisp/org.el (org-display-inline-images): Remove FIXME
Addressing this FIXME would include implementing image cache flushing
feature in Emacs itself.  A bit too much for a FIXME in Org code.
2024-05-20 15:10:31 +02:00
Ihor Radchenko 8bea06ce93
lisp/org-element.el (org-element--cache-active-p): Remove FIXME
It is not 100% clear if inlining `org-element--cache-active-p' will
yield practical improvements.  So, let's not litter the code base with
such FIXMEs.
2024-05-20 15:09:51 +02:00
Ihor Radchenko 7ef578dd4e
lisp/org-element.el (org-element--current-element): Remove FIXME
`org-item-re' is caching its results, so it is ok to use it.
2024-05-20 15:09:23 +02:00
Ihor Radchenko 0af8d7bf40
etc/ORG-NEWS: Move more impacting changes near the top for Org 9.7 release 2024-05-20 14:04:34 +02:00
Ihor Radchenko bf71c8c597
lisp/ob-scheme.el: Fix mit-scheme evaluation
* lisp/ob-scheme.el (org-babel-scheme-execute-with-geiser): Do not
sent top comment when evaluating code block.  mit-scheme has problems
processing it for some reason.
2024-05-19 15:38:45 +02:00
Kris Nelson c0b66bf9c1
org-log-beginning: Fix error creating LOGBOOK drawer at end of buffer
* lisp/org.el (org-log-beginning): Fix regression after 288c7069c where
"Error in post-command-hook (org-add-log-note): (end-of-buffer)"
is displayed after creating the LOGBOOK drawer on a heading which is
at the end of the buffer.

Reported-by: Kris Nelson <kris@kristofernelson.com>
Link: https://orgmode.org/list/766237934.317726.1715720181047@office.mailbox.org

TINYCHANGE
2024-05-19 13:43:24 +02:00
Ihor Radchenko 5af0625113
org-table-eval-formula: Fix parsing of mode string when formula has ;
* lisp/org-table.el (org-table-eval-formula): Use more strict regexp
to detect mode string in formulas.
* testing/lisp/test-org-table.el (test-org-table/eval-formula): Add
test.

Reported-by: Nick Dokos <ndokos@gmail.com>
Link: https://orgmode.org/list/87ply5v1gj.fsf@localhost
2024-05-19 13:10:49 +02:00
Ihor Radchenko 6d5fa81984
ox-md, ox-ascii, ox-texinfo: Strip blank lines from paragraphs
* lisp/org-macs.el (org-remove-blank-lines): New helper function to
strip blank lines from string.
* lisp/ox-ascii.el (org-ascii-paragraph):
* lisp/ox-latex.el (org-latex-paragraph):
* lisp/ox-md.el (org-md-paragraph):
* lisp/ox-texinfo.el (org-texinfo-paragraph): Strip blank lines from
paragraphs - these exporters are using blank lines as paragraph
separators.

Reported-by: Max Nikulin <manikulin@gmail.com>
Link: https://orgmode.org/list/v00le7$frp$1@ciao.gmane.io
2024-05-19 12:01:55 +02:00
Ihor Radchenko 14848726a0
org-export-data: Handle trailing spaces when transcoder returns nil
* lisp/ox.el (org-export--keep-spaces): New helper function containing
logic about keeping spaces in place of removed object from
`org-export--prune-tree'.  The logic is modified to keep spaces in the
case when previous plain-string object ends with a whitespace, but not
" " or "\t".  This can happen, for example, when there is a trailing
zero-width space.  We do want to keep spaces in such scenario.
(org-export-data): When transcoder returns nil, handle
trailing spaces after an object the same way `org-export--prune-tree'
does.  Remove special handling of export snippets that unconditionally
keep their trailing spaces.
(org-export--prune-tree): Use the helper function.
* testing/lisp/test-ox.el (test-org-export/export-snippet): Adjust test.

Link: https://orgmode.org/list/87h6fwmgkm.fsf@localhost
2024-05-19 12:01:54 +02:00
Joris Caravati f3e306c737
lisp/org.el: Add `org-after-note-stored-hook'
* lisp/org.el: Add `org-after-note-stored-hook' which is called at the
end of the `org-store-log-note' function.
* etc/ORG-NEWS: Document the new hook.

TINYCHANGE
2024-05-18 13:20:18 +02:00
Anand Deopurkar 0ebb36caea
lisp/org-capture.el: Restore org-store-link-plist
* org-capture.el (org-capture-fill-template): Restore original
`org-store-link-plist' after calling `org-store-link'.

To replace a %K escape (link to currently clocked task),
`org-capture-fill-template' calls `org-store-link'.  This call has the
side-effect of replacing the contents of `org-store-link-plist'.  As a
result, expected template expansions using the original
`org-store-link-plist' do not happen.

For example, suppose `org-capture' is called from a message buffer with the
template "%:subject %:from" while the clock is running.  Then
%:subject and %:from are not substituted because of the behaviour
above.  If the clock is not running, there is no problem.

Current fix restores `org-store-link-plist' to its original value
after `org-capture-fill-template' calls `org-store-link'.

TINYCHANGE
2024-05-18 12:52:04 +02:00
Ihor Radchenko ee58259bc7
org-duration-from-minutes: Accept negative durations
* lisp/org-duration.el (org-duration-from-minutes): Allow MINUTES
argument to be negative.

Reported-by: Raffael Stocker <r.stocker@mnet-mail.de>
Link: https://orgmode.org/list/yplmzfsrqjw6.fsf@mnet-mail.de
2024-05-17 14:43:04 +03:00
Ihor Radchenko 288c7069c4
org-log-beginning: Fix extra blank line created after LOGBOOK drawer
* lisp/org.el (org-log-beginning): Fix regression after f63ff07441
when additional blank is created after newly added LOGBOOK drawer.

Reported-by: Kris Nelson <kris@kristofernelson.com>
Link: https://orgmode.org/list/766237934.317726.1715720181047@office.mailbox.org
2024-05-17 14:19:29 +03:00
Ihor Radchenko ea8ed59c02
etc/ORG-NEWS (Org mode now fontifies...): Add references to manual
* etc/ORG-NEWS (Org mode now fontifies whole table lines (including
newline) according to ~org-table~ face): Add references to the manual
that explain how to set face 'inherit attribute.

Link: https://orgmode.org/list/87le4dfowy.fsf@yandex.com
2024-05-17 14:04:00 +03:00
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 071c6e986c
Update version number for the 9.6.30 release 2024-05-10 10:30:48 +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
103 changed files with 4101 additions and 2538 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~) ::
@ -2344,6 +2356,17 @@ to read than the equivalent:
: '(substring $1 (string-to-number $2) (string-to-number $3))
When the formula itself contains =;= symbol, Org mode may incorrectly
interpret everything past =;= as format specifier:
: '(concat $1 ";")
#+texinfo: @noindent
You can put an extra tailing =;= to indicate that all the earlier
instances of =;= belong to the formula itself:
: '(concat $1 ";");
*** Durations and time values
:PROPERTIES:
:DESCRIPTION: How to compute durations and time values.
@ -3370,6 +3393,15 @@ Here is the full set of built-in link types:
Execute a shell command upon activation.
- =shortdoc= ::
Link to short documentation summary for an Emacs Lisp function group.
[fn::You can run =M-x shortdoc-display-group= to list all known
documentation groups.]
For more information, see [[info:emacs#Name Help][Name Help]]
and [[info:elisp#Documentation Groups][Documentation Groups]].
For =file:= and =id:= links, you can additionally specify a line
number, or a text search string, separated by =::=. In Org files, you
@ -3411,6 +3443,8 @@ options:
| irc | =irc:/irc.com/#emacs/bob= |
| help | =help:org-store-link= |
| info | =info:org#External links= |
| shortdoc | =shortdoc:text-properties= |
| | =shortdoc:text-properties::#get-pos-property= |
| shell | =shell:ls *.org= |
| elisp | =elisp:(find-file "Elisp.org")= (Elisp form to evaluate) |
| | =elisp:org-agenda= (interactive Elisp command) |
@ -3743,7 +3777,7 @@ replacement text. Here is an example:
#+begin_src emacs-lisp
(setq org-link-abbrev-alist
'(("bugzilla" . "http://10.1.2.9/bugzilla/show_bug.cgi?id=")
'(("bugzilla" . "https://10.1.2.9/bugzilla/show_bug.cgi?id=")
("Nu Html Checker" . "https://validator.w3.org/nu/?doc=%h")
("duckduckgo" . "https://duckduckgo.com/?q=%s")
("omap" . "https://nominatim.openstreetmap.org/search?q=%s&polygon=1")
@ -6007,11 +6041,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 +6188,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 +7056,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 +7271,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 +8064,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
@ -8303,8 +8349,12 @@ given here:
- =%\N= ::
Insert the text entered at the {{{var(N)}}}th =%^{PROMPT}=, where
{{{var(N)}}} is a number, starting from 1.
Insert the text entered at the {{{var(N)}}}th =%^{PROMPT}= (but not
=%^{PROMPT}X=), where {{{var(N)}}} is a number, starting from 1.
- =%\*N= ::
Same as =%\N=, but include all the prompts.
- =%?= ::
@ -8327,7 +8377,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 +9043,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
@ -9677,11 +9727,11 @@ the estimated effort of an entry (see [[*Effort Estimates]]).
#+vindex: org-agenda-effort-filter-preset
#+vindex: org-agenda-regexp-filter-preset
Agenda built-in or custom commands are statically defined. Agenda
filters and limits allow to flexibly narrow down the list of agenda
filters and limits allow flexibly narrowing 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 +10817,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 +11003,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 +11281,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 +11334,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 +11430,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 +11452,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 +11501,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 +11657,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 +11673,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 +11930,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 +12219,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 +12519,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 +12637,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 +12677,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 +13069,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 +13687,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 +14006,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 +14814,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 +16748,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 +16781,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 +17444,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
@ -17449,30 +17519,68 @@ keywords.
#+cindex: citation
#+cindex: citation processor
The =oc.el= library provides tooling to handle citations in Org via
"citation processors" that offer some or all of the following
capabilities:
While links (see [[*Hyperlinks]]) are often sufficient to refer to
external or internal information from Org, they have their limitations
when referring to multiple targets or typesetting printed
publications.
- activate :: Fontification, tooltip preview, etc.
- follow :: At-point actions on citations via ~org-open-at-point~.
- insert :: Add and edit citations via ~org-cite-insert~.
- export :: Via different libraries for different target formats.
Org mode provides a more sophisticated markup to "cite" external
resources. For example, consider the following Org mode snippet
To use a "citation processor", the user must load them; for example;
: #+bibliography: citationdata.bib
:
: Org mode is used by various communities [cite:teaching: @orgteaching;
: and TeX: @orgtex]. [cite/author/caps:@orgtex] uses Org mode to simplify
: writing scientific publications, while [cite/author/caps:@orgteaching]
: experiment with Org babel to improve teaching.
:
: #+print_bibliography:
#+begin_src emacs-lisp
(require 'oc-bibtex)
#+end_src
Org mode will gather citation metadata from the =#+bibliography=
database and use it to typeset the exported document in arbitrary
formats. For example, the snippet below shows ASCII export output.
: Org mode is used by various communities (teaching: Birkenkrahe, Marcus,
: 2023, and TeX: Somma, Emmanuele F, 2023). Somma, Emmanuele F uses Org
: mode to simplify writing scientific publications, while Birkenkrahe,
: Marcus experiment with Org babel to improve teaching.
:
: Birkenkrahe, Marcus (2023). /Teaching Data Science with Literate
: Programming Tools/, MDPI.
:
: Somma, Emmanuele F (2023). /Simplifying LaTeX with ORG-mode in Emacs/,
: TUGboat volume.
In addition to export, users can use completion to search and insert
citations from the bibliography (via ~org-cite-insert~). Citations
also act like ordinary links, jumping to the citation metadata when
"following" them using ~org-open-at-point~.
You can customize every aspect (/capability/) of citation handling
using built-in or external /citation processors/.
Org mode ships with several built-in citation processors tailored to
work with LaTeX export and BibTeX bibliographies (=bibtex=,
=biblatex=, and =natbib= processors), or with more generic formats
described using [[https://citationstyles.org/][Citation Style
Language]] (=csl= processor).
The default citation processor is =basic= - it works with arbitrary
export formats and recognizes both BibTeX and CSL bibliographies.
More citation processors are distributed as Emacs packages.
#+vindex: org-cite-activate-processor
#+vindex: org-cite-follow-processor
#+vindex: org-cite-insert-processor
#+vindex: org-cite-export-processor
They can then configure them with ~org-cite-activate-processor~,
~org-cite-follow-processor~, ~org-cite-insert-processor~, and
~org-cite-export-processors~ respectively.
Multiple citation processors can be mixed to meet your preferences.
Configure ~org-cite-activate-processor~, ~org-cite-follow-processor~,
~org-cite-insert-processor~, and ~org-cite-export-processors~ to
select which processor to use for every citation capability:
The included "basic" processor provides all four capabilities.
- activate :: Fontification, tooltip preview, etc.
- follow :: At-point actions on citations via ~org-open-at-point~.
- insert :: Add and edit citations via ~org-cite-insert~.
- export :: Via different libraries for different target formats.
** Citations
@ -17526,15 +17634,16 @@ identifying a reference in the bibliography.
: [cite/style:common prefix ;prefix @key suffix; ... ; common suffix]
When style is not specified, default style is used
When =style= is not specified, one of the two default styles are
used
+ either the default style specified in =CITE_EXPORT= keyword (see
[[*Citation export processors]])
+ either the default style specified in the =CITE_EXPORT= keyword
(see [[*Citation export processors]])
: #+cite_export: basic numeric noauthor/bare
: [cite:@key] is the same as [cite/noauthor/bare:@key]
+ or using default =nil= style
+ or, if =CITE_EXPORT= is not set, using the default =nil= style
: [cite:@key] is the same as [cite/nil:@key]
@ -17556,8 +17665,10 @@ Org currently includes the following export processors:
where backward compatibility is not a requirement and formatting
needs are minimal;
- csl :: this export processor uses format files written in [[https://en.wikipedia.org/wiki/Citation_Style_Language][Citation
Style Language]] via [[https://github.com/andras-simonyi/citeproc-el][citeproc-el]];
- csl :: this export processor uses format files written in
[[https://en.wikipedia.org/wiki/Citation_Style_Language][Citation
Style Language]] via
[[https://github.com/andras-simonyi/citeproc-el][citeproc-el]];
- In contrast, three other processors target LaTeX and LaTeX-derived
formats exclusively:
@ -17586,13 +17697,13 @@ optional)
: #+cite_export: basic author-year author
#+texinfo: @noindent
specifies the "basic" export processor with citations inserted as
specifies the =basic= export processor with citations inserted as
author's name and references indexed by author's names and year;
: #+cite_export: csl /some/path/to/vancouver-brackets.csl
#+texinfo: @noindent
specifies the "csl" processor and CSL style, which in this case
specifies the =csl= processor and CSL style, which in this case
defines numeric citations and numeric references according to the
=Vancouver= specification (as style used in many medical journals),
following a typesetting variation putting citations between brackets;
@ -17612,9 +17723,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
@ -17625,8 +17741,8 @@ should be printed (note the colon):
: #+print_bibliography:
The bibliography printed by the LaTeX-based export processors
"bibtex", "natbib" and "biblatex" has a chapter or section heading by
default, while the "basic" and "csl" processors print the list of
=bibtex=, =natbib= and =biblatex= has a chapter or section heading by
default, while the =basic= and =csl= processors print the list of
bibliography entries without a heading.
A document may contain more than one =PRINT_BIBLIOGRAPHY= keywords.
@ -17639,9 +17755,9 @@ certain category or to control formatting. The set of supported
the different citation export processors. Some export processors do
not support passing options.
*** Bibliography options in the "biblatex" and "csl" export processors
*** Bibliography options in the =biblatex= and =csl= export processors
The "biblatex" and "csl" export processors support bibliography
The =biblatex= and =csl= export processors support bibliography
options through a property list attached to the =PRINT_BIBLIOGRAPHY=
keyword. For example,
@ -17653,10 +17769,10 @@ commas, but without any space in-between:
: #+print_bibliography: :keyword "algebraic logic" :nottype article,book
The "biblatex" export processor accepts all options supported by
The =biblatex= export processor accepts all options supported by
BibLaTeX's ~\printbibliography~ command.
The "csl" processor accepts the following options:
The =csl= processor accepts the following options:
- =:keyword <keyword(,keyword2...)>= :: Print only entries whose
keyword field contains all given keywords.
@ -18555,7 +18671,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 +18879,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 +19046,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 +19058,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 +19105,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 +19743,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 +20285,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 +20313,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.]:
@ -21262,8 +21380,8 @@ adding ~:rewrites~ rules like this:
#+texinfo: @noindent
Since =example.com/$= is used as a regular expression, it maps
=http://example.com/=, =https://example.com=,
=http://www.example.com/= and similar to
=https://example.com/=, =https://example.com=,
=https://www.example.com/= and similar to
=/home/user/example/index.php=.
The ~:rewrites~ rules are searched as a last resort if and only if no
@ -21362,7 +21480,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 +21524,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 +21890,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 +21910,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 +23212,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 +23223,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 +23243,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 +23261,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 +23354,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

File diff suppressed because it is too large Load Diff

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
@ -111,7 +115,7 @@
(mapcar #'org-trim
(split-string (org-babel-expand-body:calc body params) "[\n\r]"))))
(save-excursion
(with-current-buffer (get-buffer "*Calculator*")
(with-current-buffer "*Calculator*"
(prog1
(calc-eval (calc-top 1))
(calc-pop 1)))))

View File

@ -65,7 +65,8 @@ executed inside the protection of `save-excursion' and
"Waiting time until trying to use fallback regexp to detect prompt.
This is useful when prompt unexpectedly changes."
:type 'float
:group 'org-babel)
:group 'org-babel
:package-version '(Org . "9.7"))
(defun org-babel-comint--set-fallback-prompt ()
"Swap `comint-prompt-regexp' and `org-babel-comint-prompt-regexp-old'."

View File

@ -893,7 +893,11 @@ guess will be made."
(format "at position %S" (nth 5 info)))))
(setq exec-start-time (current-time)
result
(let ((r (save-current-buffer (funcall cmd body params))))
(let ((r
;; Code block may move point in the buffer.
;; Make sure that the point remains on the
;; code block.
(save-excursion (funcall cmd body params))))
(if (and (eq (cdr (assq :result-type params)) 'value)
(or (member "vector" result-params)
(member "table" result-params))
@ -909,7 +913,7 @@ guess will be made."
;; insert a link to `:file'.
(when (and result
(not (or (member "link" result-params)
(member "graphics" result-params))))
(member "graphics" result-params))))
(with-temp-file file
(insert (org-babel-format-result
result
@ -3136,47 +3140,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 +3364,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 +3405,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

@ -47,11 +47,12 @@
"Execute a block of Eshell code BODY with PARAMS.
This function is called by `org-babel-execute-src-block'.
The BODY can be any code which allowed executed in Eshell.
Eshell allow to execute normal shell command and Elisp code.
More details please reference Eshell Info.
The BODY argument is code which can be executed in Eshell.
Eshell allows executing normal shell command and Elisp code.
For more details, see Info node `(eshell) Top'.
The PARAMS are variables assignments."
The PARAMS argument is passed to
`org-babel-expand-body:generic' (which see)."
(let* ((session (org-babel-eshell-initiate-session
(cdr (assq :session params))))
(full-body (org-babel-expand-body:generic

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%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
@ -378,17 +381,17 @@ and the following %keys may be used.
name ------ the name of the code block
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 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
replaced with its value."
:group 'org-babel
:type 'string
:package-version '(Org . "9.6"))
:package-version '(Org . "9.7"))
(defcustom org-babel-exp-inline-code-template
"src_%lang[%switches%flags]{%body}"
"src_%lang[%switches%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
@ -399,15 +402,14 @@ and the following %keys may be used.
name ------ the name of the code block
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 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
replaced with its value."
:group 'org-babel
:type 'string
:version "26.1"
:package-version '(Org . "8.3"))
:package-version '(Org . "9.7"))
(defun org-babel-exp-code (info type)
"Return the original code block of TYPE defined by INFO, formatted for export."
@ -432,6 +434,11 @@ 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"
.
,(org-babel-exp--at-source
(when-let ((params (org-element-property :parameters (org-element-context))))
(concat " " params))))
,@(mapcar (lambda (pair)
(cons (substring (symbol-name (car pair)) 1)
(format "%S" (cdr pair))))

View File

@ -339,7 +339,6 @@ constructs (header arguments, no-web syntax etc...) are ignored."
(command (concat org-babel-haskell-lhs2tex-command
" " (org-babel-process-file-name lhs-file)
" > " (org-babel-process-file-name tex-file)))
;; FIXME: What if src block has :preserve-indentation flag?
(preserve-indentp org-src-preserve-indentation)
indentation)
;; escape haskell source-code blocks

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,30 @@ exporting the literal LaTeX source."
:group 'org-babel
:type '(repeat (string)))
(defcustom org-babel-latex-process-alist
`((png :programs ("latex" "dvipng") :description "dvi > png"
:message
"you need to install the programs: latex and dvipng."
:image-input-type "dvi" :image-output-type "png"
:image-size-adjust (1.0 . 1.0) :latex-compiler
,(if (executable-find "latexmk")
'("latexmk -f -pdf -latex -interaction=nonstopmode -output-directory=%o %f")
'("latex -interaction nonstopmode -output-directory %o %f"
"latex -interaction nonstopmode -output-directory %o %f"
"latex -interaction nonstopmode -output-directory %o %f"))
:image-converter ("dvipng -D %D -T tight -o %O %f")
:transparent-image-converter
("dvipng -D %D -T tight -bg Transparent -o %O %f")))
"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.8")
: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 +194,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

@ -137,13 +137,13 @@ This function is called by `org-babel-execute-src-block'."
(let* ((cmdline (or (cdr (assq :cmdline params)) ""))
(batch/load (or (cdr (assq :batch params)) "batchload"))
(cmdline (if (or (equal cmdline "") (equal batch/load "batchload"))
;; legacy behaviour:
;; legacy behavior:
;; ensure that --very-quiet is on command-line by default
(concat cmdline " " org-babel-maxima--command-arguments-default)
;; if using an alternate loader, :cmdline overwrites default
cmdline))
(in-file (org-babel-temp-file "maxima-" ".max"))
(cmd (format "%s -r %s %s"
(cmd (format "%s -r %s %s"
org-babel-maxima-command
(shell-quote-argument
;; bind linenum to 0 so the first line

View File

@ -230,7 +230,7 @@ convert them into an Emacs-lisp table. Otherwise return the
results as a string."
(let ((res (if (and (> (length results) 0)
(string-equal "{" (substring results 0 1)))
results ;don't covert dicts to elisp
results ;don't convert dicts to elisp
(org-babel-script-escape results))))
(if (listp res)
(mapcar (lambda (el) (if (eq el 'None)

View File

@ -182,46 +182,51 @@ is true; otherwise returns the last value."
(with-temp-buffer
(insert (format ";; -*- geiser-scheme-implementation: %s -*-" impl))
(newline)
(insert code)
(geiser-mode)
(let ((geiser-repl-window-allow-split nil)
(geiser-repl-use-other-window nil))
(let ((repl-buffer (save-current-buffer
(org-babel-scheme-get-repl impl repl host port))))
(when (not (eq impl (org-babel-scheme-get-buffer-impl
(let ((beg (point)))
(insert code)
(geiser-mode)
(let ((geiser-repl-window-allow-split nil)
(geiser-repl-use-other-window nil))
(let ((repl-buffer (save-current-buffer
(org-babel-scheme-get-repl impl repl host port))))
(when (not (eq impl (org-babel-scheme-get-buffer-impl
(current-buffer))))
(message "Implementation mismatch: %s (%s) %s (%s)" impl (symbolp impl)
(org-babel-scheme-get-buffer-impl (current-buffer))
(symbolp (org-babel-scheme-get-buffer-impl
(current-buffer)))))
(setq geiser-repl--repl repl-buffer)
(setq geiser-impl--implementation nil)
(let ((geiser-debug-jump-to-debug-p nil)
(geiser-debug-show-debug-p nil))
;; `geiser-eval-region/wait' was introduced to await the
;; result of async evaluation in geiser version 0.22.
(let ((ret (funcall (if (fboundp 'geiser-eval-region/wait)
#'geiser-eval-region/wait
#'geiser-eval-region)
(point-min)
(point-max))))
(let ((err (geiser-eval--retort-error ret)))
(setq result (cond
(output
(or (geiser-eval--retort-output ret)
"Geiser Interpreter produced no output"))
(err nil)
(t (geiser-eval--retort-result-str ret ""))))
(when (not repl)
(save-current-buffer (set-buffer repl-buffer)
(geiser-repl-exit))
(set-process-query-on-exit-flag (get-buffer-process repl-buffer) nil)
(kill-buffer repl-buffer))
(when err
(let ((msg (geiser-eval--error-msg err)))
(org-babel-eval-error-notify
nil
(concat (if (listp msg) (car msg) msg) "\n"))))))))))
(message "Implementation mismatch: %s (%s) %s (%s)" impl (symbolp impl)
(org-babel-scheme-get-buffer-impl (current-buffer))
(symbolp (org-babel-scheme-get-buffer-impl
(current-buffer)))))
(setq geiser-repl--repl repl-buffer)
(setq geiser-impl--implementation nil)
(let ((geiser-debug-jump-to-debug-p nil)
(geiser-debug-show-debug-p nil))
;; `geiser-eval-region/wait' was introduced to await the
;; result of async evaluation in geiser version 0.22.
(let ((ret (funcall (if (fboundp 'geiser-eval-region/wait)
#'geiser-eval-region/wait
#'geiser-eval-region)
;; Do not include top comment into evaluation.
;; Apparently, mit-scheme has
;; problems with the top comment we add:
;; "Unexpected read restart on: #[textual-i/o-port 27 for console]"
beg
(point-max))))
(let ((err (geiser-eval--retort-error ret)))
(setq result (cond
(output
(or (geiser-eval--retort-output ret)
"Geiser Interpreter produced no output"))
(err nil)
(t (geiser-eval--retort-result-str ret ""))))
(when (not repl)
(save-current-buffer (set-buffer repl-buffer)
(geiser-repl-exit))
(set-process-query-on-exit-flag (get-buffer-process repl-buffer) nil)
(kill-buffer repl-buffer))
(when err
(let ((msg (geiser-eval--error-msg err)))
(org-babel-eval-error-notify
nil
(concat (if (listp msg) (car msg) msg) "\n")))))))))))
result))
(defun org-babel-scheme--table-or-string (results)

View File

@ -117,23 +117,27 @@ corresponding :engine source block header argument."
(defun org-babel-sql-dbstring-mysql (host port user password database)
"Make MySQL cmd line args for database connection. Pass nil to omit that arg."
(combine-and-quote-strings
(mapconcat
#'identity
(delq nil
(list (when host (concat "-h" host))
(list (when host (concat "-h" (shell-quote-argument host)))
(when port (format "-P%d" port))
(when user (concat "-u" user))
(when password (concat "-p" password))
(when database (concat "-D" database))))))
(when user (concat "-u" (shell-quote-argument user)))
(when password (concat "-p" (shell-quote-argument password)))
(when database (concat "-D" (shell-quote-argument database)))))
" "))
(defun org-babel-sql-dbstring-postgresql (host port user database)
"Make PostgreSQL command line args for database connection.
Pass nil to omit that arg."
(combine-and-quote-strings
(mapconcat
#'identity
(delq nil
(list (when host (concat "-h" host))
(list (when host (concat "-h" (shell-quote-argument host)))
(when port (format "-p%d" port))
(when user (concat "-U" user))
(when database (concat "-d" database))))))
(when user (concat "-U" (shell-quote-argument user)))
(when database (concat "-d" (shell-quote-argument database)))))
" "))
(defun org-babel-sql-dbstring-oracle (host port user password database)
"Make Oracle command line arguments for database connection.
@ -149,8 +153,12 @@ or
<user>/<password>@<database>
using its alias."
(when user (setq user (shell-quote-argument user)))
(when password (setq password (shell-quote-argument password)))
(when database (setq database (shell-quote-argument database)))
(when host (setq host (shell-quote-argument host)))
(cond ((and user password database host port)
(format "%s/%s@%s:%s/%s" user password host port database))
(format "%s/%s@%s:%d/%s" user password host port database))
((and user password database)
(format "%s/%s@%s" user password database))
(t (user-error "Missing information to connect to database"))))
@ -161,10 +169,10 @@ using its alias."
SQL Server on Windows and Linux platform."
(mapconcat #'identity
(delq nil
(list (when host (format "-S \"%s\"" host))
(when user (format "-U \"%s\"" user))
(when password (format "-P \"%s\"" password))
(when database (format "-d \"%s\"" database))))
(list (when host (format "-S \"%s\"" (shell-quote-argument host)))
(when user (format "-U \"%s\"" (shell-quote-argument user)))
(when password (format "-P \"%s\"" (shell-quote-argument password)))
(when database (format "-d \"%s\"" (shell-quote-argument database)))))
" "))
(defun org-babel-sql-dbstring-sqsh (host user password database)
@ -172,10 +180,10 @@ SQL Server on Windows and Linux platform."
\"sqsh\" is one method to access Sybase or MS SQL via Linux platform"
(mapconcat #'identity
(delq nil
(list (when host (format "-S \"%s\"" host))
(when user (format "-U \"%s\"" user))
(when password (format "-P \"%s\"" password))
(when database (format "-D \"%s\"" database))))
(list (when host (format "-S \"%s\"" (shell-quote-argument host)))
(when user (format "-U \"%s\"" (shell-quote-argument user)))
(when password (format "-P \"%s\"" (shell-quote-argument password)))
(when database (format "-D \"%s\"" (shell-quote-argument database)))))
" "))
(defun org-babel-sql-dbstring-vertica (host port user password database)
@ -183,11 +191,11 @@ SQL Server on Windows and Linux platform."
Pass nil to omit that arg."
(mapconcat #'identity
(delq nil
(list (when host (format "-h %s" host))
(list (when host (format "-h %s" (shell-quote-argument host)))
(when port (format "-p %d" port))
(when user (format "-U %s" user))
(when user (format "-U %s" (shell-quote-argument user)))
(when password (format "-w %s" (shell-quote-argument password) ))
(when database (format "-d %s" database))))
(when database (format "-d %s" (shell-quote-argument database)))))
" "))
(defun org-babel-sql-dbstring-saphana (host port instance user password database)
@ -195,13 +203,15 @@ Pass nil to omit that arg."
Pass nil to omit that arg."
(mapconcat #'identity
(delq nil
(list (and host port (format "-n %s:%s" host port))
(and host (not port) (format "-n %s" host))
(list (and host port (format "-n %s:%s"
(shell-quote-argument host)
port))
(and host (not port) (format "-n %s" (shell-quote-argument host)))
(and instance (format "-i %d" instance))
(and user (format "-u %s" user))
(and user (format "-u %s" (shell-quote-argument user)))
(and password (format "-p %s"
(shell-quote-argument password)))
(and database (format "-d %s" database))))
(and database (format "-d %s" (shell-quote-argument database)))))
" "))
(defun org-babel-sql-convert-standard-filename (file)
@ -276,21 +286,23 @@ This function is called by `org-babel-execute-src-block'."
(or cmdline "")
(org-babel-process-file-name in-file)
(org-babel-process-file-name out-file)))
((postgresql postgres) (format
"%s%s --set=\"ON_ERROR_STOP=1\" %s -A -P \
((postgresql postgres)
(format
"%s%s --set=\"ON_ERROR_STOP=1\" %s -A -P \
footer=off -F \"\t\" %s -f %s -o %s %s"
(if dbpassword
(format "PGPASSWORD=%s " dbpassword)
"")
(or (bound-and-true-p
sql-postgres-program)
"psql")
(if colnames-p "" "-t")
(org-babel-sql-dbstring-postgresql
dbhost dbport dbuser database)
(org-babel-process-file-name in-file)
(org-babel-process-file-name out-file)
(or cmdline "")))
(if dbpassword
(format "PGPASSWORD=%s "
(shell-quote-argument dbpassword))
"")
(or (bound-and-true-p
sql-postgres-program)
"psql")
(if colnames-p "" "-t")
(org-babel-sql-dbstring-postgresql
dbhost dbport dbuser database)
(org-babel-process-file-name in-file)
(org-babel-process-file-name out-file)
(or cmdline "")))
(sqsh (format "sqsh %s %s -i %s -o %s -m csv"
(or cmdline "")
(org-babel-sql-dbstring-sqsh

View File

@ -392,7 +392,7 @@ Did you give the decimal value %1$d by mistake?" mode)))
(error "File mode %S not recognized as a valid format." mode))
((string-match-p "^o0?[0-7][0-7][0-7]$" mode)
(string-to-number (replace-regexp-in-string "^o" "" mode) 8))
((string-match-p "^[ugoa]*\\(?:[+-=][rwxXstugo]*\\)+\\(,[ugoa]*\\(?:[+-=][rwxXstugo]*\\)+\\)*$" mode)
((string-match-p "^[ugoa]*\\(?:[+=-][rwxXstugo]*\\)+\\(,[ugoa]*\\(?:[+=-][rwxXstugo]*\\)+\\)*$" mode)
;; Match regexp taken from `file-modes-symbolic-to-number'.
(file-modes-symbolic-to-number mode org-babel-tangle-default-file-mode))
((string-match-p "^[r-][w-][xs-][r-][w-][xs-][r-][w-][x-]$" mode)

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))
@ -422,11 +423,6 @@ Label is in match group 1.")
;;; Internal functions
;; FIXME: We use `org-require-package' in other places.
(defun org-cite-csl--barf-without-citeproc ()
"Raise an error if Citeproc library is not loaded."
(unless (featurep 'citeproc)
(error "Citeproc library is not loaded")))
(defun org-cite-csl--note-style-p (info)
"Non-nil when bibliography style implies wrapping citations in footnotes.
@ -435,6 +431,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 +684,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
@ -802,7 +808,7 @@ INFO is the export state, as a property list."
(defun org-cite-csl-render-citation (citation _style _backend info)
"Export CITATION object.
INFO is the export state, as a property list."
(org-cite-csl--barf-without-citeproc)
(org-require-package 'citeproc)
(let ((output (cdr (assq citation (org-cite-csl--rendered-citations info)))))
(if (not (eq 'org (org-cite-csl--output-format info)))
output
@ -813,7 +819,7 @@ INFO is the export state, as a property list."
(defun org-cite-csl-render-bibliography (_keys _files _style props _backend info)
"Export bibliography.
INFO is the export state, as a property list."
(org-cite-csl--barf-without-citeproc)
(org-require-package 'citeproc)
(pcase-let* ((format (org-cite-csl--output-format info))
(`(,outputs ,parameters) (org-cite-csl--rendered-bibliographies info))
(output (cdr (assoc props outputs))))
@ -851,7 +857,7 @@ INFO is the export state, as a property list."
"Add \"hanging\" package if missing from LaTeX output.
OUTPUT is the export document, as a string. INFO is the export state, as a
property list."
(org-cite-csl--barf-without-citeproc)
(org-require-package 'citeproc)
(if (not (eq 'org-latex (org-cite-csl--output-format info)))
output
(with-temp-buffer

View File

@ -4,7 +4,7 @@
;; Authors: Carsten Dominik <carsten.dominik@gmail.com>
;; Thomas Baumann <thomas dot baumann at ch dot tum dot de>
;; Keywords: outlines, hypermedia, calendar, wp
;; Keywords: outlines, hypermedia, calendar, text
;; URL: https://orgmode.org
;;
;; This file is part of GNU Emacs.

View File

@ -5,7 +5,7 @@
;; Authors: Bastien Guerry <bzg@gnu.org>
;; Carsten Dominik <carsten dot dominik at gmail dot com>
;; Eric Schulte <schulte dot eric at gmail dot com>
;; Keywords: org, wp, capture
;; Keywords: org, text, capture
;;
;; This file is part of GNU Emacs.
;;

View File

@ -3,7 +3,7 @@
;; Copyright (C) 2009-2024 Free Software Foundation, Inc.
;; Author: Jan Böcker <jan.boecker at jboecker dot de>
;; Keywords: outlines, hypermedia, calendar, wp
;; Keywords: outlines, hypermedia, calendar, text
;; URL: https://orgmode.org
;;
;; This file is part of GNU Emacs.

View File

@ -4,7 +4,7 @@
;; Author: Carsten Dominik <carsten.dominik@gmail.com>
;; Tassilo Horn <tassilo at member dot fsf dot org>
;; Keywords: outlines, hypermedia, calendar, wp
;; Keywords: outlines, hypermedia, calendar, text
;; URL: https://orgmode.org
;;
;; This file is part of GNU Emacs.

View File

@ -3,7 +3,7 @@
;; Copyright (C) 2004-2024 Free Software Foundation, Inc.
;; Author: Carsten Dominik <carsten.dominik@gmail.com>
;; Keywords: outlines, hypermedia, calendar, wp
;; Keywords: outlines, hypermedia, calendar, text
;; URL: https://orgmode.org
;;
;; This file is part of GNU Emacs.

View File

@ -3,7 +3,7 @@
;; Copyright (C) 2020-2024 Free Software Foundation, Inc.
;; Author: Carsten Dominik <carsten.dominik@gmail.com>
;; Maintainer: Bastien Guerry <bzg@gnu.org>
;; Keywords: outlines, hypermedia, calendar, wp
;; Keywords: outlines, hypermedia, calendar, text
;; URL: https://orgmode.org
;;
;; This file is part of GNU Emacs.

View File

@ -3,7 +3,7 @@
;; Copyright (C) 2004-2024 Free Software Foundation, Inc.
;; Author: Thomas Baumann <thomas dot baumann at ch dot tum dot de>
;; Keywords: outlines, hypermedia, calendar, wp
;; Keywords: outlines, hypermedia, calendar, text
;; URL: https://orgmode.org
;;
;; This file is part of GNU Emacs.

View File

@ -3,7 +3,7 @@
;; Copyright (C) 2004-2024 Free Software Foundation, Inc.
;; Author: Carsten Dominik <carsten.dominik@gmail.com>
;; Keywords: outlines, hypermedia, calendar, wp
;; Keywords: outlines, hypermedia, calendar, text
;; URL: https://orgmode.org
;;
;; This file is part of GNU Emacs.

View File

@ -3,7 +3,7 @@
;; Copyright (C) 2008-2024 Free Software Foundation, Inc.
;; Author: Andy Stewart <lazycat dot manatee at gmail dot com>
;; Keywords: outlines, hypermedia, calendar, wp
;; Keywords: outlines, hypermedia, calendar, text
;; URL: https://orgmode.org
;;
;; This file is part of GNU Emacs.

View File

@ -3,7 +3,7 @@
;; Copyright (C) 2018-2024 Free Software Foundation, Inc.
;; Author: Carsten Dominik <carsten.dominik@gmail.com>
;; Keywords: outlines, hypermedia, calendar, wp
;; Keywords: outlines, hypermedia, calendar, text
;; This file is part of GNU Emacs.
@ -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.
@ -369,7 +369,7 @@ another window."
(const wl-other-frame)))))
(defcustom org-link-search-must-match-exact-headline 'query-to-create
"Control fuzzy link behaviour when specific matches not found.
"Control fuzzy link behavior when specific matches not found.
When nil, if a fuzzy link does not match a more specific
target (such as a heading, named block, target, or code ref),
@ -378,7 +378,7 @@ attempt a regular text search. When set to the special value
link instead. Otherwise, signal an error rather than attempting
a regular text search.
This option only affects behaviour in Org buffers. Spaces and
This option only affects behavior in Org buffers. Spaces and
statistics cookies are ignored during heading searches."
:group 'org-link-follow
:version "24.1"
@ -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\".
@ -1598,6 +1582,52 @@ PATH is a symbol name, as a string."
:follow #'org-link--open-help
:store #'org-link--store-help)
(defvar shortdoc--groups)
(declare-function shortdoc-display-group "shortdoc"
(group &optional function same-window))
(defun org-link--open-shortdoc (path _)
"Open a \"shortdoc\" type link.
PATH is a group name, \"group::#function\" or \"group::search
string\"."
(string-match "\\`\\([^:]*\\)\\(?:::\\(.*\\)\\'\\)?" path)
(let* ((group (match-string 1 path))
(str (match-string 2 path))
(fn (and str
(eq ?# (string-to-char str))
(intern-soft (substring str 1)))))
(condition-case nil
(progn
(shortdoc-display-group group fn)
(and str (not fn) (search-forward str nil t)))
(error (user-error "Unknown shortdoc group or malformed link: `%s'"
path)))))
(defun org-link--store-shortdoc (&optional _interactive?)
"Store \"shortdoc\" type link."
(when (derived-mode-p 'shortdoc-mode)
(let* ((buffer (buffer-name))
(group (when (string-match "*Shortdoc \\(.*\\)\\*" buffer)
(match-string 1 buffer))))
(if (and group (assoc (intern-soft group) shortdoc--groups))
(org-link-store-props :type "shortdoc"
:link (format "shortdoc:%s" group)
:description nil)
(user-error "Unknown shortdoc group: %s" group)))))
(defun org-link--complete-shortdoc ()
"Create a \"shortdoc\" link using completion."
(concat "shortdoc:"
(completing-read "Shortdoc summary for functions in: "
(mapcar #'car shortdoc--groups))))
;; FIXME: Remove the condition when we drop Emacs 27 support.
;;;; "shortdoc" link type
(when (version<= "28.0.90" emacs-version)
(org-link-set-parameters "shortdoc"
:follow #'org-link--open-shortdoc
:store #'org-link--store-shortdoc
:complete #'org-link--complete-shortdoc))
;;;; "http", "https", "mailto", "ftp", and "news" link types
(dolist (scheme '("ftp" "http" "https" "mailto" "news"))
(org-link-set-parameters scheme
@ -1679,18 +1709,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 +1762,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 +1833,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 +1845,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 +1872,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 +1892,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))))
@ -1943,7 +1958,7 @@ generate a description as described in `org-link-parameters'
docstring. Otherwise, if `org-link-make-description-function' is
non-nil, this function will be called with the link target, and
the result will be the default link description. When called
non-interactively, don't allow to edit the default description."
non-interactively, don't allow editing the default description."
(interactive "P")
(let* ((wcf (current-window-configuration))
(origbuf (current-buffer))
@ -2232,7 +2247,7 @@ Also refresh fontification if needed."
(interactive)
(let ((old-regexp org-target-link-regexp)
;; Some languages, e.g., Chinese, do not use spaces to
;; separate words. Also allow to surround radio targets with
;; separate words. Also allow surrounding radio targets with
;; line-breakable characters.
(before-re "\\(?:^\\|[^[:alnum:]]\\|\\c|\\)\\(")
(after-re "\\)\\(?:$\\|[^[:alnum:]]\\|\\c|\\)")

View File

@ -3,7 +3,7 @@
;; Copyright (C) 2004-2024 Free Software Foundation, Inc.
;; Author: Carsten Dominik <carsten.dominik@gmail.com>
;; Keywords: outlines, hypermedia, calendar, wp
;; Keywords: outlines, hypermedia, calendar, text
;; URL: https://orgmode.org
;;
;; This file is part of GNU Emacs.
@ -900,7 +900,8 @@ but not scheduled today."
:type '(choice
(const :tag "Never" nil)
(const :tag "Always" t)
(const :tag "Not when scheduled today" not-today)))
(const :tag "Not when scheduled today" not-today))
:package-version '(Org . "9.7"))
(defcustom org-agenda-skip-timestamp-if-deadline-is-shown nil
"Non-nil means skip timestamp line if same entry shows because of deadline.
@ -1701,7 +1702,8 @@ Custom commands can bind this variable in the options section."
(cons (const :tag "Strategy for Tags matches" tags)
(repeat ,org-sorting-choice))
(cons (const :tag "Strategy for search matches" search)
(repeat ,org-sorting-choice)))))
(repeat ,org-sorting-choice))))
:package-version '(Org . "9.7"))
(defcustom org-agenda-cmp-user-defined nil
"A function to define the comparison `user-defined'.
@ -2385,8 +2387,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
@ -3040,7 +3041,7 @@ Pressing `<' twice means to restrict to the current subtree or region
(`todo-tree
(org-check-for-org-mode)
(org-occur (concat "^" org-outline-regexp "[ \t]*"
(regexp-quote org-match) "\\>")))
(regexp-quote org-match) "\\(?:[\t ]\\|$\\)")))
(`occur-tree
(org-check-for-org-mode)
(org-occur org-match))
@ -3899,7 +3900,7 @@ generating a new one."
;; buffer found
(get-buffer org-agenda-buffer-name)
;; C-u parameter is same as last call
(with-current-buffer (get-buffer org-agenda-buffer-name)
(with-current-buffer org-agenda-buffer-name
(and
(equal current-prefix-arg
org-agenda-last-prefix-arg)
@ -5311,8 +5312,8 @@ of what a project is and how to check if it stuck, customize the variable
(org-delete-all org-done-keywords-for-agenda
(copy-sequence org-todo-keywords-for-agenda))))
(todo-re (and todo
(format "^\\*+[ \t]+\\(%s\\)\\>"
(mapconcat #'identity todo-wds "\\|"))))
(format "^\\*+[ \t]+\\(%s\\)\\(?:[ \t]\\|$\\)"
(mapconcat #'regexp-quote todo-wds "\\|"))))
(tags-re (cond ((null tags) nil)
((member "*" tags) org-tag-line-re)
(tags
@ -5833,7 +5834,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)
@ -5934,7 +5935,7 @@ displayed in agenda view."
level category tags timestamp org-ts-regexp habit?)))
(org-add-props item props
'urgency (if habit?
(org-habit-get-urgency (org-habit-parse-todo))
(org-habit-get-urgency (org-habit-parse-todo))
(org-get-priority item))
'priority (org-get-priority item)
'org-marker (org-agenda-new-marker pos)
@ -6781,10 +6782,13 @@ scheduled items with an hour specification like [h]h:mm."
'help-echo
(format "mouse-2 or RET jump to org file %s"
(abbreviate-file-name buffer-file-name))))
;; Group 1: starting date timestamp without braces
;; Group 2: ending date timestamp without braces
(regexp (if org-agenda-include-inactive-timestamps
org-tr-regexp-both org-tr-regexp))
(d0 (calendar-absolute-from-gregorian date))
face marker hdmarker ee txt d1 d2 s1 s2 category level
(agenda-today (calendar-absolute-from-gregorian date))
face marker hdmarker block-list txt start-day end-day
category level
todo-state tags pos head donep inherited-tags effort
effort-minutes inactive?)
(goto-char (point-min))
@ -6795,37 +6799,36 @@ scheduled items with an hour specification like [h]h:mm."
(setq inactive? (eq ?\[ (char-after (match-beginning 0))))
(let ((start-time (match-string 1))
(end-time (match-string 2)))
(setq s1 (match-string 1)
s2 (match-string 2)
d1 (time-to-days
(condition-case err
(org-time-string-to-time s1)
(error
(error
"Bad timestamp %S at %d in buffer %S\nError was: %s"
s1
pos
(current-buffer)
(error-message-string err)))))
d2 (time-to-days
(condition-case err
(org-time-string-to-time s2)
(error
(error
"Bad timestamp %S at %d in buffer %S\nError was: %s"
s2
pos
(current-buffer)
(error-message-string err))))))
(when (and (> (- d0 d1) -1) (> (- d2 d0) -1))
;; Only allow days between the limits, because the normal
(setq start-day (time-to-days
(condition-case err
(org-time-string-to-time start-time)
(error
(error
"Bad timestamp %S at %d in buffer %S\nError was: %s"
start-time
pos
(current-buffer)
(error-message-string err)))))
end-day (time-to-days
(condition-case err
(org-time-string-to-time end-time)
(error
(error
"Bad timestamp %S at %d in buffer %S\nError was: %s"
end-time
pos
(current-buffer)
(error-message-string err))))))
(when (and (> (- agenda-today start-day) -1)
(> (- end-day agenda-today) -1))
;; Only allow days between the limits, because the normal
;; date stamps will catch the limits.
(save-excursion
(setq todo-state (org-get-todo-state))
(setq donep (member todo-state org-done-keywords))
(when (and donep org-agenda-skip-timestamp-if-done)
(throw :skip t))
(setq face (if (= d1 d2)
(setq face (if (= start-day end-day)
'org-agenda-calendar-event
'org-agenda-calendar-daterange))
(setq marker (org-agenda-new-marker (point))
@ -6851,29 +6854,36 @@ scheduled items with an hour specification like [h]h:mm."
(let ((remove-re
(if org-agenda-remove-timeranges-from-blocks
(concat
"<" (regexp-quote s1) ".*?>"
"<" (regexp-quote start-time) ".*?>"
"--"
"<" (regexp-quote s2) ".*?>")
"<" (regexp-quote end-time) ".*?>")
nil)))
(setq txt (org-agenda-format-item
(concat
(when inactive? org-agenda-inactive-leader)
(format
(nth (if (= d1 d2) 0 1)
org-agenda-timerange-leaders)
(1+ (- d0 d1)) (1+ (- d2 d1))))
(org-add-props head nil
'effort effort
'effort-minutes effort-minutes)
level category tags
(cond
((and (= d1 d0) (= d2 d0))
(concat "<" start-time ">--<" end-time ">"))
((= d1 d0)
(concat "<" start-time ">"))
((= d2 d0)
(concat "<" end-time ">")))
remove-re))))
;; `org-agenda-format-item' automatically creates a
;; time range when
;; `org-agenda-default-appointment-duration' is
;; non-nil and only start/end time is given.
;; We do not want it here, when the range spans
;; multiple days.
(let ((org-agenda-default-appointment-duration nil))
(setq txt (org-agenda-format-item
(concat
(when inactive? org-agenda-inactive-leader)
(format
(nth (if (= start-day end-day) 0 1)
org-agenda-timerange-leaders)
(1+ (- agenda-today start-day)) (1+ (- end-day start-day))))
(org-add-props head nil
'effort effort
'effort-minutes effort-minutes)
level category tags
(cond
((and (= start-day agenda-today) (= end-day agenda-today))
(concat "<" start-time ">--<" end-time ">"))
((= start-day agenda-today)
(concat "<" start-time ">"))
((= end-day agenda-today)
(concat "<" end-time ">")))
remove-re)))))
(org-add-props txt props
'face face
'org-marker marker 'org-hd-marker hdmarker
@ -6883,10 +6893,10 @@ scheduled items with an hour specification like [h]h:mm."
'todo-state todo-state
'urgency (org-get-priority txt)
'priority (org-get-priority txt))
(push txt ee))))
(push txt block-list))))
(goto-char pos)))
;; Sort the entries by expiration date.
(nreverse ee)))
(nreverse block-list)))
;;; Agenda presentation and sorting
@ -6975,58 +6985,71 @@ Any match of REMOVE-RE will be removed from TXT."
(time-grid-trailing-characters (nth 2 org-agenda-time-grid))
(extra (or (and (not habitp) extra) ""))
time
(ts (when dotime (concat
(if (stringp dotime) dotime "")
(and org-agenda-search-headline-for-time
;; Do not search inside
;; timestamps. They are handled
;; separately.
(replace-regexp-in-string
org-ts-regexp-both ""
txt)))))
(time-of-day (and dotime (org-get-time-of-day ts)))
stamp plain s0 s1 s2 rtn srp l
(string-containing-time
(when dotime (concat
(if (stringp dotime) dotime "")
(and org-agenda-search-headline-for-time
;; Do not search inside
;; timestamps. They are handled
;; separately.
(replace-regexp-in-string
org-ts-regexp-both ""
txt)))))
(time-of-day (and dotime (org-get-time-of-day string-containing-time)))
timestamp-range? plain-time? date-range-same-day?
time-string start-time end-time rtn
duration breadcrumbs)
(and (derived-mode-p 'org-mode) buffer-file-name
(add-to-list 'org-agenda-contributing-files buffer-file-name))
(when (and dotime time-of-day)
;; Extract starting and ending time and move them to prefix
(when (or (setq stamp (string-match org-stamp-time-of-day-regexp ts))
(setq plain (string-match org-plain-time-of-day-regexp ts)))
(setq s0 (match-string 0 ts)
srp (and stamp (match-end 3))
s1 (match-string (if plain 1 2) ts)
s2 (match-string (if plain 8 (if srp 4 6)) ts))
(when (or (setq timestamp-range?
(string-match org-stamp-time-of-day-regexp
string-containing-time))
(setq plain-time?
(string-match org-plain-time-of-day-regexp
string-containing-time)))
(setq time-string (match-string 0 string-containing-time)
date-range-same-day? (and timestamp-range? (match-end 3))
start-time (match-string (if plain-time? 1 2)
string-containing-time)
end-time (match-string (if plain-time? 8
(if date-range-same-day? 4 6))
string-containing-time))
;; If the times are in TXT (not in DOTIMES), and the prefix will list
;; them, we might want to remove them there to avoid duplication.
;; The user can turn this off with a variable.
(when (and org-prefix-has-time
org-agenda-remove-times-when-in-prefix (or stamp plain)
(string-match (concat (regexp-quote s0) " *") txt)
org-agenda-remove-times-when-in-prefix
(or timestamp-range? plain-time?)
(string-match (concat (regexp-quote time-string) " *") txt)
(not (equal ?\] (string-to-char (substring txt (match-end 0)))))
(if (eq org-agenda-remove-times-when-in-prefix 'beg)
(= (match-beginning 0) 0)
t))
(setq txt (replace-match "" nil nil txt))))
;; Normalize the time(s) to 24 hour.
(when s1 (setq s1 (org-get-time-of-day s1 t)))
(when s2 (setq s2 (org-get-time-of-day s2 t)))
(when start-time (setq start-time (org-get-time-of-day start-time t)))
(when end-time (setq end-time (org-get-time-of-day end-time t)))
;; Try to set s2 if s1 and
;; `org-agenda-default-appointment-duration' are set
(when (and s1 (not s2) org-agenda-default-appointment-duration)
(setq s2
(org-duration-from-minutes
(+ (org-duration-to-minutes s1 t)
(when (and start-time (not end-time)
org-agenda-default-appointment-duration)
(setq end-time
(org-duration-from-minutes
(+ (org-duration-to-minutes start-time t)
org-agenda-default-appointment-duration)
nil t)))
nil t)))
;; Compute the duration
(when s2
(setq duration (- (org-duration-to-minutes s2)
(org-duration-to-minutes s1))))
(when end-time
(setq duration (- (org-duration-to-minutes end-time)
(org-duration-to-minutes start-time))))
;; Format S1 and S2 for display.
(when s1 (setq s1 (format "%5s" (org-get-time-of-day s1 'overtime))))
(when s2 (setq s2 (org-get-time-of-day s2 'overtime))))
(when start-time
(setq start-time (format "%5s" (org-get-time-of-day start-time 'overtime))))
(when end-time
(setq end-time (org-get-time-of-day end-time 'overtime))))
(when (string-match org-tag-group-re txt)
;; Tags are in the string
(if (or (eq org-agenda-remove-tags t)
@ -7063,26 +7086,27 @@ Any match of REMOVE-RE will be removed from TXT."
;; particular heading.
"")))
(if (equal "" s) "" (concat s org-agenda-breadcrumbs-separator))))))
(setq time (cond (s2 (concat
(org-agenda-time-of-day-to-ampm-maybe s1)
"-" (org-agenda-time-of-day-to-ampm-maybe s2)
(when org-agenda-timegrid-use-ampm " ")))
(s1 (concat
(org-agenda-time-of-day-to-ampm-maybe s1)
(if org-agenda-timegrid-use-ampm
(concat time-grid-trailing-characters " ")
time-grid-trailing-characters)))
(setq time (cond (end-time
(concat
(org-agenda-time-of-day-to-ampm-maybe start-time)
"-" (org-agenda-time-of-day-to-ampm-maybe end-time)
(when org-agenda-timegrid-use-ampm " ")))
(start-time
(concat
(org-agenda-time-of-day-to-ampm-maybe start-time)
(if org-agenda-timegrid-use-ampm
(concat time-grid-trailing-characters " ")
time-grid-trailing-characters)))
(t ""))
category (if (symbolp category) (symbol-name category) category)
level (or with-level ""))
(if (string-match org-link-bracket-re category)
(progn
(setq l (string-width (or (match-string 2) (match-string 1))))
(when (< l (or org-prefix-category-length 0))
(setq category (copy-sequence category))
(org-add-props category nil
(let ((link-width (string-width (or (match-string 2) (match-string 1)))))
(when (< link-width (or org-prefix-category-length 0))
(setq category (copy-sequence category))
(org-add-props category nil
'extra-space (make-string
(- org-prefix-category-length l 1) ?\ ))))
(- org-prefix-category-length link-width 1) ?\ ))))
(when (and org-prefix-category-max-length
(>= (length category) org-prefix-category-max-length))
(setq category (substring category 0 (1- org-prefix-category-max-length)))))
@ -7491,8 +7515,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 +7562,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 +7572,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 +8619,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 +9247,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 +9340,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 +9367,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 +9430,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 +9718,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 +9726,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

@ -3,7 +3,7 @@
;; Copyright (C) 2004-2024 Free Software Foundation, Inc.
;; Author: Carsten Dominik <carsten.dominik@gmail.com>
;; Keywords: outlines, hypermedia, calendar, wp
;; Keywords: outlines, hypermedia, calendar, text
;; URL: https://orgmode.org
;;
;; This file is part of GNU Emacs.

View File

@ -148,7 +148,7 @@ When t, store the link to original file location.
When `file', store link to the attached file location.
When `attached', store attach: link to the attached file."
:group 'org-attach
:version "24.1"
:package-version '(Org . "9.7")
:type '(choice
(const :tag "Don't store link" nil)
(const :tag "Link to origin location" t)
@ -530,7 +530,7 @@ DIR-property exists (that is different from the unset one)."
"Turn the autotag on or (if OFF is set) off."
(when org-attach-auto-tag
;; FIXME: There is currently no way to set #+FILETAGS
;; programatically. Do nothing when before first heading
;; programmatically. Do nothing when before first heading
;; (attaching to file) to avoid blocking error.
(unless (org-before-first-heading-p)
(save-excursion

View File

@ -3,7 +3,7 @@
;; Copyright (C) 2010-2024 Free Software Foundation, Inc.
;; Author: Carsten Dominik <carsten.dominik@gmail.com>
;; Keywords: outlines, hypermedia, calendar, wp
;; Keywords: outlines, hypermedia, calendar, text
;; URL: https://orgmode.org
;;
;; This file is part of GNU Emacs.
@ -376,8 +376,10 @@ be replaced with content and expanded:
prompt/completions. Default value and completions as in
%^{prompt|default|...}X are allowed.
%? After completing the template, position cursor here.
%\\1 ... %\\N Insert the text entered at the nth %^{prompt}, where N
is a number, starting from 1.
%\\1 ... %\\N Insert the text entered at the nth %^{prompt} (but not
%^{prompt}X), where N is a number, starting from 1.
%\\*1...%\\*N Same as \\N, but for all the prompts, including
%^{prompt} and %^{prompt}X.
Apart from these general escapes, you can access information specific to
the link type that is created. For example, calling `org-capture' in emails
@ -402,7 +404,7 @@ calendar | %:type %:date
When you need to insert a literal percent sign in the template,
you can escape ambiguous cases with a backward slash, e.g., \\%i."
:group 'org-capture
:package-version '(Org . "9.6")
:package-version '(Org . "9.7")
:set (lambda (s v) (set-default-toplevel-value s (org-capture-upgrade-templates v)))
:type
(let ((file-variants '(choice :tag "Filename "
@ -717,7 +719,6 @@ of the day at point (if any) or the current HH:MM time."
(condition-case error
(org-capture-put :template (org-capture-fill-template))
((error quit)
(if (get-buffer "*Capture*") (kill-buffer "*Capture*"))
(error "Capture abort: %s" (error-message-string error))))
(setq org-capture-clock-keep (org-capture-get :clock-keep))
@ -1198,6 +1199,8 @@ may have been stored before."
(exact-position (org-capture-get :exact-position))
(insert-here? (org-capture-get :insert-here))
(level 1))
(unless (string-match org-outline-regexp-bol template)
(setq template (concat "* " template)))
(org-capture-verify-tree template)
(when exact-position (goto-char exact-position))
(cond
@ -1354,13 +1357,14 @@ may have been stored before."
(defun org-capture-place-table-line ()
"Place the template as a table line."
(require 'org-table)
(let ((text
(pcase (org-trim (org-capture-get :template))
((pred (string-match-p org-table-border-regexp))
"| %?Bad template |")
(text (concat text "\n"))))
(table-line-pos (org-capture-get :table-line-pos))
beg end)
(let* ((template (org-trim (org-capture-get :template)))
(text
(pcase template
((pred (string-match-p org-table-border-regexp))
(concat "| " template))
(text (concat text "\n"))))
(table-line-pos (org-capture-get :table-line-pos))
beg end)
(cond
((org-capture-get :exact-position)
(org-with-point-at (org-capture-get :exact-position)
@ -1675,9 +1679,12 @@ Expansion occurs in a temporary Org mode buffer."
(org-no-properties org-clock-heading)
""))
(v-K (if (marker-buffer org-clock-marker)
(org-with-point-at org-clock-marker
(org-store-link nil nil))
""))
(let ((original-link-plist org-store-link-plist)
(clocked-task-link (org-with-point-at org-clock-marker
(org-store-link nil nil))))
(setq org-store-link-plist original-link-plist)
clocked-task-link)
""))
(v-f (or (org-capture-get :original-file-nondirectory) ""))
(v-F (or (org-capture-get :original-file) ""))
(org-capture--clipboards
@ -1693,222 +1700,246 @@ Expansion occurs in a temporary Org mode buffer."
(setq template "")
(message "no template") (ding)
(sit-for 1))
(save-window-excursion
(switch-to-buffer-other-window (get-buffer-create "*Capture*"))
(erase-buffer)
(setq buffer-file-name nil)
(setq mark-active nil)
(insert template)
(org-mode)
(goto-char (point-min))
;; %[] insert contents of a file.
(save-excursion
(while (re-search-forward "%\\[\\(.+\\)\\]" nil t)
(let ((filename (expand-file-name (match-string 1)))
(beg (copy-marker (match-beginning 0)))
(end (copy-marker (match-end 0))))
(unless (org-capture-escaped-%)
(delete-region beg end)
(set-marker beg nil)
(set-marker end nil)
(condition-case error
(insert-file-contents filename)
(error
(insert (format "%%![could not insert %s: %s]"
filename
error))))))))
;; Mark %() embedded elisp for later evaluation.
(org-capture-expand-embedded-elisp 'mark)
;; Expand non-interactive templates.
(let ((regexp "%\\(:[-A-Za-z]+\\|<\\([^>\n]+\\)>\\|[aAcfFikKlLntTuUx]\\)"))
(save-excursion
(while (re-search-forward regexp nil t)
;; `org-capture-escaped-%' may modify buffer and cripple
;; match-data. Use markers instead. Ditto for other
;; templates.
(let ((pos (copy-marker (match-beginning 0)))
(end (copy-marker (match-end 0)))
(value (match-string 1))
(time-string (match-string 2)))
(unless (org-capture-escaped-%)
(delete-region pos end)
(set-marker pos nil)
(set-marker end nil)
(let* ((inside-sexp? (org-capture-inside-embedded-elisp-p))
(replacement
(pcase (string-to-char value)
(?< (format-time-string time-string time))
(?:
(or (plist-get org-store-link-plist (intern value))
""))
(?i
(if inside-sexp? v-i
;; Outside embedded Lisp, repeat leading
;; characters before initial place holder
;; every line.
(let ((lead (concat "\n"
(org-current-line-string t))))
(replace-regexp-in-string "\n" lead v-i nil t))))
(?a v-a)
(?A v-A)
(?c v-c)
(?f v-f)
(?F v-F)
(?k v-k)
(?K v-K)
(?l v-l)
(?L v-L)
(?n v-n)
(?t v-t)
(?T v-T)
(?u v-u)
(?U v-U)
(?x v-x))))
(insert
(if inside-sexp?
;; Escape sensitive characters.
(replace-regexp-in-string "[\\\"]" "\\\\\\&" replacement)
replacement))))))))
;; Expand %() embedded Elisp. Limit to Sexp originally marked.
(org-capture-expand-embedded-elisp)
;; Expand interactive templates. This is the last step so that
;; template is mostly expanded when prompting happens. Turn on
;; Org mode and set local variables. This is to support
;; completion in interactive prompts.
(let ((org-inhibit-startup t)) (org-mode))
(org-clone-local-variables buffer "\\`org-")
(let (strings) ; Stores interactive answers.
(save-excursion
(let ((regexp "%\\^\\(?:{\\([^}]*\\)}\\)?\\([CgGLptTuU]\\)?"))
(while (re-search-forward regexp nil t)
(let* ((items (and (match-end 1)
(save-match-data
(split-string (match-string-no-properties 1)
"|"))))
(key (match-string 2))
(beg (copy-marker (match-beginning 0)))
(end (copy-marker (match-end 0)))
(prompt (nth 0 items))
(default (nth 1 items))
(completions (nthcdr 2 items)))
(unless (org-capture-escaped-%)
(delete-region beg end)
(set-marker beg nil)
(set-marker end nil)
(pcase key
((or "G" "g")
(let* ((org-last-tags-completion-table
(org-global-tags-completion-table
(cond ((equal key "G") (org-agenda-files))
(file (list file))
(t nil))))
(org-add-colon-after-tag-completion t)
(ins (mapconcat
#'identity
(let ((crm-separator "[ \t]*:[ \t]*"))
(completing-read-multiple
(if prompt (concat prompt ": ") "Tags: ")
org-last-tags-completion-table nil nil nil
'org-tags-history))
":")))
(when (org-string-nw-p ins)
(unless (eq (char-before) ?:) (insert ":"))
(insert ins)
(unless (eq (char-after) ?:) (insert ":"))
(when (org-at-heading-p) (org-align-tags)))))
((or "C" "L")
(let ((insert-fun (if (equal key "C") #'insert
(lambda (s) (org-insert-link 0 s)))))
(pcase org-capture--clipboards
(`nil nil)
(`(,value) (funcall insert-fun value))
(`(,first-value . ,_)
(funcall insert-fun
(read-string "Clipboard/kill value: "
first-value
'org-capture--clipboards
first-value)))
(_ (error "Invalid `org-capture--clipboards' value: %S"
org-capture--clipboards)))))
("p"
;; We remove keyword properties inherited from
;; target buffer so `org-read-property-value' has
;; a chance to find allowed values in sub-trees
;; from the target buffer.
(setq-local org-keyword-properties nil)
(let* ((origin (set-marker (make-marker)
(org-capture-get :pos)
(org-capture-get :buffer)))
;; Find location from where to get allowed
;; values. If `:target-entry-p' is
;; non-nil, the current headline in the
;; target buffer is going to be a parent
;; headline, so location is fine.
;; Otherwise, find the parent headline in
;; the target buffer.
(pom (if (org-capture-get :target-entry-p) origin
(let ((level (progn
(while (org-up-heading-safe))
(org-current-level))))
(org-with-point-at origin
(let ((l (if (org-at-heading-p)
(org-current-level)
most-positive-fixnum)))
(while (and l (>= l level))
(setq l (org-up-heading-safe)))
(if l (point-marker)
(point-min-marker)))))))
(value
(org-read-property-value prompt pom default)))
(org-set-property prompt value)))
((or "t" "T" "u" "U")
;; These are the date/time related ones.
(let* ((upcase? (equal (upcase key) key))
(org-end-time-was-given nil)
(time (org-read-date upcase? t nil prompt)))
(org-insert-timestamp
time (or org-time-was-given upcase?)
(member key '("u" "U"))
nil nil (list org-end-time-was-given))))
(`nil
;; Load history list for current prompt.
(setq org-capture--prompt-history
(gethash prompt org-capture--prompt-history-table))
(push (org-completing-read
(org-format-prompt (or prompt "Enter string") default)
completions
nil nil nil 'org-capture--prompt-history default)
strings)
(insert (car strings))
;; Save updated history list for current prompt.
(puthash prompt org-capture--prompt-history
org-capture--prompt-history-table))
(_
(error "Unknown template placeholder: \"%%^%s\""
key))))))))
;; Replace %n escapes with nth %^{...} string.
(setq strings (nreverse strings))
(save-excursion
(while (re-search-forward "%\\\\\\([1-9][0-9]*\\)" nil t)
(unless (org-capture-escaped-%)
(replace-match
(nth (1- (string-to-number (match-string 1))) strings)
nil t)))))
;; Make sure there are no empty lines before the text, and that
;; it ends with a newline character or it is empty.
(skip-chars-forward " \t\n")
(delete-region (point-min) (line-beginning-position))
(goto-char (point-max))
(skip-chars-backward " \t\n")
(if (bobp) (delete-region (point) (line-end-position))
(end-of-line)
(delete-region (point) (point-max))
(insert "\n"))
;; Return the expanded template and kill the capture buffer.
(untabify (point-min) (point-max))
(set-buffer-modified-p nil)
(prog1 (buffer-substring-no-properties (point-min) (point-max))
(kill-buffer (current-buffer))))))
(let ((capture-tmp-buffer (generate-new-buffer "*Capture*")))
(unwind-protect
(save-window-excursion
(switch-to-buffer-other-window capture-tmp-buffer)
(erase-buffer)
(setq buffer-file-name nil)
(setq mark-active nil)
(insert template)
(org-mode)
(goto-char (point-min))
;; %[] insert contents of a file.
(save-excursion
(while (re-search-forward "%\\[\\(.+\\)\\]" nil t)
(let ((filename (expand-file-name (match-string 1)))
(beg (copy-marker (match-beginning 0)))
(end (copy-marker (match-end 0))))
(unless (org-capture-escaped-%)
(delete-region beg end)
(set-marker beg nil)
(set-marker end nil)
(condition-case error
(insert-file-contents filename)
(error
(insert (format "%%![could not insert %s: %s]"
filename
error))))))))
;; Mark %() embedded elisp for later evaluation.
(org-capture-expand-embedded-elisp 'mark)
;; Expand non-interactive templates.
(let ((regexp "%\\(:[-A-Za-z]+\\|<\\([^>\n]+\\)>\\|[aAcfFikKlLntTuUx]\\)"))
(save-excursion
(while (re-search-forward regexp nil t)
;; `org-capture-escaped-%' may modify buffer and cripple
;; match-data. Use markers instead. Ditto for other
;; templates.
(let ((pos (copy-marker (match-beginning 0)))
(end (copy-marker (match-end 0)))
(value (match-string 1))
(time-string (match-string 2)))
(unless (org-capture-escaped-%)
(delete-region pos end)
(set-marker pos nil)
(set-marker end nil)
(let* ((inside-sexp? (org-capture-inside-embedded-elisp-p))
(replacement
(pcase (string-to-char value)
(?< (format-time-string time-string time))
(?:
(or (plist-get org-store-link-plist (intern value))
""))
(?i
(if inside-sexp? v-i
;; Outside embedded Lisp, repeat leading
;; characters before initial place holder
;; every line.
(let ((lead (concat "\n"
(org-current-line-string t))))
(replace-regexp-in-string "\n" lead v-i nil t))))
(?a v-a)
(?A v-A)
(?c v-c)
(?f v-f)
(?F v-F)
(?k v-k)
(?K v-K)
(?l v-l)
(?L v-L)
(?n v-n)
(?t v-t)
(?T v-T)
(?u v-u)
(?U v-U)
(?x v-x))))
(insert
(if inside-sexp?
;; Escape sensitive characters.
(replace-regexp-in-string "[\\\"]" "\\\\\\&" replacement)
replacement))))))))
;; Expand %() embedded Elisp. Limit to Sexp originally marked.
(org-capture-expand-embedded-elisp)
;; Expand interactive templates. This is the last step so that
;; template is mostly expanded when prompting happens. Turn on
;; Org mode and set local variables. This is to support
;; completion in interactive prompts.
(let ((org-inhibit-startup t)) (org-mode))
(org-clone-local-variables buffer "\\`org-")
(let (strings ; Stores interactive answers.
strings-all ; ... include %^{prompt}X answers
)
(save-excursion
(let ((regexp "%\\^\\(?:{\\([^}]*\\)}\\)?\\([CgGLptTuU]\\)?"))
(while (re-search-forward regexp nil t)
(let* ((items (and (match-end 1)
(save-match-data
(split-string (match-string-no-properties 1)
"|"))))
(key (match-string 2))
(beg (copy-marker (match-beginning 0)))
(end (copy-marker (match-end 0)))
(prompt (nth 0 items))
(default (nth 1 items))
(completions (nthcdr 2 items)))
(unless (org-capture-escaped-%)
(delete-region beg end)
(set-marker beg nil)
(set-marker end nil)
(pcase key
((or "G" "g")
(let* ((org-last-tags-completion-table
(org-global-tags-completion-table
(cond ((equal key "G") (org-agenda-files))
(file (list file))
(t nil))))
(org-add-colon-after-tag-completion t)
(ins (mapconcat
#'identity
(let ((crm-separator "[ \t]*:[ \t]*"))
(completing-read-multiple
(if prompt (concat prompt ": ") "Tags: ")
org-last-tags-completion-table nil nil nil
'org-tags-history))
":")))
(when (org-string-nw-p ins)
(push (concat ":" ins ":") strings-all)
(unless (eq (char-before) ?:) (insert ":"))
(insert ins)
(unless (eq (char-after) ?:) (insert ":"))
(when (org-at-heading-p) (org-align-tags)))))
((or "C" "L")
(let ((insert-fun (if (equal key "C") #'insert
(lambda (s) (org-insert-link 0 s)))))
(pcase org-capture--clipboards
(`nil nil)
(`(,value)
(funcall insert-fun value)
(push value strings-all))
(`(,first-value . ,_)
(funcall insert-fun
(let ((val
(read-string "Clipboard/kill value: "
first-value
'org-capture--clipboards
first-value)))
(push val strings-all)
val)))
(_ (error "Invalid `org-capture--clipboards' value: %S"
org-capture--clipboards)))))
("p"
;; We remove keyword properties inherited from
;; target buffer so `org-read-property-value' has
;; a chance to find allowed values in sub-trees
;; from the target buffer.
(setq-local org-keyword-properties nil)
(let* ((origin (set-marker (make-marker)
(org-capture-get :pos)
(org-capture-get :buffer)))
;; Find location from where to get allowed
;; values. If `:target-entry-p' is
;; non-nil, the current headline in the
;; target buffer is going to be a parent
;; headline, so location is fine.
;; Otherwise, find the parent headline in
;; the target buffer.
(pom (if (org-capture-get :target-entry-p) origin
(let ((level (progn
(while (org-up-heading-safe))
(org-current-level))))
(org-with-point-at origin
(let ((l (if (org-at-heading-p)
(org-current-level)
most-positive-fixnum)))
(while (and l (>= l level))
(setq l (org-up-heading-safe)))
(if l (point-marker)
(point-min-marker)))))))
(value
(org-read-property-value prompt pom default)))
(org-set-property prompt value)
(push value strings-all)))
((or "t" "T" "u" "U")
;; These are the date/time related ones.
(let* ((upcase? (equal (upcase key) key))
(org-end-time-was-given nil)
(time (org-read-date upcase? t nil prompt)))
(push
(org-insert-timestamp
time (or org-time-was-given upcase?)
(member key '("u" "U"))
nil nil (list org-end-time-was-given))
strings-all)))
(`nil
;; Load history list for current prompt.
(setq org-capture--prompt-history
(gethash prompt org-capture--prompt-history-table))
(push (org-completing-read
(org-format-prompt (or prompt "Enter string") default)
completions
nil nil nil 'org-capture--prompt-history default)
strings)
(push (car strings) strings-all)
(insert (car strings))
;; Save updated history list for current prompt.
(puthash prompt org-capture--prompt-history
org-capture--prompt-history-table))
(_
(error "Unknown template placeholder: \"%%^%s\""
key))))))))
;; Replace %n escapes with nth %^{...} string.
(setq strings (nreverse strings))
(save-excursion
(while (re-search-forward "%\\\\\\([1-9][0-9]*\\)" nil t)
(unless (org-capture-escaped-%)
(replace-match
(nth (1- (string-to-number (match-string 1))) strings)
nil t))))
;; Replace %*n escapes with nth %^{...} string.
(setq strings-all (nreverse strings-all))
(save-excursion
(while (re-search-forward "%\\\\\\(\\*\\([1-9][0-9]*\\)\\)" nil t)
(unless (org-capture-escaped-%)
(replace-match
(nth (1- (string-to-number (match-string 2))) strings-all)
nil t)))))
;; Make sure there are no empty lines before the text, and that
;; it ends with a newline character or it is empty.
(skip-chars-forward " \t\n")
(delete-region (point-min) (line-beginning-position))
(goto-char (point-max))
(skip-chars-backward " \t\n")
(if (bobp) (delete-region (point) (line-end-position))
(end-of-line)
(delete-region (point) (point-max))
(insert "\n"))
;; Return the expanded template and kill the capture buffer.
(untabify (point-min) (point-max))
(buffer-substring-no-properties (point-min) (point-max)))
(when (buffer-live-p capture-tmp-buffer)
(with-current-buffer capture-tmp-buffer
(set-buffer-modified-p nil)
(kill-buffer)))))))
(defun org-capture-escaped-% ()
"Non-nil if % was escaped.

View File

@ -3,7 +3,7 @@
;; Copyright (C) 2004-2024 Free Software Foundation, Inc.
;; Author: Carsten Dominik <carsten.dominik@gmail.com>
;; Keywords: outlines, hypermedia, calendar, wp
;; Keywords: outlines, hypermedia, calendar, text
;; URL: https://orgmode.org
;;
;; This file is part of GNU Emacs.
@ -56,6 +56,8 @@
(declare-function dbus-list-activatable-names "dbus" (&optional bus))
(declare-function dbus-call-method "dbus" (bus service path interface method &rest args))
(declare-function dbus-get-property "dbus" (bus service path interface property))
(declare-function haiku-notifications-notify "haikuselect.c")
(declare-function android-notifications-notify "androidselect.c")
(defvar org-frame-title-format-backup nil)
(defvar org-state)
@ -808,6 +810,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.
@ -884,6 +887,18 @@ use libnotify if available, or fall back on a message."
((stringp org-show-notification-handler)
(start-process "emacs-timer-notification" nil
org-show-notification-handler notification))
((fboundp 'haiku-notifications-notify)
;; N.B. timeouts are not available under Haiku.
(haiku-notifications-notify :title "Org mode message"
:body notification
:urgency 'low))
((fboundp 'android-notifications-notify)
;; N.B. timeouts are not available under Haiku or Android.
(android-notifications-notify :title "Org mode message"
:body notification
;; Low urgency notifications
;; are by default hidden.
:urgency 'normal))
((fboundp 'w32-notification-notify)
(let ((id (w32-notification-notify
:title "Org mode message"
@ -1414,7 +1429,7 @@ the default behavior."
((and org-clock-in-switch-to-state
(not (looking-at (concat org-outline-regexp "[ \t]*"
org-clock-in-switch-to-state
"\\>"))))
"\\(?:[ \t]\\|$\\)"))))
(org-todo org-clock-in-switch-to-state)))
(setq org-clock-heading (org-clock--mode-line-heading))
(org-clock-find-position org-clock-in-resume)
@ -1824,7 +1839,7 @@ to, overriding the existing value of `org-clock-out-switch-to-state'."
(concat
org-outline-regexp "[ \t]*"
org-clock-out-switch-to-state
"\\>"))))
"\\(?:[ \t]\\|$\\)"))))
(org-todo org-clock-out-switch-to-state))))))
(force-mode-line-update)
(message (if remove
@ -3111,8 +3126,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

@ -3,7 +3,7 @@
;; Copyright (C) 2004-2024 Free Software Foundation, Inc.
;; Author: Carsten Dominik <carsten.dominik@gmail.com>
;; Keywords: outlines, hypermedia, calendar, wp
;; Keywords: outlines, hypermedia, calendar, text
;; URL: https://orgmode.org
;;
;; This file is part of GNU Emacs.
@ -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

@ -3,7 +3,7 @@
;; Copyright (C) 2004-2024 Free Software Foundation, Inc.
;; Author: Carsten Dominik <carsten.dominik@gmail.com>
;; Keywords: outlines, hypermedia, calendar, wp
;; Keywords: outlines, hypermedia, calendar, text
;; URL: https://orgmode.org
;;
;; This file is part of GNU Emacs.
@ -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

@ -3,7 +3,7 @@
;; Copyright (C) 2007-2024 Free Software Foundation, Inc.
;; Author: Paul Sexton <eeeickythump@gmail.com>
;; Keywords: org, wp
;; Keywords: org, text
;; This file is part of GNU Emacs.
;;
@ -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
@ -156,11 +162,29 @@ Format is: /REGEXP/TAGNAME/FLAGS,TAGTYPE/
See the ctags documentation for more information.")
(defcustom org-ctags-path-to-ctags
(if (executable-find "ctags-exuberant") "ctags-exuberant" "ctags")
(cond ((executable-find "ctags-exuberant")
"ctags-exuberant")
((boundp 'ctags-program-name)
ctags-program-name)
(t "ctags")) ; Emacs < 30
"Name of the ctags executable file."
: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 +192,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 +208,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 +230,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 +327,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 +508,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 +557,6 @@ a new topic."
'org-open-link-functions tag))))))
(org-ctags-enable)
(provide 'org-ctags)
;;; org-ctags.el ends here

View File

@ -633,7 +633,7 @@ With a numeric prefix, show all headlines up to that level."
(org-cycle-content 5))
;; `nofold' and `showall' are technically not allowed values, but
;; they are often intuitively tried by users by analogy with
;; #+STARTUP: nofold or #STARUP: showall.
;; #+STARTUP: nofold or #STARTUP: showall.
((memq org-startup-folded '(showeverything nil nofold showall))
(org-fold-show-all)))
(unless (eq org-startup-folded 'showeverything)

View File

@ -3,7 +3,7 @@
;; Copyright (C) 2009-2024 Free Software Foundation, Inc.
;; Author: Carsten Dominik <carsten.dominik@gmail.com>
;; Keywords: outlines, hypermedia, calendar, wp
;; Keywords: outlines, hypermedia, calendar, text
;; URL: https://orgmode.org
;;
;; This file is part of GNU Emacs.

View File

@ -3,7 +3,7 @@
;; Copyright (C) 2017-2024 Free Software Foundation, Inc.
;; Author: Nicolas Goaziou <mail@nicolasgoaziou.fr>
;; Keywords: outlines, hypermedia, calendar, wp
;; Keywords: outlines, hypermedia, calendar, text
;; This file is part of GNU Emacs.
@ -324,109 +324,110 @@ When optional argument CANONICAL is non-nil, ignore
`org-duration-units' and use standard time units value.
Raise an error if expected format is unknown."
(pcase (or fmt org-duration-format)
(`h:mm
(format "%d:%02d" (/ minutes 60) (mod minutes 60)))
(`h:mm:ss
(let* ((whole-minutes (floor minutes))
(seconds (mod (* 60 minutes) 60)))
(format "%s:%02d"
(org-duration-from-minutes whole-minutes 'h:mm)
seconds)))
((pred atom) (error "Invalid duration format specification: %S" fmt))
;; Mixed format. Call recursively the function on both parts.
((and duration-format
(let `(special . ,(and mode (or `h:mm:ss `h:mm)))
(assq 'special duration-format)))
(let* ((truncated-format
;; Remove "special" mode from duration format in order to
;; recurse properly. Also remove units smaller or equal
;; to an hour since H:MM part takes care of it.
(cl-remove-if-not
(lambda (pair)
(pcase pair
(`(,(and unit (pred stringp)) . ,_)
(> (org-duration--modifier unit canonical) 60))
(_ nil)))
duration-format))
(min-modifier ;smallest modifier above hour
(and truncated-format
(apply #'min
(mapcar (lambda (p)
(org-duration--modifier (car p) canonical))
truncated-format)))))
(if (or (null min-modifier) (< minutes min-modifier))
;; There is not unit above the hour or the smallest unit
;; above the hour is too large for the number of minutes we
;; need to represent. Use H:MM or H:MM:SS syntax.
(org-duration-from-minutes minutes mode canonical)
;; Represent minutes above hour using provided units and H:MM
;; or H:MM:SS below.
(let* ((units-part (* min-modifier (/ (floor minutes) min-modifier)))
(minutes-part (- minutes units-part))
(compact (memq 'compact duration-format)))
(concat
(org-duration-from-minutes units-part truncated-format canonical)
(and (not compact) " ")
(org-duration-from-minutes minutes-part mode))))))
;; Units format.
(duration-format
(let* ((fractional
(let ((digits (cdr (assq 'special duration-format))))
(and digits
(or (wholenump digits)
(error "Unknown formatting directive: %S" digits))
(format "%%.%df" digits))))
(selected-units
(sort (cl-remove-if
;; Ignore special format cells and compact option.
(lambda (pair)
(pcase pair
((or `compact `(special . ,_)) t)
(_ nil)))
duration-format)
(lambda (a b)
(> (org-duration--modifier (car a) canonical)
(org-duration--modifier (car b) canonical)))))
(separator (if (memq 'compact duration-format) "" " ")))
(cond
;; Fractional duration: use first unit that is either required
;; or smaller than MINUTES.
(fractional
(let* ((unit (car
(or (cl-find-if
(lambda (pair)
(pcase pair
(`(,u . ,req?)
(or req?
(<= (org-duration--modifier u canonical)
minutes)))))
selected-units)
;; Fall back to smallest unit.
(org-last selected-units))))
(modifier (org-duration--modifier unit canonical)))
(concat (format fractional (/ (float minutes) modifier)) unit)))
;; Otherwise build duration string according to available
;; units.
((org-string-nw-p
(org-trim
(mapconcat
(lambda (units)
(pcase-let* ((`(,unit . ,required?) units)
(modifier (org-duration--modifier unit canonical)))
(cond ((<= modifier minutes)
(let ((value (floor minutes modifier)))
(cl-decf minutes (* value modifier))
(format "%s%d%s" separator value unit)))
(required? (concat separator "0" unit))
(t ""))))
selected-units
""))))
;; No unit can properly represent MINUTES. Use the smallest
;; one anyway.
(t
(pcase-let ((`((,unit . ,_)) (last selected-units)))
(concat "0" unit))))))))
(if (< minutes 0) (concat "-" (org-duration-from-minutes (abs minutes) fmt canonical))
(pcase (or fmt org-duration-format)
(`h:mm
(format "%d:%02d" (/ minutes 60) (mod minutes 60)))
(`h:mm:ss
(let* ((whole-minutes (floor minutes))
(seconds (mod (* 60 minutes) 60)))
(format "%s:%02d"
(org-duration-from-minutes whole-minutes 'h:mm)
seconds)))
((pred atom) (error "Invalid duration format specification: %S" fmt))
;; Mixed format. Call recursively the function on both parts.
((and duration-format
(let `(special . ,(and mode (or `h:mm:ss `h:mm)))
(assq 'special duration-format)))
(let* ((truncated-format
;; Remove "special" mode from duration format in order to
;; recurse properly. Also remove units smaller or equal
;; to an hour since H:MM part takes care of it.
(cl-remove-if-not
(lambda (pair)
(pcase pair
(`(,(and unit (pred stringp)) . ,_)
(> (org-duration--modifier unit canonical) 60))
(_ nil)))
duration-format))
(min-modifier ;smallest modifier above hour
(and truncated-format
(apply #'min
(mapcar (lambda (p)
(org-duration--modifier (car p) canonical))
truncated-format)))))
(if (or (null min-modifier) (< minutes min-modifier))
;; There is not unit above the hour or the smallest unit
;; above the hour is too large for the number of minutes we
;; need to represent. Use H:MM or H:MM:SS syntax.
(org-duration-from-minutes minutes mode canonical)
;; Represent minutes above hour using provided units and H:MM
;; or H:MM:SS below.
(let* ((units-part (* min-modifier (/ (floor minutes) min-modifier)))
(minutes-part (- minutes units-part))
(compact (memq 'compact duration-format)))
(concat
(org-duration-from-minutes units-part truncated-format canonical)
(and (not compact) " ")
(org-duration-from-minutes minutes-part mode))))))
;; Units format.
(duration-format
(let* ((fractional
(let ((digits (cdr (assq 'special duration-format))))
(and digits
(or (wholenump digits)
(error "Unknown formatting directive: %S" digits))
(format "%%.%df" digits))))
(selected-units
(sort (cl-remove-if
;; Ignore special format cells and compact option.
(lambda (pair)
(pcase pair
((or `compact `(special . ,_)) t)
(_ nil)))
duration-format)
(lambda (a b)
(> (org-duration--modifier (car a) canonical)
(org-duration--modifier (car b) canonical)))))
(separator (if (memq 'compact duration-format) "" " ")))
(cond
;; Fractional duration: use first unit that is either required
;; or smaller than MINUTES.
(fractional
(let* ((unit (car
(or (cl-find-if
(lambda (pair)
(pcase pair
(`(,u . ,req?)
(or req?
(<= (org-duration--modifier u canonical)
minutes)))))
selected-units)
;; Fall back to smallest unit.
(org-last selected-units))))
(modifier (org-duration--modifier unit canonical)))
(concat (format fractional (/ (float minutes) modifier)) unit)))
;; Otherwise build duration string according to available
;; units.
((org-string-nw-p
(org-trim
(mapconcat
(lambda (units)
(pcase-let* ((`(,unit . ,required?) units)
(modifier (org-duration--modifier unit canonical)))
(cond ((<= modifier minutes)
(let ((value (floor minutes modifier)))
(cl-decf minutes (* value modifier))
(format "%s%d%s" separator value unit)))
(required? (concat separator "0" unit))
(t ""))))
selected-units
""))))
;; No unit can properly represent MINUTES. Use the smallest
;; one anyway.
(t
(pcase-let ((`((,unit . ,_)) (last selected-units)))
(concat "0" unit)))))))))
;;;###autoload
(defun org-duration-h:mm-only-p (times)

View File

@ -4,7 +4,7 @@
;; Author: Nicolas Goaziou <n.goaziou at gmail dot com>
;; Maintainer: Ihor Radchenko <yantar92 at posteo dot net>
;; Keywords: outlines, hypermedia, calendar, wp
;; Keywords: outlines, hypermedia, calendar, text
;; This file is part of GNU Emacs.
@ -648,7 +648,7 @@ IMPORTANT: The buffer copy may also have variable `buffer-file-name'
copied.
To prevent Emacs overwriting the original buffer file,
`write-contents-functions' is set to \='(always). Do not alter this
`write-contents-functions' is set to \\='(always). Do not alter this
variable and do not do anything that might alter it (like calling a
major mode) to prevent data corruption. Also, do note that Emacs may
jump into the created buffer if the original file buffer is closed and
@ -3274,7 +3274,7 @@ CONTENTS is verse block contents."
;; object types they can contain will be specified in
;; `org-element-object-restrictions'.
;;
;; Creating a new type of object requires to alter
;; Creating a new type of object requires altering
;; `org-element--object-regexp' and `org-element--object-lex', add the
;; new type in `org-element-all-objects', and possibly add
;; restrictions in `org-element-object-restrictions'.
@ -3874,7 +3874,7 @@ Assume point is at the beginning of the link."
;;
;; Also treat any newline character and associated
;; indentation as a single space character. This is not
;; compatible with RFC 3986, which requires to ignore
;; compatible with RFC 3986, which requires ignoring
;; them altogether. However, doing so would require
;; users to encode spaces on the fly when writing links
;; (e.g., insert [[shell:ls%20*.org]] instead of
@ -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 bracket: [ 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 ()
@ -4795,8 +4823,6 @@ element it has to parse."
(looking-at-p rule-regexp)))))))
(org-element-table-parser limit affiliated))
;; List.
;; FIXME: Instead of generating regexps, we should
;; better use a constant.
((looking-at-p (org-item-re))
(org-element-plain-list-parser
limit affiliated
@ -6121,11 +6147,8 @@ This function assumes `org-element--headline-cache' is a valid AVL tree."
;;;; Tools
;; FIXME: Ideally, this should be inlined to avoid overheads, but
;; inlined functions should be declared before the code that uses them
;; and some code above does use `org-element--cache-active-p'. Moving this
;; declaration on top would require restructuring the whole cache
;; section.
;; FIXME: `org-fold-core-cycle-over-indirect-buffers' should better be
;; taken out of org-fold-core to track indirect buffers in general.
(defun org-element--cache-active-p (&optional called-from-cache-change-func-p)
"Non-nil when cache is active in current buffer.
When CALLED-FROM-CACHE-CHANGE-FUNC-P is non-nil, do not assert cache
@ -7224,6 +7247,11 @@ that range. See `after-change-functions' for more information."
(when (buffer-base-buffer)
(setq-local org-element--cache nil)
(setq-local org-element--headline-cache nil))
;; Register current buffer in `org-fold-core--indirect-buffers' to
;; be used within `org-fold-core-cycle-over-indirect-buffers'.
;; FIXME: We should eventually factor out indirect buffer tracking
;; from org-fold-core.
(org-fold-core-decouple-indirect-buffer-folds)
(add-hook 'before-change-functions
#'org-element--cache-before-change nil t)
;; Run `org-element--cache-after-change' early to handle cases
@ -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

@ -4,7 +4,7 @@
;; Author: Carsten Dominik <carsten.dominik@gmail.com>,
;; Ulf Stegemann <ulf at zeitform dot de>
;; Keywords: outlines, calendar, wp
;; Keywords: outlines, calendar, text
;; URL: https://orgmode.org
;;
;; This file is part of GNU Emacs.

View File

@ -3,7 +3,7 @@
;; Copyright (C) 2004-2024 Free Software Foundation, Inc.
;; Author: Carsten Dominik <carsten.dominik@gmail.com>
;; Keywords: outlines, hypermedia, calendar, wp
;; Keywords: outlines, hypermedia, calendar, text
;; URL: https://orgmode.org
;;
;; This file is part of GNU Emacs.

View File

@ -3,7 +3,7 @@
;; Copyright (C) 2009-2024 Free Software Foundation, Inc.
;;
;; Author: Carsten Dominik <carsten.dominik@gmail.com>
;; Keywords: outlines, hypermedia, calendar, wp
;; Keywords: outlines, hypermedia, calendar, text
;; URL: https://orgmode.org
;;
;; This file is part of GNU Emacs.

View File

@ -290,7 +290,7 @@ generally less error-prone with regard to third-party packages.
Important: This variable must be set before loading Org."
:group 'org
:package-version '(Org . "9.6")
:package-version '(Org . "9.7")
:type '(choice
(const :tag "Overlays" overlays)
(const :tag "Text properties" text-properties)))
@ -581,15 +581,6 @@ unless RETURN-ONLY is non-nil."
;; would contain folding properties, which are not
;; matching the generated `local-prop'.
(unless (member local-prop (cdr (assq 'invisible char-property-alias-alist)))
;; Add current buffer to the list of indirect buffers in the base buffer.
(when (buffer-base-buffer)
(with-current-buffer (buffer-base-buffer)
(setq-local org-fold-core--indirect-buffers
(let (bufs)
(org-fold-core-cycle-over-indirect-buffers
(push (current-buffer) bufs))
(push buf bufs)
(delete-dups bufs)))))
;; Copy all the old folding properties to preserve the folding state
(with-silent-modifications
(dolist (old-prop (cdr (assq 'invisible char-property-alias-alist)))
@ -648,6 +639,16 @@ unless RETURN-ONLY is non-nil."
"Copy and decouple folding state in a newly created indirect buffer.
This function is mostly intended to be used in
`clone-indirect-buffer-hook'."
;; Add current buffer to the list of indirect buffers in the base buffer.
(when (buffer-base-buffer)
(let ((new-buffer (current-buffer)))
(with-current-buffer (buffer-base-buffer)
(setq-local org-fold-core--indirect-buffers
(let (bufs)
(org-fold-core-cycle-over-indirect-buffers
(push (current-buffer) bufs))
(push new-buffer bufs)
(delete-dups bufs))))))
(when (and (buffer-base-buffer)
(eq org-fold-core-style 'text-properties)
(not (memql 'ignore-indirect org-fold-core--optimise-for-huge-buffers)))
@ -705,7 +706,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 +1095,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 +1246,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

@ -3,7 +3,7 @@
;; Copyright (C) 2009-2024 Free Software Foundation, Inc.
;;
;; Author: Carsten Dominik <carsten.dominik@gmail.com>
;; Keywords: outlines, hypermedia, calendar, wp
;; Keywords: outlines, hypermedia, calendar, text
;; URL: https://orgmode.org
;;
;; This file is part of GNU Emacs.
@ -143,11 +143,12 @@ confirm Like t, but let the user edit the created value.
an anonymous footnote.
random Automatically generate a unique, random label."
:group 'org-footnote
:package-version '(Org . "9.7")
:type '(choice
(const :tag "Prompt for label" nil)
(const :tag "Create automatic [fn:N]" t)
(const :tag "Offer automatic [fn:N] for editing" confirm)
(const :tag "Create anoymous [fn::]" anonymous)
(const :tag "Create anonymous [fn::]" anonymous)
(const :tag "Create a random label" random))
:safe #'symbolp)

View File

@ -3,7 +3,7 @@
;; Copyright (C) 2012-2024 Free Software Foundation, Inc.
;; Author: Carsten Dominik <carsten.dominik@gmail.com>
;; Keywords: outlines, hypermedia, calendar, wp
;; Keywords: outlines, hypermedia, calendar, text
;; This file is part of GNU Emacs.

View File

@ -3,7 +3,7 @@
;; Copyright (C) 2009-2024 Free Software Foundation, Inc.
;; Author: John Wiegley <johnw at gnu dot org>
;; Keywords: outlines, hypermedia, calendar, wp
;; Keywords: outlines, hypermedia, calendar, text
;; URL: https://orgmode.org
;;
;; This file is part of GNU Emacs.

View File

@ -3,7 +3,7 @@
;; Copyright (C) 2008-2024 Free Software Foundation, Inc.
;;
;; Author: Carsten Dominik <carsten.dominik@gmail.com>
;; Keywords: outlines, hypermedia, calendar, wp
;; Keywords: outlines, hypermedia, calendar, text
;; URL: https://orgmode.org
;;
;; This file is part of GNU Emacs.

View File

@ -3,7 +3,7 @@
;; Copyright (C) 2009-2024 Free Software Foundation, Inc.
;;
;; Author: Carsten Dominik <carsten.dominik@gmail.com>
;; Keywords: outlines, hypermedia, calendar, wp
;; Keywords: outlines, hypermedia, calendar, text
;; URL: https://orgmode.org
;;
;; This file is part of GNU Emacs.

View File

@ -3,7 +3,7 @@
;; Copyright (C) 2009-2024 Free Software Foundation, Inc.
;;
;; Author: Carsten Dominik <carsten.dominik@gmail.com>
;; Keywords: outlines, hypermedia, calendar, wp
;; Keywords: outlines, hypermedia, calendar, text
;; URL: https://orgmode.org
;; This file is part of GNU Emacs.

View File

@ -760,8 +760,7 @@ command."
(defun org--print-speed-command (speed-command)
"Print information about SPEED-COMMAND in help buffer.
SPEED-COMMAND is an element of `org-speed-commands' or
`org-speed-commands-user'."
SPEED-COMMAND is an element of `org-speed-commands'."
(if (> (length (car speed-command)) 1)
(progn
(princ "\n")
@ -783,12 +782,7 @@ SPEED-COMMAND is an element of `org-speed-commands' or
(user-error "Speed commands are not activated, customize `org-use-speed-commands'"))
(with-output-to-temp-buffer "*Help*"
(princ "Speed commands\n==============\n")
(mapc #'org--print-speed-command
;; FIXME: don't check `org-speed-commands-user' past 9.6
(if (boundp 'org-speed-commands-user)
(append org-speed-commands
org-speed-commands-user)
org-speed-commands)))
(mapc #'org--print-speed-command org-speed-commands))
(with-current-buffer "*Help*"
(setq truncate-lines t)))
@ -809,12 +803,7 @@ See `org-speed-commands' for configuring them."
(when (or (and (bolp) (looking-at org-outline-regexp))
(and (functionp org-use-speed-commands)
(funcall org-use-speed-commands)))
(cdr (assoc keys
;; FIXME: don't check `org-speed-commands-user' past 9.6
(if (boundp 'org-speed-commands-user)
(append org-speed-commands
org-speed-commands-user)
org-speed-commands)))))
(cdr (assoc keys org-speed-commands))))
;;; Babel speed keys

View File

@ -3,7 +3,7 @@
;; Copyright (C) 2015-2024 Free Software Foundation, Inc.
;; Author: Nicolas Goaziou <mail@nicolasgoaziou.fr>
;; Keywords: outlines, hypermedia, calendar, wp
;; Keywords: outlines, hypermedia, calendar, text
;; This file is part of GNU Emacs.
@ -159,6 +159,16 @@ checker. Currently, two properties are supported:
(seq-remove (lambda (c) (eq name (org-lint-checker-name c)))
org-lint--checkers))))
;;;###autoload
(defun org-lint-remove-checker (name &rest names)
"Remove checker(s) from linter.
NAME is the unique check identifier, as a non-nil symbol. NAMES
are additional check identifiers to be removed."
(let ((removelist (cons name names)))
(setq org-lint--checkers
(seq-remove (lambda (c) (memq (org-lint-checker-name c) removelist))
org-lint--checkers))))
;;; Reports UI
@ -388,14 +398,25 @@ called with one argument, the key used for comparison."
(dolist (e originals reports) (funcall make-report (cdr e) (car e)))))
(defun org-lint-misplaced-heading (ast)
"Check for accidentally misplaced heading lines."
"Check for accidentally misplaced heading lines.
Example:
** Heading 1
** Heading 2** Oops heading 3
** Heading 4"
(org-with-point-at ast
(goto-char (point-min))
(let (result)
;; Heuristics for 2+ level heading not at bol.
(while (re-search-forward (rx (not (any "*\n\r ,")) ;; Not a bol; not escaped ,** heading; not " *** words"
"*" (1+ "*") " ") nil t)
(push (list (match-beginning 0) "Possibly misplaced heading line") result))
;; Limit false-positive rate by only complaining about
;; ** Heading** Heading and
;; ** Oops heading
;; Paragraph** Oops heading
(when (org-element-type-p
(org-element-at-point)
'(paragraph headline))
(push (list (match-beginning 0) "Possibly misplaced heading line") result)))
result)))
(defun org-lint-duplicate-custom-id (ast)
@ -541,7 +562,10 @@ Use :header-args: instead"
(org-element-map ast 'src-block
(lambda (b)
(when-let ((lang (org-element-property :language b)))
(unless (functionp (intern (format "org-babel-execute:%s" lang)))
(unless (or (functionp (intern (format "org-babel-execute:%s" lang)))
;; No babel backend, but there is corresponding
;; major mode.
(fboundp (org-src-get-lang-mode lang)))
(list (org-element-property :post-affiliated b)
(format "Unknown source block language: '%s'" lang)))))))

View File

@ -4,7 +4,7 @@
;;
;; Author: Carsten Dominik <carsten.dominik@gmail.com>
;; Bastien Guerry <bzg@gnu.org>
;; Keywords: outlines, hypermedia, calendar, wp
;; Keywords: outlines, hypermedia, calendar, text
;; URL: https://orgmode.org
;;
;; This file is part of GNU Emacs.
@ -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

@ -3,7 +3,7 @@
;; Copyright (C) 2013-2024 Free Software Foundation, Inc.
;; Author: Nicolas Goaziou <n.goaziou@gmail.com>
;; Keywords: outlines, hypermedia, calendar, wp
;; Keywords: outlines, hypermedia, calendar, text
;; This file is part of GNU Emacs.

View File

@ -3,7 +3,7 @@
;; Copyright (C) 2004-2024 Free Software Foundation, Inc.
;; Author: Carsten Dominik <carsten.dominik@gmail.com>
;; Keywords: outlines, hypermedia, calendar, wp
;; Keywords: outlines, hypermedia, calendar, text
;; URL: https://orgmode.org
;;
;; This file is part of GNU Emacs.
@ -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" ())
@ -268,6 +267,7 @@ This function is only useful when called from Agenda buffer."
(unless modified
(restore-buffer-modified-p nil))))))))
;;;###autoload
(defmacro org-element-with-disabled-cache (&rest body)
"Run BODY without active org-element-cache."
(declare (debug (form body)) (indent 0))
@ -815,7 +815,7 @@ Match at beginning of line when WITH-BOL is non-nil."
(and (not (bobp))
(save-excursion
(forward-line n)
(skip-chars-forward "[ \t]")
(skip-chars-forward " \t")
(eolp))))
(defun org-previous-line-empty-p ()
@ -982,20 +982,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)
@ -1244,6 +1291,10 @@ Assumes that s is a single line, starting in column 0."
t t s)))
s)
(defun org-remove-blank-lines (s)
"Remove blank lines in S."
(replace-regexp-in-string (rx "\n" (1+ (0+ space) "\n")) "\n" s))
(defun org-wrap (string &optional width lines)
"Wrap string to either a number of lines, or a width in characters.
If WIDTH is non-nil, the string is wrapped to that width, however many lines
@ -1744,6 +1795,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

@ -2,7 +2,7 @@
;; Copyright (C) 2009-2024 Free Software Foundation, Inc.
;;
;; Author: Carsten Dominik <carsten.dominik@gmail.com>
;; Keywords: outlines, hypermedia, calendar, wp
;; Keywords: outlines, hypermedia, calendar, text
;; URL: https://orgmode.org
;;
;; This file is part of GNU Emacs.
@ -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])
@ -859,6 +862,10 @@ This means, between the beginning of line and the point."
(org-mouse-in-region-p (posn-point (event-start event))))
(mouse-drag-region event)))
;; This function conflicts with touch screen gestures as it relays
;; events to `mouse-drag-region'.
(put 'org-mouse-down-mouse 'ignored-mouse-command t)
(add-hook 'org-mode-hook
(lambda ()
(setq org-mouse-context-menu-function #'org-mouse-context-menu)

View File

@ -3,7 +3,7 @@
;; Copyright (C) 2018-2024 Free Software Foundation, Inc.
;; Author: Nicolas Goaziou <mail@nicolasgoaziou.fr>
;; Keywords: outlines, hypermedia, calendar, wp
;; Keywords: outlines, hypermedia, calendar, text
;; This file is part of GNU Emacs.

View File

@ -4,7 +4,7 @@
;;
;; Author: Carsten Dominik <carsten.dominik@gmail.com>
;; John Wiegley <johnw at gnu dot org>
;; Keywords: outlines, hypermedia, calendar, wp
;; Keywords: outlines, hypermedia, calendar, text
;; URL: https://orgmode.org
;;
;; This file is part of GNU Emacs.
@ -24,7 +24,7 @@
;;; Commentary:
;; This library implementes completion support in Org mode buffers.
;; This library implements completion support in Org mode buffers.
;;; Code:

View File

@ -452,7 +452,7 @@ FORMAT and ARGS are passed to `message'."
"Write elisp DATA to FILE."
;; Fsync slightly reduces the chance of an incomplete filesystem
;; write, however on modern hardware its effectiveness is
;; questionable and it is insufficient to garantee complete writes.
;; questionable and it is insufficient to guarantee complete writes.
;; Coupled with the significant performance hit if writing many
;; small files, it simply does not make sense to use fsync here,
;; particularly as cache corruption is only a minor inconvenience.
@ -476,12 +476,17 @@ FORMAT and ARGS are passed to `message'."
(start-time (float-time)))
(unless (file-exists-p (file-name-directory file))
(make-directory (file-name-directory file) t))
(with-temp-file file
(insert ";; -*- mode: lisp-data; -*-\n")
(if pp
(let ((pp-use-max-width nil)) ; Emacs bug#58687
(pp data (current-buffer)))
(prin1 data (current-buffer))))
;; Force writing even when the file happens to be opened by
;; another Emacs process.
(cl-letf (((symbol-function #'ask-user-about-lock)
;; FIXME: Emacs 27 does not yet have `always'.
(lambda (&rest _) t)))
(with-temp-file file
(insert ";; -*- mode: lisp-data; -*-\n")
(if pp
(let ((pp-use-max-width nil)) ; Emacs bug#58687
(pp data (current-buffer)))
(prin1 data (current-buffer)))))
(org-persist--display-time
(- (float-time) start-time)
"Writing to %S" file)))

View File

@ -7,7 +7,7 @@
;; Sebastian Rose <sebastian_rose AT gmx DOT de>
;; Ross Patterson <me AT rpatterson DOT net>
;; Maintainer: Sebastian Rose <sebastian_rose AT gmx DOT de>
;; Keywords: org, emacsclient, wp
;; Keywords: org, emacsclient, text
;; This file is part of GNU Emacs.
;;

View File

@ -3,7 +3,7 @@
;; Copyright (C) 2010-2024 Free Software Foundation, Inc.
;; Author: Carsten Dominik <carsten.dominik@gmail.com>
;; Keywords: outlines, hypermedia, calendar, wp
;; Keywords: outlines, hypermedia, calendar, text
;;
;; This file is part of GNU Emacs.

View File

@ -5,7 +5,7 @@
;; Author: Carsten Dominik <carsten.dominik@gmail.com>
;; Bastien Guerry <bzg@gnu.org>
;; Dan Davison <davison at stats dot ox dot ac dot uk>
;; Keywords: outlines, hypermedia, calendar, wp
;; Keywords: outlines, hypermedia, calendar, text
;; URL: https://orgmode.org
;;
;; This file is part of GNU Emacs.
@ -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

@ -3,7 +3,7 @@
;; Copyright (C) 2004-2024 Free Software Foundation, Inc.
;; Author: Carsten Dominik <carsten.dominik@gmail.com>
;; Keywords: outlines, hypermedia, calendar, wp
;; Keywords: outlines, hypermedia, calendar, text
;; URL: https://orgmode.org
;;
;; This file is part of GNU Emacs.
@ -419,7 +419,7 @@ It is probably good to never set this variable to nil, for the sake of
portability of tables."
:group 'org-table-calculation
:type '(choice
(const :tag "Allow to cross" t)
(const :tag "Allow crossing hline" t)
(const :tag "Stick to hline" nil)
(const :tag "Error on attempt to cross" error)))
@ -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
@ -3929,7 +3935,7 @@ When non-nil, return the overlay narrowing the field."
;; Aligning table from the first row will not shrink again the
;; second row, which was not visible initially.
;;
;; However, fixing it requires to check every row, which may be
;; However, fixing it requires checking every row, which may be
;; slow on large tables. Moreover, the hindrance of this
;; pathological case is very limited.
(forward-line 0)
@ -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?
@ -5219,7 +5225,7 @@ When LOCAL is non-nil, show references for the table at point."
;; accident in Org mode.
(message "Orgtbl mode is not useful in Org mode, command ignored"))
(orgtbl-mode
(and (orgtbl-setup) (defun orgtbl-setup () nil)) ;; FIXME: Yuck!?!
(orgtbl-setup)
;; Make sure we are first in minor-mode-map-alist
(let ((c (assq 'orgtbl-mode minor-mode-map-alist)))
;; FIXME: maybe it should use emulation-mode-map-alists?
@ -5274,92 +5280,91 @@ to execute outside of tables."
(interactive)
(user-error "This key has no function outside tables"))
;; Fill in orgtbl keymap.
(let ((nfunc 0)
(bindings
'(([(meta shift left)] org-table-delete-column)
([(meta left)] org-table-move-column-left)
([(meta right)] org-table-move-column-right)
([(meta shift right)] org-table-insert-column)
([(meta shift up)] org-table-kill-row)
([(meta shift down)] org-table-insert-row)
([(meta up)] org-table-move-row-up)
([(meta down)] org-table-move-row-down)
("\C-c\C-w" org-table-cut-region)
("\C-c\M-w" org-table-copy-region)
("\C-c\C-y" org-table-paste-rectangle)
("\C-c\C-w" org-table-wrap-region)
("\C-c-" org-table-insert-hline)
("\C-c}" org-table-toggle-coordinate-overlays)
("\C-c{" org-table-toggle-formula-debugger)
("\C-m" org-table-next-row)
([(shift return)] org-table-copy-down)
("\C-c?" org-table-field-info)
("\C-c " org-table-blank-field)
("\C-c+" org-table-sum)
("\C-c=" org-table-eval-formula)
("\C-c'" org-table-edit-formulas)
("\C-c`" org-table-edit-field)
("\C-c*" org-table-recalculate)
("\C-c^" org-table-sort-lines)
("\M-a" org-table-beginning-of-field)
("\M-e" org-table-end-of-field)
([(control ?#)] org-table-rotate-recalc-marks)))
elt key fun cmd)
(while (setq elt (pop bindings))
(setq nfunc (1+ nfunc))
(setq key (org-key (car elt))
fun (nth 1 elt)
cmd (orgtbl-make-binding fun nfunc key))
(org-defkey orgtbl-mode-map key cmd))
;; Special treatment needed for TAB, RET and DEL
(org-defkey orgtbl-mode-map [(return)]
(orgtbl-make-binding 'orgtbl-ret 100 [(return)] "\C-m"))
(org-defkey orgtbl-mode-map "\C-m"
(orgtbl-make-binding 'orgtbl-ret 101 "\C-m" [(return)]))
(org-defkey orgtbl-mode-map [(tab)]
(orgtbl-make-binding 'orgtbl-tab 102 [(tab)] "\C-i"))
(org-defkey orgtbl-mode-map "\C-i"
(orgtbl-make-binding 'orgtbl-tab 103 "\C-i" [(tab)]))
(org-defkey orgtbl-mode-map [(shift tab)]
(orgtbl-make-binding 'org-table-previous-field 104
[(shift tab)] [(tab)] "\C-i"))
(org-defkey orgtbl-mode-map [backspace]
(orgtbl-make-binding 'org-delete-backward-char 109
[backspace] (kbd "DEL")))
(org-defkey orgtbl-mode-map [S-iso-lefttab]
(orgtbl-make-binding 'org-table-previous-field 107
[S-iso-lefttab] [backtab] [(shift tab)]
[(tab)] "\C-i"))
(org-defkey orgtbl-mode-map [backtab]
(orgtbl-make-binding 'org-table-previous-field 108
[backtab] [S-iso-lefttab] [(shift tab)]
[(tab)] "\C-i"))
(org-defkey orgtbl-mode-map "\M-\C-m"
(orgtbl-make-binding 'org-table-wrap-region 105
"\M-\C-m" [(meta return)]))
(org-defkey orgtbl-mode-map [(meta return)]
(orgtbl-make-binding 'org-table-wrap-region 106
[(meta return)] "\M-\C-m"))
(org-defkey orgtbl-mode-map "\C-c\C-c" 'orgtbl-ctrl-c-ctrl-c)
(org-defkey orgtbl-mode-map "\C-c|" 'orgtbl-create-or-convert-from-region))
(defun orgtbl-setup ()
"Setup orgtbl keymaps."
(let ((nfunc 0)
(bindings
'(([(meta shift left)] org-table-delete-column)
([(meta left)] org-table-move-column-left)
([(meta right)] org-table-move-column-right)
([(meta shift right)] org-table-insert-column)
([(meta shift up)] org-table-kill-row)
([(meta shift down)] org-table-insert-row)
([(meta up)] org-table-move-row-up)
([(meta down)] org-table-move-row-down)
("\C-c\C-w" org-table-cut-region)
("\C-c\M-w" org-table-copy-region)
("\C-c\C-y" org-table-paste-rectangle)
("\C-c\C-w" org-table-wrap-region)
("\C-c-" org-table-insert-hline)
("\C-c}" org-table-toggle-coordinate-overlays)
("\C-c{" org-table-toggle-formula-debugger)
("\C-m" org-table-next-row)
([(shift return)] org-table-copy-down)
("\C-c?" org-table-field-info)
("\C-c " org-table-blank-field)
("\C-c+" org-table-sum)
("\C-c=" org-table-eval-formula)
("\C-c'" org-table-edit-formulas)
("\C-c`" org-table-edit-field)
("\C-c*" org-table-recalculate)
("\C-c^" org-table-sort-lines)
("\M-a" org-table-beginning-of-field)
("\M-e" org-table-end-of-field)
([(control ?#)] org-table-rotate-recalc-marks)))
elt key fun cmd)
(while (setq elt (pop bindings))
(setq nfunc (1+ nfunc))
(setq key (org-key (car elt))
fun (nth 1 elt)
cmd (orgtbl-make-binding fun nfunc key))
(org-defkey orgtbl-mode-map key cmd))
;; Special treatment needed for TAB, RET and DEL
(org-defkey orgtbl-mode-map [(return)]
(orgtbl-make-binding 'orgtbl-ret 100 [(return)] "\C-m"))
(org-defkey orgtbl-mode-map "\C-m"
(orgtbl-make-binding 'orgtbl-ret 101 "\C-m" [(return)]))
(org-defkey orgtbl-mode-map [(tab)]
(orgtbl-make-binding 'orgtbl-tab 102 [(tab)] "\C-i"))
(org-defkey orgtbl-mode-map "\C-i"
(orgtbl-make-binding 'orgtbl-tab 103 "\C-i" [(tab)]))
(org-defkey orgtbl-mode-map [(shift tab)]
(orgtbl-make-binding 'org-table-previous-field 104
[(shift tab)] [(tab)] "\C-i"))
(org-defkey orgtbl-mode-map [backspace]
(orgtbl-make-binding 'org-delete-backward-char 109
[backspace] (kbd "DEL")))
(org-defkey orgtbl-mode-map [S-iso-lefttab]
(orgtbl-make-binding 'org-table-previous-field 107
[S-iso-lefttab] [backtab] [(shift tab)]
[(tab)] "\C-i"))
(org-defkey orgtbl-mode-map [backtab]
(orgtbl-make-binding 'org-table-previous-field 108
[backtab] [S-iso-lefttab] [(shift tab)]
[(tab)] "\C-i"))
(org-defkey orgtbl-mode-map "\M-\C-m"
(orgtbl-make-binding 'org-table-wrap-region 105
"\M-\C-m" [(meta return)]))
(org-defkey orgtbl-mode-map [(meta return)]
(orgtbl-make-binding 'org-table-wrap-region 106
[(meta return)] "\M-\C-m"))
(org-defkey orgtbl-mode-map "\C-c\C-c" 'orgtbl-ctrl-c-ctrl-c)
(org-defkey orgtbl-mode-map "\C-c|" 'orgtbl-create-or-convert-from-region)
(when orgtbl-optimized
;; If the user wants maximum table support, we need to hijack
;; some standard editing functions
(org-remap orgtbl-mode-map
'self-insert-command 'orgtbl-self-insert-command
'delete-char 'org-delete-char
'delete-forward-char 'org-delete-char
'delete-backward-char 'org-delete-backward-char)
(org-defkey orgtbl-mode-map "|" 'org-force-self-insert))
t))
;; If the user wants maximum table support, we need to hijack
;; some standard editing functions
(org-remap orgtbl-mode-map
'self-insert-command (and orgtbl-optimized 'orgtbl-self-insert-command)
'delete-char (and orgtbl-optimized 'org-delete-char)
'delete-forward-char (and orgtbl-optimized 'org-delete-char)
'delete-backward-char (and orgtbl-optimized 'org-delete-backward-char))
(org-defkey orgtbl-mode-map "|" (and orgtbl-optimized 'org-force-self-insert)))
(defun orgtbl-ctrl-c-ctrl-c (arg)
"If the cursor is inside a table, realign the table.
@ -5472,14 +5477,16 @@ a radio table."
(goto-char (org-table-begin))
(let (rtn)
(forward-line -1)
(while (looking-at "[ \t]*#\\+ORGTBL[: \t][ \t]*SEND[ \t]+\\([^ \t\r\n]+\\)[ \t]+\\([^ \t\r\n]+\\)\\([ \t]+.*\\)?")
(let ((name (org-no-properties (match-string 1)))
(transform (intern (match-string 2)))
(params (if (match-end 3)
(read (concat "(" (match-string 3) ")")))))
(push (list :name name :transform transform :params params)
rtn)
(forward-line -1)))
(catch :bob
(while (looking-at "[ \t]*#\\+ORGTBL[: \t][ \t]*SEND[ \t]+\\([^ \t\r\n]+\\)[ \t]+\\([^ \t\r\n]+\\)\\([ \t]+.*\\)?")
(let ((name (org-no-properties (match-string 1)))
(transform (intern (match-string 2)))
(params (if (match-end 3)
(read (concat "(" (match-string 3) ")")))))
(push (list :name name :transform transform :params params)
rtn)
(when (bobp) (throw :bob nil))
(forward-line -1))))
rtn)))
(defun orgtbl-send-replace-tbl (name text)
@ -6173,9 +6180,13 @@ supported."
(with-temp-buffer
(insert (orgtbl-to-orgtbl table params))
(org-table-align)
(replace-regexp-in-string
"-|" "-+"
(replace-regexp-in-string "|-" "+-" (buffer-substring 1 (buffer-size))))))
(goto-char (point-min))
(while (search-forward "-|" nil t)
(replace-match "-+"))
(goto-char (point-min))
(while (search-forward "|-" nil t)
(replace-match "+-"))
(buffer-string)))
(defun orgtbl-to-unicode (table params)
"Convert the `orgtbl-mode' TABLE into a table with unicode characters.

View File

@ -3,7 +3,7 @@
;; Copyright (C) 2017-2024 Free Software Foundation, Inc.
;;
;; Author: Rasmus Pank Roulund <emacs at pank dot eu>
;; Keywords: outlines, hypermedia, calendar, wp
;; Keywords: outlines, hypermedia, calendar, text
;; URL: https://orgmode.org
;;
;; This file is part of GNU Emacs.

View File

@ -3,7 +3,7 @@
;; Copyright (C) 2008-2024 Free Software Foundation, Inc.
;; Author: Carsten Dominik <carsten.dominik@gmail.com>
;; Keywords: outlines, hypermedia, calendar, wp
;; Keywords: outlines, hypermedia, calendar, text
;; URL: https://orgmode.org
;;
;; This file is part of GNU Emacs.

File diff suppressed because it is too large Load Diff

View File

@ -3,7 +3,7 @@
;; Copyright (C) 2012-2024 Free Software Foundation, Inc.
;; Author: Nicolas Goaziou <n.goaziou at gmail dot com>
;; Keywords: outlines, hypermedia, calendar, wp
;; Keywords: outlines, hypermedia, calendar, text
;; This file is part of GNU Emacs.
@ -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
@ -1651,6 +1652,12 @@ information."
"Transcode a PARAGRAPH element from Org to ASCII.
CONTENTS is the contents of the paragraph, as a string. INFO is
the plist used as a communication channel."
;; Ensure that we do not create multiple paragraphs, when a single
;; paragraph is expected.
;; Multiple newlines may appear in CONTENTS, for example, when
;; certain objects are stripped from export, leaving single newlines
;; before and after.
(setq contents (org-remove-blank-lines contents))
(org-ascii--justify-element
(let ((indented-line-width (plist-get info :ascii-indented-line-width)))
(if (not (wholenump indented-line-width)) contents

View File

@ -4,7 +4,7 @@
;; Author: Carsten Dominik <carsten.dominik AT gmail DOT com>
;; Nicolas Goaziou <n.goaziou AT gmail DOT com>
;; Keywords: org, wp, tex
;; Keywords: org, text, tex
;; This file is part of GNU Emacs.
@ -118,8 +118,7 @@ open The opening template for the environment, with the following escapes
%l the label, obtained from `org-beamer--get-label'
close The closing string of the environment."
:group 'org-export-beamer
:version "24.4"
:package-version '(Org . "8.1")
:package-version '(Org . "9.7")
:type '(repeat
(list
(string :tag "Environment")
@ -969,11 +968,10 @@ holding export options."
"Support for editing Beamer oriented Org mode files."
:lighter " Bm")
(when (fboundp 'font-lock-add-keywords)
(font-lock-add-keywords
'org-mode
'((":\\(B_[a-z]+\\|BMCOL\\):" 1 'org-beamer-tag prepend))
'prepend))
(font-lock-add-keywords
'org-mode
'((":\\(B_[a-z]+\\|BMCOL\\):" 1 'org-beamer-tag prepend))
'prepend)
(defface org-beamer-tag '((t (:box (:line-width 1 :color "grey40"))))
"The special face for beamer tags."
@ -1054,7 +1052,10 @@ will be displayed when `org-export-show-temporary-export-buffer'
is non-nil."
(interactive)
(org-export-to-buffer 'beamer "*Org BEAMER Export*"
async subtreep visible-only body-only ext-plist (lambda () (LaTeX-mode))))
async subtreep visible-only body-only ext-plist
(if (fboundp 'major-mode-remap)
(major-mode-remap 'latex-mode)
#'LaTeX-mode)))
;;;###autoload
(defun org-beamer-export-to-latex

View File

@ -5,7 +5,7 @@
;; Author: Carsten Dominik <carsten.dominik@gmail.com>
;; Jambunathan K <kjambunathan at gmail dot com>
;; Maintainer: TEC <orgmode@tec.tecosaur.net>
;; Keywords: outlines, hypermedia, calendar, wp
;; Keywords: outlines, hypermedia, calendar, text
;; This file is part of GNU Emacs.
@ -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
@ -2209,8 +2216,7 @@ holding export options."
(format "%s\n"
(format decl
(or (and org-html-coding-system
;; FIXME: Use Emacs 22 style here, see `coding-system-get'.
(coding-system-get org-html-coding-system 'mime-charset))
(coding-system-get org-html-coding-system :mime-charset))
"iso-8859-1"))))))
(org-html-doctype info)
"\n"
@ -2741,16 +2747,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 +2920,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
@ -3091,6 +3114,7 @@ CONTENTS is nil. INFO is a plist holding contextual information."
(attributes (org-export-read-attribute :attr_html latex-environment))
(label (org-html--reference latex-environment info t))
(caption (and (org-html--latex-environment-numbered-p latex-environment)
(org-html--math-environment-p latex-environment)
(number-to-string
(org-export-get-ordinal
latex-environment info nil
@ -3126,6 +3150,7 @@ CONTENTS is nil. INFO is a plist holding contextual information."
(let ((latex-frag (org-element-property :value latex-fragment))
(processing-type (plist-get info :with-latex)))
(cond
;; FIXME: Duplicated value in cond: t
((memq processing-type '(t mathjax))
(org-html-format-latex latex-frag 'mathjax info))
((memq processing-type '(t html))
@ -3943,7 +3968,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

@ -5,7 +5,7 @@
;; Author: Carsten Dominik <carsten.dominik@gmail.com>
;; Nicolas Goaziou <mail@nicolasgoaziou.fr>
;; Maintainer: Jack Kamm <jackkamm@gmail.com>
;; Keywords: outlines, hypermedia, calendar, wp
;; Keywords: outlines, hypermedia, calendar, text
;; URL: https://orgmode.org
;; This file is part of GNU Emacs.
@ -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

@ -7,7 +7,7 @@
;; Viktor Rosenfeld <listuser36 AT gmail DOT com>
;; Rasmus Pank Roulund <emacs AT pank DOT eu>
;; Maintainer: Marco Wahl <marcowahlsoft@gmail.com>
;; Keywords: org, wp, tex
;; Keywords: org, text, tex
;; This file is part of GNU Emacs.
@ -915,7 +915,9 @@ non-nil."
(let (org-koma-letter-special-contents)
(org-export-to-buffer 'koma-letter "*Org KOMA-LETTER Export*"
async subtreep visible-only body-only ext-plist
(lambda () (LaTeX-mode)))))
(if (fboundp 'major-mode-remap)
(major-mode-remap 'latex-mode)
#'LaTeX-mode))))
;;;###autoload
(defun org-koma-letter-export-to-latex

View File

@ -4,7 +4,7 @@
;; Author: Nicolas Goaziou <n.goaziou at gmail dot com>
;; Maintainer: Daniel Fleischer <danflscr@gmail.com>
;; Keywords: outlines, hypermedia, calendar, wp
;; Keywords: outlines, hypermedia, calendar, text
;; This file is part of GNU Emacs.
@ -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"
@ -1519,8 +1530,7 @@ The regular expressions are used to find possible warnings in the
log of a LaTeX-run. These warnings will be reported after
calling `org-latex-compile'."
:group 'org-export-latex
:version "26.1"
:package-version '(Org . "8.3")
:package-version '(Org . "9.7")
:type '(repeat
(cons
(regexp :tag "Regexp")
@ -2239,7 +2249,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) "")
@ -3039,9 +3049,7 @@ the plist used as a communication channel."
;; Multiple newlines may appear in CONTENTS, for example, when
;; certain objects are stripped from export, leaving single newlines
;; before and after.
(replace-regexp-in-string
(rx "\n" (1+ (0+ space) "\n")) "\n"
contents))
(org-remove-blank-lines contents))
;;;; Plain List
@ -3752,7 +3760,7 @@ CONTENTS is the contents of the object."
;; takes care of tables with a "verbatim" mode. Otherwise, it
;; delegates the job to either `org-latex--table.el-table',
;; `org-latex--org-table', `org-latex--math-table' or
;; `org-latex--org-align-string-tabbing' functions,
;; `org-table--org-tabbing' functions,
;; depending of the type of the table and the mode requested.
;;
;; `org-latex--align-string' is a subroutine used to build alignment
@ -4275,7 +4283,10 @@ will be displayed when `org-export-show-temporary-export-buffer'
is non-nil."
(interactive)
(org-export-to-buffer 'latex "*Org LATEX Export*"
async subtreep visible-only body-only ext-plist (lambda () (LaTeX-mode))))
async subtreep visible-only body-only ext-plist
(if (fboundp 'major-mode-remap)
(major-mode-remap 'latex-mode)
#'LaTeX-mode)))
;;;###autoload
(defun org-latex-convert-region-to-latex ()

View File

@ -4,7 +4,7 @@
;; Author: Nicolas Goaziou <n.goaziou at gmail dot com>
;; Luis R Anaya <papoanaya aroba hot mail punto com>
;; Keywords: outlines, hypermedia, calendar, wp
;; Keywords: outlines, hypermedia, calendar, text
;; This file is part of GNU Emacs.
@ -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

@ -3,7 +3,7 @@
;; Copyright (C) 2012-2024 Free Software Foundation, Inc.
;; Author: Nicolas Goaziou <n.goaziou@gmail.com>
;; Keywords: org, wp, markdown
;; Keywords: org, text, markdown
;; This file is part of GNU Emacs.
@ -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 "[-] ")
@ -628,6 +633,12 @@ information."
"Transcode PARAGRAPH element into Markdown format.
CONTENTS is the paragraph contents. INFO is a plist used as
a communication channel."
;; Ensure that we do not create multiple paragraphs, when a single
;; paragraph is expected.
;; Multiple newlines may appear in CONTENTS, for example, when
;; certain objects are stripped from export, leaving single newlines
;; before and after.
(setq contents (org-remove-blank-lines contents))
(let ((first-object (car (org-element-contents paragraph))))
;; If paragraph starts with a #, protect it.
(if (and (stringp first-object) (string-prefix-p "#" first-object))

View File

@ -3,7 +3,7 @@
;; Copyright (C) 2010-2024 Free Software Foundation, Inc.
;; Author: Jambunathan K <kjambunathan at gmail dot com>
;; Keywords: outlines, hypermedia, calendar, wp
;; Keywords: outlines, hypermedia, calendar, text
;; URL: https://orgmode.org
;; This file is part of GNU Emacs.
@ -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

@ -3,7 +3,7 @@
;; Copyright (C) 2013-2024 Free Software Foundation, Inc.
;; Author: Nicolas Goaziou <n.goaziou@gmail.com>
;; Keywords: org, wp
;; Keywords: org, text
;; This file is part of GNU Emacs.

View File

@ -2,7 +2,7 @@
;; Copyright (C) 2006-2024 Free Software Foundation, Inc.
;; Author: David O'Toole <dto@gnu.org>
;; Keywords: hypermedia, outlines, wp
;; Keywords: hypermedia, outlines, text
;; This file is part of GNU Emacs.
;;
@ -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

@ -2,7 +2,7 @@
;; Copyright (C) 2012-2024 Free Software Foundation, Inc.
;; Author: Jonathan Leech-Pepin <jonathan.leechpepin at gmail dot com>
;; Keywords: outlines, hypermedia, calendar, wp
;; Keywords: outlines, hypermedia, calendar, text
;; This file is part of GNU Emacs.
@ -1517,7 +1517,12 @@ information."
"Transcode a PARAGRAPH element from Org to Texinfo.
CONTENTS is the contents of the paragraph, as a string. INFO is
the plist used as a communication channel."
contents)
;; Ensure that we do not create multiple paragraphs, when a single
;; paragraph is expected.
;; Multiple newlines may appear in CONTENTS, for example, when
;; certain objects are stripped from export, leaving single newlines
;; before and after.
(org-remove-blank-lines contents))
;;;; Plain List

View File

@ -4,7 +4,7 @@
;; Author: Nicolas Goaziou <mail@nicolasgoaziou.fr>
;; Maintainer: Ihor Radchenko <yantar92 at posteo dot net>
;; Keywords: outlines, hypermedia, calendar, wp
;; Keywords: outlines, hypermedia, calendar, text
;; This file is part of GNU Emacs.
@ -185,7 +185,7 @@ All these properties should be backend agnostic. Backend
specific properties are set through `org-export-define-backend'.
Properties redefined there have precedence over these.")
(defconst org-export-filters-alist
(defvar org-export-filters-alist
'((:filter-body . org-export-filter-body-functions)
(:filter-bold . org-export-filter-bold-functions)
(:filter-babel-call . org-export-filter-babel-call-functions)
@ -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")
@ -1897,6 +1880,38 @@ INFO is a plist containing export directives."
(let ((transcoder (cdr (assq type (plist-get info :translate-alist)))))
(and (functionp transcoder) transcoder)))))
(defun org-export--keep-spaces (data info)
"Non-nil, when post-blank spaces after removing DATA should be preserved.
INFO is the info channel.
This function returns nil, when previous exported element already has
trailing spaces or when DATA does not have non-zero non-nil
`:post-blank' property.
When the return value is non-nil, it is a string containing the trailing
spaces."
;; When DATA is an object, interpret this as if DATA should be
;; ignored (see `org-export--prune-tree'). Keep spaces in place of
;; removed element, if necessary. Example: "Foo.[10%] Bar" would
;; become "Foo.Bar" if we do not keep spaces. Another example: "A
;; space@@ascii:*@@ character." should become "A space character"
;; in non-ASCII export.
(let ((post-blank (org-element-post-blank data)))
(unless (or (not post-blank)
(zerop post-blank)
(eq 'element (org-element-class data)))
(let ((previous (org-export-get-previous-element data info)))
(unless (or (not previous)
(pcase (org-element-type previous)
(`plain-text
(string-match-p
(rx (any " \t\r\n") eos) previous))
(_ (org-element-post-blank previous))))
;; When previous element does not have
;; trailing spaces, keep the trailing
;; spaces from DATA.
(make-string post-blank ?\s))))))
;;;###autoload
(defun org-export-data (data info)
"Convert DATA into current backend format.
@ -1917,7 +1932,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))))))
@ -1947,15 +1962,11 @@ Return a string."
(eq (plist-get info :with-archived-trees) 'headline)
(org-element-property :archivedp data)))
(let ((transcoder (org-export-transcoder data info)))
(or (and (functionp transcoder)
(if (eq type 'link)
(broken-link-handler
(funcall transcoder data nil info))
(funcall transcoder data nil info)))
;; Export snippets never return a nil value so
;; that white spaces following them are never
;; ignored.
(and (eq type 'export-snippet) ""))))
(and (functionp transcoder)
(if (eq type 'link)
(broken-link-handler
(funcall transcoder data nil info))
(funcall transcoder data nil info)))))
;; Element/Object with contents.
(t
(let ((transcoder (org-export-transcoder data info)))
@ -1996,8 +2007,8 @@ Return a string."
(puthash
data
(cond
((not results) "")
((memq type '(nil org-data plain-text raw)) results)
((not results) (or (org-export--keep-spaces data info) ""))
((memq type '(nil org-data plain-text raw)) results)
;; Append the same white space between elements or objects
;; as in the original buffer, and call appropriate filters.
(t
@ -2658,24 +2669,13 @@ from tree."
(let ((type (org-element-type data)))
(if (org-export--skip-p data info selected excluded)
(if (memq type '(table-cell table-row)) (push data ignore)
(let ((post-blank (org-element-post-blank data)))
(if (or (not post-blank) (zerop post-blank)
(eq 'element (org-element-class data)))
(org-element-extract data)
(if-let ((keep-spaces (org-export--keep-spaces data info)))
;; Keep spaces in place of removed
;; element, if necessary.
;; Example: "Foo.[10%] Bar" would become
;; "Foo.Bar" if we do not keep spaces.
(let ((previous (org-export-get-previous-element data info)))
(if (or (not previous)
(pcase (org-element-type previous)
(`plain-text
(string-match-p
(rx whitespace eos) previous))
(_ (org-element-post-blank previous))))
;; Previous object ends with whitespace already.
(org-element-extract data)
(org-element-set data (make-string post-blank ?\s)))))))
(org-element-set data keep-spaces)
(org-element-extract data)))
(if (and (eq type 'headline)
(eq (plist-get info :with-archived-trees)
'headline)
@ -6254,7 +6254,7 @@ them."
("no" :default "Illustrasjon")
("nb" :default "Illustrasjon")
("nn" :default "Illustrasjon")
("pl" :default "Obrazek") ; alternativly "Rysunek"
("pl" :default "Obrazek") ; alternatively "Rysunek"
("pt_BR" :default "Figura")
("ro" :default "Imaginea")
("ru" :html "&#1056;&#1080;&#1089;&#1091;&#1085;&#1086;&#1082;" :utf-8 "Рисунок")
@ -6277,7 +6277,7 @@ them."
("no" :default "Illustrasjon %d")
("nb" :default "Illustrasjon %d")
("nn" :default "Illustrasjon %d")
("pl" :default "Obrazek %d") ; alternativly "Rysunek %d"
("pl" :default "Obrazek %d") ; alternatively "Rysunek %d"
("pt_BR" :default "Figura %d:")
("ro" :default "Imaginea %d:")
("ru" :html "&#1056;&#1080;&#1089;. %d.:" :utf-8 "Рис. %d.:")
@ -6438,7 +6438,7 @@ them."
("nl" :default "Zie figuur %s"
:html "Zie figuur&nbsp;%s" :latex "Zie figuur~%s")
("nn" :default "Sjå figur %s")
("pl" :default "Patrz obrazek %s") ; alternativly "Patrz rysunek %s"
("pl" :default "Patrz obrazek %s") ; alternatively "Patrz rysunek %s"
("pt_BR" :default "Veja a figura %s")
("ro" :default "Vezi figura %s")
("sl" :default "Glej sliko %s")
@ -6769,7 +6769,7 @@ use it to set a major mode there, e.g.,
(interactive)
(org-export-to-buffer \\='latex \"*Org LATEX Export*\"
async subtreep visible-only body-only ext-plist
#\\='LaTeX-mode))
(major-mode-remap \\='latex-mode)))
When expressed as an anonymous function, using `lambda',
POST-PROCESS needs to be quoted.

View File

@ -13,7 +13,7 @@ ifneq ($(wildcard .git),)
# Use the org.el header.
ORGVERSION := $(patsubst %-dev,%,$(shell $(BATCH) --eval "(require 'lisp-mnt)" \
--visit lisp/org.el --eval '(princ (lm-header "version"))'))
GITVERSION := $(shell git describe --match release\* --abbrev=6 HEAD 2>/dev/null || echo "release_N/A-N/A-$(shell git describe --match release\* --abbrev=6 --always HEAD)")
GITVERSION := $(shell git describe --match release\* --abbrev=6 HEAD 2>/dev/null || echo "${ORGVERSION}-$(shell git describe --match release\* --abbrev=6 --always HEAD)")
GITSTATUS := $(shell git status -uno --porcelain)
else
-include mk/version.mk

View File

@ -6,3 +6,5 @@ SCHEDULED: <2024-01-17 Wed 10:00-12:30>
SCHEDULED: <2024-01-17 Wed 13:00-15:00>
* TODO four
SCHEDULED: <2024-01-17 Wed 19:00>
* TODO five
<2024-01-17 Wed 19:00>--<2024-01-18 Thu 18:00>

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))
@ -265,7 +265,7 @@ Here is one at the end of a line. {{{results(=2=)}}}
(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=)}}}")
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
@ -430,7 +430,7 @@ be evaluated."
"Test exporting a source block with a flag."
(should
(string-match
"\\`#\\+BEGIN_SRC emacs-lisp -some-flag$"
"\\`#\\+BEGIN_SRC emacs-lisp :flags -some-flag$"
(org-test-with-temp-text
"#+BEGIN_SRC emacs-lisp :flags -some-flag\n\(+ 1 1)\n#+END_SRC"
(org-babel-exp-process-buffer)
@ -570,7 +570,7 @@ src_emacs-lisp{(+ 1 1)}"
(ert-deftest ob-export/body-with-coderef ()
"Test exporting a code block with coderefs."
(should
(equal "#+begin_src emacs-lisp\n0 (ref:foo)\n#+end_src"
(equal "#+begin_src emacs-lisp :exports code\n0 (ref:foo)\n#+end_src"
(org-test-with-temp-text
"#+BEGIN_SRC emacs-lisp :exports code\n0 (ref:foo)\n#+END_SRC"
(let ((org-export-use-babel t)
@ -579,7 +579,7 @@ src_emacs-lisp{(+ 1 1)}"
(buffer-string))))
(should
(equal
"#+begin_src emacs-lisp -l \"r:%s\"\n1 r:foo\n#+end_src"
"#+begin_src emacs-lisp -l \"r:%s\" -lisp :exports code\n1 r:foo\n#+end_src"
(org-test-with-temp-text
"#+BEGIN_SRC emacs-lisp -l \"r:%s\" -lisp :exports code\n1 r:foo\n#+END_SRC"
(let ((org-export-use-babel t))

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

@ -168,6 +168,14 @@
(save-excursion
(goto-char (point-min))
(should (search-forward "agenda-file2:19:00-20:00 Scheduled: TODO four")))
;; `org-agenda-default-appointment-duration'
;; should not affect date range in timestamps.
(save-excursion
(goto-char (point-min))
(should-not (re-search-forward "agenda-file2:19:00-20:00.+TODO five" nil t)))
(save-excursion
(goto-char (point-min))
(should (search-forward "agenda-file2:19:00...... (1/2): TODO five")))
;; Bug https://list.orgmode.org/orgmode/20211119135325.7f3f85a9@hsu-hh.de/
(save-excursion
(goto-char (point-min))
@ -598,7 +606,7 @@ DEADLINE: " (cdr timestamp))))
(dolist (org-agenda-skip-scheduled-repeats-after-deadline '(nil t))
(org-test-at-time "2024-01-01 8:00"
(org-test-with-temp-text-in-file "
* TODO Do me every day before Jan, 12th (included)
* TODO Do me every day until Jan, 5th (inclusive)
SCHEDULED: <2024-01-03 Wed +1d> DEADLINE: <2024-01-05 Fri>
"
(let ((org-agenda-span 'week)
@ -614,15 +622,15 @@ SCHEDULED: <2024-01-03 Wed +1d> DEADLINE: <2024-01-05 Fri>
(string-match-p
"Week-agenda (W01):
Monday 1 January 2024 W01
[^:]+:In 4 d.: TODO Do me every day before Jan, 12th (included)
[^:]+:In 4 d.: TODO Do me every day until Jan, 5th (inclusive)
Tuesday 2 January 2024
Wednesday 3 January 2024
[^:]+:Scheduled: TODO Do me every day before Jan, 12th (included)
[^:]+:Scheduled: TODO Do me every day until Jan, 5th (inclusive)
Thursday 4 January 2024
[^:]+:Scheduled: TODO Do me every day before Jan, 12th (included)
[^:]+:Scheduled: TODO Do me every day until Jan, 5th (inclusive)
Friday 5 January 2024
[^:]+:Scheduled: TODO Do me every day before Jan, 12th (included)
[^:]+:Deadline: TODO Do me every day before Jan, 12th (included)
[^:]+:Scheduled: TODO Do me every day until Jan, 5th (inclusive)
[^:]+:Deadline: TODO Do me every day until Jan, 5th (inclusive)
Saturday 6 January 2024
Sunday 7 January 2024"
(buffer-string)))
@ -631,19 +639,19 @@ Sunday 7 January 2024"
(string-match-p
"Week-agenda (W01):
Monday 1 January 2024 W01
[^:]+:In 4 d.: TODO Do me every day before Jan, 12th (included)
[^:]+:In 4 d.: TODO Do me every day until Jan, 5th (inclusive)
Tuesday 2 January 2024
Wednesday 3 January 2024
[^:]+:Scheduled: TODO Do me every day before Jan, 12th (included)
[^:]+:Scheduled: TODO Do me every day until Jan, 5th (inclusive)
Thursday 4 January 2024
[^:]+:Scheduled: TODO Do me every day before Jan, 12th (included)
[^:]+:Scheduled: TODO Do me every day until Jan, 5th (inclusive)
Friday 5 January 2024
[^:]+:Scheduled: TODO Do me every day before Jan, 12th (included)
[^:]+:Deadline: TODO Do me every day before Jan, 12th (included)
[^:]+:Scheduled: TODO Do me every day until Jan, 5th (inclusive)
[^:]+:Deadline: TODO Do me every day until Jan, 5th (inclusive)
Saturday 6 January 2024
[^:]+:Scheduled: TODO Do me every day before Jan, 12th (included)
[^:]+:Scheduled: TODO Do me every day until Jan, 5th (inclusive)
Sunday 7 January 2024
[^:]+:Scheduled: TODO Do me every day before Jan, 12th (included)"
[^:]+:Scheduled: TODO Do me every day until Jan, 5th (inclusive)"
(buffer-string))))))
(org-test-agenda--kill-all-agendas))))
@ -690,43 +698,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

@ -244,6 +244,30 @@
:immediate-finish t))))
(org-capture nil "t")
(buffer-string))))
;; Do not raise an error on templates that do not start with a heading.
(should
(org-test-with-temp-text-in-file ""
(let* ((file (buffer-file-name))
(org-capture-templates
`(("t" "Test" entry (file ,file) "Foo"
:immediate-finish t))))
(org-capture nil "t"))))
(should
(org-test-with-temp-text-in-file ""
(let* ((file (buffer-file-name))
(org-capture-templates
`(("t" "Test" entry (file ,file) "*bold*"
:immediate-finish t))))
(org-capture nil "t"))))
;; Raise an error on templates with a lower level heading after a
;; higher level one.
(should-error
(org-test-with-temp-text-in-file ""
(let* ((file (buffer-file-name))
(org-capture-templates
`(("t" "Test" entry (file ,file) "** X\n* Y"
:immediate-finish t))))
(org-capture nil "t"))))
;; With a 0 prefix argument, ignore surrounding lists.
(should
(equal "Foo\n* X\nBar\n"
@ -589,6 +613,16 @@
"| 2 |" :immediate-finish t))))
(org-capture nil "t"))
(buffer-string))))
;; Prepend | when the template does not start with it
(should
(equal "| 1 |\n| 2 |\n"
(org-test-with-temp-text-in-file "| 1 |\n"
(let* ((file (buffer-file-name))
(org-capture-templates
`(("t" "Table" table-line (file ,file)
"2 |" :immediate-finish t))))
(org-capture nil "t")
(buffer-string)))))
;; When `:prepend' is nil, add the row at the end of the table.
(should
(equal "| a |\n| x |\n"

View File

@ -118,7 +118,7 @@ the buffer."
(org-clock-timestamps-change 'up 1)
(buffer-string))))))
(ert-deftest test-org-clok/org-clock-update-time-maybe ()
(ert-deftest test-org-clock/org-clock-update-time-maybe ()
"Test `org-clock-update-time-maybe' specifications."
(should
(equal

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

@ -3630,6 +3630,20 @@ Foo Bar
(org-open-at-point))
nil)))))
;;; Thing at point
(ert-deftest test-org/thing-at-point/url ()
"Test that `thing-at-point' returns the URL at point."
(org-test-with-temp-text
"[[https://www.gnu.org/software/emacs/][GNU Emacs]]"
(when (boundp 'thing-at-point-provider-alist)
(should (string= (thing-at-point 'url)
"https://www.gnu.org/software/emacs/")))
(when (boundp 'bounds-of-thing-at-point-provider-alist)
(should (equal (bounds-of-thing-at-point 'url)
'(1 . 51))))))
;;; Node Properties
@ -4072,7 +4086,17 @@ text"
(save-excursion
(goto-char (point-min))
(org-ctrl-c-ctrl-c))
(should (org-fold-folded-p (point) 'outline))))
(should (org-fold-folded-p (point) 'outline)))
;; Quit column view.
(org-test-with-temp-text
"* Heading<point>
text"
(org-columns)
(should org-columns-overlays)
(save-excursion
(goto-char (point-min))
(org-ctrl-c-ctrl-c))
(should-not org-columns-overlays)))
;;; Navigation
@ -8896,7 +8920,22 @@ CLOSED: %s
(let ((org-todo-keywords '((sequence "TODO" "DONE"))))
(org-test-with-temp-text "* TODO H\n<2012-03-29 Thu +2y>"
(org-todo '-)
(buffer-string))))))
(buffer-string)))))
;; C-u forces logging note.
;; However, logging falls back to "time" when `org-inhibit-logging'
;; is 'note.
(dolist (org-inhibit-logging '(nil t note))
(let ((org-todo-keywords '((sequence "TODO" "DONE"))))
(org-test-with-temp-text "* TODO H\n"
(unwind-protect
(progn
(org-todo '(4))
(should (string-match-p "DONE" (buffer-string)))
(should (member #'org-add-log-note post-command-hook))
(if (eq org-inhibit-logging 'note)
(should (eq org-log-note-how 'time))
(should (eq org-log-note-how 'note))))
(remove-hook 'post-command-hook #'org-add-log-note))))))
;;; Timestamps API
@ -9356,6 +9395,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 +9423,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

Some files were not shown because too many files have changed in this diff Show More