From afe50b7132cb9e5d5e3209ee91be0683963b072d Mon Sep 17 00:00:00 2001 From: Ihor Radchenko Date: Sun, 24 Jul 2022 20:09:12 +0800 Subject: [PATCH 1/4] Fix Emacs 26 compatibility * lisp/org-plot.el (org-plot/gnuplot): Do not use `if-let'. * lisp/ox-ascii.el (org-ascii--describe-links): * lisp/ox-md.el (org-md--headline-referred-p): Do not use `ignore-error'. * testing/org-test.el (org-test-at-time): Fallback to older definition of `decode-time' when it cannot accept 3 arguments. --- lisp/org-plot.el | 7 ++++--- lisp/ox-ascii.el | 7 ++++--- lisp/ox-md.el | 5 +++-- testing/org-test.el | 9 +++++++-- 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/lisp/org-plot.el b/lisp/org-plot.el index bf84c99e0..4183b2af6 100644 --- a/lisp/org-plot.el +++ b/lisp/org-plot.el @@ -682,9 +682,10 @@ line directly before or after the table." (looking-at "[[:space:]]*#\\+")) (setf params (org-plot/collect-options params)))) ;; Dump table to datafile - (if-let ((dump-func (plist-get type :data-dump))) - (funcall dump-func table data-file num-cols params) - (org-plot/gnuplot-to-data table data-file params)) + (let ((dump-func (plist-get type :data-dump))) + (if dump-func + (funcall dump-func table data-file num-cols params) + (org-plot/gnuplot-to-data table data-file params))) ;; Check type of ind column (timestamp? text?) (when (plist-get params :check-ind-type) (let* ((ind (1- (plist-get params :ind))) diff --git a/lisp/ox-ascii.el b/lisp/ox-ascii.el index 88a75a815..76a1a71fa 100644 --- a/lisp/ox-ascii.el +++ b/lisp/ox-ascii.el @@ -950,9 +950,10 @@ channel." (org-export-resolve-fuzzy-link link info) ;; Ignore broken links. On broken link, ;; `org-export-resolve-id-link' will throw an - ;; error and `ignore-error' will return nil. - (ignore-error 'org-link-broken - (org-export-resolve-id-link link info))))) + ;; error and we will return nil. + (condition-case nil + (org-export-resolve-id-link link info) + (org-link-broken nil))))) (when dest (concat (org-ascii--fill-string diff --git a/lisp/ox-md.el b/lisp/ox-md.el index 91b7ee657..3551e4184 100644 --- a/lisp/ox-md.el +++ b/lisp/ox-md.el @@ -195,8 +195,9 @@ of contents can refer to headlines." (lambda (link) (equal headline ;; Ignore broken links. - (ignore-error 'org-link-broken - (org-export-resolve-link link info)))) + (condition-case nil + (org-export-resolve-id-link link info) + (org-link-broken nil)))) info t)))) (defun org-md--headline-title (style level title &optional anchor tags) diff --git a/testing/org-test.el b/testing/org-test.el index 3565dd0cf..161b2f49c 100644 --- a/testing/org-test.el +++ b/testing/org-test.el @@ -470,8 +470,13 @@ TIME can be a non-nil Lisp time value, or a string specifying a date and time." (apply ,(symbol-function 'current-time-zone) (or time ,at) args))) ((symbol-function 'decode-time) - (lambda (&optional time zone form) (funcall ,(symbol-function 'decode-time) - (or time ,at) zone form))) + (lambda (&optional time zone form) + (condition-case nil + (funcall ,(symbol-function 'decode-time) + (or time ,at) zone form) + (wrong-number-of-arguments + (funcall ,(symbol-function 'decode-time) + (or time ,at)))))) ((symbol-function 'encode-time) (lambda (time &rest args) (apply ,(symbol-function 'encode-time) (or time ,at) args))) From 01b0fb14bc9f4e5e253f09f85df2f932c1b96bcf Mon Sep 17 00:00:00 2001 From: Robert Pluim Date: Tue, 14 Jun 2022 11:29:12 +0200 Subject: [PATCH 2/4] 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. --- lisp/ob-core.el | 2 +- lisp/ob-julia.el | 8 ++++---- lisp/ob-lua.el | 2 +- lisp/ob-table.el | 2 +- lisp/org-agenda.el | 6 +++--- lisp/org-plot.el | 2 +- lisp/org-table.el | 2 +- lisp/org.el | 4 ++-- lisp/ox-html.el | 2 +- lisp/ox-publish.el | 2 +- 10 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lisp/ob-core.el b/lisp/ob-core.el index 23ef162a7..37155d4c5 100644 --- a/lisp/ob-core.el +++ b/lisp/ob-core.el @@ -480,7 +480,7 @@ value. The value can either be a string or a closure that evaluates to a string. The closure is evaluated when the source block is being evaluated (e.g. during execution or export), with point at the source block. It is not possible to use an -arbitrary function symbol (e.g. 'some-func), since org uses +arbitrary function symbol (e.g. \\='some-func), since org uses lexical binding. To achieve the same functionality, call the function within a closure (e.g. (lambda () (some-func))). diff --git a/lisp/ob-julia.el b/lisp/ob-julia.el index abddca361..be0110f48 100644 --- a/lisp/ob-julia.el +++ b/lisp/ob-julia.el @@ -250,8 +250,8 @@ end") (defun org-babel-julia-evaluate-external-process (body result-type result-params column-names-p) "Evaluate BODY in external julia process. -If RESULT-TYPE equals 'output then return standard output as a -string. If RESULT-TYPE equals 'value then return the value of the +If RESULT-TYPE equals \\='output then return standard output as a +string. If RESULT-TYPE equals \\='value then return the value of the last statement in BODY, as elisp." (cl-case result-type (value @@ -274,8 +274,8 @@ last statement in BODY, as elisp." (defun org-babel-julia-evaluate-session (session body result-type result-params column-names-p) "Evaluate BODY in SESSION. -If RESULT-TYPE equals 'output then return standard output as a -string. If RESULT-TYPE equals 'value then return the value of the +If RESULT-TYPE equals \\='output then return standard output as a +string. If RESULT-TYPE equals \\='value then return the value of the last statement in BODY, as elisp." (cl-case result-type (value diff --git a/lisp/ob-lua.el b/lisp/ob-lua.el index 48de0dbad..c8c28498e 100644 --- a/lisp/ob-lua.el +++ b/lisp/ob-lua.el @@ -395,7 +395,7 @@ fd:close()" (org-babel-lua-table-or-string results))))) (defun org-babel-lua-read-string (string) - "Strip 's from around Lua string." + "Strip single quotes from around Lua string." (org-unbracket-string "'" "'" string)) (provide 'ob-lua) diff --git a/lisp/ob-table.el b/lisp/ob-table.el index 2f092998d..0f6d41c5e 100644 --- a/lisp/ob-table.el +++ b/lisp/ob-table.el @@ -84,7 +84,7 @@ is the equivalent of the following source code block: #+end_src NOTE: The quotation marks around the function name, -'source-block', are optional. +\\='source-block\\=', are optional. NOTE: By default, string variable names are interpreted as references to source-code blocks, to force interpretation of a diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el index 71aac271f..4831c66b0 100644 --- a/lisp/org-agenda.el +++ b/lisp/org-agenda.el @@ -1615,7 +1615,7 @@ alpha-down Sort headlines alphabetically, reversed. The different possibilities will be tried in sequence, and testing stops if one comparison returns a \"not-equal\". For example, the default - '(time-up category-keep priority-down) + \\='(time-up category-keep priority-down) means: Pull out all entries having a specified time of day and sort them, in order to make a time schedule for the current day the first thing in the agenda listing for the day. Of the entries without a time indication, keep @@ -4124,7 +4124,7 @@ dimming them." ;FIXME: The arg isn't used, actually! If the header at `org-hd-marker' is blocked according to `org-entry-blocked-p', then if `org-agenda-dim-blocked-tasks' is -'invisible and the header is not blocked by checkboxes, set the +\\='invisible and the header is not blocked by checkboxes, set the text property `org-todo-blocked' to `invisible', otherwise set it to t." (when (get-text-property 0 'todo-state entry) @@ -7399,7 +7399,7 @@ Argument ARG is the prefix argument." When in a restricted subtree, remove it. The restriction will span over the entire file if TYPE is `file', -or if type is '(4), or if the cursor is before the first headline +or if type is \\='(4), or if the cursor is before the first headline in the file. Otherwise, only apply the restriction to the current subtree." (interactive "P") diff --git a/lisp/org-plot.el b/lisp/org-plot.el index 4183b2af6..7958ffd58 100644 --- a/lisp/org-plot.el +++ b/lisp/org-plot.el @@ -280,7 +280,7 @@ When NORMALISE is non-nil, the count is divided by the number of values." collect (cons n (/ (length m) normaliser))))) (defun org--plot/prime-factors (value) - "Return the prime decomposition of VALUE, e.g. for 12, '(3 2 2)." + "Return the prime decomposition of VALUE, e.g. for 12, \\='(3 2 2)." (let ((factors '(1)) (i 1)) (while (/= 1 value) (setq i (1+ i)) diff --git a/lisp/org-table.el b/lisp/org-table.el index 860fd6e56..f41f6ffdf 100644 --- a/lisp/org-table.el +++ b/lisp/org-table.el @@ -5465,7 +5465,7 @@ The table is taken from the parameter TXT, or from the buffer at point." (nreverse table))))) (defun org-table-collapse-header (table &optional separator max-header-lines) - "Collapse the lines before 'hline into a single header. + "Collapse the lines before \\='hline into a single header. The given TABLE is a list of lists as returned by `org-table-to-lisp'. The leading lines before the first `hline' symbol are considered diff --git a/lisp/org.el b/lisp/org.el index 06af12339..a6155c138 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -1694,7 +1694,7 @@ OK to kill that hidden subtree. When nil, kill without remorse." (const :tag "Never kill a hidden subtree with C-k" error))) (defcustom org-special-ctrl-o t - "Non-nil means, make `C-o' insert a row in tables." + "Non-nil means, make `open-line' (\\[open-line]) insert a row in tables." :group 'org-edit-structure :type 'boolean) @@ -3301,7 +3301,7 @@ Replace format-specifiers in the command as noted below and use %i: The LaTeX fragment to be converted. For example, this could be used with LaTeXML as -\"latexmlc 'literal:%i' --profile=math --preload=siunitx.sty 2>/dev/null\"." +\"latexmlc \\='literal:%i\\=' --profile=math --preload=siunitx.sty 2>/dev/null\"." :group 'org-latex :package-version '(Org . "9.4") :type '(choice diff --git a/lisp/ox-html.el b/lisp/ox-html.el index 81ef002a0..32c0699a6 100644 --- a/lisp/ox-html.el +++ b/lisp/ox-html.el @@ -2909,7 +2909,7 @@ Starred and \"displaymath\" environments are not numbered." (defun org-html--unlabel-latex-environment (latex-frag) "Change environment in LATEX-FRAG string to an unnumbered one. -For instance, change an 'equation' environment to 'equation*'." +For instance, change an \\='equation\\=' environment to \\='equation*\\='." (replace-regexp-in-string "\\`[ \t]*\\\\begin{\\([^*]+?\\)}" "\\1*" diff --git a/lisp/ox-publish.el b/lisp/ox-publish.el index 636bd0d2a..51e2352b4 100644 --- a/lisp/ox-publish.el +++ b/lisp/ox-publish.el @@ -839,7 +839,7 @@ in `org-export-options-alist' or in export back-ends. In the latter case, optional argument BACKEND has to be set to the back-end where the option is defined, e.g., - (org-publish-find-property file :subtitle 'latex) + (org-publish-find-property file :subtitle \\='latex) Return value may be a string or a list, depending on the type of PROPERTY, i.e. \"behavior\" parameter from `org-export-options-alist'." From a0a078049b8c097b61187ccca445ee3cfb187100 Mon Sep 17 00:00:00 2001 From: Ihor Radchenko Date: Sun, 24 Jul 2022 20:19:47 +0800 Subject: [PATCH 3/4] Fix compiler warnings * lisp/oc-basic.el (org-open-file): Declare function. --- lisp/oc-basic.el | 1 + 1 file changed, 1 insertion(+) diff --git a/lisp/oc-basic.el b/lisp/oc-basic.el index 9ed1b810f..8c76e200e 100644 --- a/lisp/oc-basic.el +++ b/lisp/oc-basic.el @@ -73,6 +73,7 @@ (require 'seq) (declare-function org-open-at-point "org" (&optional arg)) +(declare-function org-open-file "org" (path &optional in-emacs line search)) (declare-function org-element-interpret-data "org-element" (data)) (declare-function org-element-property "org-element" (property element)) From 1c3a46268f29bcfa35824c6e68607f6feed99023 Mon Sep 17 00:00:00 2001 From: Ihor Radchenko Date: Sun, 17 Oct 2021 14:34:10 +0800 Subject: [PATCH 4/4] Backport from main: Fix compatibility with Emacs 26 * lisp/org-compat.el (org-replace-buffer-contents): Add compatibility function for `replace-buffer-contents'. * lisp/org-src.el (org-edit-src-save, org-edit-src-exit): Use `org-replace-buffer-contents'. --- lisp/org-compat.el | 5 +++++ lisp/org-src.el | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lisp/org-compat.el b/lisp/org-compat.el index c26eb6f10..da544a567 100644 --- a/lisp/org-compat.el +++ b/lisp/org-compat.el @@ -113,6 +113,11 @@ the symbol of the calling function, for example." ;;; Emacs < 27.1 compatibility +(if (version< emacs-version "27.1") + (defsubst org-replace-buffer-contents (source &optional _max-secs _max-costs) + (replace-buffer-contents source)) + (defalias 'org-replace-buffer-contents #'replace-buffer-contents)) + (unless (fboundp 'proper-list-p) ;; `proper-list-p' was added in Emacs 27.1. The function below is ;; taken from Emacs subr.el 200195e824b^. diff --git a/lisp/org-src.el b/lisp/org-src.el index 54f901252..89d0c28a4 100644 --- a/lisp/org-src.el +++ b/lisp/org-src.el @@ -1235,7 +1235,7 @@ Throw an error if there is no such buffer." (insert (with-current-buffer write-back-buf (buffer-string)))) (save-restriction (narrow-to-region beg end) - (replace-buffer-contents write-back-buf 0.1 nil) + (org-replace-buffer-contents write-back-buf 0.1 nil) (goto-char (point-max)))) (when (and expecting-bol (not (bolp))) (insert "\n"))) (kill-buffer write-back-buf) @@ -1283,7 +1283,7 @@ Throw an error if there is no such buffer." (buffer-string)))) (save-restriction (narrow-to-region beg end) - (replace-buffer-contents write-back-buf 0.1 nil) + (org-replace-buffer-contents write-back-buf 0.1 nil) (goto-char (point-max)))) (when (and expecting-bol (not (bolp))) (insert "\n"))))) (when write-back-buf (kill-buffer write-back-buf))