From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nick Dokos Subject: Re: Re: manipulating the agenda from elisp? Date: Fri, 08 Apr 2011 01:00:40 -0400 Message-ID: <5451.1302238840@alphaville.dokosmarshall.org> References: <87bp0h2z80.fsf@norang.ca> Reply-To: nicholas.dokos@hp.com Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from [140.186.70.92] (port=52095 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q8448-00072Y-MT for emacs-orgmode@gnu.org; Fri, 08 Apr 2011 01:17:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q8446-00082p-LK for emacs-orgmode@gnu.org; Fri, 08 Apr 2011 01:17:04 -0400 Received: from vms173005pub.verizon.net ([206.46.173.5]:38855) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q8446-0007xI-Bt for emacs-orgmode@gnu.org; Fri, 08 Apr 2011 01:17:02 -0400 Received: from alphaville.dokosmarshall.org ([unknown] [173.76.32.106]) by vms173005.mailsrvcs.net (Sun Java(tm) System Messaging Server 7u2-7.02 32bit (built Apr 16 2009)) with ESMTPA id <0LJB004SYINQRTG0@vms173005.mailsrvcs.net> for emacs-orgmode@gnu.org; Fri, 08 Apr 2011 00:16:44 -0500 (CDT) In-reply-to: Message from "Filippo A. Salustri" of "Thu\, 07 Apr 2011 23\:53\:15 EDT." List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: "Filippo A. Salustri" Cc: Bernt Hansen , nicholas.dokos@hp.com, emacs-orgmode@gnu.org Filippo A. Salustri wrote: > That's a good start! =C2=A0Thanks! > Cheers. > Fil >=20 > On 7 April 2011 23:34, Bernt Hansen wrote: >=20 > "Filippo A. Salustri" writes: >=20=20=20=20 > > Hi, > > I'm thinking I might like to try some programming to do things to t= he > > agenda from an elisp function. > > I tried 'apropos agenda' but I didn't really see the kind of thing > > I'm looking for. > > What I'm hoping is for some way to iterate over each item in the > > agenda, and be able to access the content of the item in some > > structured way. > > I think I've seen functions that can pull info like TODO state and > > priority from the item under the cursor, so it's the iteration part > > that I'm really interested in. > > > > Any advice? >=20=20=20=20 Be sure to read the "Hacking" appendix in the org manual, in particular "Using the property API" and "Using the mapping API". Nick > Hi Fil, >=20=20=20=20 > I just found the B f code to execute an arbitrary function on marked > entries in the agenda. =C2=A0Maybe this will help? >=20=20=20=20 > This following code visits the marked entries and just displays the > heading for the task. >=20=20=20=20 > Mark multiple entries in the agenda with 'm' and then 'B f bh/test RE= T' > should display the heading of each marked task in the *Messages* buff= er. >=20=20=20=20 > --8<---------------cut here---------------start------------->8--- > (defun bh/test () > =C2=A0(interactive) > =C2=A0(let* ((marker (or (org-get-at-bol 'org-marker) > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= (org-agenda-error))) > =C2=A0 =C2=A0 =C2=A0 =C2=A0 (buffer (marker-buffer marker)) > =C2=A0 =C2=A0 =C2=A0 =C2=A0 (pos (marker-position marker))) > =C2=A0 =C2=A0(with-current-buffer buffer > =C2=A0 =C2=A0 =C2=A0(if (org-mode-p) > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(save-excursion > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(goto-char pos) > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(message "%s" (nth 4 (org-he= ading-components)))))))) > --8<---------------cut here---------------end--------------->8--- >=20=20=20=20 > Depending on what you want to do you can either act on marked entries= or > create a custom agenda skip function that can visit the tasks as the > agenda is built. >=20=20=20=20 > HTH, > Bernt >=20 > -- > Filippo A. Salustri, Ph.D., P.Eng. > Mechanical and Industrial Engineering > Ryerson University > 350 Victoria St, Toronto, ON > M5B 2K3, Canada > Tel: 416/979-5000 ext 7749 > Fax: 416/979-5265 > Email: salustri@ryerson.ca > http://deseng.ryerson.ca/~fil/ >=20 >=20 > ---------------------------------------------------- > Alternatives: >=20 > ----------------------------------------------------