all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [PATCH] Capture: Expand keyword within %(SEXP) in template
@ 2012-11-02  9:20 Ryo TAKAISHI
  2012-11-02 11:50 ` Nicolas Goaziou
  0 siblings, 1 reply; 12+ messages in thread
From: Ryo TAKAISHI @ 2012-11-02  9:20 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: Ryo TAKAISHI

* lisp/org-capture.el: If %(SEXP) has %:keyword, expand it using org-store-link-plist.

I want to expand %:description keyword in sexp "%(func %:description)".
But if org-capture template is "%(function %:keyword)", function take a symbol %:keyword, it does'nt expand.
This patch expand %:keyword within %(SEXP), so funcsion is taken %:keyword's value.
For example, when capture template is "%(func %:description)" and a keyword :description is "foobar", func is taken string "foobar".

Modified from a patch proposal by Ryo TAKAISHI.

TINYCHANGE
---
 lisp/org-capture.el |   10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/lisp/org-capture.el b/lisp/org-capture.el
index be973b0..a8e49d6 100644
--- a/lisp/org-capture.el
+++ b/lisp/org-capture.el
@@ -1620,7 +1620,15 @@ The template may still contain \"%?\" for cursor positioning."
       (goto-char (match-beginning 0))
       (let ((template-start (point)))
 	(forward-char 1)
-	(let ((result (org-eval (read (current-buffer)))))
+	(let* ((sexp (mapcar '(lambda (attr)
+				(let* ((attr-symbol (symbol-name attr))
+				       (key (if (string-match "%\\(:.*\\)" attr-symbol)
+						(intern (match-string 1 attr-symbol))
+					      nil)))
+				  (or (plist-get org-store-link-plist key)
+				      attr)))
+			     (read (current-buffer))))
+	       (result (org-eval sexp)))
 	  (delete-region template-start (point))
 	  (insert result))))))
 
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2012-11-05 12:43 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-02  9:20 [PATCH] Capture: Expand keyword within %(SEXP) in template Ryo TAKAISHI
2012-11-02 11:50 ` Nicolas Goaziou
2012-11-02 13:55   ` Ryo TAKAISHI
2012-11-02 14:11     ` Nicolas Goaziou
2012-11-02 15:36       ` Ryo TAKAISHI
2012-11-03  8:45         ` Nicolas Goaziou
2012-11-04  7:51           ` Ryo TAKAISHI
2012-11-04 13:10             ` Nicolas Goaziou
2012-11-04 15:05               ` Ryo TAKAISHI
2012-11-05  0:38                 ` Nicolas Goaziou
2012-11-05 12:34                   ` Ryo TAKAISHI
2012-11-05 12:39                     ` Nicolas Goaziou

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.