Browse Source

Clock: Manipulating effort strings, and a mode line menu

Clicking on the clock in the mode line now pops up a menu with
clocking options.

A new command `C-c C-x C-e' allows to set or change the effort
estimate of the task currently being clocked.  This is mainly useful
when using an alert notification when the task should be finished.

Based on a patch by Konstantin Antipin.
Carsten Dominik 16 years ago
parent
commit
a5f080361a
5 changed files with 79 additions and 17 deletions
  1. 5 0
      doc/ChangeLog
  2. 8 2
      doc/org.texi
  3. 12 0
      lisp/ChangeLog
  4. 47 13
      lisp/org-clock.el
  5. 7 2
      lisp/org.el

+ 5 - 0
doc/ChangeLog

@@ -1,3 +1,8 @@
+2009-06-17  Carsten Dominik  <carsten.dominik@gmail.com>
+
+	* org.texi (Clocking work time): Document the key to update effort
+	estimates.
+
 2009-06-02  Carsten Dominik  <carsten.dominik@gmail.com>
 2009-06-02  Carsten Dominik  <carsten.dominik@gmail.com>
 
 
 	* org.texi (Clocking work time): Document the clock time display.
 	* org.texi (Clocking work time): Document the clock time display.

+ 8 - 2
doc/org.texi

@@ -5273,7 +5273,9 @@ to show only the current clocking instance, @code{today} to show all time
 clocked on this tasks today (see also the variable
 clocked on this tasks today (see also the variable
 @code{org-extend-today-until}), @code{all} to include all time, or
 @code{org-extend-today-until}), @code{all} to include all time, or
 @code{auto} which is the default@footnote{See also the variable
 @code{auto} which is the default@footnote{See also the variable
-@code{org-clock-modeline-total}.}.
+@code{org-clock-modeline-total}.}.@*
+Clicking with @kbd{mouse-1} onto the mode line entry will pop up a menu with
+clocking options.
 @kindex C-c C-x C-o
 @kindex C-c C-x C-o
 @item C-c C-x C-o
 @item C-c C-x C-o
 @vindex org-log-note-clock-out
 @vindex org-log-note-clock-out
@@ -5284,8 +5286,12 @@ HH:MM}.  See the variable @code{org-log-note-clock-out} for the
 possibility to record an additional note together with the clock-out
 possibility to record an additional note together with the clock-out
 time stamp@footnote{The corresponding in-buffer setting is:
 time stamp@footnote{The corresponding in-buffer setting is:
 @code{#+STARTUP: lognoteclock-out}}.
 @code{#+STARTUP: lognoteclock-out}}.
+@kindex C-c C-x C-e
+@item C-c C-x C-e
+Update the effort estimate for the current clock task.
 @kindex C-c C-y
 @kindex C-c C-y
-@item C-c C-y
+@kindex C-c C-c
+@item C-c C-y @ @ @r{or}@ @ C-c C-c
 Recompute the time interval after changing one of the time stamps.  This
 Recompute the time interval after changing one of the time stamps.  This
 is only necessary if you edit the time stamps directly.  If you change
 is only necessary if you edit the time stamps directly.  If you change
 them with @kbd{S-@key{cursor}} keys, the update is automatic.
 them with @kbd{S-@key{cursor}} keys, the update is automatic.

+ 12 - 0
lisp/ChangeLog

@@ -1,3 +1,15 @@
+2009-06-17  Carsten Dominik  <carsten.dominik@gmail.com>
+
+	* org-clock.el (org-clock-menu): New function.
+	(org-clock-update-mode-line): Update help string.
+	(org-clock-modify-effort-estimate): New function.
+	(org-clock-mark-default-task): New function.
+
+	* org.el (org-hh:mm-string-to-minutes): Also take just a number of
+	minutes as input.
+	(org-org-menu): Add new clocking stuff.
+	(org-clock-is-active): New function.
+
 2009-06-14  Carsten Dominik  <carsten.dominik@gmail.com>
 2009-06-14  Carsten Dominik  <carsten.dominik@gmail.com>
 
 
 	* org.el (org-open-non-existing-files): Improve docstring.
 	* org.el (org-open-non-existing-files): Improve docstring.

+ 47 - 13
lisp/org-clock.el

@@ -222,6 +222,16 @@ of a different task.")
 
 
 (defvar org-clock-mode-line-map (make-sparse-keymap))
 (defvar org-clock-mode-line-map (make-sparse-keymap))
 (define-key org-clock-mode-line-map [mode-line mouse-2] 'org-clock-goto)
 (define-key org-clock-mode-line-map [mode-line mouse-2] 'org-clock-goto)
+(define-key org-clock-mode-line-map [mode-line mouse-1] 'org-clock-menu)
+
+(defun org-clock-menu ()
+  (interactive)
+  (popup-menu
+   '("Clock"
+     ["Clock out" org-clock-out t]
+     ["Change effort estimate" org-clock-modify-effort-estimate t]
+     ["Go to clock entry" org-clock-goto t]
+     ["Switch task" (lambda () (interactive) (org-clock-in '(4))) :active t :keys "C-u C-c C-x C-i"])))
 
 
 (defun org-clock-history-push (&optional pos buffer)
 (defun org-clock-history-push (&optional pos buffer)
   "Push a marker to the clock history."
   "Push a marker to the clock history."
@@ -342,7 +352,7 @@ If not, show simply the clocked time like 01:50."
   (setq org-mode-line-string
   (setq org-mode-line-string
 	(org-propertize
 	(org-propertize
 	 (let ((clock-string (org-clock-get-clock-string))
 	 (let ((clock-string (org-clock-get-clock-string))
-	       (help-text "Org-mode clock is running. Mouse-2 to go there."))
+	       (help-text "Org-mode clock is running.\nmouse-1 shows a menu\nmouse-2 will jump to task"))
 	   (if (and (> org-clock-string-limit 0)
 	   (if (and (> org-clock-string-limit 0)
 		    (> (length clock-string) org-clock-string-limit))
 		    (> (length clock-string) org-clock-string-limit))
 	       (org-propertize (substring clock-string 0 org-clock-string-limit)
 	       (org-propertize (substring clock-string 0 org-clock-string-limit)
@@ -363,17 +373,36 @@ previous clocking intervals."
 		   (time-to-seconds org-clock-start-time)) 60)))
 		   (time-to-seconds org-clock-start-time)) 60)))
     (+ currently-clocked-time (or org-clock-total-time 0))))
     (+ currently-clocked-time (or org-clock-total-time 0))))
 
 
-(defun org-clock-increase-effort-estimate (add-effort)
+(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 forat hh:mm or mm.
+WHen the strig 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
 This will update the \"Effort\" property of currently clocked item, and
 the mode line."
 the mode line."
- (interactive "sHow much to add? (hh:mm or mm)? ")
+ (interactive)
  (when (org-clock-is-active)
  (when (org-clock-is-active)
-   (let ((add-effort-minutes (org-hh:mm-string-to-minutes add-effort)))
-     (setq org-clock-effort
-	   (org-minutes-to-hh:mm-string
-	    (+ add-effort-minutes
-	       (org-hh:mm-string-to-minutes (or org-clock-effort "")))))
+   (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-hh:mm-string-to-minutes (substring current 1)))
+	 (setq current 0))
+       (setq value (org-hh:mm-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-entry-put org-clock-marker "Effort" org-clock-effort)
      (org-clock-update-mode-line))))
      (org-clock-update-mode-line))))
 
 
@@ -454,9 +483,7 @@ the clocking selection, associated with the letter `d'."
 
 
       (when (equal select '(16))
       (when (equal select '(16))
 	;; Mark as default clocking task
 	;; Mark as default clocking task
-	(save-excursion
-	  (org-back-to-heading t)
-	  (move-marker org-clock-default-task (point))))
+	(org-clock-mark-default-task))
 
 
       (setq target-pos (point))  ;; we want to clock in at this location
       (setq target-pos (point))  ;; we want to clock in at this location
       (save-excursion
       (save-excursion
@@ -546,6 +573,14 @@ the clocking selection, associated with the letter `d'."
 		  (run-with-timer 60 60 'org-clock-update-mode-line))
 		  (run-with-timer 60 60 'org-clock-update-mode-line))
 	    (message "Clock starts at %s - %s" ts msg-extra)))))))
 	    (message "Clock starts at %s - %s" ts msg-extra)))))))
 
 
+(defun org-clock-mark-default-task ()
+  "Mark current task as default task."
+  (interactive)
+  (save-excursion
+    (org-back-to-heading t)
+    (move-marker org-clock-default-task (point))))
+
+
 (defvar msg-extra)
 (defvar msg-extra)
 (defun org-clock-get-sum-start ()
 (defun org-clock-get-sum-start ()
   "Return the time from which clock times should be counted.
   "Return the time from which clock times should be counted.
@@ -1467,8 +1502,7 @@ The details of what will be saved are regulated by the variable
 
 
 
 
 ;; Suggested bindings
 ;; Suggested bindings
-(org-defkey org-mode-map "\C-c\C-x\C-e" 'org-clock-increase-effort-estimate)
-(global-set-key "\C-c\C-x\C-e" 'org-clock-increase-effort-estimate)
+(org-defkey org-mode-map "\C-c\C-x\C-e" 'org-clock-modify-effort-estimate)
 
 
 (provide 'org-clock)
 (provide 'org-clock)
 
 

+ 7 - 2
lisp/org.el

@@ -13115,7 +13115,7 @@ If no number is found, the return value is 0."
     (+ (* (string-to-number (match-string 1 s)) 60)
     (+ (* (string-to-number (match-string 1 s)) 60)
        (string-to-number (match-string 2 s))))
        (string-to-number (match-string 2 s))))
    ((string-match "\\([0-9]+\\)" s)
    ((string-match "\\([0-9]+\\)" s)
-    (string-to-number (match-string 2 s)))
+    (string-to-number (match-string 1 s)))
    (t 0)))
    (t 0)))
 
 
 ;;;; Files
 ;;;; Files
@@ -14986,10 +14986,15 @@ See the individual commands for more information."
      ["Insert Timer String" org-timer t]
      ["Insert Timer String" org-timer t]
      ["Insert Timer Item" org-timer-item t])
      ["Insert Timer Item" org-timer-item t])
     ("Logging work"
     ("Logging work"
-     ["Clock in" org-clock-in t]
+     ["Clock in" org-clock-in :active t :keys "C-c C-x C-i"]
+     ["Switch task" (lambda () (interactive) (org-clock-in '(4))) :active t :keys "C-u C-c C-x C-i"]
      ["Clock out" org-clock-out t]
      ["Clock out" org-clock-out t]
      ["Clock cancel" org-clock-cancel t]
      ["Clock cancel" org-clock-cancel t]
+     "--"
+     ["Mark as default task" org-clock-mark-default-task t]
+     ["Clock in, mark as default" (lambda () (interactive) (org-clock-in '(16))) :active t :keys "C-u C-u C-c C-x C-i"]
      ["Goto running clock" org-clock-goto t]
      ["Goto running clock" org-clock-goto t]
+     "--"
      ["Display times" org-clock-display t]
      ["Display times" org-clock-display t]
      ["Create clock table" org-clock-report t]
      ["Create clock table" org-clock-report t]
      "--"
      "--"