From 2be22d9aa4829432d3c3e511d664f3fc2f454354 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Fri, 17 Dec 2010 22:18:15 +0000 Subject: [PATCH] org-agenda: allow %() in prefix format * org-agenda.el (org-compile-prefix-format): Allow %() expression. Signed-off-by: Julien Danjou --- lisp/org-agenda.el | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el index 23ad0e79f..f32c60e4a 100644 --- a/lisp/org-agenda.el +++ b/lisp/org-agenda.el @@ -1316,6 +1316,8 @@ This format works similar to a printf format, with the following meaning: %t the time-of-day specification if one applies to the entry, in the format HH:MM %s Scheduling/Deadline information, a short string + %(expression) Eval expression and replaces the control string + by the result All specifiers work basically like the standard `%s' of printf, but may contain two additional characters: A question mark just after the `%' and @@ -5389,11 +5391,12 @@ The resulting form is returned and stored in the variable (t " %-12:c%?-12t% s"))) (start 0) varform vars var e c f opt) - (while (string-match "%\\(\\?\\)?\\([-+]?[0-9.]*\\)\\([ .;,:!?=|/<>]?\\)\\([ctsei]\\)" + (while (string-match "%\\(\\?\\)?\\([-+]?[0-9.]*\\)\\([ .;,:!?=|/<>]?\\)\\([ctsei]\\|(.+)\\)" s start) - (setq var (cdr (assoc (match-string 4 s) - '(("c" . category) ("t" . time) ("s" . extra) - ("i" . category-icon) ("T" . tag) ("e" . effort)))) + (setq var (or (cdr (assoc (match-string 4 s) + '(("c" . category) ("t" . time) ("s" . extra) + ("i" . category-icon) ("T" . tag) ("e" . effort)))) + 'eval) c (or (match-string 3 s) "") opt (match-beginning 1) start (1+ (match-beginning 0))) @@ -5409,12 +5412,14 @@ The resulting form is returned and stored in the variable (save-match-data (if (string-match "\\.[0-9]+" x) (string-to-number (substring (match-string 0 x) 1))))))) - (if opt - (setq varform - `(if (equal "" ,var) - "" - (format ,f (if (equal "" ,var) "" (concat ,var ,c))))) - (setq varform `(format ,f (if (equal ,var "") "" (concat ,var ,c (get-text-property 0 'extra-space ,var)))))) + (if (eq var 'eval) + (setq varform `(format ,f (org-eval ,(read (match-string 4 s))))) + (if opt + (setq varform + `(if (equal "" ,var) + "" + (format ,f (if (equal "" ,var) "" (concat ,var ,c))))) + (setq varform `(format ,f (if (equal ,var "") "" (concat ,var ,c (get-text-property 0 'extra-space ,var))))))) (setq s (replace-match "%s" t nil s)) (push varform vars)) (setq vars (nreverse vars))