diff options
author | Carsten Dominik <carsten.dominik@gmail.com> | 2009-06-16 09:42:05 +0200 |
---|---|---|
committer | Carsten Dominik <carsten.dominik@gmail.com> | 2009-06-16 09:42:05 +0200 |
commit | 951125da8da3e51e5b55f7ef9f195a2cc3dbd4ba (patch) | |
tree | a86aa7cac0c88049747ca70da73aa663efcc47f8 | |
parent | 3825cc6bcb389b578317916b51369059a59f7618 (diff) | |
download | org-mode-951125da8da3e51e5b55f7ef9f195a2cc3dbd4ba.tar.gz |
intermediate
-rw-r--r-- | lisp/org-clock.el | 19 | ||||
-rw-r--r-- | lisp/org.el | 21 |
2 files changed, 35 insertions, 5 deletions
diff --git a/lisp/org-clock.el b/lisp/org-clock.el index ad55bc1..c519269 100644 --- a/lisp/org-clock.el +++ b/lisp/org-clock.el @@ -363,6 +363,20 @@ 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) + "Add to or set the effort estimate of the item currently being clocked. +This will update the \"Effort\" property of currently clocked item, and +the mode line." + (interactive "sHow much to add? (hh:mm or mm)? ") + (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 ""))))) + (org-entry-put org-clock-marker "Effort" org-clock-effort) + (org-clock-update-mode-line)))) + (defvar org-clock-notification-was-shown nil "Shows if we have shown notification already.") @@ -1451,6 +1465,11 @@ The details of what will be saved are regulated by the variable (add-hook 'org-mode-hook 'org-clock-load) (add-hook 'kill-emacs-hook 'org-clock-save)) + +;; 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) + (provide 'org-clock) ;; arch-tag: 7b42c5d4-9b36-48be-97c0-66a869daed4c diff --git a/lisp/org.el b/lisp/org.el index 0cd7c23..aaf3882 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -3024,6 +3024,10 @@ If TABLE-TYPE is non-nil, also check for table.el-type tables." (defvar org-clock-start-time) (defvar org-clock-marker (make-marker) "Marker recording the last clock-in.") +(defun org-clock-is-active () + "Return non-nil if clock is currently running. +The return value is actually the clock marker." + (marker-buffer org-clock-marker)) (eval-and-compile (org-autoload @@ -13101,11 +13105,18 @@ If there is already a time stamp at the cursor position, update it." (format org-time-clocksum-format h m))) (defun org-hh:mm-string-to-minutes (s) - "Convert a string H:MM to a number of minutes." - (if (string-match "\\([0-9]+\\):\\([0-9]+\\)" s) - (+ (* (string-to-number (match-string 1 s)) 60) - (string-to-number (match-string 2 s))) - 0)) + "Convert a string H:MM to a number of minutes. +If the string is just a number, interprete it as minutes. +In fact, the first hh:mm or number in the string will be taken, +there can be extra stuff in the string. +If no number is found, the return value is 0." + (cond + ((string-match "\\([0-9]+\\):\\([0-9]+\\)" s) + (+ (* (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))) + (t 0))) ;;;; Files |