From mboxrd@z Thu Jan 1 00:00:00 1970 From: John Kitchin Subject: Re: Need help understanding how to limit a function to a tree Date: Wed, 28 Feb 2018 19:35:14 -0800 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="001a11468de63b67b70566518cdc" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:38932) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1erF02-0004Xh-AK for emacs-orgmode@gnu.org; Wed, 28 Feb 2018 22:35:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1erF00-0004C7-Ut for emacs-orgmode@gnu.org; Wed, 28 Feb 2018 22:35:18 -0500 Received: from mail-wm0-x234.google.com ([2a00:1450:400c:c09::234]:38219) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1erF00-00049z-C5 for emacs-orgmode@gnu.org; Wed, 28 Feb 2018 22:35:16 -0500 Received: by mail-wm0-x234.google.com with SMTP id z9so8835169wmb.3 for ; Wed, 28 Feb 2018 19:35:15 -0800 (PST) In-Reply-To: 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: mediapathic steen Cc: org-mode-email --001a11468de63b67b70566518cdc Content-Type: text/plain; charset="UTF-8" You probably want this: #+BEGIN_SRC emacs-lisp (defun my-redo () (interactive) (org-map-entries (lambda () (org-todo "TODO")) "TODO=\"DONE\"" ;; the match argument 'tree)) ;; the scope #+END_SRC Then call: M-x my-redo in the tree you want to reset. John ----------------------------------- Professor John Kitchin Doherty Hall A207F Department of Chemical Engineering Carnegie Mellon University Pittsburgh, PA 15213 412-268-7803 @johnkitchin http://kitchingroup.cheme.cmu.edu On Wed, Feb 28, 2018 at 4:36 PM, mediapathic steen wrote: > I have a subtree that contains a daily list of things to do (which I keep > as TODOs rather than checklist form for more granular time tracking). I > want to reset all of the DONE to TODO every day when I start it. Right now > I have this piece of code I copypasted from somewhere now lost (possibly > this very group): > > (org-map-entries (lambda () > (when > (string= > (nth 2 (org-heading-components)) "DONE") > (org-todo "TODO")))) > > This more or less makes sense to me. I have this code sitting in the > subtree, and in order to do my daily reset, I edit the subtree in an > indirect buffer, eval-region the code, then kill the buffer. > > What I would like to accomplish: > 1) Can you help me understand how to modify this code so that it only > applies to the subtree it's run in (parents also would be fine in this case > but not necessary and seems more of a challenge)? Doing the indirect buffer > thing seems more hassle than is reasonable. > > 2) I think I understand how to put this in my init in such a way that I > can C-x invoke it, rather than having to eval-region it, but I'm not > certain. Can you point me toward a reasonable tutorial or hints on how to > do that in general? > > Thanks in advance, > -- Steen > --001a11468de63b67b70566518cdc Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
You probably want this:

#+BEGIN_SR= C emacs-lisp
(defun my-redo ()
=C2=A0 (interactive)
=C2=A0 (org-map-entries
=C2=A0 =C2=A0(lambda ()
= =C2=A0 =C2=A0 =C2=A0(org-todo "TODO"))
=C2=A0 =C2=A0&qu= ot;TODO=3D\"DONE\""=C2=A0 ;; the match argument
= =C2=A0 =C2=A0'tree))=C2=A0 ;; the scope
#+END_SRC
=

Then call:

M-x my-redo=C2=A0

in the tree you want to reset.

=


John

-----------------------------------Professor John Kitchin=C2=A0
Doherty Hall A207F
Department of Chemi= cal Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
41= 2-268-7803

On Wed, Feb 28, 2018 at 4:36 PM, mediapathic= steen <mediapathic@gmail.com> wrote:
I have a subtree that contains a daily list of things to do= (which I keep as TODOs rather than checklist form for more granular time t= racking). I want to reset all of the DONE to TODO every day when I start it= . Right now I have this piece of code I copypasted from somewhere now lost = (possibly this very group):

(org-map-entries (lambda ()
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (when
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (string=3D
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(nth 2 (org-heading-= components)) "DONE")
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(org-todo "TODO= "))))

This more or less makes sense to me. I have this code sitting in the subtre= e, and=C2=A0 in order to do my daily reset, I edit the subtree in an indire= ct buffer, eval-region the code, then kill the buffer.

What I would like to accomplish:
1) Can you help me understand how to modify this code so that it only appli= es to the subtree it's run in (parents also would be fine in this case = but not necessary and seems more of a challenge)? Doing the indirect buffer= thing seems more hassle than is reasonable.

2) I think I understand how to put this in my init in such a way that I can= C-x invoke it, rather than having to eval-region it, but I'm not certa= in. Can you point me toward a reasonable tutorial or hints on how to do tha= t in general?

Thanks in advance,
-- Steen

--001a11468de63b67b70566518cdc--