emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [O] Using Properties in Capture Templates.


From: Bastien
Subject: Re: [O] Using Properties in Capture Templates.
Date: Wed, 23 Jan 2013 15:33:30 +0100
User-agent: Gnus/5.130006 (Ma Gnus v0.6) Emacs/24.3.50 (gnu/linux)

Hi Ian,

Ian Barton <address@hidden> writes:

> I want to create a capture template which prompts for certain properties 
> in a property draw, but alos creates some other properties without 
> prompting for a value. However, I am having trouble mixing properties 
> which are entered by the user and blank properties. The following 
> example shows what I mean:
>
> #+begin_src emacs-lisp
> (defun capture-letter-file (path)
>    (let ((name (read-string "File name: ")))
>      (expand-file-name (format "%s-%s.org"
>                                (format-time-string "%Y-%m-%d")
>                                name) path)))
>
> ("z"
>     "Letter template"
>     plain
>     (file (capture-letter-file  "~/dropbox/org/org_files/letters"))
>     "#+STARTUP: showall indent\n#+STARTUP: hidestars\n#+OPTIONS: H:2 
> num:nil tags:nil toc:nil timestamps:nil\n* 
> Letter\n:PROPERTIES:\n:to_address:%^{salutation}p %^{to_name}p 
> %^{subject}p %^{the_closing}p:END:\n
> ")
>
> #+end_src
> This produces:
>
> #+STARTUP: showall indent
> #+STARTUP: hidestars
> #+OPTIONS: H:2 num:nil tags:nil toc:nil timestamps:nil
> * Letter
> :PROPERTIES:
> :salutation: aaa
> :to_name:  bbb
> :subject:  ccc
> :the_closing: zzz
> :END:
> :to_address:   :END:
>
> Note the two :END: values and the :to_address: is placed outside the 
> values for which the user was prompted. I have tried omitting the 
> :PROPERTIES: and :END: from the template and letting org create them, 
> but still end up with the :to_address: property being placed outside the 
> property draw.

Yes, mixing interactive properties and hardcoded ones seem to produce
wrong results.  In the meantime, you can use this trick:

        ("z"
         "Letter template"
         plain
         (capture-letter-file  "~/dropbox/org/org_files/letters"))
         "#+STARTUP: showall indent\n#+STARTUP: hidestars\n#+OPTIONS: H:2 
num:nil tags:nil toc:nil timestamps:nil\n
* Letter\n  :PROPERTIES:\n  :to_address: %\\1\n  :to_name: %\\2\n  :subject: 
%\\3\n  :the_closing: %\\4\n  :END:\n

# %^{salutation} %^{to_name} %^{subject} %^{the_closing}

%?")

He bit hackish but should work.

HTH,

-- 
 Bastien



reply via email to

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