Nick, thank you so much. That worked like a charm!

On Sat, Feb 11, 2012 at 1:17 PM, Nick Dokos <nicholas.do...@hp.com> wrote:

> Peter Salazar <cycleofs...@gmail.com> 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:
> >
> > ----------------------------------------------------
>

Reply via email to