From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ryo TAKAISHI Subject: [PATCH] Capture: Expand keyword within %(SEXP) in template Date: Fri, 2 Nov 2012 18:20:01 +0900 Message-ID: <1351848001-11636-1-git-send-email-ryo.takaishi.0@gmail.com> Return-path: Received: from eggs.gnu.org ([208.118.235.92]:45864) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TUDQE-0003r9-BJ for emacs-orgmode@gnu.org; Fri, 02 Nov 2012 05:20:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TUDQA-0007MC-1y for emacs-orgmode@gnu.org; Fri, 02 Nov 2012 05:20:14 -0400 Received: from mail-pa0-f41.google.com ([209.85.220.41]:34485) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TUDQ9-0007LD-Ri for emacs-orgmode@gnu.org; Fri, 02 Nov 2012 05:20:09 -0400 Received: by mail-pa0-f41.google.com with SMTP id fa10so2506589pad.0 for ; Fri, 02 Nov 2012 02:20:08 -0700 (PDT) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org 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