forked from mirrors/org-mode
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.
This commit is contained in:
parent
522d7d0afe
commit
22050243b8
89
lisp/org.el
89
lisp/org.el
|
@ -9779,49 +9779,56 @@ statistics everywhere."
|
||||||
(while (re-search-forward box-re (line-end-position) t)
|
(while (re-search-forward box-re (line-end-position) t)
|
||||||
(setq cnt-all 0 cnt-done 0 cookie-present t)
|
(setq cnt-all 0 cnt-done 0 cookie-present t)
|
||||||
(setq is-percent (match-end 2) checkbox-beg (match-beginning 0))
|
(setq is-percent (match-end 2) checkbox-beg (match-beginning 0))
|
||||||
(save-match-data
|
(when (org-element-type-p
|
||||||
(unless (outline-next-heading) (throw 'exit nil))
|
(save-excursion
|
||||||
(while (and (looking-at org-complex-heading-regexp)
|
(goto-char checkbox-beg)
|
||||||
(> (setq l1 (length (match-string 1))) level))
|
(save-match-data (org-element-context)))
|
||||||
(setq kwd (and (or recursive (= l1 ltoggle))
|
'(statistics-cookie
|
||||||
(match-string 2)))
|
;; Special case - statistics cookie inside properties.
|
||||||
(if (or (eq org-provide-todo-statistics 'all-headlines)
|
keyword))
|
||||||
(and (eq org-provide-todo-statistics t)
|
(save-match-data
|
||||||
(or (member kwd org-done-keywords)))
|
(unless (outline-next-heading) (throw 'exit nil))
|
||||||
(and (listp org-provide-todo-statistics)
|
(while (and (looking-at org-complex-heading-regexp)
|
||||||
(stringp (car org-provide-todo-statistics))
|
(> (setq l1 (length (match-string 1))) level))
|
||||||
(or (member kwd org-provide-todo-statistics)
|
(setq kwd (and (or recursive (= l1 ltoggle))
|
||||||
(member kwd org-done-keywords)))
|
(match-string 2)))
|
||||||
(and (listp org-provide-todo-statistics)
|
(if (or (eq org-provide-todo-statistics 'all-headlines)
|
||||||
(listp (car org-provide-todo-statistics))
|
(and (eq org-provide-todo-statistics t)
|
||||||
(or (member kwd (car org-provide-todo-statistics))
|
(or (member kwd org-done-keywords)))
|
||||||
(and (member kwd org-done-keywords)
|
(and (listp org-provide-todo-statistics)
|
||||||
(member kwd (cadr org-provide-todo-statistics))))))
|
(stringp (car org-provide-todo-statistics))
|
||||||
(setq cnt-all (1+ cnt-all))
|
(or (member kwd org-provide-todo-statistics)
|
||||||
(and (eq org-provide-todo-statistics t)
|
(member kwd org-done-keywords)))
|
||||||
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)
|
(and (listp org-provide-todo-statistics)
|
||||||
(listp (car org-provide-todo-statistics))
|
(listp (car org-provide-todo-statistics))
|
||||||
(member kwd org-done-keywords)
|
(or (member kwd (car org-provide-todo-statistics))
|
||||||
(member kwd (cadr org-provide-todo-statistics)))
|
(and (member kwd org-done-keywords)
|
||||||
(and (listp org-provide-todo-statistics)
|
(member kwd (cadr org-provide-todo-statistics))))))
|
||||||
(stringp (car org-provide-todo-statistics))
|
(setq cnt-all (1+ cnt-all))
|
||||||
(member kwd org-done-keywords)))
|
(and (eq org-provide-todo-statistics t)
|
||||||
(setq cnt-done (1+ cnt-done)))
|
kwd
|
||||||
(outline-next-heading)))
|
(setq cnt-all (1+ cnt-all))))
|
||||||
(setq new
|
(when (or (and (member org-provide-todo-statistics '(t all-headlines))
|
||||||
(if is-percent
|
(member kwd org-done-keywords))
|
||||||
(format "[%d%%]" (floor (* 100.0 cnt-done)
|
(and (listp org-provide-todo-statistics)
|
||||||
(max 1 cnt-all)))
|
(listp (car org-provide-todo-statistics))
|
||||||
(format "[%d/%d]" cnt-done cnt-all))
|
(member kwd org-done-keywords)
|
||||||
ndel (- (match-end 0) checkbox-beg))
|
(member kwd (cadr org-provide-todo-statistics)))
|
||||||
(goto-char checkbox-beg)
|
(and (listp org-provide-todo-statistics)
|
||||||
(insert new)
|
(stringp (car org-provide-todo-statistics))
|
||||||
(delete-region (point) (+ (point) ndel))
|
(member kwd org-done-keywords)))
|
||||||
(when org-auto-align-tags (org-fix-tags-on-the-fly)))
|
(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
|
(when cookie-present
|
||||||
(run-hook-with-args 'org-after-todo-statistics-hook
|
(run-hook-with-args 'org-after-todo-statistics-hook
|
||||||
cnt-done (- cnt-all cnt-done))))))
|
cnt-done (- cnt-all cnt-done))))))
|
||||||
|
|
Loading…
Reference in New Issue