emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Kyle Meyer <kyle@kyleam.com>
To: Jeff Filipovits <jrfilipovits@gmail.com>, emacs-orgmode@gnu.org
Subject: Re: agenda view help - viewing all time entries for a tag
Date: Sat, 12 Jan 2019 18:19:55 -0500	[thread overview]
Message-ID: <87bm4lwjj8.fsf@kyleam.com> (raw)
In-Reply-To: <CAGE1zdk+E+ZuUS_ZF+21Cw1vG7tym6g+UOpNJzVWqPq=2D+7mQ@mail.gmail.com>

[sorry for the slow response]

Jeff Filipovits <jrfilipovits@gmail.com> 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	other threads:[~2019-01-12 23:34 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-26 12:55 agenda view help - viewing all time entries for a tag Jeff Filipovits
2019-01-12 23:19 ` Kyle Meyer [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87bm4lwjj8.fsf@kyleam.com \
    --to=kyle@kyleam.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=jrfilipovits@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).