summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Guerry <bzg@altern.org>2011-03-17 15:52:23 +0000
committerBastien Guerry <bzg@altern.org>2011-03-23 15:11:59 +0100
commit8d0c034047c618042b4dd61d7df2c572f38b9b0b (patch)
tree0e2a1583cab85a7ef2ffa6d2ce21a79b42baa145
parentc4dbff58bee7966a3ff8748a05ac0528e017f908 (diff)
downloadorg-mode-8d0c034047c618042b4dd61d7df2c572f38b9b0b.tar.gz
`org-clock-report': use :scope sutree when inserting from within a subtree.
* org-clock.el (org-clock-report): change the scope of the inserted clock report depending on whether the point is within a subtree (:scope subtree) or not (:scope file).
-rw-r--r--lisp/org-clock.el13
1 files changed, 10 insertions, 3 deletions
diff --git a/lisp/org-clock.el b/lisp/org-clock.el
index c567a26..87b175c 100644
--- a/lisp/org-clock.el
+++ b/lisp/org-clock.el
@@ -1652,7 +1652,10 @@ fontified, and then returned."
(defun org-clock-report (&optional arg)
"Create a table containing a report about clocked time.
If the cursor is inside an existing clocktable block, then the table
-will be updated. If not, a new clocktable will be inserted.
+will be updated. If not, a new clocktable will be inserted. The scope
+of the new clock will be subtree when called from within a subtree, and
+file elsewhere.
+
When called with a prefix argument, move to the first clock table in the
buffer and update it."
(interactive "P")
@@ -1662,8 +1665,12 @@ buffer and update it."
(org-show-entry))
(if (org-in-clocktable-p)
(goto-char (org-in-clocktable-p))
- (org-create-dblock (append (list :name "clocktable")
- org-clock-clocktable-default-properties)))
+ (let ((props (if (ignore-errors
+ (save-excursion (org-back-to-heading)))
+ (list :name "clocktable" :scope 'subtree)
+ (list :name "clocktable"))))
+ (org-create-dblock
+ (org-combine-plists org-clock-clocktable-default-properties props))))
(org-update-dblock))
(defun org-in-clocktable-p ()