emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [BUG] org-element loading fails with "regexp" argument not "stringp"
@ 2023-07-04 23:51 Justin
  2023-07-05 10:35 ` Ihor Radchenko
  0 siblings, 1 reply; 6+ messages in thread
From: Justin @ 2023-07-04 23:51 UTC (permalink / raw)
  To: emacs-orgmode

Using emacs 26.1 (in case it matters).  Loading is failing at:

(defconst org-element--current-element-re
   (rx
    (or
     (group-n 1 (regexp org-element--latex-begin-environment-nogroup))

rx is a macro, and so org-element* is not being evaluated.  It's 
complaining that the argument to regexp is not a stringp.

Does the rx argument need a backquote?  org-element-clock-line-re uses 
rx-to-string with a backquote?

(rx `(or (group-n 1 (regexp ,org-element--...

-Justin



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [BUG] org-element loading fails with "regexp" argument not "stringp"
  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   ` [PATCH] Fix Emacs-26 compatibility (was: Re: [BUG] org-element loading fails with "regexp" argument not "stringp") Max Nikulin
  0 siblings, 1 reply; 6+ messages in thread
From: Ihor Radchenko @ 2023-07-05 10:35 UTC (permalink / raw)
  To: Justin; +Cc: emacs-orgmode

Justin <justinvallon@gmail.com> writes:

> Using emacs 26.1 (in case it matters).  Loading is failing at:
>
> (defconst org-element--current-element-re
>    (rx
>     (or
>      (group-n 1 (regexp org-element--latex-begin-environment-nogroup))
>
> rx is a macro, and so org-element* is not being evaluated.  It's 
> complaining that the argument to regexp is not a stringp.
>
> Does the rx argument need a backquote?  org-element-clock-line-re uses 
> rx-to-string with a backquote?

No, it does not need.
The failure is because Emacs 26 does not yet support (regex variable).

However, you will see many more failures with Emacs 26 on the latest
main.

I am not sure if we need to try tackling them all, considering that Org
9.7 will not need to be compatible with Emacs 26.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH] Fix Emacs-26 compatibility (was: Re: [BUG] org-element loading fails with "regexp" argument not "stringp")
  2023-07-05 10:35 ` Ihor Radchenko
@ 2023-07-05 16:00   ` Max Nikulin
  2023-07-06  9:54     ` Ihor Radchenko
  0 siblings, 1 reply; 6+ messages in thread
From: Max Nikulin @ 2023-07-05 16:00 UTC (permalink / raw)
  To: Justin; +Cc: emacs-orgmode

[-- 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


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] Fix Emacs-26 compatibility (was: Re: [BUG] org-element loading fails with "regexp" argument not "stringp")
  2023-07-05 16:00   ` [PATCH] Fix Emacs-26 compatibility (was: Re: [BUG] org-element loading fails with "regexp" argument not "stringp") Max Nikulin
@ 2023-07-06  9:54     ` Ihor Radchenko
  2023-07-08  4:56       ` [PATCH v2] " Max Nikulin
  0 siblings, 1 reply; 6+ messages in thread
From: Ihor Radchenko @ 2023-07-06  9:54 UTC (permalink / raw)
  To: Max Nikulin; +Cc: Justin, emacs-orgmode

Max Nikulin <manikulin@gmail.com> writes:

> 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 condition:
>      (wrong-number-of-arguments
>       (0 . 1)
>       3)
>     FAILED   935/1069  test-org/delete-indentation

Yup, it is because `org-delete-indentation' now uses 3 arguments when
calling `delete-indentation', while in Emacs 26 `delete-indentation'
only accepted up to 1.

And there are many warnings of which I have clue about the origin.
Except `string-search' undefined, which is not yet available in Emacs 26.

> 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'.

You are removing `org-protocol-flatten' function, which is a breaking
change. We should leave an obsolete alias.

Also, you are defining `flatten-tree' function, which is outside Org's
namespace. We should better avoid it and use something like
`org-flatten-tree'.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v2] Fix Emacs-26 compatibility (was: Re: [BUG] org-element loading fails with "regexp" argument not "stringp")
  2023-07-06  9:54     ` Ihor Radchenko
@ 2023-07-08  4:56       ` Max Nikulin
  2023-07-08  9:18         ` Ihor Radchenko
  0 siblings, 1 reply; 6+ messages in thread
From: Max Nikulin @ 2023-07-08  4:56 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 498 bytes --]

On 06/07/2023 16:54, Ihor Radchenko wrote:
> You are removing `org-protocol-flatten' function, which is a breaking
> change. We should leave an obsolete alias.

I have added an alias for this function hardly known to anybody else.

> Also, you are defining `flatten-tree' function, which is outside Org's
> namespace. We should better avoid it and use something like
> `org-flatten-tree'.

The idea was to minimize conflicts with your branch for the compat 
package. I hope, it will be merged soon.

[-- Attachment #2: v2-0001-org-element.el-Fix-Emacs-26-compatibility.patch --]
[-- Type: text/x-patch, Size: 2911 bytes --]

From 635710157476239314d7fe5231fbec2163cbe52d Mon Sep 17 00:00:00 2001
From: Max Nikulin <manikulin@gmail.com>
Date: Wed, 5 Jul 2023 22:44:33 +0700
Subject: [PATCH v2 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: v2-0002-org-compat.el-org-flatten-tree-for-Emacs-26-compa.patch --]
[-- Type: text/x-patch, Size: 5106 bytes --]

From e85b19dba86bc3a5937376a0001453dbe3a5dc24 Mon Sep 17 00:00:00 2001
From: Max Nikulin <manikulin@gmail.com>
Date: Wed, 5 Jul 2023 22:50:44 +0700
Subject: [PATCH v2 2/2] org-compat.el: `org--flatten-tree' for Emacs-26
 compatibility

* lisp/org-compat.el (org--flatten-tree): New internal compatibility
alias or function based on `flatten-tree' added to Emacs-27.1.
* lisp/org-protocol.el (org-protocol-flatten): Convert to an obsolete
function alias.
(org-protocol-flatten-greedy): Use the `org--flatten-tree' new
compatibility alias or function instead of `org-protocol-flatten'.
* lisp/org-src.el (org-src--get-known-shells): Make the function
compatible with Emacs-26 by using `org--flatten-tree' instead of
`flatten-tree'.

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   | 19 +++++++++++++++++++
 lisp/org-protocol.el | 24 +++++++++---------------
 lisp/org-src.el      |  2 +-
 3 files changed, 29 insertions(+), 16 deletions(-)

diff --git a/lisp/org-compat.el b/lisp/org-compat.el
index c5ab655d2..bbda04a15 100644
--- a/lisp/org-compat.el
+++ b/lisp/org-compat.el
@@ -211,6 +211,25 @@     (defmacro org-combine-change-calls (_beg _end &rest body)
       `(progn ,@body))
   (defalias 'org-combine-change-calls 'combine-change-calls))
 
+;; `flatten-tree' was added in Emacs 27.1.
+(if (fboundp 'flatten-tree)
+    (defalias 'org--flatten-tree #'flatten-tree)
+  ;; The implementation is taken from Emacs subr.el 8664ba18c7c5.
+  (defun org--flatten-tree (tree)
+    "Return a \"flattened\" copy of TREE.
+
+A `flatten-tree' polyfill for compatibility with Emacs versions
+older than 27.1"
+    (let (elems)
+      (while (consp tree)
+        (let ((elem (pop tree)))
+          (while (consp elem)
+            (push (cdr elem) tree)
+            (setq elem (car elem)))
+          (if elem (push elem elems))))
+      (if tree (push tree elems))
+      (nreverse elems))))
+
 (if (version< emacs-version "27.1")
     (defsubst org-replace-buffer-contents (source &optional _max-secs _max-costs)
       (replace-buffer-contents source))
diff --git a/lisp/org-protocol.el b/lisp/org-protocol.el
index 2b07a377e..d6cc39aa9 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 (org--flatten-tree (if org-protocol-reverse-list-of-files
+                              param-list
+                            (reverse param-list))))
 	 (trigger (car l))
 	 (len 0)
 	 dir
@@ -368,21 +368,15 @@ (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.
+(define-obsolete-function-alias 'org-protocol-flatten
+  (if (fboundp 'flatten-tree) 'flatten-tree 'org--flatten-tree)
+  "9.7"
+  "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))))))
+This function transforms it into a flat list.")
 
 (defun org-protocol-parse-parameters (info &optional new-style default-order)
   "Return a property list of parameters from INFO.
diff --git a/lisp/org-src.el b/lisp/org-src.el
index e1f7d50dc..7edbe0570 100644
--- a/lisp/org-src.el
+++ b/lisp/org-src.el
@@ -208,7 +208,7 @@ (defun org-src--get-known-shells ()
 The shells are associated with `sh-mode'."
   (mapcar
    (lambda (shell) (cons (symbol-name shell) 'sh))
-   (delete-dups (flatten-tree sh-ancestor-alist))))
+   (delete-dups (org--flatten-tree sh-ancestor-alist))))
 
 (defcustom org-src-lang-modes
   `(("C" . c)
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] Fix Emacs-26 compatibility (was: Re: [BUG] org-element loading fails with "regexp" argument not "stringp")
  2023-07-08  4:56       ` [PATCH v2] " Max Nikulin
@ 2023-07-08  9:18         ` Ihor Radchenko
  0 siblings, 0 replies; 6+ messages in thread
From: Ihor Radchenko @ 2023-07-08  9:18 UTC (permalink / raw)
  To: Max Nikulin; +Cc: emacs-orgmode

Max Nikulin <manikulin@gmail.com> writes:

> On 06/07/2023 16:54, Ihor Radchenko wrote:
>> You are removing `org-protocol-flatten' function, which is a breaking
>> change. We should leave an obsolete alias.
>
> I have added an alias for this function hardly known to anybody else.

It was easy enough, so why not. There is no reason to avoid
backward-compatible code when it costs us very little.

>> Also, you are defining `flatten-tree' function, which is outside Org's
>> namespace. We should better avoid it and use something like
>> `org-flatten-tree'.
>
> The idea was to minimize conflicts with your branch for the compat 
> package.

When used together with compat, we would fight for the same namespace,
loading either Org's or compat's variant of the function depending on
the loading order.

Of course, it would not matter this time - compat's definition of
`flatten-tree' is a copy-paste from the Emacs implementation, just as
ours. But such practice is to be avoided.

> ... I hope, it will be merged soon.

Applied, onto main.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=caa27be10
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=879ba22ef
Thanks!

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-07-08  9:19 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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   ` [PATCH] Fix Emacs-26 compatibility (was: Re: [BUG] org-element loading fails with "regexp" argument not "stringp") Max Nikulin
2023-07-06  9:54     ` Ihor Radchenko
2023-07-08  4:56       ` [PATCH v2] " Max Nikulin
2023-07-08  9:18         ` Ihor Radchenko

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).