From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bastien Subject: Re: Using Properties in Capture Templates. Date: Wed, 23 Jan 2013 15:33:30 +0100 Message-ID: <87txq89dfp.fsf@bzg.ath.cx> References: <50FA5A0F.2080009@wilkesley.net> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([208.118.235.92]:34280) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ty1OR-0001j3-EV for emacs-orgmode@gnu.org; Wed, 23 Jan 2013 09:33:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ty1OO-0007Ie-Pd for emacs-orgmode@gnu.org; Wed, 23 Jan 2013 09:33:34 -0500 Received: from mail-wi0-f171.google.com ([209.85.212.171]:65308) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ty1OO-0007HL-JC for emacs-orgmode@gnu.org; Wed, 23 Jan 2013 09:33:32 -0500 Received: by mail-wi0-f171.google.com with SMTP id hn14so764466wib.10 for ; Wed, 23 Jan 2013 06:33:31 -0800 (PST) In-Reply-To: <50FA5A0F.2080009@wilkesley.net> (Ian Barton's message of "Sat, 19 Jan 2013 08:32:15 +0000") 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: ian@manor-farm.org Cc: emacs-orgmode@gnu.org Hi Ian, Ian Barton 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