emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [O] agenda view help - viewing all time entries for a tag


From: Kyle Meyer
Subject: Re: [O] agenda view help - viewing all time entries for a tag
Date: Sat, 12 Jan 2019 18:19:55 -0500

[sorry for the slow response]

Jeff Filipovits <address@hidden> writes:

> Say I have a calendar file which is in the following format:
>
> * description of deadline    :client1:
> DEADLINE: <2018-10-28 Tue>
>
> * a meeting :client1:
> <2018-11-1 Thu 10:00>
>
>  I would like to be able to view all headlines and time entries associated
> with a particular tag, and to have that information visible in an agenda
> buffer, and for the entries to appear in chronological order along with the
> associated dates
>
> [...]
> 
> It seems like this should be relatively easy to accomplish.

Hmm, I might be missing something obvious, but here’s the best I can
come up with.

First, specify that you want the tag search to sort based on timestamp,
earliest first:

  (add-to-list 'org-agenda-sorting-strategy '(tags timestamp-up))

Then make a custom function that when called on a heading returns the
first timestamp:

  (defun my/org-get-first-timestamp ()
    (save-excursion
      (or (and (re-search-forward org-ts-regexp
                                  (save-excursion (outline-next-heading)
                                                  (point))
                                  t)
               (match-string 1))
          "")))

(Org might already have a function that would do that, but that seems to
work.)

Now use that function in the agenda prefix for tag searches:

  (add-to-list 'org-agenda-prefix-format '(tags . 
"%-21(my/org-get-first-timestamp) "))

With the example you gave---but changing 2018-11-1 to 2018-11-01 to make
a valid timestamp---‘C-c a m client1’ gives me:

  Headlines with TAGS match: client1
  Press ‘C-u r’ to search again
  2018-10-28 Tue        description of deadline                                 
         :client1:
  2018-11-01 Thu 10:00  a meeting                                               
         :client1:

-- 
Kyle



reply via email to

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