emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [O] Alternate format for datetree


From: John Hendy
Subject: Re: [O] Alternate format for datetree
Date: Thu, 6 Sep 2012 10:33:33 -0500

On Thu, Sep 6, 2012 at 12:42 AM, c b <address@hidden> wrote:
> Hi John and Nick,
>
> Thank a lot for your suggestions. I finally got it working. It took a while
> to figure out that the back-tick is different from the quote.
> I am an elisp newbie. Is there an easy explanation of why we need a
> back-tick vs. quote?
>
> Also, I found that while the template works, it creates a new tree every
> time I capture an entry as follows
>

<snip>

> #1. Is there any way to consolidate this like the following?

You might check out a question I asked that's quite similar.
Basically... no, not unless the headline already exists. Then you have
to use file+olp instead of file+headline. Check out my example:
-- http://lists.gnu.org/archive/html/emacs-orgmode/2012-08/msg01465.html

Orgmode can file to a headline passed in the capture template
immediately after the =(... file+headline
"headline-to-file-under-here")=, but the longer =`(format...= tells
Org to insert that text every time. Thus, our sub-headline evaluation
will always create that text anew. The workaround will be for you to
re-arrange the =`(format...= section and put it above. In other words,
this:

----------
(setq org-capture-templates
`(("t" "test" entry
(file+headline "~/file.org"
,(format "%s"
(format-time-string "%m")))
,(format "** %s \n*** %s-%s \n**** [%s-%s-%s %s %s:%s] "
(format-time-string "%d")
(format-time-string "%Y")
(format-time-string "%A")
(format-time-string "%Y")
(format-time-string "%m")
(format-time-string "%d")
(format-time-string "%a")
(format-time-string "%H")
(format-time-string "%M"))
)))
----------

Needs to become something like this:
----------
(setq org-capture-templates
`(("t" "test" entry
(file+olp "~/file.org"
,(format "%s" ;; first headline
(format-time-string "%m")
,(format "%s" ;; second headline
(format-time-string "%d")
,(format "%s - %s"
(format-time-string "%Y")
(format-time-string "%A")))
,(format "**** [%s-%s-%s %s %s:%s] "
(format-time-string "%Y")
(format-time-string "%m")
(format-time-string "%d")
(format-time-string "%a")
(format-time-string "%H")
(format-time-string "%M"))
)))
----------

Something like that (I wrote this in email and didn't check it). That
tells Org to look for a *pre-existing* headline structure in this
form:
----------
* Month (in ## format, like 09 for September)
** Day (in ## format, like 06 for the 6th)
*** Year - Day (in #### - Name format like 2012 - Thursday
----------

And under that, it will file:
----------
**** [timestamp] what you write
----------

But... this means you need to pre-create your daily headline structure.

I think a reasonable feature request would be to have something like a
=:use-existing-capture-headline t= option that would tell Org to
*either* create a new capture headline (as on the first time used that
day) or file into a pre-existing headline if one already exists in
that form. Something like a hybrid between file+headline and file+olp.

Hope that makes sense. I think my example in the link above should help as well.

>
> * 09
> ** 05
> *** 2012 - Wednesday
> **** [2012-09-05 Wed 22:31] My first working month tree note
> **** [2012-09-05 Wed 22:35] My first working month tree note
>
> #2 The time always is reported as 22:31 (I guess that's the time I launched
> emacs). Is there a way for the time stamp to be corrected based on the
> current time? I generally leave emacs running for days together, so the time
> it's launched doesn't really work for me.

Did you change the above to 21:35 or did it file like that? Not sure
why H:M wouldn't expand to the current date. One thing that just
occurred to me, however, is to replace that whole timestamp string
with "%%U% and Org will just expand it to a date+time stamp.

Good luck,
John

>
> Once again, thanks a lot for your help!
>
> -c. b.
>
> On Sun, Aug 26, 2012 at 11:08 PM, John Hendy <address@hidden> wrote:
>>
>> On Sun, Aug 26, 2012 at 11:04 PM, Nick Dokos <address@hidden>
>> wrote:
>> > John Hendy <address@hidden> wrote:
>> >
>> >> On Sun, Aug 26, 2012 at 3:11 PM, c b <address@hidden> wrote:
>> >> > Hi,
>> >> >
>> >> > I have been using org-mode for about 18 months now and love it. I
>> >> > recently
>> >> > came across the org-capture file+datetree format and it is just what
>> >> > I am
>> >> > looking for, except that I need a slightly different format described
>> >> > as
>> >> > below
>> >> >
>> >> > Currently format is
>> >> >
>> >> > * 2012
>> >> > ** 2012-08
>> >> > *** 2012-08-26 Sunday
>> >> > **** [2012-08-26 Sun 13:00] My note for this Sunday afternoon
>> >> >
>> >> > Needed format is
>> >> >
>> >> > * 08
>> >> > ** 26
>> >> > *** 2012 Sunday
>> >> > **** [2012-08-26 Sun 13:00] My note for this Sunday afternoon
>> >> >
>> >> > Basically, I need to have the "root" of the date tree on the month,
>> >> > followed
>> >> > by date and then Year, so that for a particular date, I can see all
>> >> > yearly
>> >> > activity.
>> >> >
>> >> > Is there currently a way to alter this?
>> >> >
>> >> > If not, how would I go about adding a file+monthtree format for
>> >> > org-capture?
>> >> >
>> >> > Any suggestions would be appreciated
>> >>
>> >> I was looking for something similar and someone provided a custom
>> >> capture template that allowed for using inactive timestamps vs. the
>> >> default datetree format.
>> >>
>> >> See the example provided here:
>> >> - http://osdir.com/ml/emacs-orgmode-gnu/2012-08/msg00396.html
>> >>
>> >> I fiddled with this a bit, not really being familiar and learned a
>> >> good bit in the process to achieve your desired format. Give this a
>> >> try:
>> >>
>> >> #+begin_src .emacs
>> >> (setq org-capture-templates
>> >> `(("t" "test" entry
>> >> (file+headline "~/file.org"
>> >> ,(format "%s"
>> >> (format-time-string "%m")))
>> >> ,(format "** %s \n*** %s-%s \n**** [%s-%s-%s %s %s:%s] "
>> >> (format-time-string "%d")
>> >> (format-time-string "%Y")
>> >> (format-time-string "%A")
>> >> (format-time-string "%Y")
>> >> (format-time-string "%m")
>> >> (format-time-string "%d")
>> >> (format-time-string "%a")
>> >> (format-time-string "%H")
>> >> (format-time-string "%M"))
>> >> )))
>> >> #+end_src
>> >>
>> >> One thing I couldn't figure out was how to insert a %? after that
>> >> second long format option. If I just put in %?, loading .emacs caused
>> >> the error "Not enough arguments to format" or something like that. I'm
>> >> sure there's some secret elisp escape syntax I just don't know. I
>> >> tried various combinations of \ and '("") with no success.
>> >>
>> >
>> > Try
>> >
>> > --8<---------------cut here---------------start------------->8---
>> > ,(format "** %s \n*** %s-%s \n**** [%s-%s-%s %s %s:%s] %%?"
>> > --8<---------------cut here---------------end--------------->8---
>> >
>> > You basically need to escape the % from being interpreted by format.
>> > C-h f format RET says
>> >
>> > ,----
>> > | ...
>> > | Use %% to put a single % into the output.
>> > | ...
>> > `----
>>
>> Perfect -- thanks!
>> John
>>
>> >
>> > Nick
>> >
>> >> That'd put the finishing touch on things so your cursor was where you
>> >> wanted it.
>> >>
>> >> Also, for those seeing this... is this how you would accomplish c.b's
>> >> goal? I just used the sample provided to me in the earlier mailing
>> >> list email to see if I was up for the challenge, but I have no basis
>> >> for knowing whether it's a good solution.
>> >>
>> >>
>> >> Hope that helps!
>> >> John
>> >>
>> >> >
>> >> > Kindly copy me on the response as I am not subscribed to this mailing
>> >> > list.
>> >> >
>> >> > Thanks,
>> >> > c.b.
>> >>
>
>



reply via email to

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