Browse Source

intermediate

Carsten Dominik 16 years ago
parent
commit
951125da8d
2 changed files with 35 additions and 5 deletions
  1. 19 0
      lisp/org-clock.el
  2. 16 5
      lisp/org.el

+ 19 - 0
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

+ 16 - 5
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