From mboxrd@z Thu Jan 1 00:00:00 1970 From: Peter Salazar Subject: Re: automatically mark DONE when all sub checkboxes are checked Date: Mon, 13 Feb 2012 03:08:05 -0500 Message-ID: References: <14795.1328984224@alphaville> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=f46d04138a9d6cba9204b8d3fa0c Return-path: Received: from eggs.gnu.org ([140.186.70.92]:37907) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RwqxI-00057J-CK for emacs-orgmode@gnu.org; Mon, 13 Feb 2012 03:08:14 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RwqxD-0001bo-Qn for emacs-orgmode@gnu.org; Mon, 13 Feb 2012 03:08:12 -0500 Received: from mail-wi0-f169.google.com ([209.85.212.169]:51546) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RwqxD-0001bX-Bk for emacs-orgmode@gnu.org; Mon, 13 Feb 2012 03:08:07 -0500 Received: by wibhj13 with SMTP id hj13so4169985wib.0 for ; Mon, 13 Feb 2012 00:08:06 -0800 (PST) In-Reply-To: <14795.1328984224@alphaville> 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: nicholas.dokos@hp.com Cc: emacs-orgmode@gnu.org --f46d04138a9d6cba9204b8d3fa0c Content-Type: text/plain; charset=ISO-8859-1 Nick, thank you so much. That worked like a charm! On Sat, Feb 11, 2012 at 1:17 PM, Nick Dokos wrote: > Peter Salazar wrote: > > > Hello everyone! Org-mode is amazing. I've totally fallen in love with > it. Glad to be joining the > > community. > > > > I'm trying to get org-mode to automatically mark DONE when all sub > checkboxes are checked. On http:/ > > /orgmode.org/worg/org-faq.html, I found a function that purports to do > this. > > > > I pasted the function into my .emacs file, but now I'm getting an error > message when I launch: > > "Symbol's value as variable is void: org-checkbox-statistics-hook." > > > > Any thoughts? Thanks in advance! > > > > You need to do the add-to-list *after* the variable is defined. The > variable is defined in org-list.el, so one way to do it is > > (require 'org-list) > (add-to-list 'org-checkbox-statistics-hook (function > ndk/checkbox-list-complete)) > > This is the sledge hammer approach - and depending on exactly when it's > done, it might cause other problems (e.g. it should probably be done > after the rest of org is loaded). There are various other ways to do it > more gently - e.g. > > (eval-after-load 'org-list > '(add-to-list 'org-checkbox-statistics-hook (function > ndk/checkbox-list-complete))) > > I'll probably modify the faq to say this (actually, I think the whole > kit-n-caboodle > should be moved over to org-hacks and a link should be planted in org-faq > pointing to > the org-hacks entry.) > > Nick > > > ;; see http://thread.gmane.org/gmane.emacs.orgmode/42715 > > (add-to-list 'org-checkbox-statistics-hook (function > ndk/checkbox-list-complete)) > > > > (defun ndk/checkbox-list-complete () > > (save-excursion > > (org-back-to-heading t) > > (let ((beg (point)) end) > > (end-of-line) > > (setq end (point)) > > (goto-char beg) > > (if (re-search-forward > "\\[\\([0-9]*%\\)\\]\\|\\[\\([0-9]*\\)/\\([0-9]*\\)\\]" end t) > > (if (match-end 1) > > (if (equal (match-string 1) "100%") > > ;; all done - do the state change > > (org-todo 'done) > > (org-todo 'todo)) > > (if (and (> (match-end 2) (match-beginning 2)) > > (equal (match-string 2) (match-string 3))) > > (org-todo 'done) > > (org-todo 'todo)))))))) > > > > P.S. Not sure if it's relevant, but I'm on OSX using Aquamacs 2.4. > > > > > > ---------------------------------------------------- > > Alternatives: > > > > ---------------------------------------------------- > --f46d04138a9d6cba9204b8d3fa0c Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Nick, thank you so much. That worked like a charm!


On Sat, Feb 11, 2012 at 1:17 PM, Nick Dokos <nicholas.dokos@hp.com&= gt; wrote:
Peter Salazar <cycleofsong@gmail.com> wrote:

> Hello everyone! Org-mode is amazing. I've totally fallen in love w= ith it. Glad to be joining the
> community.=A0
>
> I'm trying to get org-mode to automatically mark DONE when all sub= checkboxes are checked. On=A0http:/
> /or= gmode.org/worg/org-faq.html, I found a function that purports to do thi= s.
>
> I pasted the function into my .emacs file, but now I'm getting an = error message when I launch:
> "Symbol's value as variable is void: org-checkbox-statistics-= hook."=A0
>
> Any thoughts? Thanks in advance!=A0
>

You need to do the add-to-list *after* the variable is defined. The variable is defined in org-list.el, so one way to do it is

=A0 =A0 =A0 =A0 (require 'org-list)
=A0 =A0 =A0 =A0 (add-to-list 'org-checkbox-statistics-hook (function n= dk/checkbox-list-complete))

This is the sledge hammer approach - and depending on exactly when it's=
done, it might cause other problems (e.g. it should probably be done
after the rest of org is loaded). There are various other ways to do it
more gently - e.g.

(eval-after-load 'org-list
=A0 =A0 '(add-to-list 'org-checkbox-statistics-hook (function ndk/= checkbox-list-complete)))

I'll probably modify the faq to say this (actually, I think the whole k= it-n-caboodle
should be moved over to org-hacks and a link should be planted in org-faq p= ointing to
the org-hacks entry.)

Nick

> ;; see http://thread.gmane.org/gmane.emacs.orgmode/42715
> (add-to-list 'org-checkbox-statistics-hook (function ndk/checkbox-= list-complete))
>
> (defun ndk/checkbox-list-complete ()
> =A0 (save-excursion
> =A0 =A0 (org-back-to-heading t)
> =A0 =A0 (let ((beg (point)) end)
> =A0 =A0 =A0 (end-of-line)
> =A0 =A0 =A0 (setq end (point))
> =A0 =A0 =A0 (goto-char beg)
> =A0 =A0 =A0 (if (re-search-forward "\\[\\([0-9]*%\\)\\]\\|\\[\\([= 0-9]*\\)/\\([0-9]*\\)\\]" end t)
> =A0 =A0 =A0 =A0 =A0 =A0 (if (match-end 1)
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (if (equal (match-string 1) "100%= ")
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ;; all done - do the state cha= nge
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (org-todo 'done)
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (org-todo 'todo))
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 (if (and (> (match-end 2) (match-beginn= ing 2))
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(equal (match-string 2)= (match-string 3)))
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (org-todo 'done)
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (org-todo 'todo))))))))
>
> P.S. Not sure if it's relevant, but I'm on OSX using Aquamacs = 2.4.
>
>
> ----------------------------------------------------
> Alternatives:
>
> ----------------------------------------------------

--f46d04138a9d6cba9204b8d3fa0c--