Browse Source

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/
Ihor Radchenko 4 years ago
parent
commit
1c83f6fa02
1 changed files with 7 additions and 2 deletions
  1. 7 2
      lisp/org-agenda.el

+ 7 - 2
lisp/org-agenda.el

@@ -6947,7 +6947,7 @@ and stored in the variable `org-prefix-format-compiled'."
 		  (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))
@@ -6956,7 +6956,12 @@ and stored in the variable `org-prefix-format-compiled'."
 	  (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))