From ffbf7fe29913e33e3f20544be49b6cc2c0ef6409 Mon Sep 17 00:00:00 2001 Message-Id: From: Ihor Radchenko 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