summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarsten Dominik <carsten.dominik@gmail.com>2009-06-17 07:40:09 +0200
committerCarsten Dominik <carsten.dominik@gmail.com>2009-06-17 07:40:22 +0200
commita5f080361aae47a1ea495066bace9d3adae28726 (patch)
treef1841d9768d768d9579413982718b1c8cea3f8da
parent951125da8da3e51e5b55f7ef9f195a2cc3dbd4ba (diff)
downloadorg-mode-a5f080361aae47a1ea495066bace9d3adae28726.tar.gz
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.
-rw-r--r--doc/ChangeLog5
-rw-r--r--doc/org.texi10
-rwxr-xr-xlisp/ChangeLog12
-rw-r--r--lisp/org-clock.el60
-rw-r--r--lisp/org.el9
5 files changed, 79 insertions, 17 deletions
diff --git a/doc/ChangeLog b/doc/ChangeLog
index 5775a33..c3b1b3e 100644
--- a/doc/ChangeLog
+++ b/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>
* org.texi (Clocking work time): Document the clock time display.
diff --git a/doc/org.texi b/doc/org.texi
index 9b5a0e6..a8a6105 100644
--- a/doc/org.texi
+++ b/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
@code{org-extend-today-until}), @code{all} to include all time, or
@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
@item C-c C-x C-o
@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
time stamp@footnote{The corresponding in-buffer setting is:
@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
-@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
is only necessary if you edit the time stamps directly. If you change
them with @kbd{S-@key{cursor}} keys, the update is automatic.
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index c8bdc4d..05bfa8c 100755
--- a/lisp/ChangeLog
+++ b/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>
* org.el (org-open-non-existing-files): Improve docstring.
diff --git a/lisp/org-clock.el b/lisp/org-clock.el
index c519269..2df3254 100644
--- a/lisp/org-clock.el
+++ b/lisp/org-clock.el
@@ -222,6 +222,16 @@ of a different task.")
(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-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)
"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
(org-propertize
(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)
(> (length clock-string) 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)))
(+ 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.
+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
the mode line."
- (interactive "sHow much to add? (hh:mm or mm)? ")
+ (interactive)
(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-clock-update-mode-line))))
@@ -454,9 +483,7 @@ the clocking selection, associated with the letter `d'."
(when (equal select '(16))
;; 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
(save-excursion
@@ -546,6 +573,14 @@ the clocking selection, associated with the letter `d'."
(run-with-timer 60 60 'org-clock-update-mode-line))
(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)
(defun org-clock-get-sum-start ()
"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
-(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)
diff --git a/lisp/org.el b/lisp/org.el
index aaf3882..c789f89 100644
--- a/lisp/org.el
+++ b/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 2 s))))
((string-match "\\([0-9]+\\)" s)
- (string-to-number (match-string 2 s)))
+ (string-to-number (match-string 1 s)))
(t 0)))
;;;; Files
@@ -14986,10 +14986,15 @@ See the individual commands for more information."
["Insert Timer String" org-timer t]
["Insert Timer Item" org-timer-item t])
("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 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]
+ "--"
["Display times" org-clock-display t]
["Create clock table" org-clock-report t]
"--"