From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bastien 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 Message-ID: <874o72koig.fsf@altern.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from [140.186.70.92] (port=55616 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q0Aou-0006rq-Cm for emacs-orgmode@gnu.org; Thu, 17 Mar 2011 06:52:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q0Aos-0003IA-W8 for emacs-orgmode@gnu.org; Thu, 17 Mar 2011 06:52:44 -0400 Received: from mail-wy0-f195.google.com ([74.125.82.195]:59280) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q0Aos-0003Hx-PL for emacs-orgmode@gnu.org; Thu, 17 Mar 2011 06:52:42 -0400 Received: by wyb32 with SMTP id 32so478718wyb.6 for ; Thu, 17 Mar 2011 03:52:41 -0700 (PDT) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain 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. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=org-clock.el.patch 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 () --=-=-= Content-Type: text/plain -- Bastien --=-=-=--