emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Bastien <bzg@altern.org>
To: emacs-orgmode@gnu.org
Subject: org-clock-report to insert a :scope sutree report when called from within a subtree?
Date: Thu, 17 Mar 2011 11:52:23 +0100	[thread overview]
Message-ID: <874o72koig.fsf@altern.org> (raw)

[-- Attachment #1: Type: text/plain, Size: 381 bytes --]

Hi all,

The default when creating a clock report is to use :scope file.  I find
it not practical for big files, where the report can take long to build.

I'm thinking of applying this change: when called from within a subtree,
`C-c C-x C-r' will insert a clock report with ":scope subtree", and use
":scope subtree" elsewhere.

Please let me know if you think that's a bad idea.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: org-clock.el.patch --]
[-- Type: text/x-patch, Size: 1286 bytes --]

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

[-- Attachment #3: Type: text/plain, Size: 14 bytes --]


-- 
 Bastien

             reply	other threads:[~2011-03-17 10:52 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-17 10:52 Bastien [this message]
2011-03-17 13:26 ` org-clock-report to insert a :scope sutree report when called from within a subtree? John Hendy
2011-03-23 14:16   ` Bastien
2011-03-23 14:12 ` [Accepted] " Bastien Guerry
2011-03-23 14:15 ` Bastien

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=874o72koig.fsf@altern.org \
    --to=bzg@altern.org \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).