summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien <bzg@gnu.org>2020-02-13 01:25:26 +0100
committerBastien <bzg@gnu.org>2020-02-13 01:25:26 +0100
commit57841b526497c828f2b4d4295c459661f5f471ef (patch)
tree5c750127b3a96fa4842db6fa2824fa9db958aea0
parent63fd0c09ca1bf55c335062ebcf6be4bbdc147a25 (diff)
downloadorg-mode-57841b5264.tar.gz
org-clock.el: Allow to tell time you got back when resolving
* lisp/org-clock.el (org-clock-resolve): Allow to tell at what time (i.e. a HH:MM string) you "got back". Thanks to Dan Drake for suggesting this.
-rw-r--r--lisp/org-clock.el25
1 files changed, 19 insertions, 6 deletions
diff --git a/lisp/org-clock.el b/lisp/org-clock.el
index aee6ead..fdab2ce 100644
--- a/lisp/org-clock.el
+++ b/lisp/org-clock.el
@@ -1061,6 +1061,8 @@ g/G Indicate that you \"got back\" X minutes ago. This is quite
different from `k': it clocks you out from the beginning of
the idle period and clock you back in X minutes ago.
+t/T Indicate that you \"got back\" at time HH:MM.
+
s/S Subtract the idle time from the current clock. This is the
same as keeping 0 minutes.
@@ -1076,11 +1078,11 @@ to be CLOCKED OUT."))))
(while (or (null char-pressed)
(and (not (memq char-pressed
'(?k ?K ?g ?G ?s ?S ?C
- ?j ?J ?i ?q)))
+ ?j ?J ?i ?q ?t ?T)))
(or (ding) t)))
(setq char-pressed
(read-char (concat (funcall prompt-fn clock)
- " [jkKgGSscCiq]? ")
+ " [jkKgGSscCiqtT]? ")
nil 45)))
(and (not (memq char-pressed '(?i ?q))) char-pressed)))))
(default
@@ -1090,8 +1092,19 @@ to be CLOCKED OUT."))))
(and (memq ch '(?k ?K))
(read-number "Keep how many minutes? " default)))
(gotback
- (and (memq ch '(?g ?G))
- (read-number "Got back how many minutes ago? " default)))
+ (or (and (memq ch '(?g ?G))
+ (read-number "Got back how many minutes ago? " default))
+ (and (memq ch '(?t ?T))
+ (let* ((time (read-string "At what HH:MM time did you get back? "))
+ (mins (floor (float-time
+ (org-time-subtract
+ nil (encode-time
+ (org-parse-time-string
+ (concat (format-time-string "%F " last-valid)
+ time)))))
+ 60)))
+ (if (wholenump mins) mins
+ (user-error "Enter a time in the past"))))))
(subtractp (memq ch '(?s ?S)))
(barely-started-p (org-time-less-p
(org-time-subtract last-valid (cdr clock))
@@ -1127,9 +1140,9 @@ to be CLOCKED OUT."))))
(t
(error "Unexpected, please report this as a bug")))
(and gotback last-valid)
- (memq ch '(?K ?G ?S))
+ (memq ch '(?K ?G ?S ?T))
(and start-over
- (not (memq ch '(?K ?G ?S ?C))))
+ (not (memq ch '(?K ?G ?S ?C ?T))))
fail-quietly)))))
;;;###autoload