Re: [Orgmode] org-remember templates with dynamic target headline
Hi Carsten, I think that would work, yes. Can you give an example of what it would look like now? Are you saying we can use a function call for a single element, or to produce the entire list? Thanks, Keith Carsten Dominik wrote: On Jun 17, 2009, at 8:20 AM, Nick Dokos wrote: Daniel J. Sinder wrote: I want a remember template that will have a target headline based on the date on which I call org-remember. For a simple example, the effect I'd like to achieve is shown by putting the following in my .emacs: (setq org-remember-templates `(("Journal" ?j "* %u %?\n" "~/org/wjournal.org" ,(format-time-string "%G: Week %V" I'm an elisp noob, but I realize the problem here is that format-time-string is only evaluated once when my .emacs is read. So, unless I restart emacs every week. This doesn't work. How can I cause format-time-string to be re-evaluated whenever org-remember is called? You cannot, unless you change the code. Keith Swartz had a similar question recently and although I cannot find it in the Gmane archive (second time today - maybe I'm doing something wrong), here is the last part of the thread: Hi Nick, thank you for the reminder, I had wanted to do something about this. I am indeed a bit hesitant to allow just a lisp form here, because erroneous setup of the remember template structure might then lead to hard-to-trace problems. However, I am fine with allowing a *function* in this element, as it is in fact already allowed for the target file name. I have just pushed a fix that will accept a function in this place and call it to get the true headline. Daniel, Keith, Hope that solves your issue. - Carsten , | To: Robert Goldman | cc: emacs-orgmode@gnu.org | From: Nick Dokos | Cc: nicholas.do...@hp.com | Reply-to: nicholas.do...@hp.com | Subject: Re: [Orgmode] Re: Emacs-orgmode Digest, Vol 39, Issue 122 | X-Mailer: MH-E 8.1; nmh 1.2; GNU Emacs 23.0.93 | Date: Sat, 30 May 2009 15:39:40 -0400 | Sender: n...@gamaville.dokosmarshall.org | | Robert Goldman wrote: | | > > 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.2000...@oneroad.com> | > > Content-Type: text/plain; charset=ISO-8859-1; format=flowed | > > | > > ... | > > | > > 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" | > | | That's correct. | | > 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. | > | | It's the latter. | | You can figure out things like this fairly quickly by inserting a | (debug) at the appropriate place, and re-evaluating the defun. When the | function gets called, it will jump into the debugger when it evals the | (debug) form, and you can use the full power of lisp to examine | state. For example, here I defined the template the way you suggested, | placed a (debug)
Re: [Orgmode] Question about cycle mode and sorting/refiling
Hi Carsten, The changes in the latest git version appear to have fixed these problems. Thanks. However, I've discovered a new problem, which is probably not related. If you refile one or more items to the same subtree, it wreaks havoc. In some cases, the item or entire subtree is apparently lost. It's late, but I'll try to submit a small test case soon. Thanks, Keith Carsten Dominik wrote: On Jun 4, 2009, at 8:20 PM, Keith Swartz wrote: A few weeks back, I asked about hooks when refiling and/or sorting, and am happy to report that these are working great for me ... /if/ I refile one item at a time. I'm unable to figure out why if I try to refile multiple items in a /region/, it doesn't have the same behavior. Here are my hook definitions: (setq org-after-refile-insert-hook '(lambda() (org-up-heading-safe) (org-sort-entries-or-items nil ?p)) (setq org-after-sorting-entries-or-items-hook '(lambda() (org-cycle) (org-cycle)) There seem to be parenthesis missing from these definitions, but I am assuming that you do have them in your real setup. If I position the cursor on an item and refile it, it: a) resorts the destination tree by priority, and b) restores the visibility to folded, the way I like it. HOWEVER, if I select multiple items in a folded subtree (with transient-mark-mode on; I'm using emacs 22.3), and reflie those, it does not always work. I can't figure out the rules for when it does, and when it doesn't, but when it does work, that appears to be an abnormality. What happens in this scenario is that it will refile the items, but it will neither resort the destination folder (even though the hook is being called), I believe this problem is now solved, I needed to deactive the region before calling this hook. Please upgrade to the latest git release and try again. the visibility of the refiled nodes is not reset. Plus, the visibility of all items below the current point in the /originating/ folder is also changed to children. I am not sure if I understand correctly. Do you mean the outline node where the refiled items *originate* changes visibility? I cannot reproduce this. Maybe you can try with the latest version and then, if the problem persists, come up with a test case. HTH - Carsten ___ Emacs-orgmode mailing list Remember: use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode
[Orgmode] Question about cycle mode and sorting/refiling
A few weeks back, I asked about hooks when refiling and/or sorting, and am happy to report that these are working great for me ... /if/ I refile one item at a time. I'm unable to figure out why if I try to refile multiple items in a /region/, it doesn't have the same behavior. Here are my hook definitions: (setq org-after-refile-insert-hook '(lambda() (org-up-heading-safe) (org-sort-entries-or-items nil ?p)) (setq org-after-sorting-entries-or-items-hook '(lambda() (org-cycle) (org-cycle)) If I position the cursor on an item and refile it, it: a) resorts the destination tree by priority, and b) restores the visibility to folded, the way I like it. HOWEVER, if I select multiple items in a folded subtree (with transient-mark-mode on; I'm using emacs 22.3), and reflie those, it does not always work. I can't figure out the rules for when it does, and when it doesn't, but when it does work, that appears to be an abnormality. What happens in this scenario is that it will refile the items, but it will neither resort the destination folder (even though the hook is being called), and the visibility of the refiled nodes is not reset. Plus, the visibility of all items below the current point in the /originating/ folder is also changed to children. What's causing the discrepancy? Hopefully knowing this will be enough to tell me how I can adjust the hooks accordingly. Thanks, Keith -- Keith M. Swartz | Senior Software Architect | 206.545.4324 Oracle Applications Technology Integration Seattle, WA | AIM/Y!: kswartz26 Please see Contact Info in aria for dates of HQ Visits ___ Emacs-orgmode mailing list Remember: use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode
[Orgmode] Re: Lazy evaluation when defining org-remember-template (aka Emacs-orgmode Digest, Vol 39, Issue 122)
Nick, Just wanted to report that this solution worked perfectly. Thank you! And thank you, also, to Robert for the suggested rewrite. Of course, as soon as I read your post, my hands froze above the keyboard for about two minutes while my brain exercised a massive page fault (it gets awfully fragmented in there after fifteen years), but it was worth it. I'm inclined to agree with you, Nick, about making this change permanent. In this case, the most likely problem would be an error, and worst case scenario might be localized data loss that could probably be retrieved. (I can't conceive of what someone would enter to make that happen, though.) But still, I'm always very reluctant to have code perform an eval() on any user-entered data without intense scrubbing, and I'm fine making this one-line change to the code myself. Thanks again, Keith Robert Goldman wrote: 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.2000...@oneroad.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed ... 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" That's correct. 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. It's the latter. You can figure out things like this fairly quickly by inserting a (debug) at the appropriate place, and re-evaluating the defun. When the function gets called, it will jump into the debugger when it evals the (debug) form, and you can use the full power of lisp to examine state. For example, here I defined the template the way you suggested, placed a (debug) in org-remember-apply-template, just after the insertion of the template in the remember buffer, re-evaluated the defun (there is an eval-defun, but I prefer to do that by going to the end of the defun - which I can do quickly: repeat M-C-u until I'm at the beginning of the defun and M-C-f to move over the whole defun - and then C-x C-e to eval the last sexpression.) I then call org-remember and in the resulting debug buffer, say e headline which says (format-time-string "%A") e entry which says ("* TODO %?%^{To do} %^g :LOGBOOK: - Added: %U :END:" (quote "d:/tmp/_my.todo") (format-time-string "%A")) Now you can see that the headline is the third element of this list (i.e. (nth 2 entry) - the numbering starts from 0). 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. But even org cannot perform miracles !-) Somebody has to "force the thunk" in order for delayed evaluation to work. You'd need something like this patch: --- a/lisp/org-remember.el +++ b/lisp/org-remember.el @@ -388,7 +388,7 @@ to be run from that hook to function properly." (functionp (nth 1 entry (nth 1 entry) org-default-notes-file)) - (headline (nth 2 entry)) + (headline (eval (nth 2 entry))) (v-c (and (> (length kill-ring) 0) (current-kill 0))) (v-x (or (org-g
[Orgmode] Lazy evaluation when defining org-remember-template
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. :) Thanks, Keith ___ Emacs-orgmode mailing list Remember: use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode
[Orgmode] Re: Question about tracking TODO state changes and M-S-ENTER
I agree -- now you have choice instead of inconsistency. I like it. I mean, as a user, I like it. If I had to maintain this code, I'd hate it. So I'm glad it's you and not me. Kudos. :D But seriously, thanks for the discussion. Although if the variable name really is ...-seletion-... and not ...-selection-... then I'd have to go back to saying it's a bug. :) Keith PS: Whoops, I see Bernt already caught that! Man, you people are fast. Carsten Dominik wrote: On May 27, 2009, at 10:04 PM, Keith Swartz wrote: Actually, that's a good idea. I just went and modified my remember template to emulate the logbook behavior, so now I can use that consistently. Should have thought of that. But we still have an inconsistency here. There seems to be a rather widespread agreement that creating a TODO item shouldn't register a state change. If there's no objection to that (and there isn't from me), then changing a regular bullet to the "TODO" state for the first time shouldn't either. So I think that's kind of a bug. I am, actually, going the other way here. I do very much like to have state notes when I am really working on stuff. But setting up state notes has the annoying side-effect that I am also prompted for notes when I really want to flip through to some initial state, without taking notes. Therefore, just so that you hate it more (:-) I have also introduced yet another variable `org-treat-S-cursor-todo-seletion-as-state-change', and I will set it (personally) to nil. Then I can use S-right to flip through states without taking notes, and C-c C-t to switch to a state with taking a note. I call this not inconsistency or a bug, I'd call it choice :-) - Carsten I don't think it's worth having a variable to turn it on/off, imho, since there are other ways to achieve this, but if we want to preserve that functionality for backwards compatibility for a few releases, I'd think it's not much work to add one. Thanks for the great ideas. Keith ___ Emacs-orgmode mailing list Remember: use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode
Re: [Orgmode] Question about tracking TODO state changes and M-S-ENTER
Carsten Dominik wrote: On May 27, 2009, at 10:43 AM, Keith Swartz wrote: I can see where M-S-ENTER prompting for a status note change would be annoying. Personally, I don't use that feature, so I didn't think of that -- I'm more interested in the timestamps. Basically, I like being able to record /when/ something was first entered as a todo item -- gives me a good way to see which items are the oldest. One thought is to record the state change, but default the status note to "TODO created", rather than prompting for it. Then again, maybe a variable is the best answer here, because sooner or later, somebody is going to want to change that. Normally, I'd hate to add more and more variables just to complicate things, but org-mode seems to have no shortage of them. (That's a good thing!) :) Do you now hate or like it??? :-) There is now a new variable `org-treat-insert-todo-heading-as-state-change', default nil. Ugh! That's it, now I hate it. :-) Just kidding; our emails crossed paths, but this is exactly what I proposed. Thanks Carsten! Keith --- Carsten Dominik wrote: On May 26, 2009, at 10:23 AM, Manish wrote: On Sat, May 23, 2009 at 4:45 AM, Keith Swartz wrote: I'm using org-mode 6.25e right now, and I've turned on the functionality to track todo state changes. If I create a list item (M-ENTER) and then change it to a TODO (C-c C-t), it correctly puts the state change in the :LOGBOOK: drawer as I've configured it. However, if I use M-S-ENTER to combine the above two steps into one (create a "TODO" item), it does NOT create an entry in the LOGBOOK for State "TODO" from "" at all. Is that a bug? IMO, this is not really a state change. In interesting point, and something up for discussion. I personally am neter interesting in recording a time stamp when first switching an item to TODO. Furthermore, for other state changes I prefer to record a note. However, M-S-RET is really meant for fast adding of one or more TODO entries, and being prompted for a state change note would be really annoying here. Up for discussion, I am willing to install a variable here - Carsten ___ Emacs-orgmode mailing list Remember: use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode
[Orgmode] Re: Question about tracking TODO state changes and M-S-ENTER
Bernt Hansen wrote: Keith Swartz writes: Carsten Dominik wrote: On May 26, 2009, at 10:23 AM, Manish wrote: On Sat, May 23, 2009 at 4:45 AM, Keith Swartz wrote: However, if I use M-S-ENTER to combine the above two steps into one (create a "TODO" item), it does NOT create an entry in the LOGBOOK for State "TODO" from "" at all. Is that a bug? IMO, this is not really a state change. In interesting point, and something up for discussion. I personally am neter interesting in recording a time stamp when first switching an item to TODO. Furthermore, for other state changes I prefer to record a note. However, M-S-RET is really meant for fast adding of one or more TODO entries, and being prompted for a state change note would be really annoying here. Up for discussion, I am willing to install a variable here I can see where M-S-ENTER prompting for a status note change would be annoying. Personally, I don't use that feature, so I didn't think of that -- I'm more interested in the timestamps. Basically, I like being able to record /when/ something was first entered as a todo item -- gives me a good way to see which items are the oldest. One thought is to record the state change, but default the status note to "TODO created", rather than prompting for it. Then again, maybe a variable is the best answer here, because sooner or later, somebody is going to want to change that. Normally, I'd hate to add more and more variables just to complicate things, but org-mode seems to have no shortage of them. (That's a good thing!) :) I use org-remember for creating tasks where I want to know the created time. I create most of my tasks with the remember interface and it's easy to put the date in the template with %u. For me every log entry creates a log drawer and I wouldn't want that by default for every new task created with M-S-RET. http://doc.norang.ca/org-mode.html#Remember Actually, that's a good idea. I just went and modified my remember template to emulate the logbook behavior, so now I can use that consistently. Should have thought of that. But we still have an inconsistency here. There seems to be a rather widespread agreement that creating a TODO item shouldn't register a state change. If there's no objection to that (and there isn't from me), then changing a regular bullet to the "TODO" state for the first time shouldn't either. So I think that's kind of a bug. I don't think it's worth having a variable to turn it on/off, imho, since there are other ways to achieve this, but if we want to preserve that functionality for backwards compatibility for a few releases, I'd think it's not much work to add one. Thanks for the great ideas. Keith ___ Emacs-orgmode mailing list Remember: use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode
Re: [Orgmode] Question about tracking TODO state changes and M-S-ENTER
I can see where M-S-ENTER prompting for a status note change would be annoying. Personally, I don't use that feature, so I didn't think of that -- I'm more interested in the timestamps. Basically, I like being able to record /when/ something was first entered as a todo item -- gives me a good way to see which items are the oldest. One thought is to record the state change, but default the status note to "TODO created", rather than prompting for it. Then again, maybe a variable is the best answer here, because sooner or later, somebody is going to want to change that. Normally, I'd hate to add more and more variables just to complicate things, but org-mode seems to have no shortage of them. (That's a good thing!) :) Thanks, Keith Carsten Dominik wrote: On May 26, 2009, at 10:23 AM, Manish wrote: On Sat, May 23, 2009 at 4:45 AM, Keith Swartz wrote: I'm using org-mode 6.25e right now, and I've turned on the functionality to track todo state changes. If I create a list item (M-ENTER) and then change it to a TODO (C-c C-t), it correctly puts the state change in the :LOGBOOK: drawer as I've configured it. However, if I use M-S-ENTER to combine the above two steps into one (create a "TODO" item), it does NOT create an entry in the LOGBOOK for State "TODO" from "" at all. Is that a bug? IMO, this is not really a state change. In interesting point, and something up for discussion. I personally am neter interesting in recording a time stamp when first switching an item to TODO. Furthermore, for other state changes I prefer to record a note. However, M-S-RET is really meant for fast adding of one or more TODO entries, and being prompted for a state change note would be really annoying here. Up for discussion, I am willing to install a variable here - Carsten -- Manish ___ Emacs-orgmode mailing list Remember: use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode ___ Emacs-orgmode mailing list Remember: use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode
Re: [Orgmode] Question about tracking TODO state changes and M-S-ENTER
Fair enough. And you could further argue that M-S-Enter creates an initial state, so no "change" takes place. But then I'd say the fact that it records changing from nothing to TODO in the /first/ example is a bug. At the very least, it's inconsistent. The end result of those two operations really ought to be the same. The current behavior discourages me from using M-S-Enter because then I can't tell when I initially recorded the task, unlike in the first use case. Cheers, Keith Manish wrote: On Sat, May 23, 2009 at 4:45 AM, Keith Swartz wrote: I'm using org-mode 6.25e right now, and I've turned on the functionality to track todo state changes. If I create a list item (M-ENTER) and then change it to a TODO (C-c C-t), it correctly puts the state change in the :LOGBOOK: drawer as I've configured it. However, if I use M-S-ENTER to combine the above two steps into one (create a "TODO" item), it does NOT create an entry in the LOGBOOK for State "TODO" from "" at all. Is that a bug? IMO, this is not really a state change. ___ Emacs-orgmode mailing list Remember: use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode
[Orgmode] org-export-html-table-use-header-tags-for-first-column
Shouldn't that variable have been titled org-export-html-table-use-header-tags-for-first-row? Thanks for the new release! Cheers, Keith ___ Emacs-orgmode mailing list Remember: use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode
[Orgmode] Question about tracking TODO state changes and M-S-ENTER
I'm using org-mode 6.25e right now, and I've turned on the functionality to track todo state changes. If I create a list item (M-ENTER) and then change it to a TODO (C-c C-t), it correctly puts the state change in the :LOGBOOK: drawer as I've configured it. However, if I use M-S-ENTER to combine the above two steps into one (create a "TODO" item), it does NOT create an entry in the LOGBOOK for State "TODO" from "" at all. Is that a bug? Thanks, Keith ___ Emacs-orgmode mailing list Remember: use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode
[Orgmode] Looking for some org-mode hooks
Hi there, I've recently switched to using org-mode for tracking todo items, and I'm finding it to be well worth the effort. I've read through the manual, and browsed past messages on the mail archive, but have a few questions about whether or not a few enhancements I want to do are currently possible in the latest version. First, is there a hook that gets executed after sorting a subtree? In other words, if I'm viewing a subtree as folded/children only, then sort it, it changes to display all subtrees. I want it to automatically revert back to the visibility I had. I'm hoping I can just set the visibility in a hook. Second, along the same lines, is there a hook that gets executed after refiling an item? In this case, I'd like to resort the node to which the item has been refiled. So, for instance, if I refile an item with priority A to a new node, I'd like that node sorted so that the new item appears at or near the top (assuming I sort by priority first). Thanks in advance, Keith S. ___ Emacs-orgmode mailing list Remember: use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode