From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nick Dokos Subject: Re: automatically mark DONE when all sub checkboxes are checked Date: Sat, 11 Feb 2012 13:17:04 -0500 Message-ID: <14795.1328984224@alphaville> References: Reply-To: nicholas.dokos@hp.com Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([140.186.70.92]:35857) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RwHVV-0004VK-Pm for emacs-orgmode@gnu.org; Sat, 11 Feb 2012 13:17:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RwHVU-0000YM-7W for emacs-orgmode@gnu.org; Sat, 11 Feb 2012 13:17:09 -0500 Received: from g5t0006.atlanta.hp.com ([15.192.0.43]:46281) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RwHVU-0000YF-0z for emacs-orgmode@gnu.org; Sat, 11 Feb 2012 13:17:08 -0500 In-Reply-To: Message from Peter Salazar of "Fri\, 10 Feb 2012 16\:06\:18 EST." 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: Peter Salazar Cc: nicholas.dokos@hp.com, emacs-orgmode@gnu.org Peter Salazar wrote: > Hello everyone! Org-mode is amazing. I've totally fallen in love with it.= Glad to be joining the > community.=C2=A0 >=20 > I'm trying to get org-mode to automatically mark DONE when all sub checkb= oxes are checked. On=C2=A0http:/ > /orgmode.org/worg/org-faq.html, I found a function that purports to do th= is. >=20 > I pasted the function into my .emacs file, but now I'm getting an error m= essage when I launch: > "Symbol's value as variable is void: org-checkbox-statistics-hook."=C2=A0 >=20 > Any thoughts? Thanks in advance!=C2=A0 >=20 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-co= mplete)) 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-lis= t-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 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-co= mplete)) >=20 > (defun ndk/checkbox-list-complete () > =C2=A0 (save-excursion > =C2=A0 =C2=A0 (org-back-to-heading t) > =C2=A0 =C2=A0 (let ((beg (point)) end) > =C2=A0 =C2=A0 =C2=A0 (end-of-line) > =C2=A0 =C2=A0 =C2=A0 (setq end (point)) > =C2=A0 =C2=A0 =C2=A0 (goto-char beg) > =C2=A0 =C2=A0 =C2=A0 (if (re-search-forward "\\[\\([0-9]*%\\)\\]\\|\\[\\(= [0-9]*\\)/\\([0-9]*\\)\\]" end t) > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (if (match-end 1) > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (if (equal (match= -string 1) "100%") > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ;; = all done - do the state change > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (or= g-todo 'done) > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (org-todo = 'todo)) > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (if (and (> (match-end 2= ) (match-beginning 2)) > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0(equal (match-string 2) (match-string 3))) > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (org-todo = 'done) > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (org-todo 'todo))= )))))) >=20 > P.S. Not sure if it's relevant, but I'm on OSX using Aquamacs 2.4. >=20 >=20 > ---------------------------------------------------- > Alternatives: >=20 > ----------------------------------------------------