Ver Fonte

Refresh agenda when updating the filter while the clock report is following

* lisp/org-agenda.el (org-agenda-filter-by-tag): Refresh agenda when
updating the filter while the clock report is following the filter.

When the clock table in the agenda has been set up to respect the
current agenda tags filter, modifying the filter will now
automatically rebuild the agenda to make sure that also the clock
report is updated along with it.  Updating the entire agenda is not
strictly necessary - updating the table would be enough.  However,
right now we do not really have a function that will update only the
clock table, as inserting the table is currently part of building the
agenda itself.  Maybe someone can optimize this in the future.

This feature was requested by Sebastien Vauban.
Carsten Dominik há 14 anos atrás
pai
commit
09c5ff8359
1 ficheiros alterados com 12 adições e 7 exclusões
  1. 12 7
      lisp/org-agenda.el

+ 12 - 7
lisp/org-agenda.el

@@ -3609,7 +3609,7 @@ given in `org-agenda-start-on-weekday'."
     (when (and org-agenda-clockreport-mode clocktable-start)
     (when (and org-agenda-clockreport-mode clocktable-start)
       (let ((org-agenda-files (org-agenda-files nil 'ifmode))
       (let ((org-agenda-files (org-agenda-files nil 'ifmode))
 	    ;; the above line is to ensure the restricted range!
 	    ;; the above line is to ensure the restricted range!
-	    (p org-agenda-clockreport-parameter-plist)
+	    (p (copy-sequence org-agenda-clockreport-parameter-plist))
 	    tbl)
 	    tbl)
 	(setq p (org-plist-delete p :block))
 	(setq p (org-plist-delete p :block))
 	(setq p (plist-put p :tstart clocktable-start))
 	(setq p (plist-put p :tstart clocktable-start))
@@ -3623,7 +3623,6 @@ given in `org-agenda-start-on-weekday'."
 						      ""
 						      ""
 						    x))
 						    x))
 						filter ""))))
 						filter ""))))
-	(message "%s" (plist-get p :tags)) (sit-for 2)
 	(setq tbl (apply 'org-get-clocktable p))
 	(setq tbl (apply 'org-get-clocktable p))
 	(insert tbl)))
 	(insert tbl)))
     (goto-char (point-min))
     (goto-char (point-min))
@@ -5922,7 +5921,7 @@ to switch to narrowing."
 	 (effort-prompt "")
 	 (effort-prompt "")
 	 (inhibit-read-only t)
 	 (inhibit-read-only t)
 	 (current org-agenda-filter)
 	 (current org-agenda-filter)
-	 a n tag)
+	 maybe-reftresh a n tag)
     (unless char
     (unless char
       (message
       (message
        "%s by tag [%s ], [TAB], %s[/]:off, [+-]:narrow, [>=<?]:effort: "
        "%s by tag [%s ], [TAB], %s[/]:off, [+-]:narrow, [>=<?]:effort: "
@@ -5968,11 +5967,13 @@ to switch to narrowing."
 	    (if modifier
 	    (if modifier
 		(push modifier org-agenda-filter))))
 		(push modifier org-agenda-filter))))
 	(if (not (null org-agenda-filter))
 	(if (not (null org-agenda-filter))
-	    (org-agenda-filter-apply org-agenda-filter))))
+	    (org-agenda-filter-apply org-agenda-filter)))
+      (setq maybe-reftresh t))
      ((equal char ?/)
      ((equal char ?/)
       (org-agenda-filter-by-tag-show-all)
       (org-agenda-filter-by-tag-show-all)
       (when (get 'org-agenda-filter :preset-filter)
       (when (get 'org-agenda-filter :preset-filter)
-	(org-agenda-filter-apply org-agenda-filter)))
+	(org-agenda-filter-apply org-agenda-filter))
+      (setq maybe-reftresh t))
      ((or (equal char ?\ )
      ((or (equal char ?\ )
 	  (setq a (rassoc char alist))
 	  (setq a (rassoc char alist))
 	  (and (>= char ?0) (<= char ?9)
 	  (and (>= char ?0) (<= char ?9)
@@ -5988,8 +5989,12 @@ to switch to narrowing."
       (setq org-agenda-filter
       (setq org-agenda-filter
 	    (cons (concat (if strip "-" "+") tag)
 	    (cons (concat (if strip "-" "+") tag)
 		  (if narrow current nil)))
 		  (if narrow current nil)))
-      (org-agenda-filter-apply org-agenda-filter))
-     (t (error "Invalid tag selection character %c" char)))))
+      (org-agenda-filter-apply org-agenda-filter)
+      (setq maybe-reftresh t))
+     (t (error "Invalid tag selection character %c" char)))
+    (when (and maybe-reftresh
+	       (eq org-agenda-clockreport-mode 'with-filter))
+      (org-agenda-redo))))
 
 
 (defun org-agenda-get-represented-tags ()
 (defun org-agenda-get-represented-tags ()
   "Get a list of all tags currently represented in the agenda."
   "Get a list of all tags currently represented in the agenda."