emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] [PATCH] Capture: Expand keyword within %(SEXP) in template


From: Nicolas Goaziou
Subject: Re: [O] [PATCH] Capture: Expand keyword within %(SEXP) in template
Date: Sat, 03 Nov 2012 09:45:01 +0100

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]