Org-mode mailing list
 help / color / mirror / Atom feed
From: Ihor Radchenko <yantar92@gmail.com>
To: Radon Rosborough <radon.neon@gmail.com>
Cc: Emacs-orgmode@gnu.org
Subject: Re: [BUG] org-compile-prefix-format regexp change breaks eval forms [9.4.6 (9.4.6-gf72a65)]
Date: Sun, 30 May 2021 16:04:20 +0800
Message-ID: <87fsy4abqz.fsf@localhost> (raw)
In-Reply-To: <CADB4rJGFMv2uH2ORG_k1vboNVVv_jv4S35n89K4jhKBU+zUj-Q@mail.gmail.com>

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

Radon Rosborough <radon.neon@gmail.com> writes:

> If you insert the format string into a temporary buffer, then the `read'
> function will read up to the closing parenthesis and update point
> accordingly. That would be a foolproof way to handle all possible Lisp
> forms: use a regexp to find the start, and then use `read' to find the end.
> Then proceed with regexp matching, and repeat like that.

Thanks for the suggestion! The patch is attached.

Best,
Ihor


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Allow-sexps-with-nested-parenthesis-in-org-agenda-pr.patch --]
[-- Type: text/x-diff, Size: 1862 bytes --]

From ffbf7fe29913e33e3f20544be49b6cc2c0ef6409 Mon Sep 17 00:00:00 2001
Message-Id: <ffbf7fe29913e33e3f20544be49b6cc2c0ef6409.1622361756.git.yantar92@gmail.com>
From: Ihor Radchenko <yantar92@gmail.com>
Date: Sun, 30 May 2021 16:00:07 +0800
Subject: [PATCH] Allow sexps with nested parenthesis in
 org-agenda-prefix-format

* lisp/org-agenda.el (org-compile-prefix-format): Use `read' instead
of pure regexp matching to determine bounds of %(sexp) expressions in
`org-agenda-prefix-format'.

Fixes https://orgmode.org/list/87fsy8yi1e.fsf@localhost/
---
 lisp/org-agenda.el | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index f49a24f88..fcfcd872e 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -6942,7 +6942,7 @@ (defun org-compile-prefix-format (key)
 		  (and (string-match "\\.[0-9]+" x)
 		       (string-to-number (substring (match-string 0 x) 1)))))))
       (if (eq var 'eval)
-	  (setq varform `(format ,f (org-eval ,(read (match-string 4 s)))))
+	  (setq varform `(format ,f (org-eval ,(read (substring s (match-beginning 4))))))
 	(if opt
 	    (setq varform
 		  `(if (member ,var '("" nil))
@@ -6951,7 +6951,12 @@ (defun org-compile-prefix-format (key)
 	  (setq varform
 		`(format ,f (if (member ,var '("" nil)) ""
 			      (concat ,var ,c (get-text-property 0 'extra-space ,var)))))))
-      (setq s (replace-match "%s" t nil s))
+      (if (eq var 'eval)
+          (setf (substring s (match-beginning 0)
+                           (+ (match-beginning 4)
+                              (length (format "%S" (read (substring s (match-beginning 4)))))))
+                "%s")
+        (setq s (replace-match "%s" t nil s)))
       (push varform vars))
     (setq vars (nreverse vars))
     (with-current-buffer (or org-agenda-buffer (current-buffer))
-- 
2.26.3


  reply	other threads:[~2021-05-30  8:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-26 23:42 Radon Rosborough
2021-05-27  3:25 ` Ihor Radchenko
2021-05-29 21:18   ` Radon Rosborough
2021-05-30  8:04     ` Ihor Radchenko [this message]
2021-05-30 16:48       ` Radon Rosborough

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://orgmode.org

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87fsy4abqz.fsf@localhost \
    --to=yantar92@gmail.com \
    --cc=Emacs-orgmode@gnu.org \
    --cc=radon.neon@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

Org-mode mailing list

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://orgmode.org/list/0 list/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 list list/ https://orgmode.org/list \
		emacs-orgmode@gnu.org
	public-inbox-index list

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.yhetil.org/yhetil.emacs.orgmode
	nntp://news.gmane.io/gmane.emacs.orgmode


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git