emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Ryo TAKAISHI <ryo.takaishi.0@gmail.com>
To: emacs-orgmode@gnu.org
Cc: Ryo TAKAISHI <ryo.takaishi.0@gmail.com>
Subject: [PATCH] Capture: Expand keyword within %(SEXP) in template
Date: Fri,  2 Nov 2012 18:20:01 +0900	[thread overview]
Message-ID: <1351848001-11636-1-git-send-email-ryo.takaishi.0@gmail.com> (raw)

* 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

             reply	other threads:[~2012-11-02  9:20 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-02  9:20 Ryo TAKAISHI [this message]
2012-11-02 11:50 ` [PATCH] Capture: Expand keyword within %(SEXP) in template 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1351848001-11636-1-git-send-email-ryo.takaishi.0@gmail.com \
    --to=ryo.takaishi.0@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).