From mboxrd@z Thu Jan 1 00:00:00 1970 From: James TD Smith Subject: [PATCH 2/3] Add clock resuming. Date: Thu, 23 Oct 2008 11:27:42 +0100 Message-ID: <1224757662-32103-4-git-send-email-ahktenzero@mohorovi.cc> References: <60CAB6A3-82C6-4EA1-8944-FE120A7EA0D2@uva.nl> <1224757662-32103-1-git-send-email-ahktenzero@mohorovi.cc> <1224757662-32103-2-git-send-email-ahktenzero@mohorovi.cc> <1224757662-32103-3-git-send-email-ahktenzero@mohorovi.cc> Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KsxPy-00016B-AJ for emacs-orgmode@gnu.org; Thu, 23 Oct 2008 06:27:50 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KsxPx-00015n-Ia for emacs-orgmode@gnu.org; Thu, 23 Oct 2008 06:27:49 -0400 Received: from [199.232.76.173] (port=44987 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KsxPx-00015S-4q for emacs-orgmode@gnu.org; Thu, 23 Oct 2008 06:27:49 -0400 Received: from 81-86-40-42.dsl.pipex.com ([81.86.40.42]:57553 helo=yog-sothoth.mohorovi.cc) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KsxPv-00060J-Tk for emacs-orgmode@gnu.org; Thu, 23 Oct 2008 06:27:48 -0400 In-Reply-To: <1224757662-32103-3-git-send-email-ahktenzero@mohorovi.cc> 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 If the option `org-clock-resume' is t, and the first clock line in an entry is is open, clocking into that task resumes the clock from that time. --- lisp/ChangeLog | 8 ++++++++ lisp/org-clock.el | 28 +++++++++++++++++++++------- 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index e4ffc88..438296d 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -3,6 +3,14 @@ * org.el (org-insert-todo-heading): Fix bug with force-heading argument. +2008-10-23 James TD Smith + + * org-clock.el (org-clock-in-resume): Add a custom option to + toggle starting the clock from an open clock line. + (org-clock-in): When clocking in to an entry, if + `org-clock-in-resume' is set, check if the first clock line is + open and if so, start the clock from the time in the clock line. + 2008-10-22 Carsten Dominik * org-exp.el (org-export-as-ascii): Handle the case that we are diff --git a/lisp/org-clock.el b/lisp/org-clock.el index da86b0d..40272d4 100644 --- a/lisp/org-clock.el +++ b/lisp/org-clock.el @@ -95,6 +95,12 @@ The function is called with point at the beginning of the headline." :group 'org-clock :type 'integer) +(defcustom org-clock-in-resume nil + "If non-nil, when clocking into a task with a clock entry which +has not been closed, resume the clock from that point" + :group 'org-clock + :type 'boolean) + ;;; The clock for measuring work time. (defvar org-mode-line-string "") @@ -291,12 +297,21 @@ the clocking selection, associated with the letter `d'." (t "???"))) (setq org-clock-heading (org-propertize org-clock-heading 'face nil)) (org-clock-find-position) - - (insert "\n") (backward-char 1) - (org-indent-line-function) - (insert org-clock-string " ") - (setq org-clock-start-time (current-time)) - (setq ts (org-insert-time-stamp (current-time) 'with-hm 'inactive)) + (if (and org-clock-in-resume + (looking-at (concat "^[ \\t]* " org-clock-string + " \\[\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\}" + " +\\sw+ +[012][0-9]:[0-5][0-9]\\)\\]$"))) + (progn (message "Matched %s" (match-string 1)) + (setq ts (concat "[" (match-string 1) "]")) + (goto-char (match-end 1)) + (setq org-clock-start-time + (apply 'encode-time (org-parse-time-string (match-string 1))))) + (progn + (insert "\n") (backward-char 1) + (org-indent-line-function) + (insert org-clock-string " ") + (setq org-clock-start-time (current-time)) + (setq ts (org-insert-time-stamp org-clock-start-time 'with-hm 'inactive)))) (move-marker org-clock-marker (point) (buffer-base-buffer)) (or global-mode-string (setq global-mode-string '(""))) (or (memq 'org-mode-line-string global-mode-string) @@ -962,7 +977,6 @@ the currently selected interval size." (re-search-forward "#\\+END:") (end-of-line 0)))) - (defun org-clocktable-add-file (file table) (if table (let ((lines (org-split-string table "\n")) -- 1.5.6.5