From 6c862699a6db3f6b76391c05380d92d9f1b3838f Mon Sep 17 00:00:00 2001 From: Ihor Radchenko Date: Fri, 7 Jun 2024 16:50:41 +0200 Subject: [PATCH 01/28] 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. --- lisp/org-lint.el | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lisp/org-lint.el b/lisp/org-lint.el index aed774ee2..44064fb5c 100644 --- a/lisp/org-lint.el +++ b/lisp/org-lint.el @@ -395,7 +395,10 @@ called with one argument, the key used for comparison." ;; 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) - (unless (org-at-block-p) ; Inside a block, where the chances to have heading a slim. + (unless (org-element-type-p + (org-element-at-point) + '(comment-block example-block export-block src-block) + ) ; Inside a block, where the chances to have heading a slim. (push (list (match-beginning 0) "Possibly misplaced heading line") result))) result))) From 915e883645a47ba84b8823efa21c859a62f46ed2 Mon Sep 17 00:00:00 2001 From: Ihor Radchenko Date: Sat, 8 Jun 2024 21:02:40 +0200 Subject: [PATCH 02/28] 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 --- lisp/org-lint.el | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/lisp/org-lint.el b/lisp/org-lint.el index 44064fb5c..2d87ae270 100644 --- a/lisp/org-lint.el +++ b/lisp/org-lint.el @@ -388,17 +388,24 @@ 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) - (unless (org-element-type-p - (org-element-at-point) - '(comment-block example-block export-block src-block) - ) ; Inside a block, where the chances to have heading a slim. + ;; 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))) From 0c066946668a47c7679de99121dba13d57811c15 Mon Sep 17 00:00:00 2001 From: Ihor Radchenko Date: Sun, 9 Jun 2024 11:21:48 +0200 Subject: [PATCH 03/28] etc/ORG-NEWS: Announce removal of searching inside hidden parts of links --- etc/ORG-NEWS | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index 26f927d42..b76fdc3e2 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -28,6 +28,15 @@ constant. If you still want to use python-mode with ob-python, you might consider [[https://gitlab.com/jackkamm/ob-python-mode-mode][ob-python-mode-mode]], where the code to support python-mode has been ported to. +*** It is no longer possible to reveal hidden parts of the links during isearch + +Org 9.6 introduced support for searching hidden parts of the links. + +Unfortunately, we had to drop this support because its implementation +turned out to be unreliable for many users. Proper implementation +would require patching =isearch.el= and possibly a number of external +libraries implementing isearch equivalents. It cannot be done on Org +side alone. *** =ox-latex=: ~org-latex-line-break-safe~ is deprecated @@ -1719,6 +1728,9 @@ to the Org behavior. The new features and changes are listed below. **** Hidden parts of the links can now be searched and revealed during isearch +[2024-06-09 Sun] Since Org 9.7, this is no longer working. See +changes for Org 9.7. + In the past, hidden parts of the links could not be searched using isearch (=C-s=). Now, they are searchable by default. The hidden match is also revealed temporarily during isearch. From 2a6a0480d34c879f07649298c17685f6d89b4978 Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Mon, 10 Jun 2024 00:38:13 +0200 Subject: [PATCH 04/28] Backport commit 77d0eed74 from Emacs ; Fix typos 77d0eed74e1d934e28f364cb3adb06365e71335e Stefan Kangas Mon Jun 10 00:40:26 2024 +0200 --- lisp/ob-maxima.el | 2 +- lisp/ob-python.el | 2 +- lisp/ol.el | 4 ++-- lisp/org-attach.el | 2 +- lisp/org-cycle.el | 2 +- lisp/org-element.el | 2 +- lisp/org-footnote.el | 2 +- lisp/org-pcomplete.el | 2 +- lisp/org-persist.el | 2 +- lisp/org.el | 10 +++++----- lisp/ox.el | 6 +++--- 11 files changed, 18 insertions(+), 18 deletions(-) diff --git a/lisp/ob-maxima.el b/lisp/ob-maxima.el index 1103317a8..ef875cfe8 100644 --- a/lisp/ob-maxima.el +++ b/lisp/ob-maxima.el @@ -137,7 +137,7 @@ 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 diff --git a/lisp/ob-python.el b/lisp/ob-python.el index 89cdf4c47..3f81449eb 100644 --- a/lisp/ob-python.el +++ b/lisp/ob-python.el @@ -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) diff --git a/lisp/ol.el b/lisp/ol.el index 20f1b89c0..7a7f4f558 100644 --- a/lisp/ol.el +++ b/lisp/ol.el @@ -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" diff --git a/lisp/org-attach.el b/lisp/org-attach.el index 16f6e1e29..fc7f50a08 100644 --- a/lisp/org-attach.el +++ b/lisp/org-attach.el @@ -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 diff --git a/lisp/org-cycle.el b/lisp/org-cycle.el index b325b042d..8a39bdb8c 100644 --- a/lisp/org-cycle.el +++ b/lisp/org-cycle.el @@ -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) diff --git a/lisp/org-element.el b/lisp/org-element.el index 9f8e8df59..34520d16e 100644 --- a/lisp/org-element.el +++ b/lisp/org-element.el @@ -4489,7 +4489,7 @@ Assume point is at the beginning of the timestamp." (and (org-string-nw-p warning-string) (concat " " warning-string)) (cdr brackets)))) (concat - ;; Opening backet: [ or < + ;; Opening bracket: [ or < (car brackets) ;; Starting date/time: YYYY-MM-DD DAY[ HH:MM] (if (eq type 'diary) diff --git a/lisp/org-footnote.el b/lisp/org-footnote.el index 24cb8bf18..b886e4c0e 100644 --- a/lisp/org-footnote.el +++ b/lisp/org-footnote.el @@ -148,7 +148,7 @@ random Automatically generate a unique, random label." (const :tag "Prompt for label" nil) (const :tag "Create automatic [fn:N]" t) (const :tag "Offer automatic [fn:N] for editing" confirm) - (const :tag "Create anoymous [fn::]" anonymous) + (const :tag "Create anonymous [fn::]" anonymous) (const :tag "Create a random label" random)) :safe #'symbolp) diff --git a/lisp/org-pcomplete.el b/lisp/org-pcomplete.el index 0d311f959..01ee2ac8b 100644 --- a/lisp/org-pcomplete.el +++ b/lisp/org-pcomplete.el @@ -24,7 +24,7 @@ ;;; Commentary: -;; This library implementes completion support in Org mode buffers. +;; This library implements completion support in Org mode buffers. ;;; Code: diff --git a/lisp/org-persist.el b/lisp/org-persist.el index 9f2fd3424..c855c6604 100644 --- a/lisp/org-persist.el +++ b/lisp/org-persist.el @@ -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. diff --git a/lisp/org.el b/lisp/org.el index 2f937c0e2..ab676e623 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -8738,7 +8738,7 @@ there is one, return it." (save-window-excursion ;; We have no direct control over how ;; `with-output-to-temp-buffer' displays the buffer. Try - ;; to gain more space, makign sure that only the Org + ;; to gain more space, making sure that only the Org ;; buffer and the *Select link* buffer are displayed for ;; the duration of selection. (ignore-errors (delete-other-windows)) @@ -10041,7 +10041,7 @@ where CURRENT-TODO-KEYWORD belongs over on in another sequence." org-todo-key-alist)))) field-number ; current todo keyword column in the completion buffer. todo-binding-spec todo-keyword todo-char input-char) - ;; Display todo selection dialogue, read the user input, and return. + ;; Display todo selection dialog, read the user input, and return. (save-excursion (save-window-excursion ;; Select todo keyword list buffer, and display it unless EXPERT-INTERFACE. @@ -12224,7 +12224,7 @@ Returns the new tags string, or nil to not change the current settings." (move-overlay org-tags-overlay ov-start ov-end) ;; Highlight tags overlay in Org buffer. (org-set-current-tags-overlay current-tags ov-prefix) - ;; Display tag selection dialogue, read the user input, and return. + ;; Display tag selection dialog, read the user input, and return. (save-excursion (save-window-excursion ;; Select tag list buffer, and display it unless EXPERT-INTERFACE. @@ -12239,7 +12239,7 @@ Returns the new tags string, or nil to not change the current settings." ;; Insert current tags. (org-fast-tag-insert "Inherited" inherited-tags inherited-face "\n") (org-fast-tag-insert "Current" current-tags current-face "\n\n") - ;; Display whether next change exits selection dialogue. + ;; Display whether next change exits selection dialog. (org-fast-tag-show-exit exit-after-next) ;; Show tags, tag groups, and bindings in a grid. ;; Each tag in the grid occupies FIELD-WIDTH characters. @@ -20965,7 +20965,7 @@ SEPARATOR is the string to insert after each link." "The method to use for dropped file.") (defun org--dnd-xds-function (need-name filename) "Handle file with FILENAME dropped via XDS protocol. -When NEED-NAME is t, FILNAME is the base name of the file to be +When NEED-NAME is t, FILENAME is the base name of the file to be saved. When NEED-NAME is nil, the drop is complete." (if need-name diff --git a/lisp/ox.el b/lisp/ox.el index 578e4f36a..b28fe2179 100644 --- a/lisp/ox.el +++ b/lisp/ox.el @@ -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 "Рисунок" :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 "Рис. %d.:" :utf-8 "Рис. %d.:") @@ -6438,7 +6438,7 @@ them." ("nl" :default "Zie figuur %s" :html "Zie figuur %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") From 4d4d59874c723cfe86ba2ae8485406e82d168a8b Mon Sep 17 00:00:00 2001 From: Ihor Radchenko Date: Mon, 10 Jun 2024 11:13:58 +0200 Subject: [PATCH 05/28] 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. --- lisp/org-fold-core.el | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/lisp/org-fold-core.el b/lisp/org-fold-core.el index 664846a61..8372b86b0 100644 --- a/lisp/org-fold-core.el +++ b/lisp/org-fold-core.el @@ -641,13 +641,14 @@ 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) - (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 (current-buffer) bufs) - (delete-dups bufs))))) + (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))) From ce350490cae7c29614b4a5763c7697f222f26dd4 Mon Sep 17 00:00:00 2001 From: Kyle Meyer Date: Mon, 10 Jun 2024 18:27:58 -0400 Subject: [PATCH 06/28] 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. --- lisp/ob-core.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lisp/ob-core.el b/lisp/ob-core.el index c5dd20b0e..d1984b2d6 100644 --- a/lisp/ob-core.el +++ b/lisp/ob-core.el @@ -909,7 +909,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 From 6eab01c580f2d77858f949bddc950395c1ba2a59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20Engdeg=C3=A5rd?= Date: Mon, 10 Jun 2024 13:59:31 +0200 Subject: [PATCH 07/28] Backport commit 331573e40 from Emacs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 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 --- lisp/org-element.el | 2 +- lisp/org-macs.el | 2 +- lisp/org.el | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lisp/org-element.el b/lisp/org-element.el index 34520d16e..b15f0b69d 100644 --- a/lisp/org-element.el +++ b/lisp/org-element.el @@ -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 diff --git a/lisp/org-macs.el b/lisp/org-macs.el index 555ff44a3..694e747b0 100644 --- a/lisp/org-macs.el +++ b/lisp/org-macs.el @@ -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 () diff --git a/lisp/org.el b/lisp/org.el index ab676e623..ff5b63212 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -20749,7 +20749,7 @@ it has a `diary' type." (yank-media-handler "image/.*" #'org--image-yank-media-handler) ;; Looks like different DEs go for different handler names, ;; https://larsee.com/blog/2019/05/clipboard-files/. - (yank-media-handler "x/special-\\(?:gnome\|KDE\|mate\\)-files" + (yank-media-handler "x/special-\\(?:gnome\\|KDE\\|mate\\)-files" #'org--copied-files-yank-media-handler)) (when (boundp 'x-dnd-direct-save-function) (setq-local x-dnd-direct-save-function #'org--dnd-xds-function))) From 008e6030ac5309c71e15705957c049aa55324071 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Mon, 10 Jun 2024 10:58:46 -0400 Subject: [PATCH 08/28] 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 --- lisp/ox.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lisp/ox.el b/lisp/ox.el index b28fe2179..1c52ca290 100644 --- a/lisp/ox.el +++ b/lisp/ox.el @@ -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) From 3e4c89e55649f95cffbf70fcf64dcbc69760f96f Mon Sep 17 00:00:00 2001 From: Ihor Radchenko Date: Tue, 11 Jun 2024 12:42:28 +0200 Subject: [PATCH 09/28] 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 Link: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=71484 --- lisp/org.el | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index ff5b63212..1698399c4 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -16981,10 +16981,11 @@ buffer boundaries with possible narrowing." (t nil)))) (defun org-image--align (link) - "Determine the alignment of the image link. + "Determine the alignment of the image LINK. +LINK is a link object. In decreasing order of priority, this is controlled: -- Per image by the value of `:center' or ``:align' in the +- Per image by the value of `:center' or `:align' in the affiliated keyword `#+attr_org'. - By the `#+attr_html' or `#+attr_latex` keywords with valid `:center' or `:align' values. @@ -16998,15 +16999,16 @@ will cause it to be right-aligned. A value of \"left\" or nil implies no special alignment." (let ((par (org-element-lineage link 'paragraph))) ;; Only align when image is not surrounded by paragraph text: - (when (and (= (org-element-begin link) + (when (and par ; when image is not in paragraph, but in table/headline/etc, do not align + (= (org-element-begin link) (save-excursion (goto-char (org-element-contents-begin par)) (skip-chars-forward "\t ") (point))) ;account for leading space ;before link (<= (- (org-element-contents-end par) - (org-element-end link)) - 1)) ;account for trailing newline + (org-element-end link)) + 1)) ;account for trailing newline ;at end of paragraph (save-match-data ;; Look for a valid ":center t" or ":align left|center|right" From a0950e943236b67794754c1da74bb0b001d625ba Mon Sep 17 00:00:00 2001 From: Ihor Radchenko Date: Wed, 12 Jun 2024 12:47:48 +0200 Subject: [PATCH 10/28] 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. --- lisp/ob-core.el | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lisp/ob-core.el b/lisp/ob-core.el index d1984b2d6..2e0e86f70 100644 --- a/lisp/ob-core.el +++ b/lisp/ob-core.el @@ -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)) From 84945f9de037949b2be3801acb496540c9365722 Mon Sep 17 00:00:00 2001 From: Ihor Radchenko Date: Wed, 12 Jun 2024 15:31:45 +0200 Subject: [PATCH 11/28] 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 Link: https://orgmode.org/list/CAJ+Teoehk30LKVCTwMy0uREBHkNVBvrOLDZYboUQ4wBV6Fnwzw@mail.gmail.com --- lisp/org-table.el | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/lisp/org-table.el b/lisp/org-table.el index 37ce91570..4a2623b55 100644 --- a/lisp/org-table.el +++ b/lisp/org-table.el @@ -5477,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) From e4902995a0643c7658fb51b14911eaff2891a1e3 Mon Sep 17 00:00:00 2001 From: Ihor Radchenko Date: Thu, 13 Jun 2024 15:16:54 +0200 Subject: [PATCH 12/28] org-babel: Reduce verbosity when running in batch mode * lisp/ob-C.el (org-babel-C-header-to-C): * lisp/ob-awk.el (org-babel-execute:awk): * lisp/ob-core.el (org-babel-execute-src-block): (org-babel-insert-result): * lisp/ob-ditaa.el (org-babel-execute:ditaa): * lisp/ob-gnuplot.el (org-babel-execute:gnuplot): (org-babel-prep-session:gnuplot): * lisp/ob-groovy.el (org-babel-execute:groovy): * lisp/ob-maxima.el (org-babel-execute:maxima): * lisp/ob-screen.el (org-babel-execute:screen): * lisp/ob-sed.el (org-babel-execute:sed): Suppress progress messages when running noninteractively (batch export, for example). This change follows the existing behavior of `org-babel-exp-src-block'. Reported-by: Eli Zaretskii Link: https://yhetil.org/emacs-devel/868qzd9hjg.fsf@gnu.org/ --- lisp/ob-C.el | 2 +- lisp/ob-awk.el | 2 +- lisp/ob-core.el | 57 ++++++++++++++++++++++++---------------------- lisp/ob-ditaa.el | 5 ++-- lisp/ob-gnuplot.el | 6 ++--- lisp/ob-groovy.el | 2 +- lisp/ob-maxima.el | 4 ++-- lisp/ob-screen.el | 2 +- lisp/ob-sed.el | 2 +- 9 files changed, 43 insertions(+), 39 deletions(-) diff --git a/lisp/ob-C.el b/lisp/ob-C.el index d13c65d26..f7735ee72 100644 --- a/lisp/ob-C.el +++ b/lisp/ob-C.el @@ -482,7 +482,7 @@ int get_column_num (int nbcols, const char** header, const char* column) (defun org-babel-C-header-to-C (head type) "Convert an elisp list of header table into a C or D vector specifying a variable with the name of the table." - (message "%S" type) + (unless noninteractive (message "%S" type)) (let ((table (car head)) (headers (cdr head)) (typename (pcase type diff --git a/lisp/ob-awk.el b/lisp/ob-awk.el index 9577a39ee..d94da405f 100644 --- a/lisp/ob-awk.el +++ b/lisp/ob-awk.el @@ -61,7 +61,7 @@ "Execute a block of Awk code BODY with org-babel. PARAMS is a plist of src block parameters . This function is called by `org-babel-execute-src-block'." - (message "Executing Awk source code block") + (unless noninteractive (message "Executing Awk source code block")) (let* ((result-params (cdr (assq :result-params params))) (cmd-line (cdr (assq :cmd-line params))) (in-file (cdr (assq :in-file params))) diff --git a/lisp/ob-core.el b/lisp/ob-core.el index 2e0e86f70..0b329266a 100644 --- a/lisp/ob-core.el +++ b/lisp/ob-core.el @@ -855,8 +855,9 @@ guess will be made." (forward-line) (skip-chars-forward " \t") (let ((result (org-babel-read-result))) - (message (format "Cached: %s" - (replace-regexp-in-string "%" "%%" (format "%S" result)))) + (unless noninteractive + (message (format "Cached: %s" + (replace-regexp-in-string "%" "%%" (format "%S" result))))) result))) ((org-babel-confirm-evaluate info) (let* ((lang (nth 0 info)) @@ -879,18 +880,19 @@ guess will be made." result exec-start-time) (unless (fboundp cmd) (error "No org-babel-execute function for %s!" lang)) - (message "Executing %s %s %s..." - (capitalize lang) - (pcase executor-type - ('src-block "code block") - ('inline-src-block "inline code block") - ('babel-call "call") - ('inline-babel-call "inline call") - (e (symbol-name e))) - (let ((name (nth 4 info))) - (if name - (format "(%s)" name) - (format "at position %S" (nth 5 info))))) + (unless noninteractive + (message "Executing %s %s %s..." + (capitalize lang) + (pcase executor-type + ('src-block "code block") + ('inline-src-block "inline code block") + ('babel-call "call") + ('inline-babel-call "inline call") + (e (symbol-name e))) + (let ((name (nth 4 info))) + (if name + (format "(%s)" name) + (format "at position %S" (nth 5 info)))))) (setq exec-start-time (current-time) result (let ((r @@ -2760,20 +2762,21 @@ INFO may provide the values of these header arguments (in the ;; In this case `table-align' does the work ;; for us. (not (and (listp result) - (member "append" result-params)))) + (member "append" result-params)))) (indent-rigidly beg end indent)) - (let ((time-info - ;; Only show the time when something other than - ;; 0s will be shown, i.e. check if the time is at - ;; least half of the displayed precision. - (if (and exec-time (> (float-time exec-time) 0.05)) - (format " (took %.1fs)" (float-time exec-time)) - ""))) - (if (null result) - (if (member "value" result-params) - (message "Code block returned no value%s." time-info) - (message "Code block produced no output%s." time-info)) - (message "Code block evaluation complete%s." time-info)))) + (unless noninteractive + (let ((time-info + ;; Only show the time when something other than + ;; 0s will be shown, i.e. check if the time is at + ;; least half of the displayed precision. + (if (and exec-time (> (float-time exec-time) 0.05)) + (format " (took %.1fs)" (float-time exec-time)) + ""))) + (if (null result) + (if (member "value" result-params) + (message "Code block returned no value%s." time-info) + (message "Code block produced no output%s." time-info)) + (message "Code block evaluation complete%s." time-info))))) (when end (set-marker end nil)) (when outside-scope (narrow-to-region visible-beg visible-end)) (set-marker visible-beg nil) diff --git a/lisp/ob-ditaa.el b/lisp/ob-ditaa.el index ba8e65394..715d8ddf0 100644 --- a/lisp/ob-ditaa.el +++ b/lisp/ob-ditaa.el @@ -113,8 +113,9 @@ This function is called by `org-babel-execute-src-block'." (unless (file-exists-p org-ditaa-jar-path) (error "Could not find ditaa.jar at %s" org-ditaa-jar-path)) (with-temp-file in-file (insert body)) - (message cmd) (shell-command cmd) - (when pdf-cmd (message pdf-cmd) (shell-command pdf-cmd)) + (unless noninteractive (message cmd)) + (shell-command cmd) + (when pdf-cmd (unless noninteractive (message pdf-cmd)) (shell-command pdf-cmd)) nil)) ;; signal that output has already been written to file (defun org-babel-prep-session:ditaa (_session _params) diff --git a/lisp/ob-gnuplot.el b/lisp/ob-gnuplot.el index dc5cd0e52..956763c58 100644 --- a/lisp/ob-gnuplot.el +++ b/lisp/ob-gnuplot.el @@ -210,7 +210,7 @@ This function is called by `org-babel-execute-src-block'." (let ((script-file (org-babel-temp-file "gnuplot-script-"))) (with-temp-file script-file (insert (concat body "\n"))) - (message "gnuplot \"%s\"" script-file) + (unless noninteractive (message "gnuplot \"%s\"" script-file)) (setq output (shell-command-to-string (format @@ -219,7 +219,7 @@ This function is called by `org-babel-execute-src-block'." script-file (if (member system-type '(cygwin windows-nt ms-dos)) t nil))))) - (message "%s" output)) + (unless noninteractive (message "%s" output))) (with-temp-buffer (insert (concat body "\n")) (gnuplot-mode) @@ -232,7 +232,7 @@ This function is called by `org-babel-execute-src-block'." "Prepare SESSION according to the header arguments in PARAMS." (let* ((session (org-babel-gnuplot-initiate-session session)) (var-lines (org-babel-variable-assignments:gnuplot params))) - (message "%S" session) + (unless noninteractive (message "%S" session)) (org-babel-comint-in-buffer session (dolist (var-line var-lines) (insert var-line) diff --git a/lisp/ob-groovy.el b/lisp/ob-groovy.el index 908df9337..d87ef4bb6 100644 --- a/lisp/ob-groovy.el +++ b/lisp/ob-groovy.el @@ -52,7 +52,7 @@ parameters may be used, like groovy -v" (defun org-babel-execute:groovy (body params) "Execute Groovy BODY according to PARAMS. This function is called by `org-babel-execute-src-block'." - (message "Executing Groovy source code block") + (unless noninteractive (message "Executing Groovy source code block")) (let* ((processed-params (org-babel-process-params params)) (session (org-babel-groovy-initiate-session (nth 0 processed-params))) (result-params (nth 2 processed-params)) diff --git a/lisp/ob-maxima.el b/lisp/ob-maxima.el index ef875cfe8..681154adf 100644 --- a/lisp/ob-maxima.el +++ b/lisp/ob-maxima.el @@ -131,7 +131,7 @@ Return nil if LINE is zero-length or it matches a regexp in (defun org-babel-execute:maxima (body params) "Execute Maxima BODY according to PARAMS. This function is called by `org-babel-execute-src-block'." - (message "Executing Maxima source code block") + (unless noninteractive (message "Executing Maxima source code block")) (let ((result-params (split-string (or (cdr (assq :results params)) ""))) (result (let* ((cmdline (or (cdr (assq :cmdline params)) "")) @@ -151,7 +151,7 @@ This function is called by `org-babel-execute-src-block'." (format "(linenum:0, %s(%S))$" batch/load in-file)) cmdline))) (with-temp-file in-file (insert (org-babel-maxima-expand body params))) - (message cmd) + (unless noninteractive (message cmd)) ;; " | grep -v batch | grep -v 'replaced' | sed '/^$/d' " (let ((raw (org-babel-eval cmd ""))) (mapconcat diff --git a/lisp/ob-screen.el b/lisp/ob-screen.el index ffb66d659..a56afc705 100644 --- a/lisp/ob-screen.el +++ b/lisp/ob-screen.el @@ -52,7 +52,7 @@ In case you want to use a different screen than one selected by your $PATH") (defun org-babel-execute:screen (body params) "Send BODY via screen to a terminal using Babel, according to PARAMS. \"default\" session is used when none is specified in the PARAMS." - (message "Sending source code block to interactive terminal session...") + (unless noninteractive (message "Sending source code block to interactive terminal session...")) (save-window-excursion (let* ((session (cdr (assq :session params))) (socket (org-babel-screen-session-socketname session))) diff --git a/lisp/ob-sed.el b/lisp/ob-sed.el index fa6a2bb19..83d9684ad 100644 --- a/lisp/ob-sed.el +++ b/lisp/ob-sed.el @@ -65,7 +65,7 @@ BODY is the source inside a sed source block and PARAMS is an association list over the source block configurations. This function is called by `org-babel-execute-src-block'." - (message "Executing sed source code block") + (unless noninteractive (message "Executing sed source code block")) (let* ((result-params (cdr (assq :result-params params))) (cmd-line (cdr (assq :cmd-line params))) (in-file (cdr (assq :in-file params))) From a13d8fe83b5d49a97ec3c60d5312549db1be9055 Mon Sep 17 00:00:00 2001 From: Ihor Radchenko Date: Thu, 13 Jun 2024 17:26:02 +0200 Subject: [PATCH 13/28] org-babel-exp-process-buffer: Fix edge case when src block ends at eob * lisp/ob-exp.el (org-babel-exp-process-buffer): When src block ends at eob, do not leave the #+end_src behind after replacement. --- lisp/ob-exp.el | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lisp/ob-exp.el b/lisp/ob-exp.el index 657cb2b52..5516530c5 100644 --- a/lisp/ob-exp.el +++ b/lisp/ob-exp.el @@ -265,8 +265,9 @@ this template." (if (not (eq type 'babel-call)) (progn (skip-chars-forward " \t") (point)) - (skip-chars-forward " \r\t\n") - (line-beginning-position))))) + (unless (eobp) + (skip-chars-forward " \r\t\n") + (line-beginning-position)))))) ((not rep) ;; Replacement code cannot be determined. ;; Leave the code block as is. @@ -291,8 +292,9 @@ this template." (cond ((not replacement) (goto-char end)) ((equal replacement "") (goto-char end) - (skip-chars-forward " \r\t\n") - (forward-line 0) + (unless (eobp) + (skip-chars-forward " \r\t\n") + (forward-line 0)) (delete-region begin (point))) (t (if (org-src-preserve-indentation-p element) From 96113f3b595ea24a7b133d61a5e668213224f157 Mon Sep 17 00:00:00 2001 From: Ihor Radchenko Date: Thu, 13 Jun 2024 17:26:44 +0200 Subject: [PATCH 14/28] org-export--set-variables: Fix variable assignment * lisp/ox.el (org-export--set-variables): Assume that variables are listed as (var value) - as a list. Only use the second element of the list as the value, following example in `org-export-get-environment'. (org-export-get-environment): Use `org-export--set-variables'. * testing/lisp/test-ox.el (test-org-export/bind-keyword): Add new test. Reported-by: Suhail Singh Link: https://orgmode.org/list/87cyonhuq3.fsf@gmail.com --- lisp/ox.el | 5 ++--- testing/lisp/test-ox.el | 13 ++++++++++++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/lisp/ox.el b/lisp/ox.el index 1c52ca290..29390bf0e 100644 --- a/lisp/ox.el +++ b/lisp/ox.el @@ -1398,8 +1398,7 @@ external parameters overriding Org default settings, but still inferior to file-local settings." ;; First install #+BIND variables since these must be set before ;; global options are read. - (dolist (pair (org-export--list-bound-variables)) - (set (make-local-variable (car pair)) (nth 1 pair))) + (org-export--set-variables (org-export--list-bound-variables)) ;; Get and prioritize export options... (org-combine-plists ;; ... from global variables... @@ -2585,7 +2584,7 @@ Return the updated communication channel." (defun org-export--set-variables (variable-alist) "Set buffer-local variables according to VARIABLE-ALIST in current buffer." (pcase-dolist (`(,var . ,val) variable-alist) - (set (make-local-variable var) val))) + (set (make-local-variable var) (car val)))) (cl-defun org-export-copy-buffer (&key to-buffer drop-visibility drop-narrowing drop-contents diff --git a/testing/lisp/test-ox.el b/testing/lisp/test-ox.el index 9b1b900ca..0a39ddf2d 100644 --- a/testing/lisp/test-ox.el +++ b/testing/lisp/test-ox.el @@ -133,7 +133,18 @@ variable, and communication channel under `info'." (org-export-create-backend :transcoders '((section . (lambda (s c i) - (if (eq test-ox-var 'value) "Yes" "No"))))))))))) + (if (eq test-ox-var 'value) "Yes" "No")))))))))) + ;; Seen from elisp code blocks as well. + (should + (string-match-p "::: \"test value\"" + (org-test-with-temp-text "#+BIND: test-ox-var \"test value\" + +#+begin_src emacs-lisp :results value :exports results :eval yes +(format \"::: %S\" test-ox-var) +#+end_src" + (let ((org-export-allow-bind-keywords t)) + (org-export-as + (org-test-default-backend))))))) (ert-deftest test-org-export/parse-option-keyword () "Test reading all standard #+OPTIONS: items." From d7b5c19daa4aece68c8ea97aa414fd4d4ec989df Mon Sep 17 00:00:00 2001 From: Ihor Radchenko Date: Thu, 13 Jun 2024 18:01:37 +0200 Subject: [PATCH 15/28] DnD: Create directory when `org-yank-image-save-method' is a directory * lisp/org.el (org--dnd-attach-file): Make sure that target directory is created before copying file when `org-yank-image-save-method' is set to specific directory (not 'attach). Reported-by: ISouthRain Link: https://orgmode.org/list/tencent_AABB2DEBF7ABFBC795348C288E0EBFCFDD0A@qq.com --- lisp/org.el | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index 1698399c4..795a4d51b 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -20941,15 +20941,18 @@ SEPARATOR is the string to insert after each link." ('private (or org-yank-dnd-default-attach-method org-attach-method))))) (if separatep - (funcall - (pcase method - ('cp #'copy-file) - ('mv #'rename-file) - ('ln #'add-name-to-file) - ('lns #'make-symbolic-link)) - filename - (expand-file-name (file-name-nondirectory filename) - org-yank-image-save-method)) + (progn + (unless (file-directory-p org-yank-image-save-method) + (make-directory org-yank-image-save-method t)) + (funcall + (pcase method + ('cp #'copy-file) + ('mv #'rename-file) + ('ln #'add-name-to-file) + ('lns #'make-symbolic-link)) + filename + (expand-file-name (file-name-nondirectory filename) + org-yank-image-save-method))) (org-attach-attach filename nil method)) (insert (org-link-make-string From 13fdbf73ff1c1310dcb6ba59228d9321460fa6e6 Mon Sep 17 00:00:00 2001 From: Ihor Radchenko Date: Fri, 14 Jun 2024 11:40:20 +0200 Subject: [PATCH 16/28] mk: Prevent search local id: db when building manuals * mk/org-fixup.el (org-make-manual): (org-make-guide): (org-make-manuals): Disable local ID db when building Org documentation. This makes sure that local IDs on the build machine can never influence the build process. Reported-by: Eli Zaretskii Link: https://yhetil.org/emacs-devel/868qzd9hjg.fsf@gnu.org/ --- mk/org-fixup.el | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/mk/org-fixup.el b/mk/org-fixup.el index e595eac7b..efb9fb299 100644 --- a/mk/org-fixup.el +++ b/mk/org-fixup.el @@ -30,14 +30,18 @@ "Generate the Texinfo file out of the Org manual." (require 'ox-texinfo) (find-file "../doc/org-manual.org") - (let ((org-confirm-babel-evaluate nil)) + (let ((org-confirm-babel-evaluate nil) + ;; We do not want to search local user files when building manuals. + (org-id-track-globally nil)) (org-texinfo-export-to-texinfo))) (defun org-make-guide () "Generate the Texinfo file out of the Org guide." (require 'ox-texinfo) (find-file "../doc/org-guide.org") - (let ((org-confirm-babel-evaluate nil)) + (let ((org-confirm-babel-evaluate nil) + ;; We do not want to search local user files when building manuals. + (org-id-track-globally nil)) (org-texinfo-export-to-texinfo))) (make-obsolete 'org-make-manuals @@ -48,7 +52,9 @@ (require 'ox-texinfo) (dolist (manual '("../doc/org-manual.org" "../doc/org-guide.org")) (find-file manual) - (let ((org-confirm-babel-evaluate nil)) + (let ((org-confirm-babel-evaluate nil) + ;; We do not want to search local user files when building manuals. + (org-id-track-globally nil)) (org-texinfo-export-to-texinfo)))) (defun org-make-org-version (org-release org-git-version) From 4bb071937489ad992285a6cbe8edc818ed08c1d6 Mon Sep 17 00:00:00 2001 From: Ihor Radchenko Date: Fri, 14 Jun 2024 13:48:10 +0200 Subject: [PATCH 17/28] org-capture-templates: Remove no-longer-supported variants from :type spec * lisp/org-capture.el (org-capture-templates): Remove "sexp" type from allowed values of capture targets. S-exp support has been removed in f5645675a336d8. --- lisp/org-capture.el | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lisp/org-capture.el b/lisp/org-capture.el index 6603b5e01..f10e36937 100644 --- a/lisp/org-capture.el +++ b/lisp/org-capture.el @@ -408,8 +408,7 @@ you can escape ambiguous cases with a backward slash, e.g., \\%i." (let ((file-variants '(choice :tag "Filename " (file :tag "Literal") (function :tag "Function") - (variable :tag "Variable") - (sexp :tag "Form")))) + (variable :tag "Variable")))) `(repeat (choice :value ("" "" entry (file "~/org/notes.org") "") (list :tag "Multikey description" @@ -452,12 +451,12 @@ you can escape ambiguous cases with a backward slash, e.g., \\%i." (list :tag "File & function" (const :format "" file+function) ,file-variants - (sexp :tag " Function")) + (function :tag " Function")) (list :tag "Current clocking task" (const :format "" clock)) (list :tag "Function" (const :format "" function) - (sexp :tag " Function"))) + (function :tag " Function"))) (choice :tag "Template " (string) (list :tag "File" From bd8b861ee99a1d7621221df1d1470eb967874e2d Mon Sep 17 00:00:00 2001 From: Ihor Radchenko Date: Thu, 13 Jun 2024 14:53:03 +0200 Subject: [PATCH 18/28] org-num-skip-tags: Avoid using function that is not pre-loaded in autoloads * lisp/org-num.el (org-num-skip-tags): Make sure that function used for :safe `defcustom' slot does not require functions that are not defined in org-loaddefs.el. This is because `org-num-skip-tags' is autoloaded and cannot rely upon requires in org-num.el. Instead, it may only use pre-loaded functions and other autoloaded Org mode functions. Reported-by: Eli Zaretskii Link: https://yhetil.org/emacs-devel/868qzd9hjg.fsf@gnu.org/ --- lisp/org-compat.el | 11 +++++++++++ lisp/org-num.el | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/lisp/org-compat.el b/lisp/org-compat.el index d6620f962..41c26ad72 100644 --- a/lisp/org-compat.el +++ b/lisp/org-compat.el @@ -251,6 +251,17 @@ removed." default))) ": "))) +(if (fboundp 'list-of-strings-p) + (defalias 'org-list-of-strings-p #'list-of-strings-p) + ;; From Emacs subr.el. +;;;###autoload + (defun org-list-of-strings-p (object) + "Return t if OBJECT is nil or a list of strings." + (declare (pure t) (side-effect-free error-free)) + (while (and (consp object) (stringp (car object))) + (setq object (cdr object))) + (null object))) + ;;; Emacs < 27.1 compatibility diff --git a/lisp/org-num.el b/lisp/org-num.el index aebfef050..a8fcf3333 100644 --- a/lisp/org-num.el +++ b/lisp/org-num.el @@ -144,7 +144,7 @@ control tag inheritance." :group 'org-appearance :package-version '(Org . "9.3") :type '(repeat (string :tag "Tag")) - :safe (lambda (val) (and (listp val) (cl-every #'stringp val)))) + :safe #'org-list-of-strings-p) ;;;###autoload (defcustom org-num-skip-unnumbered nil From 2347eac669e4d6ceddecc05e1d0d288ce446fe0a Mon Sep 17 00:00:00 2001 From: Ihor Radchenko Date: Fri, 14 Jun 2024 15:03:49 +0200 Subject: [PATCH 19/28] lisp/org.el (org--dnd-rmc): Fix `read-multiple-choice' call MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * lisp/org.el (org--dnd-rmc): Add docstring. Fix the call to `read-multiple-choice' when extended help ("?") is requested by the user. Reported-by: Johann Klähn Link: https://orgmode.org/list/87ikyhg9qi.fsf@jklaehn.de --- lisp/org.el | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/lisp/org.el b/lisp/org.el index 795a4d51b..44734a733 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -20873,11 +20873,25 @@ When nil, use `org-attach-method'." (defvar org-attach-method) (defun org--dnd-rmc (prompt choices) + "Display a menu or dialog and select with PROMPT among CHOICES. +PROMPT is the prompt string. CHOICES is a list of choices. Each +choice is a list of (key description value). VALUE from the selected +choice is returned." (if (null (and ;; Emacs <=28 does not have `use-dialog-box-p'. (fboundp 'use-dialog-box-p) (use-dialog-box-p))) - (caddr (read-multiple-choice prompt choices)) + (progn + (setq choices + (mapcar + (pcase-lambda (`(,key ,message ,val)) + ;; `read-multiple-choice' expects VAL to be a long + ;; description of the choice - string or nil. Move VAL + ;; further, so that it is not seen by the extended + ;; help in `read-multiple-choice'. + (list key message nil val)) + choices)) + (nth 3 (read-multiple-choice prompt choices))) (setq choices (mapcar (pcase-lambda (`(_key ,message ,val)) From fd8ddf2874ca00505aa096c6172ea750cd5e9eaa Mon Sep 17 00:00:00 2001 From: Ihor Radchenko Date: Fri, 14 Jun 2024 15:29:08 +0200 Subject: [PATCH 20/28] org-clock-sum: Gracefully skip invalid CLOCK lines * lisp/org-clock.el (org-clock-sum): Skip invalid CLOCK lines (malformed or with times missing). Display a warning. This brings back the old behavior with such CLOCK lines being silently skipped. Now, we also display a warning. Reported-by: Robert Nyman Link: https://list.orgmode.org/orgmode/0e2ed754-bc71-4558-9c46-f17d73981fe5@NymanTechnology.com/ --- lisp/org-clock.el | 47 +++++++++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/lisp/org-clock.el b/lisp/org-clock.el index 5555bb1bc..c6fd507b0 100644 --- a/lisp/org-clock.el +++ b/lisp/org-clock.el @@ -2048,28 +2048,31 @@ PROPNAME lets you set a custom text property instead of :org-clock-minutes." (cond ((and (eq element-type 'clock) (match-end 2)) ;; Two time stamps. - (let* ((timestamp (org-element-property :value element)) - (ts (float-time - (org-encode-time - (list 0 - (org-element-property :minute-start timestamp) - (org-element-property :hour-start timestamp) - (org-element-property :day-start timestamp) - (org-element-property :month-start timestamp) - (org-element-property :year-start timestamp) - nil -1 nil)))) - (te (float-time - (org-encode-time - (list 0 - (org-element-property :minute-end timestamp) - (org-element-property :hour-end timestamp) - (org-element-property :day-end timestamp) - (org-element-property :month-end timestamp) - (org-element-property :year-end timestamp) - nil -1 nil)))) - (dt (- (if tend (min te tend) te) - (if tstart (max ts tstart) ts)))) - (when (> dt 0) (cl-incf t1 (floor dt 60))))) + (condition-case nil + (let* ((timestamp (org-element-property :value element)) + (ts (float-time + (org-encode-time + (list 0 + (org-element-property :minute-start timestamp) + (org-element-property :hour-start timestamp) + (org-element-property :day-start timestamp) + (org-element-property :month-start timestamp) + (org-element-property :year-start timestamp) + nil -1 nil)))) + (te (float-time + (org-encode-time + (list 0 + (org-element-property :minute-end timestamp) + (org-element-property :hour-end timestamp) + (org-element-property :day-end timestamp) + (org-element-property :month-end timestamp) + (org-element-property :year-end timestamp) + nil -1 nil)))) + (dt (- (if tend (min te tend) te) + (if tstart (max ts tstart) ts)))) + (when (> dt 0) (cl-incf t1 (floor dt 60)))) + (error + (org-display-warning (format "org-clock-sum: Ignoring invalid %s" (org-current-line-string)))))) ((match-end 4) ;; A naked time. (setq t1 (+ t1 (string-to-number (match-string 5)) From 55fd660b4e33f215c8af7a3bfe16dc198f1a6159 Mon Sep 17 00:00:00 2001 From: Ihor Radchenko Date: Fri, 14 Jun 2024 16:22:00 +0200 Subject: [PATCH 21/28] org-element: Auto-undefer deferred properties that depend on buffer positions * lisp/org-element.el (org-element--get-node-properties): (org-element--headline-parse-title): (org-element--headline-parse-title-raw): (org-element--headline-parse-title-parse): (org-element-comment-block-parser): (org-element-example-block-parser): (org-element-export-block-parser): (org-element-latex-environment-parser): (org-element-src-block-parser): (org-element-table-parser): (org-element--parse-generic-emphasis): (org-element-export-snippet-parser): (org-element-inline-babel-call-parser): (org-element-latex-fragment-parser): Auto-undefer node properties that are calculated based on buffer position of the node. This will make the return value of `org-element-at-point' a little more robust once the buffer is modified. The :begin/:end, and other positional properties may not be up-to-date, but at least some other properties may be "frozen" if they are undeferred early. Auto-undefer is still disabled for properties that do not depend on buffer positions and may benefit from dynamic calculation that takes into account syntax changes that are influenced by global variables. --- lisp/org-element.el | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/lisp/org-element.el b/lisp/org-element.el index b15f0b69d..191bb5698 100644 --- a/lisp/org-element.el +++ b/lisp/org-element.el @@ -1188,7 +1188,7 @@ parse properties for property drawer at point." (property-name-symbol (intern property-name)) (property-value (org-element-deferred-create - nil #'org-element--substring + t #'org-element--substring (- (match-beginning 3) begin) (- (match-end 3) begin)))) (cond @@ -1355,7 +1355,7 @@ Throw `:org-element-deferred-retry' signal at the end." (title-end (point)) (raw-value (org-element-deferred-create - nil #'org-element--headline-raw-value + t #'org-element--headline-raw-value (- title-start begin) (- title-end begin)))) (org-element-put-property headline :raw-value raw-value) (org-element-put-property headline :level level) @@ -1386,12 +1386,12 @@ Throw `:org-element-deferred-retry' signal at the end." (defconst org-element--headline-parse-title-raw (org-element-deferred-create - nil #'org-element--headline-parse-title t) + t #'org-element--headline-parse-title t) "Constant holding deferred value for raw headline `:title' property.") (defconst org-element--headline-parse-title-parse (org-element-deferred-create - nil #'org-element--headline-parse-title nil) + t #'org-element--headline-parse-title nil) "Constant holding deferred value for parsed headline `:title' property.") (defconst org-element--headline-deferred @@ -2414,7 +2414,7 @@ Assume point is at comment block beginning." (if (eobp) (point) (line-beginning-position)))) (value (org-element-deferred-create - nil #'org-element--substring + t #'org-element--substring (- contents-begin begin) (- contents-end begin)))) (org-element-create @@ -2532,7 +2532,7 @@ Return a new syntax node of `example-block' type containing `:begin', (contents-begin (line-beginning-position 2)) (value (org-element-deferred-create - nil #'org-element--unescape-substring + t #'org-element--unescape-substring (- contents-begin begin) (- contents-end begin))) (pos-before-blank (progn (goto-char contents-end) @@ -2612,7 +2612,7 @@ Assume point is at export-block beginning." (if (eobp) (point) (line-beginning-position)))) (value (org-element-deferred-create - nil #'org-element--unescape-substring + t #'org-element--unescape-substring (- contents-begin begin) (- contents-end begin)))) (org-element-create @@ -2800,7 +2800,7 @@ Assume point is at the beginning of the latex environment." (begin (car affiliated)) (value (org-element-deferred-create - nil #'org-element--substring + t #'org-element--substring (- code-begin begin) (- code-end begin))) (end (progn (skip-chars-forward " \r\t\n" limit) @@ -3059,7 +3059,7 @@ Assume point is at the beginning of the block." ;; Retrieve code. (value (org-element-deferred-create - nil #'org-element--unescape-substring + t #'org-element--unescape-substring (- (line-beginning-position 2) begin) (- contents-end begin))) (pos-before-blank (progn (goto-char contents-end) @@ -3159,7 +3159,7 @@ Assume point is at the beginning of the table." :contents-end (and (eq type 'org) table-end) :value (and (eq type 'table.el) (org-element-deferred-create - nil #'org-element--substring + t #'org-element--substring (- table-begin begin) (- table-end begin))) :post-blank (count-lines pos-before-blank end) @@ -3322,7 +3322,7 @@ Assume point is at first MARK." (list :value (and (memq type '(code verbatim)) (org-element-deferred-create - nil #'org-element--substring + t #'org-element--substring (- contents-begin origin) (- contents-end origin)))) (list :contents-begin contents-begin @@ -3572,7 +3572,7 @@ Assume point is at the beginning of the snippet." (value (when contents-end (org-element-deferred-create - nil #'org-element--substring + t #'org-element--substring (- contents-begin begin) (- contents-end begin)))) (post-blank (skip-chars-forward " \t")) @@ -3667,7 +3667,7 @@ Assume point is at the beginning of the babel call." (replace-regexp-in-string "\n[ \t]*" " " (org-trim p))))) (value (org-element-deferred-create - nil #'org-element--substring + t #'org-element--substring 0 (- (point) begin))) (post-blank (skip-chars-forward " \t")) (end (point))) @@ -3801,7 +3801,7 @@ Assume point is at the beginning of the LaTeX fragment." 'latex-fragment (list :value (org-element-deferred-create - nil #'org-element--substring + t #'org-element--substring 0 (- after-fragment begin)) :begin begin :end end From 1387e361350794610ac1d5e5629381652713197b Mon Sep 17 00:00:00 2001 From: Ihor Radchenko Date: Sat, 15 Jun 2024 13:14:58 +0200 Subject: [PATCH 22/28] Update version number for the 9.7.4 release --- lisp/org.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lisp/org.el b/lisp/org.el index 44734a733..2be404e36 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -9,7 +9,7 @@ ;; URL: https://orgmode.org ;; Package-Requires: ((emacs "26.1")) -;; Version: 9.7.3 +;; Version: 9.7.4 ;; This file is part of GNU Emacs. ;; From be39e61c4efa5027536809c89b90bfe66b76b712 Mon Sep 17 00:00:00 2001 From: Ihor Radchenko Date: Sat, 15 Jun 2024 15:45:40 +0200 Subject: [PATCH 23/28] Use emacs-internal coding system to read/write Elisp data * lisp/org-persist.el (org-persist--read-elisp-file): (org-persist--write-elisp-file): * lisp/ox.el (org-export-async-start): Suggested by Emacs maintainer. Link: https://list.orgmode.org/861q4zy0va.fsf@gnu.org/ --- lisp/org-persist.el | 4 ++-- lisp/ox.el | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lisp/org-persist.el b/lisp/org-persist.el index c855c6604..52f4b0eef 100644 --- a/lisp/org-persist.el +++ b/lisp/org-persist.el @@ -416,7 +416,7 @@ FORMAT and ARGS are passed to `message'." (defun org-persist--read-elisp-file (&optional buffer-or-file) "Read elisp data from BUFFER-OR-FILE or current buffer." (let (;; UTF-8 is explicitly used in `org-persist--write-elisp-file'. - (coding-system-for-read 'utf-8) + (coding-system-for-read 'emacs-internal) (buffer-or-file (or buffer-or-file (current-buffer)))) (with-temp-buffer (if (bufferp buffer-or-file) @@ -464,7 +464,7 @@ FORMAT and ARGS are passed to `message'." (let ((write-region-inhibit-fsync t) ;; We set UTF-8 here and in `org-persist--read-elisp-file' ;; to avoid the overhead from `find-auto-coding'. - (coding-system-for-write 'utf-8) + (coding-system-for-write 'emacs-internal) (print-circle (not no-circular)) print-level print-length diff --git a/lisp/ox.el b/lisp/ox.el index 29390bf0e..35bbf84a0 100644 --- a/lisp/ox.el +++ b/lisp/ox.el @@ -6671,7 +6671,7 @@ and `org-export-to-file' for more specialized functions." (with-temp-message "Initializing asynchronous export process" (let ((copy-fun (org-element--generate-copy-script (current-buffer))) (temp-file (make-temp-file "org-export-process"))) - (let ((coding-system-for-write 'utf-8-emacs-unix)) + (let ((coding-system-for-write 'emacs-internal)) (write-region ;; Null characters (from variable values) are inserted ;; within the file. As a consequence, coding system for From a9a05dab81eb4e7d6c74bb9755d50c08973f00d1 Mon Sep 17 00:00:00 2001 From: Ihor Radchenko Date: Sat, 15 Jun 2024 16:15:45 +0200 Subject: [PATCH 24/28] lisp/org-src.el (org-src-lang-modes): Fix :type definition MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reported-by: Mattias Engdegård Link: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=71566 --- lisp/org-src.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lisp/org-src.el b/lisp/org-src.el index d152fbfe8..262bd4628 100644 --- a/lisp/org-src.el +++ b/lisp/org-src.el @@ -241,8 +241,8 @@ but the mode to use is `tuareg-mode'." :package-version '(Org . "9.7") :type '(repeat (cons - (string "Language name") - (symbol "Major mode")))) + (string :tag "Language name") + (symbol :tag "Major mode")))) (defcustom org-src-block-faces nil "Alist of faces to be used for source-block. From 12243b9910b2a44c0584cc95492446a34cf7c2bd Mon Sep 17 00:00:00 2001 From: Ihor Radchenko Date: Sat, 15 Jun 2024 16:33:12 +0200 Subject: [PATCH 25/28] lisp/ob-lilypond.el (org-src-lang-modes): Fix alist value LilyPond-mode name should be a symbol as per `org-src-lang-modes' spec. Reported-by: Michael Albinus Link: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=71566 --- lisp/ob-lilypond.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lisp/ob-lilypond.el b/lisp/ob-lilypond.el index 35df76fc9..a8d85ce7c 100644 --- a/lisp/ob-lilypond.el +++ b/lisp/ob-lilypond.el @@ -41,7 +41,7 @@ (declare-function org-fold-show-all "org-fold" (&optional types)) (add-to-list 'org-babel-tangle-lang-exts '("LilyPond" . "ly")) -(add-to-list 'org-src-lang-modes '("lilypond" . "LilyPond")) +(add-to-list 'org-src-lang-modes '("lilypond" . LilyPond)) (defvar org-babel-default-header-args:lilypond '() "Default header arguments for lilypond code blocks. From 008c28426d8973ce2ba0734488669cc2d3261e47 Mon Sep 17 00:00:00 2001 From: Ihor Radchenko Date: Sat, 15 Jun 2024 16:45:54 +0200 Subject: [PATCH 26/28] ob-clojure-cli-command: Fix :type declaration MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * lisp/ob-clojure.el (ob-clojure-cli-command): Allow nil value. It can happen, even though it will yield error (which is a different issue). But let's follow other defcustoms in the file. Reported-by: Mattias Engdegård Link: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=71566 --- lisp/ob-clojure.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lisp/ob-clojure.el b/lisp/ob-clojure.el index 4a54acc51..c7ebbbb95 100644 --- a/lisp/ob-clojure.el +++ b/lisp/ob-clojure.el @@ -130,7 +130,7 @@ (defcustom ob-clojure-cli-command (when-let (cmd (executable-find "clojure")) (concat cmd " -M")) "Clojure CLI command used by the Clojure `clojure-cli' backend." - :type 'string + :type '(choice string (const nil)) :group 'org-babel :package-version '(Org . "9.7")) From 8a82a06bec0c369cfb5c5944f9fca5456e3bd426 Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Mon, 10 Jun 2024 00:38:13 +0200 Subject: [PATCH 27/28] ORG-NEWS: Backport commit 77d0eed74 from Emacs ; Fix typos 77d0eed74e1d934e28f364cb3adb06365e71335e Stefan Kangas Mon Jun 10 00:40:26 2024 +0200 [km] This should have been included with 2a6a0480d. --- etc/ORG-NEWS | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index 26f927d42..32e56cba8 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -276,7 +276,7 @@ passing universal argument. When using this feature, IDs should not include =::=, which is used in links to indicate the start of the search string. For backwards -compability, existing IDs including =::= will still be matched (but +compatibility, existing IDs including =::= will still be matched (but cannot be used together with search option). A new org-lint checker has been added to warn about this. @@ -417,8 +417,8 @@ in the dynamic block. A global default formatting function for =colview= dynamic blocks can be set via the new option ~org-columns-dblock-formatter~ which defaults to the new function ~org-columns-dblock-write-default~, that -implements the previous (fixed) formatting behaviour. Hence, the -default behaviour is identical to previous versions. +implements the previous (fixed) formatting behavior. Hence, the +default behavior is identical to previous versions. The global default function can be overridden for any given =colview= dynamic block individually by specifying a custom formatter function @@ -884,7 +884,7 @@ order to remain backward-compatible. Before, a ClojureScript source block used the same backend as Clojure, configured in ~org-babel-clojure-backend~ and relied on an undocumented -~:target~ paramter. +~:target~ parameter. Now, there's ~org-babel-clojurescript-backend~ to determine the backend used for evaluation of ClojureScript. @@ -962,7 +962,7 @@ manner with ~run-python~. *** New hook option ~org-indent-post-buffer-init-functions~ -This allows to run functions after ~org-indent~ intializes a buffer to +This allows to run functions after ~org-indent~ initializes a buffer to enrich its properties. *** New option ~org-agenda-start-with-archives-mode~ @@ -1025,7 +1025,7 @@ of the dynamic block. This new option can be used to set the global default formatting function that will be used for =colview= dynamic blocks that do not specify any ~:formatter~ parameter. Its default value (the new function ~org-columns-dblock-write-default~) yields the -previous (fixed) formatting behaviour. +previous (fixed) formatting behavior. *** New allowed value of ~org-md-headline-style~ to mix ATX and Setext style headlines @@ -1569,12 +1569,12 @@ is initiated only when user explicitly executes R/Julia-mode commands that trigger session interactions (requires ESS 24.01.0 or newer). The same session will remain available in the context of Org babel. -*** ~org-store-link~ behaviour storing additional =CUSTOM_ID= links has changed +*** ~org-store-link~ behavior storing additional =CUSTOM_ID= links has changed Previously, when storing =id:= link, ~org-store-link~ stored an additional "human readable" link using a node's =CUSTOM_ID= property. -This behaviour has been expanded to store an additional =CUSTOM_ID= +This behavior has been expanded to store an additional =CUSTOM_ID= link when storing any type of external link type in an Org file, not just =id:= links. From 165319f5847e6f1c9e868e1ca98ec853d50496c6 Mon Sep 17 00:00:00 2001 From: Kyle Meyer Date: Sat, 15 Jun 2024 14:19:28 -0400 Subject: [PATCH 28/28] ob-core: Revert recent indentation change * lisp/ob-core.el (org-babel-insert-result): Fix indentation change from e4902995a. --- lisp/ob-core.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lisp/ob-core.el b/lisp/ob-core.el index 0b329266a..db75f1f0a 100644 --- a/lisp/ob-core.el +++ b/lisp/ob-core.el @@ -2762,7 +2762,7 @@ INFO may provide the values of these header arguments (in the ;; In this case `table-align' does the work ;; for us. (not (and (listp result) - (member "append" result-params)))) + (member "append" result-params)))) (indent-rigidly beg end indent)) (unless noninteractive (let ((time-info