emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Programmatically construct agenda from list of headline ids
@ 2016-04-24 19:45 Alexander Baier
  2016-04-26 16:16 ` Herbert Sitz
  0 siblings, 1 reply; 3+ messages in thread
From: Alexander Baier @ 2016-04-24 19:45 UTC (permalink / raw)
  To: emacs-orgmode

Hi!

As the title mentions I have a list of ids of existing org headlines and
want create an agenda view listing all of these headlines.

Is there functionality in org-agenda, that allows me to do this?

Best Regards,
-- 
Alexander Baier

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Programmatically construct agenda from list of headline ids
  2016-04-24 19:45 Programmatically construct agenda from list of headline ids Alexander Baier
@ 2016-04-26 16:16 ` Herbert Sitz
  2016-04-29 17:19   ` Alexander Baier
  0 siblings, 1 reply; 3+ messages in thread
From: Herbert Sitz @ 2016-04-26 16:16 UTC (permalink / raw)
  To: emacs-orgmode

Alexander Baier <alexander.baier <at> mailbox.org> writes:

> 
> Hi!
> 
> As the title mentions I have a list of ids of existing org headlines and
> want create an agenda view listing all of these headlines.
> 
> Is there functionality in org-agenda, that allows me to do this?
> 
> Best Regards,

Nobody else has offered help yet, so I'll take a shot.  What exactly are
your "ids"?  Do you mean you have headlines with assigned CUSTOM_ID
properties, and you have a list of values for which you want to show the
headlines in agenda?  If so, I think you could just assemble the list in a
command that sticks new search conditions into one of your custom agenda views.

E.g., if you currently had a custom agenda search mapped to "i" for two
different CUSTOM_IDs, like this:

  (setq org-agenda-custom-commands
           '(("i" tags "CUSTOM_ID=323|CUSTOM_ID=832")))

you could reissue command to get the search done for different list of
custom ids:

  (setq org-agenda-custom-commands
           '(("i" tags "CUSTOM_ID=153|CUSTOM_ID=932|CUSTOM_ID=293")))

I haven't tested this, but I expect it or something similar would work. 
There are probably tweaks you could make, e.g, list could be combined into a
regular expression so you don't need to repeat multiple 'CUSTOM_ID=' sections.

For more info on custom agenda views see:
http://orgmode.org/org.html#Custom-agenda-views
and for more info on property searches see:
http://orgmode.org/org.html#Matching-tags-and-properties

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Programmatically construct agenda from list of headline ids
  2016-04-26 16:16 ` Herbert Sitz
@ 2016-04-29 17:19   ` Alexander Baier
  0 siblings, 0 replies; 3+ messages in thread
From: Alexander Baier @ 2016-04-29 17:19 UTC (permalink / raw)
  To: Herbert Sitz; +Cc: emacs-orgmode

On 2016-04-26 16:16 Herbert Sitz wrote:
> Alexander Baier <alexander.baier <at> mailbox.org> writes:
>> As the title mentions I have a list of ids of existing org headlines and
>> want create an agenda view listing all of these headlines.
>> 
>> Is there functionality in org-agenda, that allows me to do this?
>
> Nobody else has offered help yet, so I'll take a shot.

Thanks you! :)

> What exactly are your "ids"?  Do you mean you have headlines with
> assigned CUSTOM_ID properties, and you have a list of values for which
> you want to show the headlines in agenda?

The ids I am talking about are generated by org-id.  A list of these
might look as follows:

#+BEGIN_SRC emacs-lisp
  '("55b95977-5e5b-4457-bb76-533499bc34e7"
    "249d04f4-7352-488c-bf05-1b00578c414a"
    "1833d6fc-46bf-4827-93a8-3f8c22310053"
    "4d9c0cb1-fb10-4e28-a15b-63ae03169b39")
#+END_SRC

> If so, I think you could just assemble the list in a command that
> sticks new search conditions into one of your custom agenda views.
>
> E.g., if you currently had a custom agenda search mapped to "i" for
> two different CUSTOM_IDs, like this:
>
>   (setq org-agenda-custom-commands
>            '(("i" tags "CUSTOM_ID=323|CUSTOM_ID=832")))
>
> you could reissue command to get the search done for different list of
> custom ids:
>
>   (setq org-agenda-custom-commands
>            '(("i" tags "CUSTOM_ID=153|CUSTOM_ID=932|CUSTOM_ID=293")))
>
> I haven't tested this, but I expect it or something similar would
> work.  There are probably tweaks you could make, e.g, list could be
> combined into a regular expression so you don't need to repeat
> multiple 'CUSTOM_ID=' sections.

I want to avoid using custom agendas. I aim to use the agenda view as a
method of presenting a list of tasks, not as a search based view
triggered manually by the user (as it is normally used). The closest
example of what I am trying to achieve is the behaviour achieved by
org-contacts (when searching for a contact), which uses the agenda view,
without "polluting" the custom-agenda-selection.

Although this is not the way I wanted to populate my agenda view, I
settled on the same approach used by org-contacts. I define a skip
function that only keeps headlines whose ID is a member of my list of
ids. Here is the code:

#+BEGIN_SRC emacs-lisp
  (let ((org-agenda-skip-function
         (lambda ()
           (if (member (org-id-get (point)) list-of-ids)
               nil
             (outline-next-heading)))))
    ;; (org-todo-list) or similar calls
    )
#+END_SRC

IIUC, this approach will scan each headline in all my agenda files only
to find those few (usually < 10) I already know how to retrieve, as I
have the relevant IDs. That is why I wanted to know whether I can just
pass those IDs to an agenda creation command which will then simply
render the corresponding headlines as an agenda view.

Kind regards,
-- 
Alexander Baier

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-04-29 17:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-24 19:45 Programmatically construct agenda from list of headline ids Alexander Baier
2016-04-26 16:16 ` Herbert Sitz
2016-04-29 17:19   ` Alexander Baier

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).