From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: [PATCH] Capture: Expand keyword within %(SEXP) in template Date: Sat, 03 Nov 2012 09:45:01 +0100 Message-ID: <87sj8rgjn6.fsf@gmail.com> References: <1351848001-11636-1-git-send-email-ryo.takaishi.0@gmail.com> <87ip9oi5qt.fsf@gmail.com> <878vak9kib.fsf@gmail.com> <87a9v0hz7j.fsf@gmail.com> <87lieknhjy.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([208.118.235.92]:50243) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TUZPo-0006Rb-0H for emacs-orgmode@gnu.org; Sat, 03 Nov 2012 04:49:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TUZPn-0006XI-2k for emacs-orgmode@gnu.org; Sat, 03 Nov 2012 04:49:15 -0400 Received: from mail-wg0-f49.google.com ([74.125.82.49]:46996) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TUZPm-0006XB-Qj for emacs-orgmode@gnu.org; Sat, 03 Nov 2012 04:49:14 -0400 Received: by mail-wg0-f49.google.com with SMTP id gg4so2082322wgb.30 for ; Sat, 03 Nov 2012 01:49:13 -0700 (PDT) In-Reply-To: <87lieknhjy.fsf@gmail.com> (Ryo TAKAISHI's message of "Sat, 03 Nov 2012 00:36:01 +0900") 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: Ryo TAKAISHI Cc: emacs-orgmode@gnu.org Hello, > I fix these problem. A new patch expand keyword recursively, and only > symbol. Great. > + (let* ((sexp (mapcar 'org-capture-expand-keyword-in-embedded-elisp > + (read (current-buffer)))) > + (result (org-eval sexp))) > (delete-region template-start (point)) > (insert result)))))) > > +(defun org-capture-expand-keyword-in-embedded-elisp (attr) > + (cond ((consp attr) > + (mapcar 'org-capture-expand-keyword-in-embedded-elisp attr)) > + ((symbolp attr) > + (let* ((attr-symbol (symbol-name attr)) > + (key (and (string-match "%\\(:.*\\)" attr-symbol) > + (intern (match-string 1 attr-symbol))))) > + (or (plist-get org-store-link-plist key) > + attr))) > + (t attr))) The code looks good, although I would have moved the external `mapcar' within the worker function in order to make its purpose clearer. Also, would you mind to provide a docstring for the function? Something along the lines of: "Recursively replace capture link keywords in ATTR sexp. Such keywords are prefixed with "%:". See `org-capture-template' for more information." You may also want to rename it `org-capture--expand-keyword-in-embedded-elisp' to insist on the fact it is an internal function. That's not mandatory, though. Finally, this feature must be documented in `org-capture-templates' docstring and org.texi. Thank you for working on it. Regards, -- Nicolas Goaziou