Commit Graph

5654 Commits

Author SHA1 Message Date
Kyrylo Simonov 00778ce2a6
Fix missing customization groups
* lisp/ob-tangle.el (org-babel-tangle): Add missing group definition.
(org-babel-post-tangle-hook):
(org-babel-pre-tangle-hook):
(org-babel-tangle-body-hook):
(org-babel-tangle-finished-hook):
(org-babel-tangle-comment-format-beg):
(org-babel-tangle-comment-format-end):
(org-babel-tangle-uncomment-comments):
(org-babel-process-comment-text):
(org-babel-tangle-default-file-mode): Move under `org-babel-tangle'
group.
* lisp/ol-bbdb.el (org-bbdb-anniversaries): Move under `org-agenda'
instead of a non-existent `org-bbdb'.
* lisp/ol-bibtex.el (org-bibtex): Add missing group definition.
* lisp/ol-gnus.el (org-gnus-no-server): Move under group
`org-link-follow' instead of a non-existent `org-gnus'.
* lisp/org-plot.el (org-plot): Add missing group definition.
* lisp/org.el (org-startup): Add missing group definition.
* lisp/ox-latex.el (org-latex-pdf-process): Move under
`org-export-latex' instead of a non-existent `org-export-pdf'.
* lisp/ox-man.el (org-man-pdf-process): Remove reference to
non-existent group `org-export-pdf'.

TINYCHANGE
2022-11-16 09:59:44 +08:00
Ihor Radchenko 5a10517d02
Add missing :package-version tags in changed `defcustom'
* lisp/ob-clojure.el (ob-clojure-babashka-command):
(ob-clojure-nbb-command):
* lisp/ob-exp.el (org-babel-exp-code-template):
* lisp/ob-latex.el (org-babel-latex-pdf-svg-process):
* lisp/org-agenda.el (org-agenda-show-outline-path):
* lisp/org-capture.el (org-capture-templates):
* lisp/org-clock.el (org-clocktable-defaults):
* lisp/org-persist.el (org-persist-directory):
(org-persist-remote-files):
(org-persist-default-expiry):
* lisp/org-refile.el (org-refile-use-outline-path):
* lisp/org-src.el (org-src-lang-modes):
* lisp/org.el (org-resource-download-policy):
(org-safe-remote-resources):
(org-time-stamp-custom-formats):
(org-property-separators):
(org-preview-latex-process-alist):
(org-structure-template-alist):
* lisp/ox-latex.el (org-latex-inline-image-rules):
(org-latex-src-block-backend):
(org-latex-engraved-options):
(org-latex-engraved-theme):
* lisp/ox-md.el (org-md-toplevel-hlevel):
* lisp/ox-texinfo.el (org-texinfo-with-latex): Add :package-version
keywords to the new custom options, and those with the value or
meaning changed.
2022-11-13 15:29:15 +08:00
Ihor Radchenko 8a827437a5
org--at-headline-data-p: Fix when at :post-blank after heading
* lisp/org.el (org--at-headline-data-p): Fix infinite loop when within
blank lines after empty heading.

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

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

Reported-by: Uwe Brauer <oub@mat.ucm.es>
Link: https://orgmode.org/list/87k04ppp1t.fsf@localhost
2022-11-07 15:05:37 +08:00
Adam Porter 155dc778e8
* lisp/org.el: (org-get-indirect-buffer) Allow indirect base buffers
Previously, calling this function on an indirect buffer would fail,
preventing the user from making a new indirect buffer based on an
indirect buffer (e.g. imagine the user makes an indirect buffer for a
large subtree, then wants to make another one for a subtree of that).
Now, the base buffer of the buffer is used, when applicable.

Also, the function is partially rewritten to be clearer, and a
docstring is added.

