From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dave Abrahams Subject: Re: Checkbox difficulties Date: Tue, 11 Oct 2011 10:08:10 -0400 Message-ID: References: <87y5x3jjcl.fsf@gmail.com> <22596.1317621010@alphaville.dokosmarshall.org> <23215.1317681137@alphaville.americas.hpqcorp.net> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([140.186.70.92]:36473) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RDd0L-00040K-C7 for emacs-orgmode@gnu.org; Tue, 11 Oct 2011 10:08:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RDd0B-00011l-UF for emacs-orgmode@gnu.org; Tue, 11 Oct 2011 10:08:25 -0400 Received: from mail-vx0-f169.google.com ([209.85.220.169]:36326) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RDd0B-00011a-PH for emacs-orgmode@gnu.org; Tue, 11 Oct 2011 10:08:15 -0400 Received: by vcbfo14 with SMTP id fo14so6855502vcb.0 for ; Tue, 11 Oct 2011 07:08:14 -0700 (PDT) In-Reply-To: (Dave Abrahams's message of "Thu, 06 Oct 2011 17:25:02 -0400") 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 on Thu Oct 06 2011, Dave Abrahams wrote: > Here's a version that deals with at least one of your caveats: > > (defun ndk/checkbox-list-complete () > (save-excursion > (org-back-to-heading t) > (when looking-at (concat > "^\\*+[ \t]+" > org-todo-regexp ;; first match group here > "[ \t].*\\[" "\\(100%\\)\\|[0-9]+%" > "\\|" "\\([0-9]+\\)" "/" "\\([0-9]+\\)" "\\]") > (if (or (match-string 2) > (and (match-string 3) > (equal (match-string 3) (match-string 4)))) > (org-todo 'done) > (org-todo 'todo))))) Whoops! Looks like I made some edits to that after my last test. Please try this one instead: --8<---------------cut here---------------start------------->8--- (defun dwa/checkbox-list-complete () (save-excursion (org-back-to-heading t) (when (looking-at (concat "^\\*+[ \t]+" org-todo-regexp ;; first match group here "[ \t].*\\[" "\\(?:" "\\(?2:100%\\)\\|[0-9]+%" "\\|" "\\(?3:[0-9]+\\)" "/" "\\(?4:[0-9]+\\)" "\\)" "\\]")) (if (or (match-string 2) (and (match-string 3) (equal (match-string 3) (match-string 4)))) (org-todo 'done) (org-todo 'todo))))) --8<---------------cut here---------------end--------------->8--- -- Dave Abrahams BoostPro Computing http://www.boostpro.com