From mboxrd@z Thu Jan 1 00:00:00 1970 From: Adam Spiers Subject: [PATCH] org-clock-modify-effort-estimate: display a message when no clock is active Date: Mon, 5 Mar 2012 00:09:28 +0000 Message-ID: <20120305000928.GA29990@atlantic.linksys.moosehall> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from eggs.gnu.org ([208.118.235.92]:45522) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S4LUa-0006xI-Rh for emacs-orgmode@gnu.org; Sun, 04 Mar 2012 19:09:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S4LUY-0007dM-Uy for emacs-orgmode@gnu.org; Sun, 04 Mar 2012 19:09:32 -0500 Received: from arctic.adamspiers.org ([85.119.82.176]:37756) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S4LUY-0007d7-MB for emacs-orgmode@gnu.org; Sun, 04 Mar 2012 19:09:30 -0500 Received: from localhost (70.83.187.81.in-addr.arpa [81.187.83.70]) by arctic.adamspiers.org (Postfix) with ESMTP id 035F624F39 for ; Mon, 5 Mar 2012 00:09:28 +0000 (UTC) Content-Disposition: inline List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: org-mode mailing list --- lisp/org-clock.el | 57 +++++++++++++++++++++++++++-------------------------- 1 files changed, 29 insertions(+), 28 deletions(-) diff --git a/lisp/org-clock.el b/lisp/org-clock.el index 9206608..1613f77 100644 --- a/lisp/org-clock.el +++ b/lisp/org-clock.el @@ -563,39 +563,40 @@ previous clocking intervals." (+ currently-clocked-time (or org-clock-total-time 0)))) (defun org-clock-modify-effort-estimate (&optional value) - "Add to or set the effort estimate of the item currently being clocked. + "Add to or set the effort estimate of the item currently being clocked. VALUE can be a number of minutes, or a string with format hh:mm or mm. When the string starts with a + or a - sign, the current value of the effort property will be changed by that amount. This will update the \"Effort\" property of currently clocked item, and the mode line." - (interactive) - (when (org-clock-is-active) - (let ((current org-clock-effort) sign) - (unless value - ;; Prompt user for a value or a change - (setq value - (read-string - (format "Set effort (hh:mm or mm%s): " - (if current - (format ", prefix + to add to %s" org-clock-effort) - ""))))) - (when (stringp value) - ;; A string. See if it is a delta - (setq sign (string-to-char value)) - (if (member sign '(?- ?+)) - (setq current (org-duration-string-to-minutes current) - value (substring value 1)) - (setq current 0)) - (setq value (org-duration-string-to-minutes value)) - (if (equal ?- sign) - (setq value (- current value)) - (if (equal ?+ sign) (setq value (+ current value))))) - (setq value (max 0 value) - org-clock-effort (org-minutes-to-hh:mm-string value)) - (org-entry-put org-clock-marker "Effort" org-clock-effort) - (org-clock-update-mode-line) - (message "Effort is now %s" org-clock-effort)))) + (interactive) + (if (org-clock-is-active) + (let ((current org-clock-effort) sign) + (unless value + ;; Prompt user for a value or a change + (setq value + (read-string + (format "Set effort (hh:mm or mm%s): " + (if current + (format ", prefix + to add to %s" org-clock-effort) + ""))))) + (when (stringp value) + ;; A string. See if it is a delta + (setq sign (string-to-char value)) + (if (member sign '(?- ?+)) + (setq current (org-duration-string-to-minutes current) + value (substring value 1)) + (setq current 0)) + (setq value (org-duration-string-to-minutes value)) + (if (equal ?- sign) + (setq value (- current value)) + (if (equal ?+ sign) (setq value (+ current value))))) + (setq value (max 0 value) + org-clock-effort (org-minutes-to-hh:mm-string value)) + (org-entry-put org-clock-marker "Effort" org-clock-effort) + (org-clock-update-mode-line) + (message "Effort is now %s" org-clock-effort)) + (message "Clock is not currently active"))) (defvar org-clock-notification-was-shown nil "Shows if we have shown notification already.") -- 1.7.8.206.g71406