* [PATCH 1/3] Add org-eval @ 2010-12-17 17:18 Julien Danjou 2010-12-17 17:18 ` [PATCH 2/3] org-capture: use org-eval Julien Danjou 2010-12-17 17:18 ` [PATCH 3/3] org-agenda: allow %() in prefix format Julien Danjou 0 siblings, 2 replies; 4+ messages in thread From: Julien Danjou @ 2010-12-17 17:18 UTC (permalink / raw) To: emacs-orgmode; +Cc: Julien Danjou * org-agenda.el (org-eval): New function. Signed-off-by: Julien Danjou <julien@danjou.info> --- lisp/org-agenda.el | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-) diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el index 19535b4..a23d7d7 100644 --- a/lisp/org-agenda.el +++ b/lisp/org-agenda.el @@ -5369,6 +5369,12 @@ The modified list may contain inherited tags, and tags matched by (append new list) (append list new))))) +(defun org-eval (form) + "Eval FORM and return result." + (condition-case error + (eval form) + (error (format "%%![Error: %s]" error)))) + (defun org-compile-prefix-format (key) "Compile the prefix format into a Lisp form that can be evaluated. The resulting form is returned and stored in the variable -- 1.7.2.3 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/3] org-capture: use org-eval 2010-12-17 17:18 [PATCH 1/3] Add org-eval Julien Danjou @ 2010-12-17 17:18 ` Julien Danjou 2010-12-17 17:18 ` [PATCH 3/3] org-agenda: allow %() in prefix format Julien Danjou 1 sibling, 0 replies; 4+ messages in thread From: Julien Danjou @ 2010-12-17 17:18 UTC (permalink / raw) To: emacs-orgmode; +Cc: Julien Danjou * org-capture.el (org-capture-fill-template): Use org-eval. --- lisp/org-capture.el | 5 +---- 1 files changed, 1 insertions(+), 4 deletions(-) diff --git a/lisp/org-capture.el b/lisp/org-capture.el index b85b011..29ecbc1 100644 --- a/lisp/org-capture.el +++ b/lisp/org-capture.el @@ -1206,10 +1206,7 @@ The template may still contain \"%?\" for cursor positioning." (goto-char (match-beginning 0)) (let ((template-start (point))) (forward-char 1) - (let ((result - (condition-case error - (eval (read (current-buffer))) - (error (format "%%![Error: %s]" error))))) + (let ((result (org-eval (read (current-buffer))))) (delete-region template-start (point)) (insert result))))) -- 1.7.2.3 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 3/3] org-agenda: allow %() in prefix format 2010-12-17 17:18 [PATCH 1/3] Add org-eval Julien Danjou 2010-12-17 17:18 ` [PATCH 2/3] org-capture: use org-eval Julien Danjou @ 2010-12-17 17:18 ` Julien Danjou 2010-12-17 17:58 ` Lawrence Mitchell 1 sibling, 1 reply; 4+ messages in thread From: Julien Danjou @ 2010-12-17 17:18 UTC (permalink / raw) To: emacs-orgmode; +Cc: Julien Danjou * org-agenda.el (org-compile-prefix-format): Allow %() expression. Signed-off-by: Julien Danjou <julien@danjou.info> --- lisp/org-agenda.el | 25 +++++++++++++++---------- 1 files changed, 15 insertions(+), 10 deletions(-) diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el index a23d7d7..e0b54b8 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)) -- 1.7.2.3 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 3/3] org-agenda: allow %() in prefix format 2010-12-17 17:18 ` [PATCH 3/3] org-agenda: allow %() in prefix format Julien Danjou @ 2010-12-17 17:58 ` Lawrence Mitchell 0 siblings, 0 replies; 4+ messages in thread From: Lawrence Mitchell @ 2010-12-17 17:58 UTC (permalink / raw) To: emacs-orgmode Julien Danjou wrote: > + %(expression) Eval expression and replaces the control string > + by the result Nitpick, use "replace", not "replaces". [...] Cheers, Lawrence -- Lawrence Mitchell <wence@gmx.li> ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-12-17 18:05 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2010-12-17 17:18 [PATCH 1/3] Add org-eval Julien Danjou 2010-12-17 17:18 ` [PATCH 2/3] org-capture: use org-eval Julien Danjou 2010-12-17 17:18 ` [PATCH 3/3] org-agenda: allow %() in prefix format Julien Danjou 2010-12-17 17:58 ` Lawrence Mitchell
Code repositories for project(s) associated with this external index https://git.savannah.gnu.org/cgit/emacs.git https://git.savannah.gnu.org/cgit/emacs/org-mode.git This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.