emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Automatic tagging based on # of todo items as children
@ 2010-02-15 10:27 Marcel van der Boom
  0 siblings, 0 replies; 4+ messages in thread
From: Marcel van der Boom @ 2010-02-15 10:27 UTC (permalink / raw)
  To: emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 1089 bytes --]

Hi,

I would like to have org-mode assist me in tagging headlines with a
'prj' tag if that headline contains more than one todo item. It does
not matter if the items are completed or not, if it has more than one
task as its children, I would like to have it tagged with 'prj'

I came up with this:

#+begin_src elisp
(defun ensure-prj-tag()
  "Ensure a header gets a prj tag" 
  (interactive) 
  (org-toggle-tag "prj"
    (if (> (length (org-map-entries t "/+TODO|DONE|CANCELLED" 'tree))1) 'on 'off))
)
#+end_src

which sort-of works if the cursor is on the heading.

I need some help with the following:
- I would like it to be automatic and the org-todo-statistics hook
  seem candidates to attach a function to, but I also want it for
  heading which do not have a [1/N] or [%] counter. How to proceed?
- Can I do this automatically on a whole file? 

marcel

-- 
Marcel van der Boom  -- http://hsdev.com/mvdb.vcf
HS-Development BV    -- http://www.hsdev.com
So! web applications -- http://make-it-so.info
Cobra build          -- http://cobra.mrblog.nl

[-- Attachment #1.2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 1347 bytes --]

[-- Attachment #2: Type: text/plain, Size: 201 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

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

* Automatic tagging based on # of todo items as children
@ 2010-02-15 11:05 mrb
  2010-02-16  4:53 ` Carsten Dominik
  0 siblings, 1 reply; 4+ messages in thread
From: mrb @ 2010-02-15 11:05 UTC (permalink / raw)
  To: emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 1089 bytes --]

Hi,

I would like to have org-mode assist me in tagging headlines with a
'prj' tag if that headline contains more than one todo item. It does
not matter if the items are completed or not, if it has more than one
task as its children, I would like to have it tagged with 'prj'

I came up with this:

#+begin_src elisp
(defun ensure-prj-tag()
  "Ensure a header gets a prj tag" 
  (interactive) 
  (org-toggle-tag "prj"
    (if (> (length (org-map-entries t "/+TODO|DONE|CANCELLED" 'tree))1)
'on 'off)) )
#+end_src

which sort-of works if the cursor is on the heading.

I need some help with the following:
- I would like it to be automatic and the org-todo-statistics hook
  seem candidates to attach a function to, but I also want it for
  heading which do not have a [1/N] or [%] counter. How to proceed?
- Can I do this automatically on a whole file? 

marcel

-- 
Marcel van der Boom  -- http://hsdev.com/mvdb.vcf
HS-Development BV    -- http://www.hsdev.com
So! web applications -- http://make-it-so.info
Cobra build          -- http://cobra.mrblog.nl

[-- Attachment #1.2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 1347 bytes --]

[-- Attachment #2: Type: text/plain, Size: 201 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

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

* Re: Automatic tagging based on # of todo items as children
  2010-02-15 11:05 Automatic tagging based on # of todo items as children mrb
@ 2010-02-16  4:53 ` Carsten Dominik
  2010-02-17 17:43   ` mrb
  0 siblings, 1 reply; 4+ messages in thread
From: Carsten Dominik @ 2010-02-16  4:53 UTC (permalink / raw)
  To: mrb; +Cc: emacs-orgmode

Hi Marcel,

there is not simple other way, because only when making TODO  
statistics are the TODO children counted.  You can hook into `org- 
after-todo-state-change-hook' with a function that moves back up to  
the parent and then counts children with TODO keyword.

THis is untested:

(defun my-define-prj ()
   (save-excursion
     (when (org-up-heading-safe)
       (let ((beg (point))
	    (end (org-end-of-subtree t t))
	    two-not-done)
	(goto-char beg)
	(goto-char (point-at-eol))
	(setq two-not-done
	      (and (re-search-forward org-not-done-heading-regexp end t)
		   (re-search-forward org-not-done-heading-regexp end t)))
	(goto-char beg)
	(org-toggle-tag "prj" (if two-not-done 'on 'off))))))

(add-hook 'org-after-todo-state-change-hook 'my-define-prj)

- Carsten



On Feb 15, 2010, at 12:05 PM, mrb@hsdev.com wrote:

> Hi,
>
> I would like to have org-mode assist me in tagging headlines with a
> 'prj' tag if that headline contains more than one todo item. It does
> not matter if the items are completed or not, if it has more than one
> task as its children, I would like to have it tagged with 'prj'
>
> I came up with this:
>
> #+begin_src elisp
> (defun ensure-prj-tag()
>  "Ensure a header gets a prj tag"
>  (interactive)
>  (org-toggle-tag "prj"
>    (if (> (length (org-map-entries t "/+TODO|DONE|CANCELLED" 'tree))1)
> 'on 'off)) )
> #+end_src
>
> which sort-of works if the cursor is on the heading.
>
> I need some help with the following:
> - I would like it to be automatic and the org-todo-statistics hook
>  seem candidates to attach a function to, but I also want it for
>  heading which do not have a [1/N] or [%] counter. How to proceed?
> - Can I do this automatically on a whole file?
>
> marcel
>
> -- 
> Marcel van der Boom  -- http://hsdev.com/mvdb.vcf
> HS-Development BV    -- http://www.hsdev.com
> So! web applications -- http://make-it-so.info
> Cobra build          -- http://cobra.mrblog.nl
> _______________________________________________
> Emacs-orgmode mailing list
> Please use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode

- Carsten

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

* Re: Automatic tagging based on # of todo items as children
  2010-02-16  4:53 ` Carsten Dominik
@ 2010-02-17 17:43   ` mrb
  0 siblings, 0 replies; 4+ messages in thread
From: mrb @ 2010-02-17 17:43 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 1243 bytes --]

On Tue 16-Feb-2010 05:53
Carsten Dominik <carsten.dominik@gmail.com> wrote:

> there is not simple other way, because only when making TODO  
> statistics are the TODO children counted.  You can hook into `org- 
> after-todo-state-change-hook' with a function that moves back up to  
> the parent and then counts children with TODO keyword.
> 
> THis is untested:
> 
> (defun my-define-prj ()
>    (save-excursion
>      (when (org-up-heading-safe)
>        (let ((beg (point))
> 	    (end (org-end-of-subtree t t))
> 	    two-not-done)
> 	(goto-char beg)
> 	(goto-char (point-at-eol))
> 	(setq two-not-done
> 	      (and (re-search-forward org-not-done-heading-regexp end
> t) (re-search-forward org-not-done-heading-regexp end t)))
> 	(goto-char beg)
> 	(org-toggle-tag "prj" (if two-not-done 'on 'off))))))
> 
> (add-hook 'org-after-todo-state-change-hook 'my-define-prj)
> 

Thanks! That is close enough at this time. It neatly adds/removes the
tag when there are more/less than 2 open TODO items.  

marcel

-- 
Marcel van der Boom  -- http://hsdev.com/mvdb.vcf
HS-Development BV    -- http://www.hsdev.com
So! web applications -- http://make-it-so.info
Cobra build          -- http://cobra.mrblog.nl

[-- Attachment #1.2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 1347 bytes --]

[-- Attachment #2: Type: text/plain, Size: 201 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

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

end of thread, other threads:[~2010-02-17 17:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-02-15 11:05 Automatic tagging based on # of todo items as children mrb
2010-02-16  4:53 ` Carsten Dominik
2010-02-17 17:43   ` mrb
  -- strict thread matches above, loose matches on Subject: below --
2010-02-15 10:27 Marcel van der Boom

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