emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Jari Aalto <jari.aalto@cante.net>
To: emacs-orgmode@gnu.org
Subject: Re: [PATCH] Update both indicators: [/] and [%]
Date: Sun, 21 Dec 2008 02:50:30 +0200	[thread overview]
Message-ID: <87ej02s65l.fsf@jondo.cante.net> (raw)
In-Reply-To: <275A94E5-0E4D-4583-8218-2C9F693DF673@uva.nl>

Carsten Dominik <dominik@science.uva.nl> 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 <jari.aalto@cante.net>
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 <jari.aalto@cante.net>
---
 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  <jari.aalto@cante.net>
+
+	* 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  <carsten.dominik@gmail.com>
 
 	* 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

  reply	other threads:[~2008-12-21  0:50 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-20 19:25 Jari Aalto
2008-12-20 20:35 ` Carsten Dominik
2008-12-21  0:50   ` Jari Aalto [this message]
2008-12-21  5:55     ` Bernt Hansen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ej02s65l.fsf@jondo.cante.net \
    --to=jari.aalto@cante.net \
    --cc=emacs-orgmode@gnu.org \
    --subject='Re: [PATCH] Update both indicators: [/] and [%]' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Code repositories for project(s) associated with this inbox:

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).