From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jari Aalto Subject: Re: [PATCH] Update both indicators: [/] and [%] Date: Sun, 21 Dec 2008 02:50:30 +0200 Message-ID: <87ej02s65l.fsf@jondo.cante.net> References: <87iqpesl75.fsf@jondo.cante.net> <275A94E5-0E4D-4583-8218-2C9F693DF673@uva.nl> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LECWs-0005q0-Ms for emacs-orgmode@gnu.org; Sat, 20 Dec 2008 19:50:46 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LECWq-0005pb-4u for emacs-orgmode@gnu.org; Sat, 20 Dec 2008 19:50:45 -0500 Received: from [199.232.76.173] (port=51707 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LECWp-0005pY-VC for emacs-orgmode@gnu.org; Sat, 20 Dec 2008 19:50:43 -0500 Received: from main.gmane.org ([80.91.229.2]:40591 helo=ciao.gmane.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LECWp-0004h3-Do for emacs-orgmode@gnu.org; Sat, 20 Dec 2008 19:50:43 -0500 Received: from list by ciao.gmane.org with local (Exim 4.43) id 1LECWl-0000o3-7u for emacs-orgmode@gnu.org; Sun, 21 Dec 2008 00:50:39 +0000 Received: from a91-155-187-216.elisa-laajakaista.fi ([91.155.187.216]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 21 Dec 2008 00:50:39 +0000 Received: from jari.aalto by a91-155-187-216.elisa-laajakaista.fi with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 21 Dec 2008 00:50:39 +0000 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Carsten Dominik writes: > Hi Jari, > > if I try to fetch from your repo, git download in excess o 10MB, so > something must be wrong here. Can you please post a patch? > Hm, the repo is copy of yours. I'll see it later. Jari >From 9f64abd92bad42d7b8e0f5e6cfe61e88e18c907c Mon Sep 17 00:00:00 2001 From: Jari Aalto Date: Sun, 21 Dec 2008 02:49:40 +0200 Subject: [PATCH] org.el: (org-update-parent-todo-statistics): update both indicators Signed-off-by: Jari Aalto --- lisp/ChangeLog | 8 ++++++++ lisp/org.el | 17 ++++++++++++----- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index bec5200..c38c4e5 100755 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,11 @@ +2008-12-20 Jari Aalto + + * org.el (org-update-parent-todo-statistics-1): New function. + Accept argument RE to update paricular statistics. + (org-update-parent-todo-statistics): Move functionality + to `org-update-parent-todo-statistics-1'. Update both + indicators: [/] and [%]. + 2008-12-20 Carsten Dominik * org.el (org-get-refile-targets, org-refile-get-location): Use diff --git a/lisp/org.el b/lisp/org.el index 2e2f953..d4b3c40 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -8304,10 +8304,9 @@ For calling through lisp, arg is also interpreted in the following way: (save-excursion (run-hook-with-args 'org-trigger-hook change-plist))))))) -(defun org-update-parent-todo-statistics () - "Update any statistics cookie in the parent of the current headline." - (interactive) - (let ((box-re "\\(\\(\\[[0-9]*%\\]\\)\\|\\(\\[[0-9]*/[0-9]*\\]\\)\\)") +(defun org-update-parent-todo-statistics-1 (re) + "Update statistics cookie matching RE in the parent of the current headline." + (let ((box-re re) level (cnt-all 0) (cnt-done 0) is-percent kwd) (catch 'exit (save-excursion @@ -8315,7 +8314,8 @@ For calling through lisp, arg is also interpreted in the following way: (unless (and level (re-search-forward box-re (point-at-eol) t)) (throw 'exit nil)) - (setq is-percent (match-end 2)) + (if (save-match-data (string-match "%" (match-string 0))) + (setq is-percent t)) (save-match-data (unless (outline-next-heading) (throw 'exit nil)) (while (looking-at org-todo-line-regexp) @@ -8333,6 +8333,13 @@ For calling through lisp, arg is also interpreted in the following way: (run-hook-with-args 'org-after-todo-statistics-hook cnt-done (- cnt-all cnt-done)))))) +(defun org-update-parent-todo-statistics () + "Update any statistics cookie in the parent of the current headline." + (interactive) + (dolist (re '("\\(\\[[0-9]*%\\]\\)" + "\\(\\[[0-9]*/[0-9]*\\]\\)")) + (org-update-parent-todo-statistics-1 re))) + (defvar org-after-todo-statistics-hook nil "Hook that is called after a TODO statistics cookie has been updated. Each function is called with two arguments: the number of not-done entries -- 1.6.0.2