emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Bastien <bzg@altern.org>
To: ian@manor-farm.org
Cc: emacs-orgmode@gnu.org
Subject: Re: Using Properties in Capture Templates.
Date: Wed, 23 Jan 2013 15:33:30 +0100	[thread overview]
Message-ID: <87txq89dfp.fsf@bzg.ath.cx> (raw)
In-Reply-To: <50FA5A0F.2080009@wilkesley.net> (Ian Barton's message of "Sat, 19 Jan 2013 08:32:15 +0000")

Hi Ian,

Ian Barton <lists@wilkesley.net> 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	other threads:[~2013-01-23 14:33 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-19  8:32 Using Properties in Capture Templates Ian Barton
2013-01-23 14:33 ` Bastien [this message]

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=87txq89dfp.fsf@bzg.ath.cx \
    --to=bzg@altern.org \
    --cc=emacs-orgmode@gnu.org \
    --cc=ian@manor-farm.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).