emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Need help understanding how to limit a function to a tree
@ 2018-03-01  0:36 mediapathic steen
  2018-03-01  3:35 ` John Kitchin
  0 siblings, 1 reply; 3+ messages in thread
From: mediapathic steen @ 2018-03-01  0:36 UTC (permalink / raw)
  To: emacs-orgmode

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

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

* Re: Need help understanding how to limit a function to a tree
  2018-03-01  0:36 Need help understanding how to limit a function to a tree mediapathic steen
@ 2018-03-01  3:35 ` John Kitchin
  2018-03-01  9:15   ` mediapathic steen
  0 siblings, 1 reply; 3+ messages in thread
From: John Kitchin @ 2018-03-01  3:35 UTC (permalink / raw)
  To: mediapathic steen; +Cc: org-mode-email

[-- Attachment #1: Type: text/plain, Size: 1881 bytes --]

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

[-- Attachment #2: Type: text/html, Size: 2796 bytes --]

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

* Re: Need help understanding how to limit a function to a tree
  2018-03-01  3:35 ` John Kitchin
@ 2018-03-01  9:15   ` mediapathic steen
  0 siblings, 0 replies; 3+ messages in thread
From: mediapathic steen @ 2018-03-01  9:15 UTC (permalink / raw)
  To: John Kitchin; +Cc: org-mode-email

This worked a treat, and I learned a bit more. Thanks so much!

-- Steen

> On Feb 28, 2018, at 7:35 PM, John Kitchin <jkitchin@andrew.cmu.edu> wrote:
> 
> 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 <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 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
> 

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

end of thread, other threads:[~2018-03-01  9:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-01  0:36 Need help understanding how to limit a function to a tree mediapathic steen
2018-03-01  3:35 ` John Kitchin
2018-03-01  9:15   ` mediapathic steen

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