From mboxrd@z Thu Jan 1 00:00:00 1970 From: Chris Poole Subject: Re: How to find the headline matching a string Date: Sat, 31 May 2014 17:51:18 +0100 Message-ID: References: <87bnuedl38.fsf@ericabrahamsen.net> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=001a11c1d9c094cb8d04fab4f846 Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:40073) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WqmVA-0006FH-6L for emacs-orgmode@gnu.org; Sat, 31 May 2014 12:51:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WqmV5-00048C-GX for emacs-orgmode@gnu.org; Sat, 31 May 2014 12:51:24 -0400 Received: from mail-oa0-f48.google.com ([209.85.219.48]:58180) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WqmV5-000483-Aa for emacs-orgmode@gnu.org; Sat, 31 May 2014 12:51:19 -0400 Received: by mail-oa0-f48.google.com with SMTP id g18so3089415oah.35 for ; Sat, 31 May 2014 09:51:18 -0700 (PDT) In-Reply-To: <87bnuedl38.fsf@ericabrahamsen.net> 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-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Eric Abrahamsen Cc: "emacs-orgmode@gnu.org" --001a11c1d9c094cb8d04fab4f846 Content-Type: text/plain; charset=UTF-8 Eric Abrahamsen: > the `org-map-entries' function can be given a scope of 'agenda That worked perfectly, thanks. Here's what I ended up with: (org-map-entries (lambda () (when (equal title (org-get-heading t t)) (org-entry-put (point) "TODO" "DONE"))) tag 'agenda) Cheers, Chris On Sat, May 31, 2014 at 4:27 PM, Eric Abrahamsen wrote: > Chris Poole writes: > > > Hi all, > > > > Suppose I have a string, "my first task", that I know is tagged with > > "laptop". > > > > I want to search through the agenda files for a headline that matches > > this string, to be able to mark it as DONE (in an automated fashion). > > > > I can't find a function to search through for the headline --- is > > there one? > > > > Else, is it best to concat all the agenda files into a larger buffer, > > then parse the buffer and iterate through the headlines with > > org-element-map? > > > > > > Cheers, > > Chris > > Depending on how automated you need this to be, the `org-map-entries' > function can be given a scope of 'agenda (see its docstring). You could > call it with the agenda scope and a matcher for the "laptop" tag -- that > would at least get you all the headings in all the agenda files with the > "laptop" tag. Then the actual mapping function could call > `org-get-heading' on each of the matching headings, and check the text. > > In these cases, though, I generally try to find a way to know the > heading's ID property, and use `org-id-goto'. > > Hope that helps, > Eric > > > --001a11c1d9c094cb8d04fab4f846 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Eric Abrahamsen:
>=C2=A0the `org-map-entries'=C2=A0function can be given a scope of 'agenda=

That worked perfectly, thanks. Here's what I ended up wi= th:

(org-map-entries (lambda ()
=C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0(when (equal title (org-get-heading t t))
=C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0(org-entry-put (point) "TODO" "DONE&= quot;)))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0tag 'agenda)


Cheers,
Chris

--001a11c1d9c094cb8d04fab4f846--