Link: https://orgmode.org/list/8b2c1814-2c6f-fdca-8ba7-63c415bfca5e@alphapapa.net
2022-11-07 11:16:08 +08:00
Ihor Radchenko 5dc8ea0abe
org-paste-subtree: Fix when `kill-ring' is empty
* lisp/org.el (org-paste-subtree): Allow pasting from system
clipboard.
2022-11-01 09:41:38 +08:00
Ihor Radchenko 33cbb11d5a
org-kill-is-subtree-p: Handle clipboard
* lisp/org.el (org-kill-is-subtree-p): Allow `current-kill' to return
clipboard (even when `kill-ring' is empty).  Do not throw error when
clipboard is also empty.
2022-11-01 09:28:48 +08:00
Max Nikulin 57abbd4b92
org.el: Fix first call of `org-paste-subtree'
* lisp/org.el (org-paste-subtree): Do not check `kill-ring' before
calling `current-kill' since the latter can pull content of clipboard.

First call of `org-paste-subtree' failed if nothing had been yanked
before since Emacs start but system clipboard had text with valid
subtree originating from other application.  The bug was where since
the commit adding `org-paste-subtree'.

If both `kill-ring' and system clipboard are empty then `current-kill'
generates meaningful error.
2022-11-01 09:26:50 +08:00
Kyle Meyer 0681babab4 Fix recent doc string quoting issues
* lisp/org-agenda.el (org-agenda-show-outline-path):
* lisp/org.el (org-display-outline-path): Surround symbols with `...'
rather than using leading quote.

See 6013cb161 (Fix doc string quoting problems with ', 2022-07-25) for
a more detailed explanation.
2022-10-29 15:49:04 -04:00
Ihor Radchenko 7880695221
org-set-tags-command: Fix handling `org-loop-over-headlines-in-active-region'
* lisp/org.el (org-set-tags-command): Respect the non-nil value of
`org-loop-over-headlines-in-active-region'.  The code is adapted from
similar uses in other commands.

Reported-by: Alex Giorev <alex.giorev@gmail.com>
Link: https://orgmode.org/list/CAMq3WZh1sGW+BNKW1hZA+wP=iFskzShF-D-wUqWYqb_EponZ8g@mail.gmail.com
2022-10-29 13:25:38 +08:00
stardiviner 46b71f9108
org.el: Support auto display inline images when cycling
* lisp/org.el (org-toggle-inline-images): Support region.
(org-display-inline-images): Fix refresh argument logic.
(org-remove-inline-images): Support region.

* lisp/org-keys.el (org-toggle-inline-images): Update arguments.

* lisp/org-cycle.el (org-cycle-inline-images-display): Add new option to
control whether auto display inline images when cycling.
(org-cycle-display-inline-images): Add new hook function to auto display
inline images when cycling.
(org-cycle-hook): Add `org-cycle-display-inline-images' into cycling
hook by default.

* doc/org-manual.org (Exporting):
* etc/ORG-NEWS: Document the new option.
2022-10-26 12:43:07 +08:00
Ihor Radchenko e022a0cea1
org-make-tags-matcher: Do not treat PROPERTY="[X]" as timestamp match
* lisp/org.el (org-make-tags-matcher): Improve heuristics used to
detect timestamps in the matcher.

Reported-by: Daniel J. Sinder <djsinder@gmail.com>
Link: https://orgmode.org/list/CAHND-wwBsoAQs2a5XTGKyX-=fFL5AwCPup=uA+R=FRH=1rUeVg@mail.gmail.com
2022-10-25 18:36:25 +08:00
Mikhail Skorzhinskii 55767b792e
org-agenda.el: Show document title in outline path
* lisp/org-agenda.el (org-agenda-show-outline-path): Add an option to
show a document title at start of an outline path, instead of a file or
a buffer name.

* lisp/org.el (org-display-outline-path): Show a document title (#+TITLE
value) and an outline path in an echo area if the customisation option
is set to 'title.  Fallback to a file or a buffer name if the document
title is absent.
2022-10-25 14:53:14 +08:00
Mikhail Skorzhinskii d4e7bcb4bd
org-clock.el: Rename org-clock-get-file-title
* lisp/org.el (org-get-title): A new function to collect a document
title from an org-mode buffer, based on a `org-clock-get-file-title'
implementation.

* lisp/org-clock.el (org-clock-get-file-title): Removed.
2022-10-25 14:53:01 +08:00
Max Nikulin deb1517fe9
org-macs.el: Do not compare wall time and file modification time
* lisp/org-macs.el (org-file-newer-than-p): Recommend passing file
modification time instead of wall time to avoid truncation of timestamp
precision for the sake of filesystems with coarse time resolution.
(org-compile-file): Store file modification time instead of system clock
for later comparison by `org-file-newer-than-p'.
* lisp/org.el (org-babel-load-file): Use `file-newer-than-file-p'
instead of `org-file-newer-than-p' since the former is more suitable
for target-prerequisite relation in the case of equal timestamps.
Improve error reporting when source file does not exist.
Update timestamp after tangling of an org file, not before it.

This is assumed to be a better fix of the problem with change of time
representation in Emacs-29. The problem was reported by Mark Barton
<mbarton98@gmail.com> in
https://list.orgmode.org/BF5B9308-3FEF-4DC6-98C9-BFF36F19D36C@gmail.com
Paul Eggert <eggert@cs.ucla.edu> committed another variant to Emacs
as 3abb3681b5.  It was ported to Org as commit 56ba22b9df several months
later.

Unchanged timestamp of a file means failure of `org-compile-file' but in
`org-babel-load-file' the target may be considered as up to date if its
timestamp is equal to the one for the prerequisite.
So `org-file-newer-than-p' is not suitable for both cases.  The
difference matters for filesystems with coarse timestamp resolution, for
example HFS+.

Earlier call of `org-babel-load-file' for a non-existing .org file
caused "Bad bounding indices: 0, 2" error.

Update file timestamp (introduced by the commit 1525a5a64e)
after tangling of the file.  Change caused by conflict resolution during
rebasing of the initial version of the patch.  See
https://list.orgmode.org/t75efi$9pv$1@ciao.gmane.io for an argument
in support of such change.
2022-10-21 11:22:34 +08:00
Ihor Radchenko c0d629b5bd
org-read-date-get-relative: Assure case-insensitive weekday matching
* lisp/org.el (org-read-date-get-relative): Bind `case-fold-search' to
non-nil when matching weekdays.  This is to avoid breakage for
non-default value of `case-fold-search'.
2022-10-17 20:33:09 +08:00
Ihor Radchenko d972cfac89
org-create-formula-image: Do not err when `noninteractive'
* lisp/org.el (org-create-formula-image): Do not err during
noninteractive export.  Just use a fallback DPI value instead of
requesting actual display DPI.

Reported-by: Daniel Guimaraes <dcguim@gmail.com>
Link: https://orgmode.org/list/e22e7cac-03c1-ddee-1b1d-09981a384bfc@gmail.com
2022-10-16 20:48:50 +08:00
Ihor Radchenko 0e4874f17c
org-up-element: Fix jumping up from inlinetask
* lisp/org.el (org-up-element): Do not assume that
`org-back-to-heading' skips inlinetasks.  Avoid that `if' branch by
skipping over section parents.

Reported-by: Michael Dauer <mick.dauer@gmail.com>
Link: https://orgmode.org/list/CAP7OBxKKeuK_uH46SyEqQbsuBsE=XPkB=ks1TkCZTwyPZ40KaA@mail.gmail.com
2022-10-13 11:06:36 +08:00
Ihor Radchenko 88c85d620b
org-map-entries: Do not demand file buffer when SCOPE is nil
* lisp/org.el (org-map-entries): Avoid calling
`org-agenda-prepare-buffers' for non-file buffers.
`org-agenda-prepare-buffers' expects a file buffer and gives
unexpected dialogue otherwise.  Since `org-agenda-prepare-buffer' only
contains optional cache calculations and things only useful for agenda
generation, not calling it should be reasonably safe.

Reported-by: Rodrigo Morales <moralesrodrigo1100@gmail.com>
Link: https://orgmode.org/list/871r54m6xm.fsf@gmail.com
2022-10-11 16:23:05 +08:00
Ihor Radchenko dd2212395b
org-ctrl-c-ctrl-c: Update timestamp at point inside clock lines
* lisp/org.el (org-ctrl-c-ctrl-c): Update the timestamp at point, if
any; not just the clock sum.

Reported-by: "Bruce E. Robertson" <brucer42@gmail.com>
Link: https://orgmode.org/list/87mtjo2twj.fsf@gmail.com
2022-10-11 15:54:23 +08:00
Kyle Meyer e2d41c84e1 Merge branch 'km/from-emacs-master' 2022-10-10 15:41:07 -04:00
Stefan Monnier 616fc20445 Backport commit f3769bc32 from Emacs
* lisp/org.el (org-unfontify-region): Use `with-silent-modifications`.
(org-display-inline-remove-overlay): Remove ineffective binding of
`inhibit-modification-hooks` around code which doesn't modify the
buffer anyway.

org.el: Improve bindings of `inhibit-*` vars
f3769bc32a3d32377a83b33d416205f80814e422
Stefan Monnier
Fri Oct 7 12:29:56 2022 -0400
2022-10-10 15:40:05 -04:00
Ihor Radchenko ae028d0a25
org-toggle-heading: Document checkbox conversion to TODO keywords
* lisp/org.el (org-toggle-heading): Update the docstring.
2022-10-08 12:45:59 +08:00
Ihor Radchenko fcd3817450
org-toggle-heading: Use buffer-local keyword settings when possible
* lisp/org.el (org-toggle-heading): Prefer `car' of
`org-done-keywords' and `org-not-done-keywords' when converting
checkboxes to TODO-keywords.

Reported-by: autofrettage <autofrettage@protonmail.ch>
Link: https://orgmode.org/list/87v91vle4u.fsf@gmail.com
2022-10-08 12:39:31 +08:00
Ihor Radchenko b68c1666c2
org-ts-regexp0: Fix matching timestamps with no day name
* lisp/org.el (org-ts-regexp1): Update regexp to match strings like
"2022-04-29 02:00" with no day name.

Reported-by: Russell Adams <RLAdams@adamsinfoserv.com>
Link: https://orgmode.org/list/87zgk8tc17.fsf@localhost
2022-10-08 12:01:14 +08:00
Ihor Radchenko 514e3a9cd2
org-export: Suppress cache persistence in buffer copies during export
* lisp/org-element.el (org-element-cache-reset): Add new optional
argument that suppresses all persistence-related calculations.
* lisp/org-table.el (org-element-cache-reset):
* lisp/org.el (org-element-cache-reset): Update function signature.
* lisp/ox.el (org-export--generate-copy-script): Do not try to use
cache persistence in throwaway buffer copies.

Reported-by: Rudolf Adamkovič <salutis@me.com>
Link: https://list.orgmode.org/m2zgef774u.fsf@me.com/T/#t
2022-10-07 13:15:17 +08:00
Stefan Kangas 0b67b9f64f
Improve documentation of org-kill-line
* lisp/org.el (org-special-ctrl-k): Doc fix; clarify what is being
killed and improve wording.  Add command substitutions.
(org-kill-line): Doc fix; mention user options that this command
relies on.
2022-10-07 11:47:45 +08:00
Ihor Radchenko 2c8bd0cc9b
org-fill-element: Respect region selection when filling src-block
* lisp/org.el (org-fill-element): When region is not active, run
`fill-paragraph' at point inside src block.  When region is active and
within src block boundaries, run `fill-paragraph' preserving the
region.  When region is active and crosses src block boundaries, fill
the whole src block.

Reported-by: Fabio Natali <me@fabionatali.com>
Fixes: https://orgmode.org/list/201b44de-1f97-1b23-1767-970ee00f259c@posteo.eu
2022-10-05 13:20:58 +08:00
Kyle Meyer 42c418693f Merge branch 'km/from-emacs-master' 2022-10-04 18:37:42 -04:00
Stefan Kangas c2c8e66e5d Backport commit b7e867b84 from Emacs
Make point-at-eol and point-at-bol obsolete
b7e867b841f47dcff3aeaef9b5608a237386ce70
Stefan Kangas
Tue Aug 23 04:54:57 2022 +0200

[ km: This was independently covered on the main branch with
  e73c5b7d0.  I'm applying it here too for bookkeeping/traceability
  purposes. ]
2022-10-04 17:18:04 -04:00
Stefan Kangas e58217ff1f Backport commit 57259773b from Emacs
; * lisp/org/org.el: Delete unnecessary declarations.
57259773b4f0b992e38843859a8b93d82317ded3
Stefan Kangas
Sun Aug 14 23:46:33 2022 +0200
2022-10-04 17:18:04 -04:00
Stefan Kangas 25e638f726 Backport commit 1137219c9 from Emacs
Make compat alias image-refresh obsolete
1137219c97dda512a309ce4bfad5abde0d2be206
Stefan Kangas
Tue Aug 9 14:04:39 2022 +0200

[ km: This was independently covered on the main branch with
  e73c5b7d0.  I'm applying it here too for bookkeeping/traceability
  purposes. ]
2022-10-04 17:18:04 -04:00
Peder O. Klingenberg 2ac8c44f04 Backport commit b335e1a04 from Emacs
* lisp/org.el (eq): Fix load of compiled or compressed
org-loaddefs (bug#56982).

* lisp/org/org.el: Fix load of compiled or compressed org-loaddefs
b335e1a0469105bb55b9741ae3106dc0a6023ce2
Peder O. Klingenberg
Thu Aug 4 20:27:56 2022 +0200
2022-10-04 17:18:04 -04:00
Lars Ingebrigtsen 19c3969e75 Backport commit 2682ea1b3 from Emacs
* lisp/org.el (org-dynamic-block-define): Autoload because
it's referred to in org-loaddefs.el.

Fix org.el byte-compile warning in org-loaddefs.el
2682ea1b3a9524eb54efac41b3221b514374c232
Lars Ingebrigtsen
Sun Jul 31 11:43:48 2022 +0200
2022-10-04 17:18:04 -04:00
Stefan Kangas e7059f7dbe Backport commit 22a5f0223 from Emacs
* lisp/org.el (org-file-apps):
Doc fixes; don't mention XEmacs specific library EFS.

Doc fixes: don't mention EFS
22a5f022344af8c0c0a9eddc2ac5ad36392d0cef
Stefan Kangas
Thu Jul 28 10:48:38 2022 +0200
2022-10-04 17:18:04 -04:00
Stefan Kangas e74ea551bf Backport commit cc8b6101f from Emacs
* lisp/ol-eww.el (org-eww-copy-for-org-mode):
* lisp/ol-w3m.el (org-w3m-copy-for-org-mode):
* lisp/org-refile.el (org-refile):
* lisp/org.el (org-change-tag-in-region): Remove XEmacs compat
code.

Remove some XEmacs compat code from org-mode
cc8b6101f4479a80a6af7f9d80c6f9d774a85f40
Stefan Kangas
Fri May 13 23:17:16 2022 +0200
2022-10-04 17:10:50 -04:00
Paul Eggert 723af4afae Backport commit 8ef37913d from Emacs
* lisp/ol.el (org-store-link):
* lisp/org-clock.el (org-clock-sum)
(org-clock-update-time-maybe):
* lisp/org-colview.el (org-colview-construct-allowed-dates):
* lisp/org-macro.el (org-macro--vc-modified-time):
* lisp/org-macs.el (org-2ft, org-matcher-time):
* lisp/org-table.el (org-table-eval-formula):
* lisp/org.el (org-read-date, org-display-custom-time)
(org-time-string-to-time, org-timestamp-change):
Don’t assume Emacs 27 encode-time, since standalone Org still
works with Emacs 25 and it’s easier if we minimize differences
from standalone Org.  Problem reported by Max Nikulin (Bug#54731).
This reverts much of 2021-12-16T17:40:21Z!eggert@cs.ucla.edu.

Port Org encode-time usage back to Emacs 25
8ef37913d3be5ff518018acb6b0144d6e559b5ba
Paul Eggert
Tue Apr 5 17:52:34 2022 -0700

[ km: See main's 8908a1bda (org-macs.el: Introduce a helper for
  `encode-time', 2022-07-17). ]
2022-10-04 16:59:15 -04:00
Paul Eggert 772c44779c Backport commit dd0727e1e from Emacs
* lisp/ol.el (org-store-link):
* lisp/org-clock.el (org-clock-sum)
(org-clock-update-time-maybe):
* lisp/org-colview.el (org-colview-construct-allowed-dates):
* lisp/org-macro.el (org-macro--vc-modified-time):
* lisp/org-macs.el (org-2ft, org-matcher-time):
* lisp/org-table.el (org-table-eval-formula):
* lisp/org.el (org-read-date, org-display-custom-time)
(org-time-string-to-time, org-timestamp-change):
Prefer (encode-time L) to (apply #'encode-time L) where either will do.
* lisp/org-clock.el (org-clocktable-steps):
Prefer (encode-time S M ...) to (apply #'encode-time (list S M ...)).

encode-time simplifications
dd0727e1ec1f535b9b06be88173b4d3ccd55abcb
Paul Eggert
Thu Dec 16 11:17:25 2021 -0800

[ km: Note that these changes will be reverted by the port of Emacs's
  8ef37913d. ]
2022-10-04 16:55:56 -04:00
Ihor Radchenko 506d5b12dd
org-comment-line-break-function: Avoid built-in Emacs comment machinery
* lisp/org.el (org-comment-line-break-function): Rely on Org
parser (`org-adaptive-fill-function') to determine comment filling.
Handle nil values of `fill-prefix' correctly.

* testing/lisp/test-org.el (test-org/default-indent-new-line): New
test.  Written by Kaushal Modi <kaushal.modi@gmail.com>
https://list.orgmode.org/CAFyQvY36DkBSNy2mPxDNZWeoTjUK8mAqgJM-zHxNamfReqGkuQ@mail.gmail.com/

Reported-by: Richard Lawrence <richard.lawrence@uni-tuebingen.de>
Link: https://list.orgmode.org/87lf18fue9.fsf@aquinas.i-did-not-set--mail-host-address--so-tickle-me/
2022-10-04 19:47:11 +08:00
Ihor Radchenko 9db57aee3e
Do not use visual `current-indentation' when we need real values
* lisp/org-macs.el (org-current-text-indentation): New macro
calculating the real text indentation disregarding buffer visibility.
(org-do-remove-indentation):
* lisp/org-src.el (org-src--edit-element):
* lisp/org.el (org-indent-line):
(org-indent-region):
(org-toggle-fixed-width):
(org-comment-or-uncomment-region):
* lisp/ox.el (org-export-expand-include-keyword): Use
`org-current-text-indentation' instead of `current-indentation' and
`org-current-text-column' instead of `current-column' when we need
real text values but not visible values.

See https://debbugs.gnu.org/cgi/bugreport.cgi?bug=56837

Reported-by: tony aldon <tony.aldon.adm@gmail.com>
Link: https://orgmode.org/list/87k0h49s7z.fsf@localhost
2022-10-04 15:21:20 +08:00
Kyle Meyer 6a30ef2781 org.el: Move definition to silence warning
* lisp/org.el (org-agenda-file-menu-enabled): Move definition upstream
of its first use.

'make single' flags this (and so would the Emacs repo's build).
2022-10-03 18:44:22 -04:00
Kyle Meyer b196a05f5a Clean up spacing to pass Emacs's pre-commit check
Avoid trailing spaces and spaces before tabs.
2022-10-03 17:57:03 -04:00
Bhavin Gandhi 2e012db31a
org.el: Make sure `org-add-log-note' runs at the end of Org command
* lisp/org.el (org-add-log-setup): Save `this-command' and
`recursion-depth' before adding the `org-add-log-note' to
`post-command-hook'.
(org-add-log-note): Execute only if the current `(recursion-depth)'
and `this-command' are same as the ones we saved during the log-setup.

(org-log-note-this-command):
(org-log-note-recursion-depth): New variables storing `this-command'
and `recursion-depth'.

This change tries to make sure that we run the `org-add-log-note' only
after the current Org command has finished executing.  Previously, the
`post-command-hook' was getting triggered if the Org command in turn
runs some other command.

Fixes the bug originally reported by Michael Powe.

Bhavin Gandhi. [BUG] org-auto-repeat-maybe: error "Can’t expand
minibuffer to full frame" and missing log note.
Sat, 18 Jun 2022 23:30:50 +0530.
https://list.orgmode.org/CAOn=hbcsOCO++We0XgRHFoxxCEXROCpyGd1nCjzKYy-9LckQZg@mail.gmail.com/

Relevant discussion on bug-gnu-emacs: https://debbugs.gnu.org/56425
2022-09-26 20:41:54 +08:00
Ihor Radchenko c8e0a402df
org: Prefer standard version format accepted by `version-to-list'
* lisp/org.el: Rename Org version on development branch from "9.6-dev"
to "9.6-pre".  The latter is accepted by `version-to-list'.

See https://orgmode.org/list/87edvzbniw.fsf@gnu.org
2022-09-26 19:14:20 +08:00
Ihor Radchenko 3b0c4ad207
lisp/org.el: Do not skip loading org-loaddefs when using `eval-buffer'
* lisp/org.e: Do not skip loading "org-loaddefs.el" when Org mode is
loaded through M-x eval-buffer.

Fixes https://orgmode.org/list/874jwyalo1.fsf@localhost
2022-09-25 11:18:29 +08:00
TEC d1c6d02092
ob-core: Display type of element babel executes
* lisp/ob-core.el (org-babel-execute-src-block): The babel execute
function is run on more than just source blocks, so it makes sense to
note the type of element being executed.  A fourth optional argument is
added to allow for explicit specification of the type of element
responsible for the execution.

* lisp/ob-lob.el (org-babel-lob-execute-maybe): Pass the type of the
execution triggering element to `org-babel-execute-src-block'.

* lisp/org.el (org-ctrl-c-ctrl-c): When executing a babel call, pass the
type of the execution triggering element to
`org-babel-execute-src-block'.
2022-09-24 17:10:46 +08:00
Ihor Radchenko 0a6a56c804
org-adapt-indentation: Fix 'headline-data checks
* lisp/org.el (org--at-headline-data-p): New function used to check if
element at point belongs to headline data.
(org--get-expected-indentation):
(org-indent-line): Use `org--at-headline-data-p' instead of
explicit (and inaccurate) condition.
* testing/lisp/test-org.el (test-org/indent-region): Add tests.

Fixes incorrect LOGBOOK drawer indentation when
`org-adapt-indentation' is set to 'headline-data.
2022-09-24 14:07:31 +08:00
Ihor Radchenko d240386c10
org-diary-sexp-entry: Re-use cached nil return values
* lisp/org.el (org-diary-sexp-entry): Do not consider cached nil
return values as if they are not cached.
2022-09-23 12:57:13 +08:00
stardiviner 95df82c5fc
org.el: Support subtree-level org-image-actual-width overriding
* lisp/org.el (org-display-inline-image--width): Support new property
"ORG-IMAGE-ACTUAL-WIDTH" overriding global variable
`org-image-actual-width'.
2022-09-21 15:45:30 +08:00
Ihor Radchenko 4075662c29
org-diary-sexp-entry: Cache results
* lisp/org.el (org--diary-sexp-entry-cache): New variable holding
cached return values of `org-diary-sexp-entry'.
(org-diary-sexp-entry): Use `org--diary-sexp-entry-cache'.
2022-09-21 12:42:34 +08:00
Ihor Radchenko c35a856048
org-in-archived-heading-p: Improve performance
* lisp/org.el (org-in-archived-heading-p): Use explicit `while' loop
instead of `org-element-lineage'.
2022-09-21 12:26:53 +08:00
Ihor Radchenko 0057cc21e1
Improve agenda performance
* lisp/org-agenda.el (org-agenda-skip): Make use of ELEMENT argument
when calling `org-in-src-block-p'.
(org-agenda-get-sexps): Pass actual element at point to `org-agenda-skip'.
* lisp/org.el (org-end-of-subtree): Avoid unnecessary call to
`org-back-to-heading-or-point-min' when ELEMENT is provided.
2022-09-20 19:19:51 +08:00
Ihor Radchenko a526ea6a3e
Fix compiler warnings
* lisp/oc-basic.el (org-cite-basic--set-keymap): Do not use
`buffer-substring' generalized variable.  It is obsolete in Emacs 29.
Explicitly call `delete-region' + `insert'.
* lisp/org-agenda.el (org-element-lineage): Declare function.
* lisp/org.el (org--align-node-property): Use `delete-region' instead
of `buffer-substring' generalized variable.
2022-09-20 11:26:50 +08:00
TEC 1061db94ac
org: Tweak styling of url in resource prompt
* lisp/org.el (org--confirm-resource-safe): Style domain with a link,
and url with an underline.
2022-09-17 18:26:00 +08:00
TEC 1ae801e9c8
org: Add "mark domain as safe" convenience action
* lisp/org.el (org--confirm-resource-safe): Pick out domains from URLs,
and provide an option of marking that domain as safe.
2022-09-17 18:26:00 +08:00
Ihor Radchenko 17b51973bd
* lisp/org.el (org-log-beginning): Fix parens 2022-09-15 19:23:52 +08:00
Stefan Monnier 1a5e3f931c
testing: Make all files use `lexical-binding`
Mainly, add the corresponding cookie, but also add various `require`s
so that the compiler knows which vars should be trated as dynbound.
This does not fix all the warnings, but does try to eliminate
all those about "unused" variables.  For the variables truly unused,
the patch usually adds an underscore to their name to silence the warning.

Some of the fixes affect files which already used `lexical-binding`.
Not sure why the test worked before: maybe because the tests were run
without compiling them first (which could cause some of the
missing `require`d packages to be autoloaded before we got to the
problematic code, thus hiding the problem)?

I found some suspicious code, for which I added FIXMEs.

There are also a few changes to the main files.

* lisp/org-protocol.el (org-protocol-check-filename-for-protocol):
Don't call `server-edit` if it's not yet defined.  [ Needed to get
the tests to pass. ]

* lisp/ob-core.el (org-babel-temporary-directory)
(org-babel-temporary-stable-directory): Always define (and use nil
if we don't want to create a directory for it).  Simplify the code based
on the fact that (defvar V E) only evaluates E if V is not yet `boundp`.
(org-babel-temp-file, org-babel-temp-stable-file)
(org-babel-remove-temporary-directory)
(org-babel-remove-temporary-stable-directory): Adjust accordingly.

* lisp/org.el (org-log-beginning): Add FIXME.

* testing/org-test.el: Require `org` and `org-id`.
(org-id-locations-file): Don't `defconst` it.
(org-test-at-id, org-test-in-example-file, org-test-at-marker)
(org-test-with-temp-text, org-test-with-temp-text-in-file): Move edebug
specs into `declare` (and simplify them).
(org-test-with-tramp-remote-dir--worker): Declare dynbound tramp vars.
(org--compile-when): Fix quoting of `exp`.
(org-test-load): Tweak regexps.

* testing/org-batch-test-init.el: Tweak regexp, remove dead code and
add a FIXME about it.

* testing/lisp/test-ox.el: Require `ox` instead of
erroring out if it's not already loaded.  Also require `org-inlinetask`.
(org-test-with-parsed-data): Silence warnings when `info` is not used.
(test-org-export/bind-keyword): Add FIXME.

* testing/lisp/test-ox-publish.el: Require `org-test` and `ox-publish`.
(test-org-publish/resolve-external-link): Expose lambdas to
the compiler.  Remove unused var `ids`.
(test-org-publish/get-project-from-filename): Remove unused var `file`.

* testing/lisp/test-org.el: Require `org-macs`, `org`,
`org-inlinetask`, `org-refile`, and `org-agenda`.
(test-org/org-read-date): Declare `org-time-was-given` as dynbound.
(test-org/set-regexps-and-options): Add FIXME.

* testing/lisp/test-org-timer.el: Require `org-timer`.

* testing/lisp/test-org-table.el: Require `ox`.

* testing/lisp/test-org-protocol.el: Require `org-protocol` instead of
erroring out if it's not already loaded.  Also require `capture`, and
add missing `provide` statement.

* testing/lisp/test-org-pcomplete.el: Require `org`.

* testing/lisp/test-org-list.el: Require `org-list` and `org`.

* testing/lisp/test-org-lint.el: Require `org-footnote` and `org-lint`.

* testing/lisp/test-org-footnote.el: Require `org-footnote`.

* testing/lisp/test-org-element.el: Require `org-element` instead of
erroring out if it's not already loaded.  Also require `org` and
`org-inlinetask`.

* testing/lisp/test-org-duration.el: Require `org-duration`.

* testing/lisp/test-org-datetree.el: Require `org-datetree`.

* testing/lisp/test-org-colview.el: Require `org-colview`,
`org-duration`, and `org-inlinetask`.

* testing/lisp/test-org-clock.el: Require `org-duration` and `org-clock`.

* testing/lisp/test-org-archive.el: Require `org-archive`.

* testing/lisp/test-org-agenda.el
(test-org-agenda/bulk-custom-arg-func): Add FIXME.

* testing/lisp/test-ol.el: Require `ol` and `org-id`.
(test-org-link/store-link): Declare `org-store-link-props` and add FIXME.

* testing/lisp/test-oc.el (test-org-cite/export-capability): Add FIXME.

* testing/lisp/test-ob.el: Require `ob-core`, `org-src`, `ob-ref`,
and `org-table`.
(test-ob/eval-header-argument): Rename `foo` to `test-ob--foo` and
declare it as dynbound.
(test-ob/blocks-with-spaces, test-ob/specific-colnames): Add FIXME.
(test-ob/noweb-expansions-in-cache):
Declare `noweb-expansions-in-cache-var` as dynbound.

* testing/lisp/test-ob-tangle.el: Require `org` and `ob-tangle`.

* testing/lisp/test-ob-shell.el:
* testing/lisp/test-ob-python.el: Require `ob-core`.

* testing/lisp/test-ob-lob.el: Require `ob-lob`.
(temporary-value-for-test): Declare as dynbound.

* testing/lisp/test-ob-plantuml.el: Require `ob-plantuml` instead of
erroring out if it's not already loaded.
* testing/lisp/test-ob-lilypond.el: Require `ob-lilypond` instead of
erroring out if it's not already loaded.  Use `with-current-buffer`.

* testing/lisp/test-ob-julia.el: Require `ob-core`.

* testing/lisp/test-ob-java.el (org-babel-temporary-directory):
Remove dead code now that `org-babel-temporary-directory` is always bound.

* testing/lisp/test-ob-exp.el: Require `ob-exp`, `org-src`, and `org-test`.
(ob-exp/evaluate-all-executables-in-order):
Declare `*evaluation-collector*` as dynbound.

* testing/lisp/test-ob-emacs-lisp.el (ob-emacs-lisp/dynamic-lexical-edit)
(ob-emacs-lisp/dynamic-lexical-execute):
Rename dynbound var to `ob-emacs--x` and declare it as such.

* testing/lisp/test-ob-R.el: Require `ob-core`.
(ess-ask-for-ess-directory, ess-history-file): Declare vars.
2022-09-15 19:17:19 +08:00
Ihor Radchenko f8d740f707
org-log-beginning: Fix edge case when we create logbook at eob
* lisp/org.el (org-log-beginning): Fix edge case when current headline
is the last headline in the buffer and does not have a final newline.

Fixes https://orgmode.org/list/m21qvi8er5.fsf@ntnu.no
2022-09-13 22:02:11 +08:00
Ihor Radchenko 8ec328e827
org-log-beginning: Fix for headline at eob with no trailing newline
* lisp/org.el (org-log-beginning): Fix edge case when there is a
headline at the end of buffer and that headline does not have a
trailing newline.

Fixes https://orgmode.org/list/m24k0ffjyd.fsf@ntnu.no
2022-09-13 21:50:18 +08:00
Ihor Radchenko 2737128aa7
org-back-to-heading: Use cache
* lisp/org.el (org-back-to-heading): Use element cache when cache is
active.
2022-09-13 20:59:13 +08:00
Ihor Radchenko 4d8c6fbf7a
org-up-heading-safe: Consider inlinetasks
* lisp/org.el: Consider inlinetasks in the element-cache branch of the
code.

Fixes https://orgmode.org/list/CAP7OBx+G8nF1D7ci=QoduHXgqZRLkPZuDZeu8vEHEsAQ3qn3hw@mail.gmail.com
2022-09-13 20:57:31 +08:00
Ihor Radchenko 7c20552ed6
org-babel-load-languages: Link to the manual for language list
* lisp/org.el: Update docstring linking to the manual for the list of
supported babel languages.

Reported in https://orgmode.org/list/86fsh61a3u.fsf@gmail.com
2022-09-09 19:16:40 +08:00
Max Nikulin f25b308af6
org.el: Avoid dlink identifiers in `org-open-file'
* lisp/org.el (org--file-apps-entry-locator-p): Rename from
`org--file-apps-entry-dlink-p'.
(org-open-file): Avoid confusing "dlink" part of some identifiers.
Earlier `dlink' local variable was removed to prevent an issue with
distorted case of link components.
2022-09-09 19:03:51 +08:00
Max Nikulin 6e9ea3a076
org.el: Preserve case for link subgroups from `org-file-apps'
* lisp/org.el (org-open-file): Avoid matching of `org-file-apps' records
against the link converted to downcase since it caused incorrect
substitutions to the command.

Consider the following entry

    (add-to-list
     'org-file-apps
     '("\\.PDF\\(?:\\.[gx]z\\|\\.bz2\\)?::\\(#[^:]*\\)::\\(.+\\)\\'"
      . "okular --find %2 -- %s%1"))

and the link
<file:///usr/share/doc/bash/bashref.pdf::#Redirections::before>
Without the patch

    okular --find before -- /usr/share/doc/bash/bashref.pdf\#redirections

command is executed and the application can not resolve internal
cross-reference anchor.

In https://list.orgmode.org/4B51D104.9090502@jboecker.de/T/#u
https://list.orgmode.org/k2jfb2eb6811004041733zf176e0aq8367924746db81f5@mail.gmail.com/T/#u
the purpose of `dlink' is not clarified, so I assume that the only
purpose is to allow matching file suffixes, e.g. ".pdf" vs ".PDF".
2022-09-09 19:03:50 +08:00
Max Nikulin 33686b9955
org.el: Pass link match data to `org-file-apps' functions
* lisp/org.el (org--file-apps-entry-dlink-p): Fix it to pass match data
to handler functions from `org-open-file' alist when pattern field of
`org-file-apps' contains regexp subgroups.

Update `org--file-apps-entry-dlink-p' to use current convention for action
field of `org-file-apps' structure.  Currently it may be a function while
earlier s-expression was allowed.  Obsolete test wrongly separated actions
able to handle regexp subgroups matched in the link.  An example when
match data were not passed to the handler function:

    (add-to-list
     'org-file-apps
     '("\\.pdf\\(?:\\.gz\\|\\.bz2\\|\\.xz\\)?\\(?:::.*\\)?\\'"
        . my-open-pdf-locator))

Notice that lambda functions passed `consp' test, so namely
`defun' is required to reproduce the issue.

This change was missed in the commit:

     c8a3ab1e4 2016-02-03 18:30:17 +0100
     Nicolas Goaziou: `org-file-apps' accept functions instead of sexp

For discussion of the issue with evaluation of arbitrary expression see
https://list.orgmode.org/CALn3zoh+ACSU09eRurfwKjmCnw7i-_0KX7tA2jWqtu=vvQepLQ@mail.gmail.com/T/#u
Michael Brand. org-player and switch to lexical binding in org.el.
Sun, 17 Jan 2016 19:58:38 +0100
2022-09-09 19:03:49 +08:00
Ihor Radchenko e73c5b7d0d
Fix Emacs 29 compiler warnings
* lisp/oc-basic.el (org-cite-basic--parse-bibliography): Do not use
obsolete `buffer-file-name' generalized variable.  Prefer
`set-visited-file-name'.
* lisp/ol-bibtex.el (org-indent-region): Declare function.
(org-bibtex-import-from-file): Remove unused variable.
* lisp/ol.el (org-link--decode-compound): Use `ash' instead of
obsolete `lsh'.
* lisp/org-macs.el: Do no use obsolete generalized variable
`buffer-string'.
* lisp/org-plot.el (org-plot/redisplay-img-in-buffer):
* lisp/org.el (image-flush):
(org-display-inline-images): Use `image-flush' instead of obsolete
`image-refresh'.
* lisp/ox.el (org-export-to-file): Quote ' in the docstring.

All other changes are changing obsolete `point-at-bol' and
`point-at-eol' to `line-beginning-position' and `line-end-position'.
2022-09-06 20:50:59 +08:00
Ihor Radchenko a3788bd8be
org-scan-tags: Fix messed match groups in eeb4fa8c0
* lisp/org.el (org-scan-tags): Match space after TODO keyword outside
group and match the TODO-keyword in its own group.
2022-09-05 18:50:52 +08:00
Ihor Radchenko eeb4fa8c09
org-scan-tags: Fixup a1c923afd
* lisp/org.el: Drop missed 'words argument to `regexp-opt'.
2022-09-05 18:14:05 +08:00
Max Nikulin ac2d0a249e
org.el: Fix percent substitutions in `org-open-file'
* lisp/org.el (org--open-file-format-command): New function with better
coverage of mailcap RFC 1524 syntax.  Do not replace percent character
in file name or link component, fix substitution of multiple regular
expression groups matched in the link target.
(org-open-file): Use `org--open-file-format-command' instead of inline
code.
* testing/lisp/test-org.el (org-test/org--open-file-format-command):
Tests for `org--open-file-format-command'.

The primary goal of moving code outside of `org-open-file' function is to
make it testable.

It should fix the following issues:
- Maxim Nikulin. greedy substitution in org-open-file.
  Wed, 20 Jan 2021 23:08:35 +0700.
  https://list.orgmode.org/ru9ki4$t5e$1@ciao.gmane.io
- Rodrigo Morales. Org mode links: Open a PDF file at a given page
  and highlight a given string. Tue, 02 Mar 2021 15:07:32 -0500.
  https://list.orgmode.org/87lfb5pbej.fsf@gmail.com
2022-09-05 13:27:14 +08:00
Ihor Radchenko e81a094383
Assert all the Org files to load the same Org version
* lisp/org-compat.el (org-assert-version): New macro comparing Org
version at compile time and laod time.

Add `org-assert-version' call to all files:

* lisp/org-macs.el:
* lisp/org-crypt.el:
* lisp/org-ctags.el:
* lisp/org-cycle.el:
* lisp/org-datetree.el:
* lisp/org-duration.el:
* lisp/org-element.el (avl-tree):
* lisp/org-entities.el:
* lisp/org-faces.el:
* lisp/org-feed.el:
* lisp/org-fold-core.el:
* lisp/org-fold.el:
* lisp/org-footnote.el:
* lisp/org-goto.el:
* lisp/org-habit.el:
* lisp/org-id.el:
* lisp/org-indent.el:
* lisp/org-inlinetask.el:
* lisp/org-keys.el:
* lisp/org-lint.el:
* lisp/org-list.el:
* lisp/org-macro.el:
* lisp/org-mobile.el:
* lisp/org-mouse.el:
* lisp/org-num.el:
* lisp/org-pcomplete.el:
* lisp/org-persist.el:
* lisp/org-plot.el:
* lisp/org-protocol.el:
* lisp/org-refile.el:
* lisp/org-src.el:
* lisp/org-table.el:
* lisp/org-tempo.el:
* lisp/org-timer.el:
* lisp/org.el:
* lisp/ox-ascii.el:
* lisp/ox-beamer.el:
* lisp/ox-html.el:
* lisp/ox-icalendar.el:
* lisp/ox-koma-letter.el:
* lisp/ox-latex.el:
* lisp/ox-man.el:
* lisp/ox-md.el:
* lisp/ox-odt.el:
* lisp/ox-org.el:
* lisp/ox-publish.el:
* lisp/ox-texinfo.el:
* lisp/ox.el:
2022-09-04 12:24:55 +08:00
Bastien 8ef6205a56 lisp/org.el: Bump version to 9.5.5 2022-09-03 20:54:27 +02:00
Ihor Radchenko a1c923afda
org-scan-tags: Allow arbitrary character classes in todo keywords
* lisp/org.el (org-scan-tags): Do not assume that todo keywords are
words.

Fixes https://orgmode.org/list/C5370FC1-ABBB-4FA1-8364-5B1DF0FB4755@irq0.org
2022-09-03 16:12:22 +08:00
Ihor Radchenko 5ba90e161b
org-bibtex-import-from-file: Improve performance
* lisp/ol-bibtex.el (org-bibtex-put): Add new optional argument to
insert node property at point directly, without leveraging
`org-set-property'.  Add docstring.
(org-bibtex-write): Insert headline properties directly.  Add new
optional argument to suppress indentation.  Do not use `length' to
check if `org-bibtex-entries' list empty---`length' is too slow on
large lists.
(org-bibtex-import-from-file): Postpone indentation after all the
entries are imported.
* lisp/org.el (org-indent-region): Use cache.
2022-08-27 12:09:31 +08:00
Ihor Radchenko 090dacb0a9
org-fast-tag-selection: Make group tags separator not break alignment
* lisp/org.el (org-fast-tag-selection): Start " : " group tags
separator before tag column in the menu.

Reported in https://orgmode.org/list/62f04f7c.d40a0220.9da67.0a2cSMTPIN_ADDED_BROKEN@mx.google.com
2022-08-22 19:51:47 +08:00
Ihor Radchenko ccca8549a2
org-align-tags: Fix tag alignment in inlinetasks
* lisp/org.el (org-align-tags): Re-use 'line-prefix text property when
`org-indent-mode' is enabled.  The old version partially copy-pasted
the org-indent code and missed the new changes in inlinetask
alignment.  The new approach should be robust against future
org-indent changes.

Fixes https://orgmode.org/list/25334.19025.107017.390781@gargle.gargle.HOWL
2022-08-20 15:13:14 +08:00
Ihor Radchenko b4e41b9879
org-insert-heading-respect-content: Fix test failures after a1af06d64
* lisp/org.el (org-insert-todo-heading-respect-content): Ignore the
optional argument always inserting a heading.
2022-08-20 14:24:47 +08:00
Ihor Radchenko a1af06d643
org-insert-heading-respect-content: Fix the argument order
* lisp/org.el (org-insert-todo-heading-respect-content): Fix the order
of arguments inside the `org-insert-todo-heading' call.

Fixes https://orgmode.org/list/m1a683p42k.fsf@rrudakov-mbp.lan
2022-08-20 14:01:49 +08:00
Ihor Radchenko 97d4d927f2
org-agenda-prepare-buffers: Avoid excessive memory allocation
* lisp/org.el (org-agenda-prepare-buffers): Avoid creating huge lists
when computing `org-todo-keywords-for-agenda',
`org-done-keywords-for-agenda', and
`org-todo-keyword-alist-for-agenda'.  Instead of using `append' in
every single agenda file + `org-uniquify' on a giant lists at the end,
check and add unique list elements in place.

This patch reduces load on Emacs GC when the number of agenda files is
large.
2022-08-18 19:10:59 +08:00
Ihor Radchenko 4080938d60
org-agenda-prepare-buffers: Avoid repetitive updates of agenda menu
* lisp/org.el (org-agenda-file-menu-enabled): New variable controlling
whether `org-mode' updates the agenda file list in the menu.
(org-mode): Honor the new variable.
(org-agenda-prepare-buffers): Suppress `org-install-agenda-files-menu'
when opening the agenda files.  Run it once at the end.

This commit reduces performance overheads when the number of agenda
files is large.
2022-08-18 19:08:45 +08:00
Ihor Radchenko edf46425bb
org-copy-visible: Prevent Emacs storing primary-selection in kill-ring
* lisp/org.el (org-copy-visible): Make sure that the visible text is
the first entry in `kill-ring' upon exiting `org-copy-visible'.  This
was previously not the case when `select-enable-primary' is non-nil.

The fix only works in Emacs 29 after
https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=0ab572d5c991dee4818d364a65e004d20f1f45a1
See https://debbugs.gnu.org/cgi/bugreport.cgi?bug=57147

Fixes https://orgmode.org/list/25331.25617.528381.574211@gargle.gargle.HOWL
2022-08-13 22:39:53 +08:00
Ihor Radchenko 6ad65f3332
org-agenda-prepare-buffers: Avoid quadratic complexity when merging tags
* lisp/org.el (org-agenda-prepare-buffers): Use the shortest list as
the first argument in `org--tag-add-to-alist'.

`org--tag-add-to-alist' is looping over the first argument.  When we
use the accumulated tags as the first argument, each buffer tag will
need to be looped over N_buffers/2 times on average, creating
quadratic complexity.  Avoid this.

Reported in https://orgmode.org/list/62f66552.050a0220.ed346.ac05SMTPIN_ADDED_BROKEN@mx.google.com
2022-08-13 16:46:48 +08:00
Ihor Radchenko b8a0ddf52f
Use the full org-fold-core API when `org-fold-core-style' is `overlays'
The old fallback folding mechanism was re-using old function versions
to work with overlay folds directly.  Switch to using org-fold-core
API instead.  This avoids code duplication.

* lisp/ol.el (org-toggle-link-display--overlays): Merge overlay and
text-property versions.
(org-toggle-link-display--text-properties):
(org-toggle-link-display):
* lisp/org-cycle.el (org-cycle-overview--overlays):
(org-cycle-overview--text-properties):
(org-cycle-overview):
(org-cycle-content--text-properties):
(org-cycle-content):
(org-cycle-content--overlays):
* lisp/org-element.el (org-element-swap-A-B--overlays):
(org-element-swap-A-B):
(org-element-swap-A-B--text-properties):
* lisp/org-fold.el (org-fold-save-outline-visibility--overlays):
(org-fold-save-outline-visibility--text-properties):
(org-fold-save-outline-visibility):
(org-fold-region--overlays):
(org-fold-region):
(org-fold-show-all--text-properties):
(org-fold-show-all--overlays):
(org-fold-show-all):
(org-fold-show-branches-buffer--text-properties):
(org-fold-show-branches-buffer):
(org-fold-show-branches-buffer--overlays):
(org-fold--hide-drawers--overlays):
(org-fold--hide-drawers--text-properties):
(org-fold--hide-drawers):
(org-fold-show-set-visibility--overlays):
(org-fold-show-set-visibility--text-properties):
(org-fold-show-set-visibility):
(org-fold-check-before-invisible-edit--overlays):
(org-fold-check-before-invisible-edit--text-properties):
(org-fold-check-before-invisible-edit):
(org-fold--hide-wrapper-toggle):
* lisp/org-inlinetask.el (org-inlinetask-toggle-visibility--text-properties):
(org-inlinetask-toggle-visibility):
(org-inlinetask-toggle-visibility--overlays):
* lisp/org-list.el (org-list-swap-items--text-properties):
(org-list-swap-items):
(org-list-swap-items--overlays):
* lisp/org-macs.el (org-invisible-p--text-properties):
(org-invisible-p):
(org-invisible-p--overlays):
(org-find-visible--overlays):
(org-find-visible--text-properties):
(org-find-visible):
(org-find-invisible--overlays):
(org-find-invisible--text-properties):
(org-find-invisible):
* lisp/org.el (org-next-visible-heading--overlays):
(org-next-visible-heading--text-properties):
(org-next-visible-heading):
(org--forward-paragraph-once--overlays):
(org--forward-paragraph-once--text-properties):
(org--forward-paragraph-once):
(org--backward-paragraph-once--overlays):
(org--backward-paragraph-once--text-properties):
(org--backward-paragraph-once):

* testing/lisp/test-org.el (test-org/drag-element-backward):
(test-org/drag-element-forward): Update tests.
2022-08-13 15:03:28 +08:00
Ihor Radchenko 6acc58c9c6
* lisp/org.el (org-get-buffer-tags): Remove text properties from tags
Do not preserve buffer text properties.  They may will be shown in the
completion as well, which is not expected by users.

Fixes https://orgmode.org/list/CAKJdtO_0aUmiKFjS34hoD525vMFkUJuVCCzGrFfR_Lt2_Vm58g@mail.gmail.com
2022-08-11 19:38:33 +08:00
Hanno Perrey 4db67da68d
org.el: Improve automatic fast tag selection keys
* lisp/org.el (org-fast-tag-selection): After automatically assigning
a-z as keys for selection, offer A-Z range.  Continue with characters up
to tilde character before showing only blanks.  Replaces previous logic
where also hard-to-type characters were assigned.

TINYCHANGE
2022-08-08 21:17:03 +08:00
Ihor Radchenko a303a794f8
Support interactive editing of comment blocks
* lisp/org-src.el (org-edit-comment-block): New command to edit
comment block elements.  The command auto-escapes Org markup inside.
(org-src--contents-area):
* lisp/org.el (org-insert-structure-template):
(org-edit-special): Support comment blocks.
* etc/ORG-NEWS (Interactive commands now support escaping text inside
comment blocks):
(New command ~org-edit-comment-block~ to edit comment block at point):
Document the new features.

See https://orgmode.org/list/87y1wc3ruw.fsf@mat.ucm.es
2022-08-07 17:39:08 +08:00
Ihor Radchenko a0b21e3f1c
* lisp/org.el (org-set-tags-command): Put local tags on top
See https://orgmode.org/list/7AB4F327-24D0-4BA5-BD20-B329D4CBBF0A@hoowl.se
2022-08-06 15:59:47 +08:00
Ihor Radchenko 215de6176b
Partially revert "org-mode: Make local variables effective during Org startup"
This reverts commit e22b4eb7aa.

See
https://list.orgmode.org/87r11wkmew.fsf@ucl.ac.uk/T/#mab6359ed2107d5515c6bb6b266551f0c5049ceca

The problem with the commit is that correctly loading local variables
early requires re-implementing all the built-in tricks done by Emacs,
like not enabling local variables in temp buffers or non-file buffers.

In addition, even if we call `hack-local-variables' manually, Emacs
will repeat the normal call later, possibly asking for non-safe
variables twice.

In conclusion, the whole idea of manual triggering local variables is
fragile and should better be handled by Emacs itself via stable API.

testing/.dir-locals.el is kept.
2022-08-05 19:57:36 +08:00
TEC 4702a73031
org: Fix resource prompt in non-file buffers
* lisp/org.el (org--confirm-resource-safe): When `buffer-file-name' is
nil, skip over file-specific behaviour.
2022-08-03 21:39:24 +08:00
Ihor Radchenko fde93abb8c
org-mode: Prevent early fontification
* lisp/org.el (org-mode): Avoid triggering fontification when
`hack-local-variables' popup window is displayed.  Font-lock settings
are not configured yet at this point.

Fixes https://orgmode.org/list/87r120kodw.fsf@yandex.com
2022-08-03 17:33:31 +08:00
Ihor Radchenko e22b4eb7aa
org-mode: Make local variables effective during Org startup
* lisp/org.el (org-mode): Call `hack-local-variables' early during Org
mode startup.  This way, Org startup options will regard local
variable settings.

* testing/.dir-locals.el: Create a stub dir-locals file to prevent
tests from being affected by directory-local settings of the root Org
repo folder.

Fixes
https://list.orgmode.org/587be554-906c-5370-2cf2-f08b14fa58ff@gmail.com/T/#u
2022-07-31 18:17:53 +08:00
Ihor Radchenko b4d7a24f07
Make org-shiftmetaleft/org-shiftmetaright honour shift-select on MacOS
* lisp/org.el (org-shiftmetaleft):
(org-shiftmetaright): Honour shift-select bound to meta-arrow on
MacOS when `org-support-shift-select' is non-nil.

Fixes https://orgmode.org/list/CAEOO5Tdg6sdjNfAg=J_DVQ50xx1oxaFaVyyYnda6O_-t3hG2jg@mail.gmail.com
2022-07-31 15:26:40 +08:00
Ihor Radchenko f095cfc3c0
* lisp/org.el (org-store-log-note): Do not indent empty lines in notes
See https://orgmode.org/list/m235eo9d8b.fsf@ntnu.no
2022-07-31 13:07:06 +08:00
Ihor Radchenko 2861d9cad8
org-paste-subtree: Do not use `insert-before-markers'
* lisp/org.el (org-paste-subtree): Use `insert' instead of
`insert-before-markers'.  The former is what people usually expect and
doing otherwise is surprising.
* lisp/org-archive.el (org-archive-to-archive-sibling): Do not expect
`org-paste-subtree' to insert before markers.
2022-07-31 13:05:15 +08:00
Ihor Radchenko 785f003de5
org-fold-show-entry: Do not fold drawers unless requested
* lisp/org-fold.el (org-fold-show-entry): Do not fold drawers in the
unfolded entry unless the new optional argument is non-nil.  Folding
the drawers was introduced in 1027e02569, but does not follow the
function docstring.  Moreover, folding drawers creates unexpected
behaviour in some cases.  See
https://orgmode.org/list/m2a6bl4mmr.fsf@andrew.cmu.edu

* etc/ORG-NEWS (~org-fold-show-entry~ does not fold drawers by default
anymore): Document the change.

* lisp/org-agenda.el (org-agenda-show):
(org-agenda-show-and-scroll-up):
(org-agenda-show-1):
* lisp/org-compat.el (outline-toggle-children):
* lisp/org.el (org-move-subtree-down):
(org-return): Explicitly request folding drawers inside the revealed
entry in the places where it appears to make sense.

* lisp/org-timer.el (org-timer--get-timer-title): Do not unfold entry
at all.  This is a noninteractive function.
2022-07-31 10:17:08 +08:00
Ihor Radchenko bc875e5ccf
Fix feature regexp used to detect Org library names
* lisp/org.el (org-reload):
* mk/org-fixup.el (org-make-org-loaddefs): Distinguish ol-*.el and
oc-*.el libraries as parts of Org-related libraries.
2022-07-28 20:26:14 +08:00
Ihor Radchenko 5be0c709b3
* lisp/org.el (org-reload): Do not quote t symbol 2022-07-26 22:17:04 +08:00
TEC 6ad53fa22e
org: Correct regexp escaping to use regexp-quote
* lisp/org.el (org--confirm-resource-safe): `regexp-opt' was
accidentally used instead of `regexp-quote'.
2022-07-26 12:49:51 +08:00
Paul Eggert 6013cb161d Fix doc string quoting problems with '
The Emacs doc string convention is to document values as-is when that
is clear, and surrounded by `single quotes' otherwise. For example, a
doc string "(a b c)" stands for a list of symbols, and the doc string
"`a'" stands for a single symbol. The doc string "\\=`a" is typically
not correct for that single symbol, because that is equivalent to
"(quote a)" and the typical intent is to talk about the symbol, not
about the Lisp quoting construct.  One needs "\\=`X" only when talking
about something intended to be equivalent to "(quote X)", as in the
doc string "(provide \\='org-xyz)".
2022-07-25 13:10:29 -07:00
TEC 6de5431acc
org: Refactor rx to concat + regexp-opt
* lisp/org.el (org--confirm-resource-safe): Since Emacs 26 doesn't
support rx's (literal S) construct, use (concat (regexp-opt ...) ...)
instead.
2022-07-24 22:07:46 +08:00
Robert Pluim 01b0fb14bc
Backport from main: Escape single left quotes in docstrings
* lisp/ob-core.el (org-babel-default-header-args):
* lisp/ob-julia.el (org-babel-julia-evaluate-external-process):
(org-babel-julia-evaluate-session):
* lisp/ob-lua.el (org-babel-lua-read-string):
* lisp/ob-table.el (org-sbe):
* lisp/oc-basic.el (org-cite-basic--shorten-names):
* lisp/org-agenda.el (org-agenda-sorting-strategy):
(org-agenda--mark-blocked-entry):
(org-agenda-set-restriction-lock):
* lisp/org-fold-core.el (org-fold-core--specs):
(org-fold-core-remove-folding-spec):
(org-fold-core-get-folding-spec):
(org-fold-core--isearch-overlays):
* lisp/org-plot.el (org--plot/prime-factors):
* lisp/org-table.el (org-table-collapse-header):
* lisp/org.el (org-special-ctrl-o):
(org-latex-to-html-convert-command):
* lisp/ox-html.el (org-html--unlabel-latex-environment):
* lisp/ox-publish.el (org-publish-find-property):
Use \\=' when there's a need for a single left quote in a docstring.

The emacs-29 byte compiler complains about such usage.
2022-07-24 20:19:11 +08:00
TEC 99681ce389
org: Support completion of cite-related keywords
* lisp/org.el (org-get-export-keywords): Add BIBLIOGRAPHY, CITE_EXPORT,
and PRINT_BIBLIOGRAPHY to `org-options-keywords'.

It's worth noting that while based on the variable name
PRINT_BIBLIOGRAPHY may not seem to fit, it is in good company with
INCLUDE, and this variable is (exclusively) used as a list of
non-affiliated, non-block, non-export-backend-specific keywords for
pcomplete.  It may be a good idea to rename this for clarity, or split
it up in future.
2022-07-21 22:09:24 +08:00
Ihor Radchenko 9917d69543
org-indent-region: Fix when `org-adapt-indentation' is 'headline-data
* lisp/org.el (org--get-expected-indentation): Remove the extra
condition added in e3b79ad2b in the cond branch for first line in an
element.  Checking `org-adapt-indentation' t value here trigger the
last default cond branch that assumes that we are _not_ at the first
line.

The new logic explicitly avoids inheriting indentation from previous
sibling when `org-adapt-indentation' is set to 'headline-data and the
previous sibling is satisfying "headline data" condition as in
`org-indent-line'.  The case when `org-adapt-indentation' is set to t
is already handled correctly when calculating the CONTENTSP
indentation for parent headline.

Fixes https://orgmode.org/list/c13cab60-bbc9-e69e-6d0d-7fe75c5908d6@kalysto.org
2022-07-18 21:00:13 +08:00
Ihor Radchenko 057df6cce2
org-open-at-point: Do not list links under headline that cannot be opened
* lisp/org-element.el (org-element-context): Do not alter match-data.
* lisp/org.el (org-open-at-point): Update docstring listing that
`org-open-at-point' opens src-blocks and citations.
(org-offer-links-in-entry): Do not display links within invalid contexts.

Reported in https://list.orgmode.org/PAXPR06MB77609E8C8E769CD7D769FA4BC6199@PAXPR06MB7760.eurprd06.prod.outlook.com/
2022-07-17 20:14:44 +08:00
Max Nikulin ae1db7df39
Use `org-encode-time' helper macro
* lisp/ol.el (org-store-link):
* lisp/org-agenda.el (org-agenda-get-timestamps)
(org-agenda-get-progress, agenda-bulk-action):
* lisp/org-capture.el (org-capture-fill-template):
* lisp/org-clock.el (org-clock-get-sum-start)
(org-clock-special-range, org-clocktable-shift)
(org-clocktable-steps):
* lisp/org-colview.el (org-colview-construct-allowed-dates):
* lisp/org-datetree.el (org-datetree-find-iso-week-create)
(org-datetree-insert-line):
* lisp/org-element.el (org-element-timestamp-interpreter):
* lisp/org-macro.el (org-macro--vc-modified-time):
* lisp/org-macs.el (org-matcher-time):
* lisp/org.el (org-current-time, org-current-effective-time)
(org-add-planning-info, org-read-date, org-read-date-display)
(org-read-date-analyze, org-eval-in-calendar)
(org-calendar-select, org-display-custom-time)
(org-calendar-select-mouse, org-time-string-to-time)
(org-time-from-absolute, org-at-clock-log-p)
(org-date-from-calendar, org-get-cursor-date)
(org-timestamp-to-time):
* testing/lisp/test-org-clock.el (org-test-clock-create-timestamp):
* lisp/ox-icalendar.el (org-icalendar-convert-timestamp):
Avoid direct calls of `encode-time', use `org-encode-time' instead.

Org supports Emacs-26, but the recommended way to call `encode-time'
changed in Emacs-27.  In Emacs-29 DST and TZ elements of the single list
arguments became optional.  In Org it is still convenient to call the
function with separate arguments without explicit DST and TZ arguments.
The `org-encode-time' should mitigate attempts to modernize Org code
directly in the Emacs repository.
2022-07-17 16:40:18 +08:00
Paul Eggert 132a9d304e
Use unknown DST instead of standard time in timestamps
* lisp/ol.el (org-store-link): Prefer plain (encode-time ...)
to (apply 'encode-time ...), for speed.
* lisp/org-macs.el (org-parse-time-string): Return unknown DST,
not standard time.
* lisp/org.el (org-read-date-analyze): Return a timestamp with a DST
flag of -1 (unknown) rather than nil (standard time).

Max Nikulin:
A larger patch "Improve Org usage of timestamps" was suggested in
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=54764#10

Changes selected for this patch normalizes timestamp format:
if it is a list than it should contain 9 elements to be compatible
with Emacs-27 and Emacs-28 `encode-time' single argument, nil should not
be used for DST field since it means standard time while actual value
is unknown and should be guessed.

Ignacio Casso reported a problem with agenda
https://list.orgmode.org/PAXPR06MB7760238F410CBE3203F78EE0C61E9@PAXPR06MB7760.eurprd06.prod.outlook.com
due to Emacs commit dd0727e1ec1 changing Org code.  It was mostly reverted
by 8ef37913d3 (bug#54731).  Code in the Org repository did not have
the bug, but it safer to add protection against similar refactoring.
2022-07-17 16:38:50 +08:00
TEC 0583a0c5ea
org: Add setting for remote file download policy
* lisp/org.el (org-resource-download-policy, org-safe-remote-resources):
Two new customisations to configure the policy for downloading remote
resources.
(org--should-fetch-remote-resource-p, org--safe-remote-resource-p,
org--confirm-resource-safe): Introduce the new function
`org--should-fetch-remote-resource-p' for internal use determining
whether a remote resource should be downloaded according to the download
policy.  This function makes use of two helper functions,
`org--safe-remote-resource-p' and `org--confirm-resource-safe'.
(org-file-contents): Apply `org--safe-remote-resource-p' to file
downloading.

* lisp/org-persist.el (org-persist-write): Apply
`org--safe-remote-resource-p' to url downloading.

* lisp/org-attach.el (org-attach-attach, org-attach-url): Apply
`org--safe-remote-resource-p' to url downloading.
2022-07-16 17:46:01 +08:00
Ihor Radchenko 8e2fed82ed
org-fold: Make sure that changes do not leave partially folded headings
* lisp/org-fold-core.el (org-fold-core--fix-folded-region): Check
fragility in all the indirect buffers.
* lisp/org-fold.el (org-fold--reveal-headline-at-point): New function
revealing heading line or full heading when the heading only contains
blank lines.
(org-fold--reveal-outline-maybe): Check headline at the end of folded
region as well.  Use `org-fold-core--fix-folded-region'.
* lisp/org.el (org-insert-heading): Make sure that the newline in
front of heading is revealed.
2022-07-12 21:51:40 +08:00
Ihor Radchenko a79a742cbf
Revert "org.el: Improve performance of deletion commands"
This reverts commit 46df681336.

The optimization broke folding fragility checks.
2022-07-12 15:05:45 +08:00
Al Haji-Ali bc33c0133d
lisp/org.el: Save restrictions in all agenda file buffers
* lisp/org.el (org-agenda-prepare-buffers): Call
`org-with-wide-buffer' for every buffer in the agenda, instead of
calling `save-excursion'/'`save-restrictions' just for the current
buffer, to save restrictions in all buffers.  Use
`with-current-buffer' instead of `save-excursion'/'`set-buffer'.

See https://list.orgmode.org/orgmode/87y1x588rs.fsf@thinkpad.mail-host-address-is-not-set/

TINYCHANGE
2022-07-10 18:02:13 +08:00
Ihor Radchenko 0495961f36
org-auto-repeat-maybe: Use effective time for "LAST_REPEAT"
* lisp/org.el (org-auto-repeat-maybe): Use effective time when
recording LAST_REPEAT property.

Fixes https://orgmode.org/list/87sfnk7l0h.fsf@jonreeve.com
2022-07-07 18:16:14 +08:00
Sébastien Miquel 4e42500613 org.el: Fix the filling of regions containing lists
* lisp/org.el (org-setup-filling): Set fill-forward-paragraph-function.
(org--single-lines-list-is-paragraph): New internal variable.  Whether
a list with single lines items should be considered a single
paragraph.
(org--paragraph-at-point): use org--single-lines-list-is-paragraph.
(org-fill-paragraph): When an active region contains a list ensure
every item get filled.
* testing/lisp/test-org.el (test-org/fill-paragraph):
(test-org/fill-region): Test behaviour of fill-paragraph and
fill-region with an active region containing a list.

When filling paragraphs in a region, do not treat a list with single
lines items as a single paragraph.
2022-07-04 12:43:09 +02:00
Stefan Kangas 0ed0dea229
Delete some Emacs 24 compat code
Org mode supports Emacs 26 or newer:
https://orgmode.org/worg/org-maintenance.html#emacs-compatibility

* lisp/org-compat.el (org-set-transient-map)
(org-font-lock-ensure): Delete compat aliases.  Update callers.
(org-define-error): Redefine as obsolete function alias for
`define-error'.  Update callers.
(string-suffix-p): Delete compatibility definition.

* lisp/org-fold-core.el (org-fold-core--seq-partition): Delete private
function and update callers to use `seq-partition'.

* lisp/org-macs.el (org-without-partial-completion): Move from here...
* lisp/org-compat.el (org-without-partial-completion): ...to here.
Redefine as obsolete function alias for `progn'.
2022-07-02 12:10:00 +08:00
Stefan Kangas 41e19f1d7a
; Fix typos 2022-07-01 17:42:52 +08:00
Stefan Kangas 13d97ee18c
Prefer "website" to "homepage"
Emacs now advises using "website" (instead of "homepage") and
consequently to use the "URL" comment header instead of "Homepage".

* README:
* README_ELPA:
* doc/org-guide.org (Creating Footnotes):
* doc/org-manual.org (Creating Footnotes):
* etc/styles/README (URL): Prefer "website" to "homepage".

* lisp/*.el:
* mk/org-fixup.el: Replace the "Homepage" header comment with "URL".
2022-06-26 10:10:48 +08:00
Ihor Radchenko bcfed0f341
org-cycle.el: New custom setting `org-cycle-hide-drawer-startup'
* lisp/org-cycle.el (org-cycle-hide-drawer-startup):
* lisp/org-cycle.el (org-cycle-set-startup-visibility): Add new
customization to control initial folding state of the drawers.
* lisp/org.el (org-startup-options): Provide #+STARTUP option for the
new setting.

Fixes https://list.orgmode.org/m235gww8wg.fsf@ntnu.no/T/#u
2022-06-25 13:17:45 +08:00
Robert Pluim 2b1b428918
org.el (org-read-date): Point to Info documentation
* lisp/org.el (org-read-date): Add reference to Info documentation,
mainly because that describes all the available calendar navigation
commands.
2022-06-23 21:27:21 +08:00
Ihor Radchenko 7c61a3a801
org-unfontify-region: Handle invisible parts of links
* lisp/org.el (org-unfontify-region): Reveal folded parts of links.

Fixes https://orgmode.org/list/m2wndakbk0.fsf@ntnu.no
2022-06-21 20:26:22 +08:00
Stefan Kangas 45174d62b9
Remove XEmacs and ancient Emacs compat code
* lisp/org-colview.el (org-columns-remove-overlays):
* lisp/org-ctags.el (org-ctags-find-tag-interactive):
* lisp/org-macs.el (org-fit-window-to-buffer):
* lisp/org-mouse.el (org-mouse-show-context-menu):
* lisp/org-table.el (org-table-fedit-lisp-indent):
* lisp/org.el (org-version, org-reload):
* lisp/ox-html.el (org-html-template, org-html--build-meta-info):
Remove Emacs 21 and 22 compat code.

* lisp/ol-eww.el (org-eww-copy-for-org-mode):
* lisp/ol-w3m.el (org-w3m-copy-for-org-mode):
* lisp/org-clock.el (org-clock-select-task):
* lisp/org-macs.el (org-fit-window-to-buffer):
* lisp/org-refile.el (org-refile):
* lisp/org.el (org-change-tag-in-region): Remove XEmacs compat code.

* lisp/org-goto.el (org-goto--set-map):
* lisp/org-macs.el (org-fit-window-to-buffer):
* lisp/org-table.el (orgtbl-mode):
* lisp/org.el (org-setup-filling): Remove XEmacs or Emacs 19 or 20
compat code.  (It is one of these; not clear which.)
2022-06-18 15:43:30 +08:00
Ihor Radchenko 9632401dc6
Auto-Upcase/downcase #+begin/#+end in structure templates
* lisp/org-tempo.el (org-tempo-add-block):
* lisp/org.el (org-insert-structure-template): When inserting
 #+begin_type/#+end_type, follow type's case.  TYPE will become
 #+BEGIN_TYPE and type will become #+bein_type.

(org-insert-structure-template): Make sure that we use
case-insensitive match even when user changes case-fold-search value.

(org-structure-template-alist): Clarify selection of #+BEGIN/END
vs. #+begin/end in the docstring.

* etc/ORG-NEWS (Structure templates now respect case used in
~org-structure-template-alist~): Document the change.
2022-06-18 14:25:53 +08:00
Allen Li bfd63cc4f2
org: Improve org-todo handling of negative prefix args
* lisp/org.el (org-todo): Handle -1 prefix args consistently and error
on other negative args.
2022-06-18 14:07:11 +08:00
Sébastien Miquel 9fb9a2bdfb
org.el (org-format-latex-header): Put DEFAULT-PACKAGES before PACKAGES
* lisp/org.el (org-format-latex-header): Put DEFAULT-PACKAGES before
PACKAGES, as per org-latex-packages-alist's documentation.

`org-format-latex-header' is mostly used to generate in-buffer images
from LaTeX fragments.  For LaTeX document export, the header is
generated by `org-splice-latex-header' ond `org-latex-classes' instead
and the default and documented behaviour is to insert DEFAULT-PACKAGES
before PACKAGES.

See also
https://list.orgmode.org/877d5gg5rt.fsf@localhost/T/#m2ad2f3b1509e1af72016e8e6fad3557ff3083046
2022-06-18 12:46:53 +08:00
Robert Pluim e9da29b6fa
Escape single left quotes in docstrings
* lisp/ob-core.el (org-babel-default-header-args):
* lisp/ob-julia.el (org-babel-julia-evaluate-external-process):
(org-babel-julia-evaluate-session):
* lisp/ob-lua.el (org-babel-lua-read-string):
* lisp/ob-table.el (org-sbe):
* lisp/oc-basic.el (org-cite-basic--shorten-names):
* lisp/org-agenda.el (org-agenda-sorting-strategy):
(org-agenda--mark-blocked-entry):
(org-agenda-set-restriction-lock):
* lisp/org-fold-core.el (org-fold-core--specs):
(org-fold-core-remove-folding-spec):
(org-fold-core-get-folding-spec):
(org-fold-core--isearch-overlays):
* lisp/org-plot.el (org--plot/prime-factors):
* lisp/org-table.el (org-table-collapse-header):
* lisp/org.el (org-special-ctrl-o):
(org-latex-to-html-convert-command):
* lisp/ox-html.el (org-html--unlabel-latex-environment):
* lisp/ox-publish.el (org-publish-find-property):
Use \\=' when there's a need for a single left quote in a docstring.

The emacs-29 byte compiler complains about such usage.
2022-06-16 20:51:02 +08:00
Ihor Radchenko 8f59e8d93f
Fix native-comp warnings
* lisp/org-fold.el (org-fold-show-set-visibility--text-properties):
Resolve unused variable warning.

* lisp/ob-core.el (org-attach-dir):
* lisp/ob-latex.el (org-at-heading-p):
(org-back-to-heading):
(org-next-visible-heading):
* lisp/org.el (org-agenda-todo-yesterday):
* lisp/ox-ascii.el (org-at-heading-p):
(org-back-to-heading):
(org-next-visible-heading):
* lisp/ox-html.el (org-at-heading-p):
(org-back-to-heading):
(org-next-visible-heading):
* lisp/ox-icalendar.el (org-at-heading-p):
(org-back-to-heading):
(org-next-visible-heading):
* lisp/ox-latex.el (engrave-faces-latex-gen-preamble-line):
(engrave-faces-get-theme):
(engrave-faces-latex-output-style):
(engrave-faces-current-preset-style):
(engrave-faces-latex-mathescape):
* lisp/ox-odt.el (org-at-heading-p):
(org-back-to-heading):
(org-next-visible-heading):
* lisp/ox-publish.el (org-at-heading-p):
(org-back-to-heading):
(org-next-visible-heading):
* lisp/ox.el (org-at-heading-p):
(org-back-to-heading):
(org-next-visible-heading): Add declarations.
2022-06-16 13:19:10 +08:00
Ignacio Casso f9ea6c61ed
Use `set-default-toplevel-value' in `defcustom' setters
* lisp/ob-lilypond.el (org-babel-lilypond-commands):
* lisp/ob-shell.el (org-babel-shell-names):
* lisp/org-capture.el (org-capture-templates):
* lisp/org-clock.el (org-clock-ask-before-exiting):
* lisp/org-duration.el (org-duration-units):
* lisp/org-faces.el (org-set-tag-faces):
* lisp/org-footnote.el (org-footnote-section):
* lisp/org-list.el (org-plain-list-ordered-item-terminator):
(org-list-allow-alphabetical):
* lisp/org.el (org-babel-do-load-languages):
(org-set-modules):
(org-export-backends):
(org-use-fast-todo-selection):
(org-enforce-todo-dependencies):
(org-enforce-todo-checkbox-dependencies):
(org-display-custom-times):
(org-set-packages-alist):
(org-set-emph-re):
* lisp/ox-odt.el (org-odt-schema-dir): Use
`set-default-toplevel-value' instead of `set' or `set-default' in
`defcustom' :set argument.

This commit fixes a bug that occurred when using an autoload function
inside a let-binding for a custom variable when the feature defining
both the function and the custom variable had not been loaded yet.

See bug#54399 and
https://lists.gnu.org/archive/html/emacs-orgmode/2022-03/msg00085.html,
https://lists.gnu.org/archive/html/emacs-orgmode/2022-06/msg00226.html
2022-06-14 21:54:45 +08:00
Ihor Radchenko 0cdbc63a0b
org-mode: Do not re-bind `bidi-paragraph-direction'
* lisp/org.el (org-mode): Remove the old performance workaround for
right-to-left text in Org buffers.  With newer Emacs settings, it is
the 'left-to-right value of `bidi-paragraph-direction' that causes the
slowdown; not the vice versa.

Old discussion on overriding the defaults:
https://lists.gnu.org/archive/html/emacs-devel/2011-09/msg00285.html
The new discussion with example file demonstrating the performance
problem:
https://orgmode.org/list/87a6iqo7x8.fsf@localhost
2022-06-14 13:16:15 +08:00
Ihor Radchenko 147ca39750
org-in-commented-heading-p: Do not parse section unless already cached
* lisp/org.el (org-in-commented-heading-p): When element at point is
not yet in cache, parse the parent headline instead of also parsing
section up to point.
2022-06-12 13:04:25 +08:00
Ihor Radchenko 2f8e688516
org-back-to-heading-or-point-min: Rely less on cache
* lisp/org.el (org-before-first-heading-p): Do not try to parse the
whole section when there is no cached element at point.
2022-06-12 13:03:30 +08:00
Sébastien Miquel 1425a86ae7 org.el: With an active region, act with latex-preview
* lisp/org.el (org-latex-preview): With an active region, display
images for all fragments in the region. With universal prefix
argument, remove all images in the region.
2022-06-10 17:30:44 +03:00
Ihor Radchenko 57d64cf78c
Date/time prompt: Allow input of relative time in hours (e.g. +1h)
* lisp/org.el (org-read-date-analyze): Match relative hour specifier.

Fixes https://orgmode.org/list/C9A76EFA-1D76-4C5D-941D-AFA288A64CD0@icloud.com
2022-06-09 21:36:15 +08:00
Ihor Radchenko 819409baab
org-get-buffer-tags: Improve performance
* lisp/org.el (org-get-buffer-tags): Use hash table to accumulate
unique tags only.  The old approach also used hash tables under the
hood of `delete-dups', but required extra memory allocation to store
the full tag list.
2022-06-09 15:07:49 +08:00
Ihor Radchenko 46df681336
org.el: Improve performance of deletion commands
* lisp/org.el (org-delete-char):
(org-delete-backward-char): Wrap into
`org-fold-core-ignore-modifications'.  These commands are for
interactive use anyway and they have no risk of not inheriting folding
properties.
2022-06-09 15:07:29 +08:00
Ihor Radchenko c02c0d660d
org-do-emphasis-faces: Remove link folds if any
* lisp/org.el (org-do-emphasis-faces): Reveal hidden parts of links
fontified by `org-activate-link', if any.

Partially fixes
https://list.orgmode.org/t7np1d$vu8$1@ciao.gmane.io/T/#u
The proper fix should also involve `org-activate-link' not hitting
false-positives inside verbatim.
2022-06-08 21:39:19 +08:00
Bastien e0b05b0752 lisp/org.el: Bump version to 9.5.4 2022-06-03 08:37:30 +02:00
Ihor Radchenko 1525a5a64e
org-babel-load-file: Do not rely on `org-babel-tangle-file' making changes
* lisp/org.el (org-babel-load-file): Update modification time even
when `org-babel-tangle-file' does not actually modify the tangled
file.  This makes sure that modify-time comparison logic does not make
Org re-tangle Org file that had been changed but the changes did not
affect the tangled code.

See https://orgmode.org/list/t5j75h$dbo$1@ciao.gmane.io
2022-05-30 11:02:08 +08:00
Aaron L. Zeng 713c15d852
org-todo-yesterday: Fix interactive arg when in agenda buffer
* lisp/org.el (org-todo-yesterday): Fix an incorrect use of apply when
`org-todo-yesterday' intends to call `org-agenda-todo-yesterday' with
the same interactive arg.  Before this change, the command incorrectly
set the todo state of the task to blank when called with C-u C-u C-u
in an agenda buffer (supposed to bypass any blocked
checkboxes/subtasks).

TINYCHANGE
2022-05-26 12:32:58 +08:00
Tyler Grinn e268e47971
lisp/org.el: Add org-property-separators option
* lisp/org.el (org-property-separators, org-property-get-separator):
Created.
(org-entry-get, org-entry-get-with-inheritance): Use new
`org-property-get-separator' function.

* testing/lisp/test-org.el (test-org/entry-get): Added tests for
combining properties with custom separators

`org-property-separators' is a customization option that allows for
properties to be combined using a separator other than the default (a
single space).  It is an alist with the car of each element being a
list of property names or regular expression and the cdr being the
separator string, like '((("EXPORT_FILE_NAME") . "/")).
2022-05-20 15:56:11 +08:00
Ihor Radchenko cdbb1c9633
org--deadline-or-schedule: Allow warning period in TIME argument
* lisp/org.el (org--deadline-or-schedule): Match warning period if
provided in TIME arg.
* testing/lisp/test-org.el (test-org/deadline): Add relevant tests.

Fixes https://orgmode.org/list/87o85bl582.fsf@localhost
2022-05-15 14:49:10 +08:00
Ihor Radchenko 513ab7c48c
Merge branch 'bugfix' 2022-05-14 19:34:41 +08:00
Ihor Radchenko ef41f385fb
fixup! org-babel-load-file: Fix loading with non-nil COMPILE argument 2022-05-14 19:34:08 +08:00
Ihor Radchenko d6bae908f3
Fix macro indentation and re-indent code misindented by nameless
* lisp/org-fold-core.el (org-fold-core-cycle-over-indirect-buffers):
(org-fold-core-ignore-modifications):
(org-fold-core-ignore-fragility-checks):
* lisp/org-macs.el (org-element-with-disabled-cache): Fix incorrect
indentation declare statement.  Body-only macros should use (indent 0)
to avoid indenting first line differently from other body.
* lisp/org-capture.el:
* lisp/org-clock.el:
* lisp/org-fold-core.el:
* lisp/org-fold.el:
* lisp/org-id.el:
* lisp/org-list.el:
* lisp/org-macs.el:
* lisp/org.el: Reindent.

Reported in https://orgmode.org/list/CAKJdtO_Z4LBGek3SUc6-a_Z0-dDd6L26_YfMYpZTn7F92uxXJQ@mail.gmail.com
2022-05-14 16:58:35 +08:00
Ihor Radchenko c508ff41e4
Merge branch 'bugfix' 2022-05-13 18:37:04 +08:00
Ihor Radchenko 4fe59b688f
org-babel-load-file: Fix loading with non-nil COMPILE argument
* lisp/org.el (org-babel-load-file): Use correct file name to load
compiled file.

Fixes https://orgmode.org/list/t5j75h$dbo$1@ciao.gmane.io
2022-05-13 18:35:13 +08:00
Daniel Fleischer aea24b3fea lisp/org.el: Fast tag selection disabled tag face
* lisp/org.el (org-fast-tag-selection): Disabled tags face

A tag can be either selected in "current", "inherited" or disabled. When
disabled, it should have the default face. Previously, if a tag was
already selected, when deselection it will still have an org-todo face.

https://lists.gnu.org/archive/html/emacs-orgmode/2021-10/msg00350.html
2022-05-10 08:33:15 +03:00
Ignacio a3d9999d28
lisp/org.el: Match COMMENT in `org-complex-heading-regexp-format'
* lisp/org.el (org-set-regexps-and-options): Change
`org-complex-heading-regexp-format' initialization so that the regexp
it produces also matches a headline if it is commented.

TINYCHANGE
2022-05-08 18:22:01 +08:00
Ihor Radchenko f8bb414615
org-at-timestamp-p: Fix compatibility with Emacs 26
* lisp/org.el (org-at-timestamp-p): Do not use variables in regexp rx
form.  They are not yet supported in Emacs 26.  Expand them at runtime
instead.
2022-05-02 12:03:52 +08:00
Ihor Radchenko 1ed9e42238
org-todo: Fix point moving after setting todo keyword in empty heading
* lisp/org.el (org-todo): Insert new todo keyword before
`save-excursion' markers.  This avoids apparent point movement when a
new keyword is inserted into an empty heading.
Before: "* <point>" -> "*<point> TODO";
After: "* <point>" -> "* TODO<point>";

Fixes https://orgmode.org/list/87mtg6265i.fsf@yandex.com
2022-04-27 19:29:36 +08:00
Anders Johansson f813f10818
Rename remaining org-force-cycle-archived → org-cycle-force-archived 2022-04-25 19:40:06 +08:00
Anders Johansson baffebbc33
Fix bug in org-get-heading
Fixes #26, where fontification could make the matching and extraction of heading
components fail.
2022-04-25 19:40:05 +08:00
Ihor Radchenko 52a0ef94c9
Backport contributed commits 2022-04-25 19:40:03 +08:00
Ihor Radchenko 17e762426d
Move `org-buffer-list' to org-macs.el 2022-04-25 19:40:00 +08:00