From mboxrd@z Thu Jan 1 00:00:00 1970 From: Robert Goldman Subject: Re: Emacs-orgmode Digest, Vol 39, Issue 122 Date: Sat, 30 May 2009 13:50:17 -0500 Message-ID: <4A217FE9.9000408@sift.info> References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MATdY-0002fP-I2 for emacs-orgmode@gnu.org; Sat, 30 May 2009 14:50:32 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MATdT-0002W5-TV for emacs-orgmode@gnu.org; Sat, 30 May 2009 14:50:32 -0400 Received: from [199.232.76.173] (port=58220 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MATdT-0002W2-MD for emacs-orgmode@gnu.org; Sat, 30 May 2009 14:50:27 -0400 Received: from outbound-mail-21.bluehost.com ([69.89.21.16]:33324) by monty-python.gnu.org with smtp (Exim 4.60) (envelope-from ) id 1MATdT-00039V-3H for emacs-orgmode@gnu.org; Sat, 30 May 2009 14:50:27 -0400 In-Reply-To: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org > Date: Fri, 29 May 2009 23:24:58 -0700 > From: Keith Swartz > Subject: [Orgmode] Lazy evaluation when defining org-remember-template > To: "[orgmode]" > Message-ID: <4A20D13A.2000603@oneroad.com> > Content-Type: text/plain; charset=ISO-8859-1; format=flowed > > Okay, I apologize, because I think this is a really stupid elisp > question. I'm a little rusty, after about eight years of complacency in > my vast array of emacs customizations. But now that I've really gotten > into using org-mode, I find myself hacking away again...and forgetful. > > My org file has folders for each day of the week. I'd like to define a > template for org-remember that sets the default folder to whatever the > current day of the week is. > > Here's what I'm using now: > > (setq org-remember-templates > (list (list '"Todo" '?t '"* TODO %?%^{To do} %^g\n :LOGBOOK:\n - > Added: %U\n :END:" '"d:/tmp/_my.todo" (format-time-string '"%A")))) > > Works great, except for one problem. The (format-time-string) command is > executed once, when my .emacs is run, and thus becomes wrong by the time > midnight rolls around. Sure, I could create a macro so I could redefine > the variable every morning with a couple of keystrokes, but that's about > how many keystrokes I'm saving by not having to enter the day of the > week when I file it. :-) > > Is there a way I can make that command evaluate at the time it is > invoked, rather than when it is defined? I vaguely recall doing > something like this, but that was five job roles, three houses, two > recessions, and two kids ago. :) > I can't swear that this will work, but note that the way you have written this, it will all be evaluated at load time, as you say. the 'list' function will evaluate its arguments to build the list. Now, if you don't want this to be evaluated when org-remember-templates is set, you can quote the form: '(format-time-string "%A") [note that you quoted the argument to format-time-string. I don't believe that's necessary, since strings evaluate to themselves, but I have not tested this.] Actually, I think you would get something easier to read if you quoted the whole list, instead of quoting each element. Something like: (list '("Todo" ?t "* TODO %?%^{To do} %^g\n :LOGBOOK:\n - Added: %U\n :END:" "d:/tmp/_my.todo" (format-time-string "%A")))) The question then is, "what happens when org-remember-templates is retrieved?" What you want is for this function to be evaluated when the templates are found and used. That will be done by org-remember-apply-template, which we can examine.... Unfortunately, I don't see in there anything which retrieves (nth 4 entry), which is the place where your format-time-string goes, so I'm not sure what is handling this. It's a little confusing reading that function's code, since "headline" is ambiguous between whether it means the headline of the remember note to be inserted or the headline under which to insert the note... I believe it's the former. Perhaps someone else can figure this out, or perhaps you could just try quoting the list and seeing if it works to evaluate the format-time-string when you want it to. Org usually does The Right Thing. best, r