瀏覽代碼

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 14 年之前
父節點
當前提交
09c5ff8359
共有 1 個文件被更改,包括 12 次插入7 次删除
  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)
       (let ((org-agenda-files (org-agenda-files nil 'ifmode))
 	    ;; the above line is to ensure the restricted range!
-	    (p org-agenda-clockreport-parameter-plist)
+	    (p (copy-sequence org-agenda-clockreport-parameter-plist))
 	    tbl)
 	(setq p (org-plist-delete p :block))
 	(setq p (plist-put p :tstart clocktable-start))
@@ -3623,7 +3623,6 @@ given in `org-agenda-start-on-weekday'."
 						      ""
 						    x))
 						filter ""))))
-	(message "%s" (plist-get p :tags)) (sit-for 2)
 	(setq tbl (apply 'org-get-clocktable p))
 	(insert tbl)))
     (goto-char (point-min))
@@ -5922,7 +5921,7 @@ to switch to narrowing."
 	 (effort-prompt "")
 	 (inhibit-read-only t)
 	 (current org-agenda-filter)
-	 a n tag)
+	 maybe-reftresh a n tag)
     (unless char
       (message
        "%s by tag [%s ], [TAB], %s[/]:off, [+-]:narrow, [>=<?]:effort: "
@@ -5968,11 +5967,13 @@ to switch to narrowing."
 	    (if modifier
 		(push modifier 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 ?/)
       (org-agenda-filter-by-tag-show-all)
       (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 ?\ )
 	  (setq a (rassoc char alist))
 	  (and (>= char ?0) (<= char ?9)
@@ -5988,8 +5989,12 @@ to switch to narrowing."
       (setq org-agenda-filter
 	    (cons (concat (if strip "-" "+") tag)
 		  (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 ()
   "Get a list of all tags currently represented in the agenda."