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: Ian Barton
Subject: Re: [O] Alternate format for datetree
Date: Tue, 28 Aug 2012 09:49:31 +0100
User-agent: Mozilla/5.0 (X11; Linux i686; rv:14.0) Gecko/20120717 Thunderbird/14.0

On 27/08/12 07:08, John Hendy 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.


I would like to use something like this. However, using a recent git checkout of org mode and the following simple template from the original list message:

("u"
         "Test"
         entry
         (file+headline "~/test.org"
                        ,(format "%s %s"
                                 (format-time-string "%B")
                                 (format-time-string "%Y"))))
I get the following error:

Debugger entered--Lisp error: (wrong-type-argument stringp (\, (format "%s %s" (format-time-string "%B") (format-time-string "%Y")))) regexp-quote((\, (format "%s %s" (format-time-string "%B") (format-time-string "%Y"))))
  org-capture-set-target-location()
  org-capture(nil)
  call-interactively(org-capture nil nil)

I also get the same error from John Hendy's template. Is this a bug in recent versions of org, or is there an error in the template lisp? I have tried doing a git bisect, but can only go back a few commits, as my config now includes several things that have only recently been added to org.

Ian.





reply via email to

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