emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/org 22050243b8 1/3: org-update-parent-todo-statistics:


From: ELPA Syncer
Subject: [elpa] externals/org 22050243b8 1/3: org-update-parent-todo-statistics: Use parser to match statistics cookie
Date: Mon, 29 Jan 2024 12:58:42 -0500 (EST)

branch: externals/org
commit 22050243b8dff72c7ace976fcf6d036f9b9d0cda
Author: Ihor Radchenko <yantar92@posteo.net>
Commit: Ihor Radchenko <yantar92@posteo.net>

    org-update-parent-todo-statistics: Use parser to match statistics cookie
    
    * lisp/org.el (org-update-parent-todo-statistics): Ignore text
    matching statistics cookie that is inside verbatim environments or
    otherwise not detected by parser.  Leave a single exception for
    headline properties for backwards compatibility.
---
 lisp/org.el | 89 +++++++++++++++++++++++++++++++++----------------------------
 1 file changed, 48 insertions(+), 41 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index 7afb10766e..2dcff7be9b 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -9779,49 +9779,56 @@ statistics everywhere."
           (while (re-search-forward box-re (line-end-position) t)
            (setq cnt-all 0 cnt-done 0 cookie-present t)
            (setq is-percent (match-end 2) checkbox-beg (match-beginning 0))
-           (save-match-data
-             (unless (outline-next-heading) (throw 'exit nil))
-             (while (and (looking-at org-complex-heading-regexp)
-                         (> (setq l1 (length (match-string 1))) level))
-               (setq kwd (and (or recursive (= l1 ltoggle))
-                              (match-string 2)))
-               (if (or (eq org-provide-todo-statistics 'all-headlines)
-                       (and (eq org-provide-todo-statistics t)
-                            (or (member kwd org-done-keywords)))
-                       (and (listp org-provide-todo-statistics)
-                            (stringp (car org-provide-todo-statistics))
-                            (or (member kwd org-provide-todo-statistics)
-                                (member kwd org-done-keywords)))
-                       (and (listp org-provide-todo-statistics)
-                            (listp (car org-provide-todo-statistics))
-                            (or (member kwd (car org-provide-todo-statistics))
-                                (and (member kwd org-done-keywords)
-                                     (member kwd (cadr 
org-provide-todo-statistics))))))
-                   (setq cnt-all (1+ cnt-all))
-                 (and (eq org-provide-todo-statistics t)
-                      kwd
-                      (setq cnt-all (1+ cnt-all))))
-               (when (or (and (member org-provide-todo-statistics '(t 
all-headlines))
-                              (member kwd org-done-keywords))
+            (when (org-element-type-p
+                   (save-excursion
+                     (goto-char checkbox-beg)
+                     (save-match-data (org-element-context)))
+                   '(statistics-cookie
+                     ;; Special case - statistics cookie inside properties.
+                     keyword))
+             (save-match-data
+               (unless (outline-next-heading) (throw 'exit nil))
+               (while (and (looking-at org-complex-heading-regexp)
+                           (> (setq l1 (length (match-string 1))) level))
+                 (setq kwd (and (or recursive (= l1 ltoggle))
+                                (match-string 2)))
+                 (if (or (eq org-provide-todo-statistics 'all-headlines)
+                         (and (eq org-provide-todo-statistics t)
+                              (or (member kwd org-done-keywords)))
+                         (and (listp org-provide-todo-statistics)
+                              (stringp (car org-provide-todo-statistics))
+                              (or (member kwd org-provide-todo-statistics)
+                                  (member kwd org-done-keywords)))
                          (and (listp org-provide-todo-statistics)
                               (listp (car org-provide-todo-statistics))
-                              (member kwd org-done-keywords)
-                              (member kwd (cadr org-provide-todo-statistics)))
-                         (and (listp org-provide-todo-statistics)
-                              (stringp (car org-provide-todo-statistics))
-                              (member kwd org-done-keywords)))
-                 (setq cnt-done (1+ cnt-done)))
-               (outline-next-heading)))
-           (setq new
-                 (if is-percent
-                     (format "[%d%%]" (floor (* 100.0 cnt-done)
-                                             (max 1 cnt-all)))
-                   (format "[%d/%d]" cnt-done cnt-all))
-                 ndel (- (match-end 0) checkbox-beg))
-           (goto-char checkbox-beg)
-           (insert new)
-           (delete-region (point) (+ (point) ndel))
-           (when org-auto-align-tags (org-fix-tags-on-the-fly)))
+                              (or (member kwd (car 
org-provide-todo-statistics))
+                                  (and (member kwd org-done-keywords)
+                                       (member kwd (cadr 
org-provide-todo-statistics))))))
+                     (setq cnt-all (1+ cnt-all))
+                   (and (eq org-provide-todo-statistics t)
+                        kwd
+                        (setq cnt-all (1+ cnt-all))))
+                 (when (or (and (member org-provide-todo-statistics '(t 
all-headlines))
+                                (member kwd org-done-keywords))
+                           (and (listp org-provide-todo-statistics)
+                                (listp (car org-provide-todo-statistics))
+                                (member kwd org-done-keywords)
+                                (member kwd (cadr 
org-provide-todo-statistics)))
+                           (and (listp org-provide-todo-statistics)
+                                (stringp (car org-provide-todo-statistics))
+                                (member kwd org-done-keywords)))
+                   (setq cnt-done (1+ cnt-done)))
+                 (outline-next-heading)))
+             (setq new
+                   (if is-percent
+                       (format "[%d%%]" (floor (* 100.0 cnt-done)
+                                               (max 1 cnt-all)))
+                     (format "[%d/%d]" cnt-done cnt-all))
+                   ndel (- (match-end 0) checkbox-beg))
+             (goto-char checkbox-beg)
+             (insert new)
+             (delete-region (point) (+ (point) ndel))
+             (when org-auto-align-tags (org-fix-tags-on-the-fly))))
          (when cookie-present
            (run-hook-with-args 'org-after-todo-statistics-hook
                                cnt-done (- cnt-all cnt-done))))))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]