emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [O] Query for tags, and bring results into headline?


From: Matt Lundin
Subject: Re: [O] Query for tags, and bring results into headline?
Date: Mon, 16 May 2011 13:07:18 -0400
User-agent: Gnus/5.110018 (No Gnus v0.18) Emacs/24.0.50 (gnu/linux)

Nathan Neff <address@hidden> 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 via email to

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