Browse Source

Hierarchical Checkboxes and new org-mac-message.el.

Carsten Dominik 17 years ago
parent
commit
71b08c4c5e
6 changed files with 169 additions and 186 deletions
  1. 6 0
      ChangeLog
  2. 2 1
      Makefile
  3. 20 3
      ORGWEBPAGE/Changes.org
  4. 47 47
      org-install.el
  5. 11 7
      org-mac-message.el
  6. 83 128
      org.el

+ 6 - 0
ChangeLog

@@ -1,3 +1,9 @@
+2008-02-05  Carsten Dominik  <dominik@science.uva.nl>
+
+	* org.el (org-update-checkbox-count): Revamped to deal with
+	hierarchical beckboxes.  This was a patch from Miguel
+	A. Figueroa-Villanueva. 
+
 2008-02-04  Carsten Dominik  <dominik@science.uva.nl>
 
 	* org-mac-message.el: New file.

+ 2 - 1
Makefile

@@ -61,7 +61,8 @@ CP = cp -p
 ##----------------------------------------------------------------------
 
 # The following variables need to be defined by the maintainer
-LISPFILES0 = org.el org-publish.el org-mouse.el org-export-latex.el
+LISPFILES0 = org.el org-publish.el org-mouse.el org-export-latex.el \
+	     org-mac-message.el
 LISPFILES  = $(LISPFILES0) org-install.el 
 ELCFILES   = $(LISPFILES:.el=.elc)
 DOCFILES   = org.texi org.pdf org

+ 20 - 3
ORGWEBPAGE/Changes.org

@@ -10,10 +10,17 @@
 ** Overview
 
 ** Incompatible Changes
+   
+   - The variable `org-remember-use-refile-when-interactive'
+     introduced only in 5.19 is already obsolete.  Please use
+     `org-remember-interactive-interface' instead.  This new
+     variable does select the interface that is used to select
+     the target for a remember note in an interactive way.
+     Possible values are:
 
 ** Details
 
-*** Remember and Refile
+*** Remember/Refile/Goto
 
     - The use of prefix arguments for the commands `org-remember'
       and `org-refile' has been normalized:
@@ -33,7 +40,7 @@
     - When the clock is running inside an remember buffer, storing
       the remember buffer with `C-c C-c' will automatically clock
       out.  This was inspired by a request by Rainer Stengle. 
-
+      
     - Outline-path-completion is now available as an alternative
       interface in the command `org-goto'.  Please select the
       default interface you'd like to use with the new variable
@@ -43,7 +50,7 @@
       interface.  Comments?
 
     - The variable `org-remember-use-refile-when-interactive'
-      introduced only in 5.19 is obsolete.  Please use
+      introduced only in 5.19 is already obsolete.  Please use
       `org-remember-interactive-interface' instead.  This new
       variable does select the interface that is used to select
       the target for a remember note in an interactive way.
@@ -66,6 +73,12 @@
 
 *** Misc
 
+    - Checkboxes now work hierarchically.  When a plain-list item
+      with a checkbox has children with checkboxes, the status of
+      the item's checkbox is calculated from the children, each
+      time a checkbox is toggled with C-c C-c.  Thanks to Miguel
+      A. Figueroa-Villanueva for a patch to this effect.
+
     - There is a new variabls `org-special-ctrl-k'.  When set,
       `C-k' will behave specially in headlines:
 
@@ -128,6 +141,10 @@
       that gets stored upon archiving with the variable
       `org-archive-save-context-info'.
 
+    - New file `org-mac-message.el' by John Wiegley to create
+      links for messages in Apple Mail, and to follow these
+      links.
+
 * Version 5.19
 
 ** Overview

+ 47 - 47
org-install.el

@@ -8,10 +8,10 @@
 ;;;;;;  org-remember-insinuate org-open-at-point-global org-insert-link-global
 ;;;;;;  org-store-link orgtbl-mode turn-on-orgtbl org-run-like-in-org-mode
 ;;;;;;  turn-on-orgstruct++ turn-on-orgstruct orgstruct-mode org-global-cycle
