Hello,
In order to make Org much nicer to use, I felt we missed a count of items next
to the lists (or blocks, for multi-block agenda views). Here is a patch to add
this, depending on the new variable `org-agenda-display-count-of-items'
(enabled by default).
The count of items must be updated when you apply tag filtering on lists. The
patch does it as well.
Please enjoy (or be scared by the real number of items you have on your TODO
lists)!!
Best regards,
Seb
From: Sebastien Vauban sva-n...@mygooglest.com
Date: Wed, 25 Sep 2013 21:56:01 +0200
Subject: [PATCH] Display a count of items next to each list (or block)
* org-agenda.el (org-agenda-display-count-of-items): New variable.
(org-agenda-insert-count-of-items)
(org-agenda-count-visible-lines-block)
(org-agenda-remove-filtered-count): New helper functions.
(org-search-view, org-todo-list, org-tags-view): Add count of
items.
(org-agenda-filter-by-tag, org-agenda-filter-apply): Add or
remove filtered count of items.
(org-agenda-goto-block-beginning): Fix problems for position
of point.
(org-agenda-goto-next-block): New command.
---
lisp/org-agenda.el | 89 ---
1 files changed, 83 insertions(+), 6 deletions(-)
diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index c48da91..336991f 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -4652,6 +4652,8 @@ in `org-agenda-text-search-extra-files'.
(when rtnall
(insert (org-agenda-finalize-entries rtnall 'search) \n))
(goto-char (point-min))
+ (when org-agenda-display-count-of-items
+ (org-agenda-insert-count-of-items rtnall))
(or org-agenda-multi (org-agenda-fit-window-to-buffer))
(add-text-properties (point-min) (point-max)
`(org-agenda-type search
@@ -4663,6 +4665,46 @@ in `org-agenda-text-search-extra-files'.
;;; Agenda TODO list
+(defvar org-agenda-display-count-of-items t
+ Display count of items next to each list.)
+
+(defun org-agenda-insert-count-of-items (count)
+ Insert count of items at the end of current line.
+ (save-excursion
+(end-of-line)
+(insert
+ (org-add-props (format (%s) (length rtnall)) nil
+ 'face 'org-agenda-block-count
+
+(defun org-agenda-count-visible-lines-block ()
+ Count the number of items visible in the current block.
+ (interactive)
+ (let ((count 0))
+(save-excursion
+ (org-agenda-goto-block-beginning)
+ (while (equal (get-char-property (point) 'face) 'org-agenda-structure) ;
header line(s)
+ (forward-visible-line 1))
+ (while (or (equal (get-char-property (point) 'face) 'default)
+(equal (get-char-property (point) 'type) tagsmatch)
+(equal (get-char-property (point) 'type) todo)) ; entry line
+ (unless (get-char-property (point) 'invisible)
+ (setq count (1+ count)))
+ (forward-visible-line 1))
+ count)))
+
+(defun org-agenda-remove-filtered-count ()
+ Remove `X/' from filtered count string `(X/Y)'.
+
+Leaves point at total count.
+ (org-agenda-goto-block-beginning)
+ (while (not (equal (get-text-property (point) 'face)
+'org-agenda-block-count))
+(forward-char))
+ (forward-char); for (
+ (when (looking-at [0-9]*/)
+(kill-word 1) ; digits
+(delete-char 1))) ; slash
+
(defun org-agenda-propertize-selected-todo-keywords (keywords)
Use `org-todo-keyword-faces' for the selected todo KEYWORDS.
(concat
@@ -4753,6 +4795,8 @@ for a keyword. A numeric prefix directly selects the Nth
keyword in
(when rtnall
(insert (org-agenda-finalize-entries rtnall 'todo) \n))
(goto-char (point-min))
+ (when org-agenda-display-count-of-items
+ (org-agenda-insert-count-of-items rtnall))
(or org-agenda-multi (org-agenda-fit-window-to-buffer))
(add-text-properties (point-min) (point-max)
`(org-agenda-type todo
@@ -4840,6 +4884,8 @@ The prefix arg TODO-ONLY limits the search to TODO
entries.
(when rtnall
(insert (org-agenda-finalize-entries rtnall 'tags) \n))
(goto-char (point-min))
+ (when org-agenda-display-count-of-items
+ (org-agenda-insert-count-of-items rtnall))
(or org-agenda-multi (org-agenda-fit-window-to-buffer))
(add-text-properties (point-min) (point-max)
`(org-agenda-type tags
@@ -7448,6 +7494,13 @@ to switch to narrowing.
(org-agenda-filter-show-all-tag)
(when (get 'org-agenda-tag-filter :preset-filter)
(org-agenda-filter-apply org-agenda-tag-filter 'tag))
+ ;; count of items
+ (when org-agenda-display-count-of-items
+ (save-excursion
+ (goto-char (point-min)) ; beginning of first block
+ (while (or (equal (point) (point-min))
+