emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Matt Lundin <mdl@imapmail.org>
To: Nathan Neff <nathan.neff@gmail.com>
Cc: emacs-orgmode <emacs-orgmode@gnu.org>
Subject: Re: Query for tags, and bring results into headline?
Date: Mon, 16 May 2011 13:07:18 -0400	[thread overview]
Message-ID: <87hb8uk20p.fsf@fastmail.fm> (raw)
In-Reply-To: <BANLkTimAi_JVENqm5Qf0YqSqTVPCuvfB8w@mail.gmail.com> (Nathan Neff's message of "Thu, 12 May 2011 09:29:33 -0500")

Nathan Neff <nathan.neff@gmail.com> writes:

> I keep a lot of headlines tagged "question" that I
> want to review before a daily meeting.
>
> Currently I keep questions tagged with "question", and can
> easily do an agenda search for them.  No problem.
>
> Before a daily meeting, I create a daily meeting headline
> like this:
>
> * Daily Mtg 05/11/2011
>
> Then, I do an agenda search for questions.
>
> What I'm looking for is a way to query for
> headlines tagged "question", and bring the results of that query into
> the Daily Mtg 05/11/2011 headline -- preferably with
> links to the questions to easily jump to them.
>
> This way, I have a record that I asked certain questions,
> and I can easily stay within my Daily Mtg headine, and not jump
> to / from agenda and back to the daily mtg headline, which tends
> to break my concentration.
>
> Essentially, it would be a clock report, with links, except
> it would not need to filter by any time/clocking information.
>
> <Edit> I just found that I can copy the results of the agenda
> into my headline, and simply surround the headings with [[ and ]], which
> turns them into links.  This will work for the time being.
>
> I suspect that another answer is a dynamic block.  Anyone
> else doing something similar?

Here's one implementation:

--8<---------------cut here---------------start------------->8---
(defun org-dblock-write:insert-links (params)
  "Dblock function to insert links to headlines that match
tags/properties search string specified by :match."
  (let ((match (plist-get params :match))
	links)
    (unless match
      (error "Must specify :match parameter"))
    (org-map-entries 
     (lambda ()
       (let ((heading (nth 4 (org-heading-components))))
	 (add-to-list 'links
		      (format "- [[file:%s::*%s][%s]]\n"
			      (abbreviate-file-name
			       (buffer-file-name))
			      heading heading))))
     match 'agenda)
    (apply #'insert links)))
--8<---------------cut here---------------end--------------->8---

You could then create a dblock by typing C-c C-c on the following

#+begin: insert-links :match questions
#+end:

This would still need to be refined, as there are problems when a
headline contains a link, but it's meant to provide a quick proof of
concept.

Best,
Matt

  reply	other threads:[~2011-05-16 17:07 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-12 14:29 Query for tags, and bring results into headline? Nathan Neff
2011-05-16 17:07 ` Matt Lundin [this message]
2011-05-16 17:08   ` Matt Lundin
2011-05-18 15:22     ` Nathan Neff
2011-05-18 17:37       ` Matt Lundin
2011-06-16  0:02         ` Nathan Neff

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=87hb8uk20p.fsf@fastmail.fm \
    --to=mdl@imapmail.org \
    --cc=emacs-orgmode@gnu.org \
    --cc=nathan.neff@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).