From: Max Nikulin <manikulin@gmail.com>
To: Justin <justinvallon@gmail.com>
Cc: emacs-orgmode@gnu.org
Subject: [PATCH] Fix Emacs-26 compatibility (was: Re: [BUG] org-element loading fails with "regexp" argument not "stringp")
Date: Wed, 5 Jul 2023 23:00:17 +0700 [thread overview]
Message-ID: <73ee6087-4c89-9d9a-cbc6-197396a023c1@gmail.com> (raw)
In-Reply-To: <877creabn6.fsf@localhost>
[-- Attachment #1: Type: text/plain, Size: 1643 bytes --]
On 05/07/2023 17:35, Ihor Radchenko wrote:
> However, you will see many more failures with Emacs 26 on the latest
> main.
With the couple of attached patches the only failing test is
Test test-org/delete-indentation backtrace:
signal(wrong-number-of-arguments ((0 . 1) 3))
apply(signal (wrong-number-of-arguments ((0 . 1) 3)))
(setq value-20142 (apply fn-20140 args-20141))
(unwind-protect (setq value-20142 (apply fn-20140 args-20141)) (setq
(if (unwind-protect (setq value-20142 (apply fn-20140 args-20141)) (
(let (form-description-20144) (if (unwind-protect (setq value-20142
(let ((value-20142 (quote ert-form-evaluation-aborted-20143))) (let
(let* ((fn-20140 (function equal)) (args-20141 (condition-case err (
(closure (t) nil (let* ((fn-20140 (function equal)) (args-20141 (con
ert--run-test-internal(#s(ert--test-execution-info :test #s(ert-test
ert-run-test(#s(ert-test :name test-org/delete-indentation :document
ert-run-or-rerun-test(#s(ert--stats :selector "\\(org\\|ob\\|ox\\)"
ert-run-tests("\\(org\\|ob\\|ox\\)" #f(compiled-function (event-type
ert-run-tests-batch("\\(org\\|ob\\|ox\\)")
ert-run-tests-batch-and-exit("\\(org\\|ob\\|ox\\)")
(let ((org-id-track-globally t) (org-test-selector (if org-test-sele
org-test-run-batch-tests("\\(org\\|ob\\|ox\\)")
eval((org-test-run-batch-tests org-test-select-re))
command-line-1(("--eval" "(setq vc-handled-backends nil org-startup-
command-line()
normal-top-level()
Test test-org/delete-indentation condition:
(wrong-number-of-arguments
(0 . 1)
3)
FAILED 935/1069 test-org/delete-indentation
[-- Attachment #2: 0001-org-element.el-Fix-Emacs-26-compatibility.patch --]
[-- Type: text/x-patch, Size: 2908 bytes --]
From b0076919e3d13c5d788afd2d5c15e90d4fefbaa0 Mon Sep 17 00:00:00 2001
From: Max Nikulin <manikulin@gmail.com>
Date: Wed, 5 Jul 2023 22:44:33 +0700
Subject: [PATCH 1/2] org-element.el: Fix Emacs-26 compatibility
* org-element.el (org-element--current-element-re): Use `rx-to-string'
instead of `rx' to expand variables.
(org-element--cache-setup-change-functions): Avoid multiple variables in
`setq-local'.
Reported as: Justin to emacs-orgmode. [BUG] org-element loading fails
with "regexp" argument not "stringp" Tue, 4 Jul 2023 19:51:44 -0400.
https://list.orgmode.org/2ff109c7-b3ec-27ac-e75d-ae5ddac14746@vallon.homeip.net
---
lisp/org-element.el | 32 ++++++++++++++++----------------
1 file changed, 16 insertions(+), 16 deletions(-)
diff --git a/lisp/org-element.el b/lisp/org-element.el
index bfb1d206e..1c9707573 100644
--- a/lisp/org-element.el
+++ b/lisp/org-element.el
@@ -4278,20 +4278,20 @@ ;;; Parsing Element Starting At Point
;; point.
(defconst org-element--current-element-re
- (rx
- (or
- (group-n 1 (regexp org-element--latex-begin-environment-nogroup))
- (group-n 2 (regexp org-element-drawer-re-nogroup))
- (group-n 3 (regexp "[ \t]*:\\( \\|$\\)"))
- (group-n 7 (regexp org-element-dynamic-block-open-re-nogroup))
- (seq (group-n 4 (regexp "[ \t]*#\\+"))
- (or
- (seq "BEGIN_" (group-n 5 (1+ (not space))))
- (group-n 6 "CALL:")
- (group-n 8 (1+ (not space)) ":")))
- (group-n 9 (regexp org-footnote-definition-re))
- (group-n 10 (regexp "[ \t]*-----+[ \t]*$"))
- (group-n 11 "%%(")))
+ (rx-to-string
+ `(or
+ (group-n 1 (regexp ,org-element--latex-begin-environment-nogroup))
+ (group-n 2 (regexp ,org-element-drawer-re-nogroup))
+ (group-n 3 (regexp "[ \t]*:\\( \\|$\\)"))
+ (group-n 7 (regexp ,org-element-dynamic-block-open-re-nogroup))
+ (seq (group-n 4 (regexp "[ \t]*#\\+"))
+ (or
+ (seq "BEGIN_" (group-n 5 (1+ (not space))))
+ (group-n 6 "CALL:")
+ (group-n 8 (1+ (not space)) ":")))
+ (group-n 9 (regexp ,org-footnote-definition-re))
+ (group-n 10 (regexp "[ \t]*-----+[ \t]*$"))
+ (group-n 11 "%%(")))
"Bulk regexp matching multiple elements in a single regexp.
This is a bit more efficient compared to invoking regexp search
multiple times.")
@@ -6916,8 +6916,8 @@ (defun org-element--cache-setup-change-functions ()
;; Clear copied local cache to avoid extra memory usage.
;; We only use cache stored in the base buffer.
(when (buffer-base-buffer)
- (setq-local org-element--cache nil
- org-element--headline-cache nil))
+ (setq-local org-element--cache nil)
+ (setq-local org-element--headline-cache nil))
(add-hook 'before-change-functions
#'org-element--cache-before-change nil t)
;; Run `org-element--cache-after-change' early to handle cases
--
2.25.1
[-- Attachment #3: 0002-org-compat.el-Define-flatten-tree-for-Emacs-26-compa.patch --]
[-- Type: text/x-patch, Size: 4109 bytes --]
From 2f2d330e90b10a86aa6b3b9ff279bc012b339396 Mon Sep 17 00:00:00 2001
From: Max Nikulin <manikulin@gmail.com>
Date: Wed, 5 Jul 2023 22:50:44 +0700
Subject: [PATCH 2/2] org-compat.el: Define `flatten-tree' for Emacs-26
compatibility
* lisp/org-compat.el (flatten-tree): New compatibility function
earlier used as `org-protocol-flatten'.
* lisp/org-protocol.el (org-protocol-flatten): Remove the definition
of the function.
(org-protocol-flatten-greedy): Use `flatten-tree' instead of
`org-protocol-flatten'.
Reported as: Justin to emacs-orgmode. [PATCH] org-src: flatten-tree is
Emacs 27.1; require compat. Tue, 4 Jul 2023 19:21:05 -0400.
https://list.orgmode.org/0288575b-fde8-0e7d-ac74-1f0ac93ce56f@vallon.homeip.net
---
lisp/org-compat.el | 15 +++++++++++++++
lisp/org-protocol.el | 24 ++++--------------------
2 files changed, 19 insertions(+), 20 deletions(-)
diff --git a/lisp/org-compat.el b/lisp/org-compat.el
index c5ab655d2..7017a5859 100644
--- a/lisp/org-compat.el
+++ b/lisp/org-compat.el
@@ -203,6 +203,21 @@ (defun org-format-prompt (prompt default &rest format-args)
\f
;;; Emacs < 27.1 compatibility
+;; `flatten-tree' was added in Emacs 27.1.
+(unless (fboundp 'flatten-tree)
+ (defun flatten-tree (list)
+ "Transform LIST into a flat list.
+
+Greedy handlers might receive a list like this from emacsclient:
+\((\"/dir/org-protocol:/greedy:/~/path1\" (23 . 12)) (\"/dir/param\"))
+where \"/dir/\" is the absolute path to emacsclients working directory.
+This function transforms it into a flat list."
+ (if list
+ (if (consp list)
+ (append (flatten-tree (car list))
+ (flatten-tree (cdr list)))
+ (list list)))))
+
(if (version< emacs-version "29")
;; A stub when `combine-change-calls' was not yet there or had
;; critical bugs (see Emacs bug#60467).
diff --git a/lisp/org-protocol.el b/lisp/org-protocol.el
index 2b07a377e..a0d003363 100644
--- a/lisp/org-protocol.el
+++ b/lisp/org-protocol.el
@@ -328,7 +328,7 @@ (defun org-protocol-flatten-greedy (param-list &optional strip-path replacement)
Greedy handlers might receive a list like this from emacsclient:
\((\"/dir/org-protocol:/greedy:/~/path1\" (23 . 12)) (\"/dir/param\"))
where \"/dir/\" is the absolute path to emacsclient's working directory. This
-function transforms it into a flat list using `org-protocol-flatten' and
+function transforms it into a flat list using `flatten-tree' and
transforms the elements of that list as follows:
If STRIP-PATH is non-nil, remove the \"/dir/\" prefix from all members of
@@ -343,9 +343,9 @@ (defun org-protocol-flatten-greedy (param-list &optional strip-path replacement)
`org-protocol-reverse-list-of-files' was set to t and the returned list will
reflect that. emacsclient's first parameter will be the first one in the
returned list."
- (let* ((l (org-protocol-flatten (if org-protocol-reverse-list-of-files
- param-list
- (reverse param-list))))
+ (let* ((l (flatten-tree (if org-protocol-reverse-list-of-files
+ param-list
+ (reverse param-list))))
(trigger (car l))
(len 0)
dir
@@ -368,22 +368,6 @@ (defun org-protocol-flatten-greedy (param-list &optional strip-path replacement)
ret)
l)))
-;; `flatten-tree' was added in Emacs 27.1.
-(defalias 'org-protocol-flatten
- (if (fboundp 'flatten-tree) 'flatten-tree
- (lambda (list)
- "Transform LIST into a flat list.
-
-Greedy handlers might receive a list like this from emacsclient:
-\((\"/dir/org-protocol:/greedy:/~/path1\" (23 . 12)) (\"/dir/param\"))
-where \"/dir/\" is the absolute path to emacsclients working directory.
-This function transforms it into a flat list."
- (if list
- (if (consp list)
- (append (org-protocol-flatten (car list))
- (org-protocol-flatten (cdr list)))
- (list list))))))
-
(defun org-protocol-parse-parameters (info &optional new-style default-order)
"Return a property list of parameters from INFO.
If NEW-STYLE is non-nil, treat INFO as a query string (ex:
--
2.25.1
next prev parent reply other threads:[~2023-07-05 16:03 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-04 23:51 [BUG] org-element loading fails with "regexp" argument not "stringp" Justin
2023-07-05 10:35 ` Ihor Radchenko
2023-07-05 16:00 ` Max Nikulin [this message]
2023-07-06 9:54 ` [PATCH] Fix Emacs-26 compatibility (was: Re: [BUG] org-element loading fails with "regexp" argument not "stringp") Ihor Radchenko
2023-07-08 4:56 ` [PATCH v2] " Max Nikulin
2023-07-08 9:18 ` Ihor Radchenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=73ee6087-4c89-9d9a-cbc6-197396a023c1@gmail.com \
--to=manikulin@gmail.com \
--cc=emacs-orgmode@gnu.org \
--cc=justinvallon@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).