From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alexander Baier Subject: Re: Programmatically construct agenda from list of headline ids Date: Fri, 29 Apr 2016 19:19:59 +0200 Message-ID: <874makfi2o.fsf@mailbox.org> References: <87r3dueqpk.fsf@mailbox.org> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:47902) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1awC5b-0006eB-GD for emacs-orgmode@gnu.org; Fri, 29 Apr 2016 13:20:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1awC5P-0001NR-KG for emacs-orgmode@gnu.org; Fri, 29 Apr 2016 13:20:22 -0400 Received: from mx1.mailbox.org ([80.241.60.212]:47196) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1awC5O-0001GE-5t for emacs-orgmode@gnu.org; Fri, 29 Apr 2016 13:20:15 -0400 In-Reply-To: (Herbert Sitz's message of "Tue, 26 Apr 2016 16:16:52 +0000 (UTC)") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Herbert Sitz Cc: emacs-orgmode@gnu.org On 2016-04-26 16:16 Herbert Sitz wrote: > Alexander Baier 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