Browse Source

Merge branch 'maint'

Nicolas Goaziou 8 years ago
parent
commit
c0924db32c
2 changed files with 24 additions and 10 deletions
  1. 7 9
      lisp/org-clock.el
  2. 17 1
      testing/lisp/test-org-clock.el

+ 7 - 9
lisp/org-clock.el

@@ -1854,15 +1854,13 @@ PROPNAME lets you set a custom text property instead of :org-clock-minutes."
 		 (goto-char (match-beginning 0))
 		 (put-text-property (point) (point-at-eol)
 				    (or propname :org-clock-minutes) time)
-		 (if headline-filter
-		     (save-excursion
-		       (save-match-data
-			 (while
-			     (> (funcall outline-level) 1)
-			   (outline-up-heading 1 t)
-			   (put-text-property
-			    (point) (point-at-eol)
-			    :org-clock-force-headline-inclusion t))))))
+		 (when headline-filter
+		   (save-excursion
+		     (save-match-data
+		       (while (org-up-heading-safe)
+			 (put-text-property
+			  (point) (line-end-position)
+			  :org-clock-force-headline-inclusion t))))))
 	       (setq t1 0)
 	       (cl-loop for l from level to (1- lmax) do
 			(aset ltimes l 0)))))))

+ 17 - 1
testing/lisp/test-org-clock.el

@@ -318,7 +318,23 @@ contents.  The clocktable doesn't appear in the buffer."
       (insert (org-test-clock-create-clock "-10y 15:00" "-10y 18:00"))
       (insert (org-test-clock-create-clock "-2d 15:00" "-2d 18:00"))
       (test-org-clock-clocktable-contents-at-point
-       ":block untilnow :indent nil")))))
+       ":block untilnow :indent nil"))))
+  ;; Test tag filtering.
+  (should
+   (equal
+    "| Headline     | Time   |      |
+|--------------+--------+------|
+| *Total time* | *2:00* |      |
+|--------------+--------+------|
+| H1           |        | 2:00 |
+"
+    (org-test-with-temp-text "** H1\n\n*** H2 :tag:\n\n*** H3\n<point>"
+      (insert (org-test-clock-create-clock ". 1:00" ". 2:00"))
+      (goto-line 4)
+      (insert (org-test-clock-create-clock ". 2:00" ". 4:00"))
+      (goto-line 2)
+      (test-org-clock-clocktable-contents-at-point
+       ":tags \"tag\" :indent nil")))))
 
 (provide 'test-org-clock)
 ;;; test-org-clock.el end here