Re: [O] [PATCH] Display a count of items next to each list (or block)

2013-10-01 Thread Bernt Hansen


Bernt Hansen  writes:

> "Sebastien Vauban" 
> writes:
>
>> 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.
>
> This patch doesn't report correct counts when a compact agenda is used
> and you filter by some task that doesn't match any entries in your
> block.

This patch also breaks the default N and P key bindings which skips over
uninteresting lines in the agenda.

Regards,
Bernt




Re: [O] [PATCH] Display a count of items next to each list (or block)

2013-09-30 Thread Sebastien Vauban
Hi Bernt,

Bernt Hansen wrote:
> "Sebastien Vauban" writes:
>
>> 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.
>
> This patch doesn't report correct counts when a compact agenda is used and
> you filter by some task that doesn't match any entries in your block.
>
> The block is empty and shows no tasks but the counter is incorrect.
>
> ;; Compact the block agenda view
> (setq org-agenda-compact-blocks t)
>
> Filter by some tag not in these blocks
>
> / TAB PERSONAL RET
>
> Tasks to Refile (15/0)
> Stuck Projects (15/1)
>
> If the counts are correct I think this makes a good addition to org-mode.

Thanks for testing!

I may have a hard time when there is no explicit separator between blocks.
Though, I'll try to fix it ASAP and come back with a solution for that edge
case.

Best regards,
  Seb

-- 
Sebastien Vauban




Re: [O] [PATCH] Display a count of items next to each list (or block)

2013-09-28 Thread Bernt Hansen


"Sebastien Vauban" 
writes:

> 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.

This patch doesn't report correct counts when a compact agenda is used
and you filter by some task that doesn't match any entries in your
block.

The block is empty and shows no tasks but the counter is incorrect.

--8<---cut here---start->8---
;; Compact the block agenda view
(setq org-agenda-compact-blocks t)
--8<---cut here---end--->8---

Filter by some tag not in these blocks

/ TAB PERSONAL RET

--8<---cut here---start->8---
Tasks to Refile (15/0)
Stuck Projects (15/1)
--8<---cut here---end--->8---

If the counts are correct I think this makes a good addition to org-mode.

Regards,
Bernt




Re: [O] [PATCH] Display a count of items next to each list (or block)

2013-09-26 Thread Sebastien Vauban
Hi Achim,

Achim Gratz wrote:
> Am 25.09.2013 22:09, schrieb Sebastien Vauban:
>> 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).
>
> Minor nit: to my ears "item count" sounds better than "count of items".

No problem (I'm no English native speaker, and I'm glad when I'm corrected, for
improving myself).

You then mean you'd rename the variable (and potentially other comments or
names in the code)?  To `org-agenda-display-item-count'
 or `org-agenda-display-items-count'?

Best regards,
  Seb

-- 
Sebastien Vauban




Re: [O] [PATCH] Display a count of items next to each list (or block)

2013-09-26 Thread Achim Gratz

Am 25.09.2013 22:09, schrieb Sebastien Vauban:

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).


Minor nit: to my ears "item count" sounds better than "count of items".

Achim.






[O] [PATCH] Display a count of items next to each list (or block)

2013-09-25 Thread Sebastien Vauban
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" 
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))