-;;;;;;  org-cycle org-mode) "org" "org.el" (18320 41932))
+;;;;;;  org-cycle org-mode) "org" "org.el" (18344 16141))
 ;;; Generated autoloads from org.el
 
-(autoload (quote org-mode) "org" "\
+(autoload 'org-mode "org" "\
 Outline-based notes management and organizer, alias
 \"Carsten's outline-mode for keeping track of everything.\"
 
@@ -32,7 +32,7 @@ The following commands are available:
 
 \(fn)" t nil)
 
-(autoload (quote org-cycle) "org" "\
+(autoload 'org-cycle "org" "\
 Visibility cycling for Org-mode.
 
 - When this function is called with a prefix argument, rotate the entire
@@ -63,12 +63,12 @@ Visibility cycling for Org-mode.
 
 \(fn &optional ARG)" t nil)
 
-(autoload (quote org-global-cycle) "org" "\
+(autoload 'org-global-cycle "org" "\
 Cycle the global visibility.  For details see `org-cycle'.
 
 \(fn &optional ARG)" t nil)
 
-(autoload (quote orgstruct-mode) "org" "\
+(autoload 'orgstruct-mode "org" "\
 Toggle the minor more `orgstruct-mode'.
 This mode is for using Org-mode structure commands in other modes.
 The following key behave as if Org-mode was active, if the cursor
@@ -93,35 +93,35 @@ C-c C-c     Set tags / toggle checkbox
 
 \(fn &optional ARG)" t nil)
 
-(autoload (quote turn-on-orgstruct) "org" "\
+(autoload 'turn-on-orgstruct "org" "\
 Unconditionally turn on `orgstruct-mode'.
 
 \(fn)" nil nil)
 
-(autoload (quote turn-on-orgstruct++) "org" "\
+(autoload 'turn-on-orgstruct++ "org" "\
 Unconditionally turn on `orgstruct-mode', and force org-mode indentations.
 In addition to setting orgstruct-mode, this also exports all indentation and
 autofilling variables from org-mode into the buffer.  Note that turning
-off orgstruct-mode will *not* remove these additonal settings.
+off orgstruct-mode will *not* remove these additional settings.
 
 \(fn)" nil nil)
 
-(autoload (quote org-run-like-in-org-mode) "org" "\
+(autoload 'org-run-like-in-org-mode "org" "\
 Not documented
 
 \(fn CMD)" nil nil)
 
-(autoload (quote turn-on-orgtbl) "org" "\
+(autoload 'turn-on-orgtbl "org" "\
 Unconditionally turn on `orgtbl-mode'.
 
 \(fn)" nil nil)
 
-(autoload (quote orgtbl-mode) "org" "\
+(autoload 'orgtbl-mode "org" "\
 The `org-mode' table editor as a minor mode for use in other modes.
 
 \(fn &optional ARG)" t nil)
 
-(autoload (quote org-store-link) "org" "\
+(autoload 'org-store-link "org" "\
 \\<org-mode-map>Store an org-link to the current location.
 This link can later be inserted into an org-buffer with
 \\[org-insert-link].
@@ -131,25 +131,25 @@ For file links, arg negates `org-context-in-file-links'.
 
 \(fn ARG)" t nil)
 
-(autoload (quote org-insert-link-global) "org" "\
+(autoload 'org-insert-link-global "org" "\
 Insert a link like Org-mode does.
 This command can be called in any mode to insert a link in Org-mode syntax.
 
 \(fn)" t nil)
 
-(autoload (quote org-open-at-point-global) "org" "\
+(autoload 'org-open-at-point-global "org" "\
 Follow a link like Org-mode does.
 This command can be called in any mode to follow a link that has
 Org-mode syntax.
 
 \(fn)" t nil)
 
-(autoload (quote org-remember-insinuate) "org" "\
+(autoload 'org-remember-insinuate "org" "\
 Setup remember.el for use wiht Org-mode.
 
 \(fn)" nil nil)
 
-(autoload (quote org-remember-annotation) "org" "\
+(autoload 'org-remember-annotation "org" "\
 Return a link to the current location as an annotation for remember.el.
 If you are using Org-mode files as target for data storage with
 remember.el, then the annotations should include a link compatible with the
@@ -157,14 +157,14 @@ conventions in Org-mode.  This function returns such a link.
 
 \(fn)" nil nil)
 
-(autoload (quote org-remember-apply-template) "org" "\
+(autoload 'org-remember-apply-template "org" "\
 Initialize *remember* buffer with template, invoke `org-mode'.
 This function should be placed into `remember-mode-hook' and in fact requires
 to be run from that hook to function properly.
 
 \(fn &optional USE-CHAR SKIP-INTERACTIVE)" nil nil)
 
-(autoload (quote org-remember) "org" "\
+(autoload 'org-remember "org" "\
 Call `remember'.  If this is already a remember buffer, re-apply template.
 If there is an active region, make sure remember uses it as initial content
 of the remember buffer.
@@ -179,7 +179,7 @@ associated with a template in `org-remember-templates'.
 
 \(fn &optional GOTO ORG-FORCE-REMEMBER-TEMPLATE-CHAR)" t nil)
 
-(autoload (quote org-remember-handler) "org" "\
+(autoload 'org-remember-handler "org" "\
 Store stuff from remember.el into an org file.
 First prompts for an org file.  If the user just presses return, the value
 of `org-default-notes-file' is used.
@@ -217,7 +217,7 @@ See also the variable `org-reverse-note-order'.
 
 \(fn)" nil nil)
 
-(autoload (quote org-agenda-to-appt) "org" "\
+(autoload 'org-agenda-to-appt "org" "\
 Activate appointments found in `org-agenda-files'.
 When prefixed, prompt for a regular expression and use it as a
 filter: only add entries if they match this regular expression.
@@ -236,7 +236,7 @@ belonging to the category \"Work\".
 
 \(fn &optional FILTER)" t nil)
 
-(autoload (quote org-agenda) "org" "\
+(autoload 'org-agenda "org" "\
 Dispatch agenda commands to collect entries to the agenda buffer.
 Prompts for a command to execute.  Any prefix arg will be passed
 on to the selected command.  The default selections are:
@@ -263,21 +263,21 @@ Pressing `<' twice means to restrict to the current subtree or region
 
 \(fn ARG &optional KEYS RESTRICTION)" t nil)
 
-(autoload (quote org-batch-agenda) "org" "\
+(autoload 'org-batch-agenda "org" "\
 Run an agenda command in batch mode and send the result to STDOUT.
 If CMD-KEY is a string of length 1, it is used as a key in
 `org-agenda-custom-commands' and triggers this command.  If it is a
-longer string is is used as a tags/todo match string.
+longer string it is used as a tags/todo match string.
 Paramters are alternating variable names and values that will be bound
 before running the agenda command.
 
 \(fn CMD-KEY &rest PARAMETERS)" nil (quote macro))
 
-(autoload (quote org-batch-agenda-csv) "org" "\
+(autoload 'org-batch-agenda-csv "org" "\
 Run an agenda command in batch mode and send the result to STDOUT.
 If CMD-KEY is a string of length 1, it is used as a key in
 `org-agenda-custom-commands' and triggers this command.  If it is a
-longer string is is used as a tags/todo match string.
+longer string it is used as a tags/todo match string.
 Paramters are alternating variable names and values that will be bound
 before running the agenda command.
 
@@ -310,24 +310,24 @@ agenda-day   The day in the agenda where this is listed
 
 \(fn CMD-KEY &rest PARAMETERS)" nil (quote macro))
 
-(autoload (quote org-store-agenda-views) "org" "\
+(autoload 'org-store-agenda-views "org" "\
 Not documented
 
 \(fn &rest PARAMETERS)" t nil)
 
-(autoload (quote org-batch-store-agenda-views) "org" "\
+(autoload 'org-batch-store-agenda-views "org" "\
 Run all custom agenda commands that have a file argument.
 
 \(fn &rest PARAMETERS)" nil (quote macro))
 
-(autoload (quote org-cycle-agenda-files) "org" "\
+(autoload 'org-cycle-agenda-files "org" "\
 Cycle through the files in `org-agenda-files'.
 If the current buffer visits an agenda file, find the next one in the list.
 If the current buffer does not, find the first agenda file.
 
 \(fn)" t nil)
 
-(autoload (quote org-agenda-list) "org" "\
+(autoload 'org-agenda-list "org" "\
 Produce a daily/weekly view from all files in variable `org-agenda-files'.
 The view will be for the current day or week, but from the overview buffer
 you will be able to go to other days/weeks.
@@ -346,7 +346,7 @@ given in `org-agenda-start-on-weekday'.
 
 \(fn &optional INCLUDE-ALL START-DAY NDAYS)" t nil)
 
-(autoload (quote org-todo-list) "org" "\
+(autoload 'org-todo-list "org" "\
 Show all TODO entries from all agenda file in a single list.
 The prefix arg can be used to select a specific TODO keyword and limit
 the list to these.  When using \\[universal-argument], you will be prompted
@@ -355,13 +355,13 @@ for a keyword.  A numeric prefix directly selects the Nth keyword in
 
 \(fn ARG)" t nil)
 
-(autoload (quote org-tags-view) "org" "\
+(autoload 'org-tags-view "org" "\
 Show all headlines for all `org-agenda-files' matching a TAGS criterion.
 The prefix arg TODO-ONLY limits the search to TODO entries.
 
 \(fn &optional TODO-ONLY MATCH)" t nil)
 
-(autoload (quote org-agenda-list-stuck-projects) "org" "\
+(autoload 'org-agenda-list-stuck-projects "org" "\
 Create agenda view for projects that are stuck.
 Stuck projects are project that have no next actions.  For the definitions
 of what a project is and how to check if it stuck, customize the variable
@@ -370,7 +370,7 @@ MATCH is being ignored.
 
 \(fn &rest IGNORE)" t nil)
 
-(autoload (quote org-diary) "org" "\
+(autoload 'org-diary "org" "\
 Return diary information from org-files.
 This function can be used in a \"sexp\" diary entry in the Emacs calendar.
 It accesses org files and extracts information from those files to be
@@ -418,21 +418,21 @@ function from a program - use `org-agenda-get-day-entries' instead.
 
 \(fn &rest ARGS)" nil nil)
 
-(autoload (quote org-export-icalendar-this-file) "org" "\
+(autoload 'org-export-icalendar-this-file "org" "\
 Export current file as an iCalendar file.
 The iCalendar file will be located in the same directory as the Org-mode
 file, but with extension `.ics'.
 
 \(fn)" t nil)
 
-(autoload (quote org-export-icalendar-all-agenda-files) "org" "\
+(autoload 'org-export-icalendar-all-agenda-files "org" "\
 Export all files in `org-agenda-files' to iCalendar .ics files.
 Each iCalendar file will be located in the same directory as the Org-mode
 file, but with extension `.ics'.
 
 \(fn)" t nil)
 
-(autoload (quote org-export-icalendar-combine-agenda-files) "org" "\
+(autoload 'org-export-icalendar-combine-agenda-files "org" "\
 Export all files in `org-agenda-files' to a single combined iCalendar file.
 The file is stored under the name `org-combined-agenda-icalendar-file'.
 
@@ -441,27 +441,27 @@ The file is stored under the name `org-combined-agenda-icalendar-file'.
 ;;;***
 
 ;;;### (autoloads (org-publish-all org-publish-current-file org-publish-current-project
-;;;;;;  org-publish) "org-publish" "org-publish.el" (18320 38272))
+;;;;;;  org-publish) "org-publish" "org-publish.el" (18337 60100))
 ;;; Generated autoloads from org-publish.el
 
-(autoload (quote org-publish) "org-publish" "\
+(autoload 'org-publish "org-publish" "\
 Publish the project PROJECT-NAME.
 
 \(fn PROJECT-NAME &optional FORCE)" t nil)
 
-(autoload (quote org-publish-current-project) "org-publish" "\
+(autoload 'org-publish-current-project "org-publish" "\
 Publish the project associated with the current file.
 With prefix argument, force publishing all files in project.
 
 \(fn &optional FORCE)" t nil)
 
-(autoload (quote org-publish-current-file) "org-publish" "\
+(autoload 'org-publish-current-file "org-publish" "\
 Publish the current file.
 With prefix argument, force publish the file.
 
 \(fn &optional FORCE)" t nil)
 
-(autoload (quote org-publish-all) "org-publish" "\
+(autoload 'org-publish-all "org-publish" "\
 Publish all projects.
 With prefix argument, force publish all files.
 
@@ -472,10 +472,10 @@ With prefix argument, force publish all files.
 ;;;### (autoloads (org-export-as-latex org-export-region-as-latex
 ;;;;;;  org-replace-region-by-latex org-export-as-latex-to-buffer
 ;;;;;;  org-export-as-latex-batch) "org-export-latex" "org-export-latex.el"
-;;;;;;  (18320 39683))
+;;;;;;  (18337 60100))
 ;;; Generated autoloads from org-export-latex.el
 
-(autoload (quote org-export-as-latex-batch) "org-export-latex" "\
+(autoload 'org-export-as-latex-batch "org-export-latex" "\
 Call `org-export-as-latex', may be used in batch processing as
 emacs 	--batch
 	--load=$HOME/lib/emacs/org.el
@@ -484,13 +484,13 @@ emacs 	--batch
 
 \(fn)" nil nil)
 
-(autoload (quote org-export-as-latex-to-buffer) "org-export-latex" "\
+(autoload 'org-export-as-latex-to-buffer "org-export-latex" "\
 Call `org-exort-as-latex` with output to a temporary buffer.
 No file is created.  The prefix ARG is passed through to `org-export-as-latex'.
 
 \(fn ARG)" t nil)
 
-(autoload (quote org-replace-region-by-latex) "org-export-latex" "\
+(autoload 'org-replace-region-by-latex "org-export-latex" "\
 Replace the region from BEG to END with its LaTeX export.
 It assumes the region has `org-mode' syntax, and then convert it to
 LaTeX.  This can be used in any buffer.  For example, you could
@@ -499,7 +499,7 @@ then use this command to convert it.
 
 \(fn BEG END)" t nil)
 
-(autoload (quote org-export-region-as-latex) "org-export-latex" "\
+(autoload 'org-export-region-as-latex "org-export-latex" "\
 Convert region from BEG to END in `org-mode' buffer to LaTeX.
 If prefix arg BODY-ONLY is set, omit file header, footer, and table of
 contents, and only produce the region of converted text, useful for
@@ -516,7 +516,7 @@ in a window.  A non-interactive call will only retunr the buffer.
 
 \(fn BEG END &optional BODY-ONLY BUFFER)" t nil)
 
-(autoload (quote org-export-as-latex) "org-export-latex" "\
+(autoload 'org-export-as-latex "org-export-latex" "\
 Export current buffer to a LaTeX file.
 If there is an active region, export only the region.  The prefix
 ARG specifies how many levels of the outline should become

+ 11 - 7
org-mac-message.el

@@ -1,14 +1,14 @@
 ;;; org-mac-message.el - Support for links to Apple Mail messages by Message-ID
 ;; Carstens outline-mode for keeping track of everything.
-;; Copyright (C) 2008 John Wiegley
+;; Copyright (C) 2008 Free Software Foundation, Inc.
 ;;
 ;; Author: John Wiegey <johnw@gnu.org>
 ;; Version: 1.2
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;;
-;; This file is not part of GNU Emacs.
+;; This file is part of GNU Emacs.
 ;;
-;; This file is free software; you can redistribute it and/or modify
+;; Emacs is free software; you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
 ;; the Free Software Foundation; either version 3, or (at your option)
 ;; any later version.
@@ -28,26 +28,30 @@
 
 (org-add-link-type "message" 'org-mac-message-open)
 
+(declare-function do-applescript "mac.c" (string))
 (unless (fboundp 'do-applescript)
   ;; Need to fake this using shell-command-to-string
   (defun do-applescript (script)
-    (let (start return)
+    (let (start cmd return)
       (while (string-match "\n" script)
 	(setq script (replace-match "\r" t t script)))
       (while (string-match "'" script start)
-	(setq start (+ 2 match-beginning 0)
+	(setq start (+ 2 (match-beginning 0))
 	      script (replace-match "\\'" t t script)))
       (setq cmd (concat "osascript -e '" script "'"))
       (setq return (shell-command-to-string cmd))
       (concat "\"" (org-trim return) "\""))))
 
 (defun org-mac-message-open (message-id)
-  "Visit the message with the given Message-ID."
+  "Visit the message with the given Message-ID.
+This will use the command `open' with the message url."
   (start-process (concat "open message:" message-id) nil
 		 "open" (concat "message://<" (substring message-id 2) ">")))
 
 (defun org-mac-message-insert-link ()
-  "Insrt a link to the messages currently selected in Apple Mail."
+  "Insert a link to the messages currently selected in Apple Mail.
+This will use applescript to get the message-id and the subject of the
+active mail in AppleMail and make a link out of it."
   (interactive)
   (let ((subject (do-applescript "tell application \"Mail\"
 	set theMessages to selection

+ 83 - 128
org.el

@@ -4218,6 +4218,7 @@ If it is less than 8, the level-1 face gets re-used for level N+1 etc."
 (declare-function parse-time-string "parse-time" (string))
 (declare-function remember "remember" (&optional initial))
 (declare-function remember-buffer-desc "remember" ())
+(declare-function remember-finalize "remember" ())
 (defvar remember-save-after-remembering)
 (defvar remember-data-file)
 (defvar remember-register)
@@ -5955,6 +5956,7 @@ the headline hierarchy above."
 
 (defvar org-goto-selected-point nil) ; dynamically scoped parameter
 (defvar org-goto-exit-command nil) ; dynamically scoped parameter
+(defvar org-goto-local-auto-isearch-map) ; defined below
 
 (defun org-get-location (buf help)
   "Let the user select a location in the Org-mode buffer BUF.
@@ -6990,52 +6992,89 @@ Return t when things worked, nil when we are not in an item."
     (org-update-checkbox-count)))
 
 (defun org-update-checkbox-count (&optional all)
-  "Update the checkbox statistics in the current section.
+ "Update the checkbox statistics in the current section.
 This will find all statistic cookies like [57%] and [6/12] and update them
 with the current numbers.  With optional prefix argument ALL, do this for
 the whole buffer."
-  (interactive "P")
-  (save-excursion
-    (let* ((buffer-invisibility-spec (org-inhibit-invisibility)) ; Emacs 21
-	   (beg (condition-case nil
-		    (progn (outline-back-to-heading) (point))
-		  (error (point-min))))
-	   (end (move-marker (make-marker)
-			     (progn (outline-next-heading) (point))))
-	   (re "\\(\\[[0-9]*%\\]\\)\\|\\(\\[[0-9]*/[0-9]*\\]\\)")
-	   (re-box "^[ \t]*\\([-+*]\\|[0-9]+[.)]\\) +\\(\\[[- X]\\]\\)")
-	   b1 e1 f1 c-on c-off lim (cstat 0))
-      (when all
-	(goto-char (point-min))
-	(outline-next-heading)
-	(setq beg (point) end (point-max)))
-      (goto-char beg)
-      (while (re-search-forward re end t)
-	(setq cstat (1+ cstat)
-	      b1 (match-beginning 0)
-	      e1 (match-end 0)
-	      f1 (match-beginning 1)
-	      lim (cond
-		   ((org-on-heading-p) (outline-next-heading) (point))
-		   ((org-at-item-p) (org-end-of-item) (point))
-		   (t nil))
-	      c-on 0 c-off 0)
-	(goto-char e1)
-	(when lim
-	  (while (re-search-forward re-box lim t)
-	    (if (member (match-string 2) '("[ ]" "[-]"))
-		(setq c-off (1+ c-off))
-	      (setq c-on (1+ c-on))))
-;	  (delete-region b1 e1)
-	  (goto-char b1)
-	  (insert (if f1
-		      (format "[%d%%]" (/ (* 100 c-on) (max 1 (+ c-on c-off))))
-		    (format "[%d/%d]" c-on (+ c-on c-off))))
-	  (and (looking-at "\\[.*?\\]")
-	       (replace-match ""))))
-      (when (interactive-p)
-	(message "Checkbox satistics updated %s (%d places)"
-		 (if all "in entire file" "in current outline entry") cstat)))))
+ (interactive "P")
+ (save-excursion
+   (let* ((buffer-invisibility-spec (org-inhibit-invisibility)) ; Emacs 21
+	  (beg (condition-case nil
+		   (progn (outline-back-to-heading) (point))
+		 (error (point-min))))
+	  (end (move-marker (make-marker)
+			    (progn (outline-next-heading) (point))))
+	  (re "\\(\\(\\[[0-9]*%\\]\\)\\|\\(\\[[0-9]*/[0-9]*\\]\\)\\)")
+	  (re-box "^[ \t]*\\([-+*]\\|[0-9]+[.)]\\) +\\(\\[[- X]\\]\\)")
+	  (re-find (concat re "\\|" re-box))
+	  beg-cookie end-cookie is-percent c-on c-off lim
+          eline curr-ind next-ind continue-from startsearch
+          (cstat 0)
+          )
+     (when all
+       (goto-char (point-min))
+       (outline-next-heading)
+       (setq beg (point) end (point-max)))
+     (goto-char end)
+     ;; find each statistic cookie
+     (while (re-search-backward re-find beg t)
+       (setq beg-cookie (match-beginning 1)
+             end-cookie (match-end 1)
+	     cstat (+ cstat (if end-cookie 1 0))
+	     startsearch (point-at-eol)
+	     continue-from (point-at-bol)
+             is-percent (match-beginning 2)
+	     lim (cond
+		  ((org-on-heading-p) (outline-next-heading) (point))
+		  ((org-at-item-p) (org-end-of-item) (point))
+		  (t nil))
+             c-on 0
+             c-off 0)
+       (when lim
+         ;; find first checkbox for this cookie and gather
+         ;; statistics from all that are at this indentation level
+         (goto-char startsearch)
+         (if (re-search-forward re-box lim t)
+             (progn
+               (org-beginning-of-item)
+               (setq curr-ind (org-get-indentation))
+               (setq next-ind curr-ind)
+               (while (= curr-ind next-ind)
+                 (save-excursion (end-of-line) (setq eline (point)))
+                 (if (re-search-forward re-box eline t)
+		     (if (member (match-string 2) '("[ ]" "[-]"))
+			 (setq c-off (1+ c-off))
+                       (setq c-on (1+ c-on))
+                       )
+                   )
+                 (org-end-of-item)
+                 (setq next-ind (org-get-indentation))
+                 )))
+         ;; update cookie
+	 (when end-cookie
+	   (delete-region beg-cookie end-cookie)
+	   (goto-char beg-cookie)
+	   (insert
+	    (if is-percent
+		(format "[%d%%]" (/ (* 100 c-on) (max 1 (+ c-on c-off))))
+	      (format "[%d/%d]" c-on (+ c-on c-off)))))
+         ;; update items checkbox if it has one
+         (when (org-at-item-p)
+           (org-beginning-of-item)
+           (when (and (> (+ c-on c-off) 0)
+		      (re-search-forward re-box (point-at-eol) t))
+             (setq beg-cookie (match-beginning 2)
+                   end-cookie (match-end       2))
+             (delete-region beg-cookie end-cookie)
+             (goto-char beg-cookie)
+             (cond ((= c-off 0) (insert "[X]"))
+                   ((= c-on  0) (insert "[ ]"))
+                   (t           (insert "[-]")))
+             )))
+       (goto-char continue-from))
+     (when (interactive-p)
+       (message "Checkbox satistics updated %s (%d places)"
+		(if all "in entire file" "in current outline entry") cstat)))))
 
 (defun org-get-checkbox-statistics-face ()
   "Select the face for checkbox statistics.
@@ -13568,6 +13607,7 @@ from that hook."
   (when org-finish-function
     (funcall org-finish-function)))
 
+(defvar org-clock-marker) ; Defined below
 (defun org-remember-finalize ()
   "Finalize the remember process."
   (unless (fboundp 'remember-finalize)
@@ -28087,91 +28127,6 @@ Still experimental, may disappear in the future."
     ;; make tree, check each match with the callback
     (org-occur "CLOSED: +\\[\\(.*?\\)\\]" nil callback)))
 
-
-
-(defun org-update-checkbox-count (&optional all)
- "Update the checkbox statistics in the current section.
-This will find all statistic cookies like [57%] and [6/12] and update them
-with the current numbers.  With optional prefix argument ALL, do this for
-the whole buffer."
- (interactive "P")
- (save-excursion
-   (let* ((buffer-invisibility-spec (org-inhibit-invisibility)) ; Emacs 21
-	  (beg (condition-case nil
-		   (progn (outline-back-to-heading) (point))
-		 (error (point-min))))
-	  (end (move-marker (make-marker)
-			    (progn (outline-next-heading) (point))))
-	  (re "\\(\\[[0-9]*%\\]\\)\\|\\(\\[[0-9]*/[0-9]*\\]\\)")
-	  (re-box "^[ \t]*\\([-+*]\\|[0-9]+[.)]\\) +\\(\\[[- X]\\]\\)")
-	  beg-cookie end-cookie is-percent c-on c-off lim
-          eline curr-ind next-ind
-          (cstat 0)
-          )
-     (when all
-       (goto-char (point-min))
-       (outline-next-heading)
-       (setq beg (point) end (point-max)))
-     (goto-char end)
-     ;; find each statistic cookie
-     (while (re-search-backward re beg t)
-       (setq cstat (1+ cstat)
-             beg-cookie (match-beginning 0)
-             end-cookie (match-end       0)
-             is-percent (match-beginning 1)
-	     lim (cond
-		  ((org-on-heading-p) (outline-next-heading) (point))
-		  ((org-at-item-p) (org-end-of-item) (point))
-		  (t nil))
-             c-on  0
-             c-off 0
-             )
-       (when lim
-         ;; find first checkbox for this cookie and gather
-         ;; statistics from all that are at this indentation level
-         (goto-char end-cookie)
-         (if (re-search-forward re-box lim t)
-             (progn
-               (org-beginning-of-item)
-               (setq curr-ind (org-get-indentation))
-               (setq next-ind curr-ind)
-               (while (= curr-ind next-ind)
-                 (save-excursion (end-of-line) (setq eline (point)))
-                 (if (re-search-forward re-box eline t)
-		     (if (member (match-string 2) '("[ ]" "[-]"))
-			 (setq c-off (1+ c-off))
-                       (setq c-on (1+ c-on))
-                       )
-                   )
-                 (org-end-of-item)
-                 (setq next-ind (org-get-indentation))
-                 )))
-         ;; update cookie
-         (delete-region beg-cookie end-cookie)
-         (goto-char beg-cookie)
-         (insert
-          (if is-percent
-	      (format "[%d%%]" (/ (* 100 c-on) (max 1 (+ c-on c-off))))
-	    (format "[%d/%d]" c-on (+ c-on c-off))))
-         ;; update items checkbox if it has one
-         (when (org-at-item-p)
-           (org-beginning-of-item)
-           (save-excursion (end-of-line) (setq eline (point)))
-           (when (re-search-forward re-box eline t)
-             (setq beg-cookie (match-beginning 2)
-                   end-cookie (match-end       2))
-             (delete-region beg-cookie end-cookie)
-             (goto-char beg-cookie)
-             (cond ((= c-off 0) (insert "[X]"))
-                   ((= c-on  0) (insert "[ ]"))
-                   (t           (insert "[-]")))
-             )))
-       (goto-char beg-cookie)
-       )
-     (when (interactive-p)
-       (message "Checkbox satistics updated %s (%d places)"
-		(if all "in entire file" "in current outline entry") cstat)))))
-
 ;;;; Finish up
 
 (provide 'org)