فهرست منبع

New option `org-use-last-clock-out-time-as-effective-time'

* org.el (org-use-last-clock-out-time-as-effective-time): New option.
(org-current-effective-time): Use the new option.

* org-clock.el (org-clock-get-last-clock-out-time): New
function.

When set to `t', this new option will take the time of the last clock out
timestamp and use it when changing/logging the todo state.

Thanks to Gaizka Villate who suggested this.
Bastien Guerry 12 سال پیش
والد
کامیت
f3202903d6
2فایلهای تغییر یافته به همراه22 افزوده شده و 4 حذف شده
  1. 8 0
      lisp/org-clock.el
  2. 14 4
      lisp/org.el

+ 8 - 0
lisp/org-clock.el

@@ -577,6 +577,14 @@ If not, show simply the clocked time like 01:50."
 		       h m org-clock-heading)
 		      'face 'org-mode-line-clock))))
 
+(defun org-clock-get-last-clock-out-time ()
+  "Get the last clock-out time for the current subtree."
+  (save-excursion
+    (let ((end (save-excursion (org-end-of-subtree))))
+      (when (re-search-forward (concat org-clock-string
+				       ".*\\]--\\(\\[[^]]+\\]\\)") end t)
+	(org-time-string-to-time (match-string 1))))))
+
 (defun org-clock-update-mode-line ()
   (if org-clock-effort
       (org-clock-notify-once-if-expired)

+ 14 - 4
lisp/org.el

@@ -2867,6 +2867,14 @@ For example, if `org-extend-today-until' is 8, and it's 4am, then the
   :version "24.1"
   :type 'boolean)
 
+(defcustom org-use-last-clock-out-time-as-effective-time nil
+  "When non-nil, use the last clock out time for `org-todo'.
+Note that this option has precedence over the combined use of
+`org-use-effective-time' and `org-extend-today-until'."
+  :group 'org-time
+  ;; :version "24.3"
+  :type 'boolean)
+
 (defcustom org-edit-timestamp-down-means-later nil
   "Non-nil means S-down will increase the time in a time stamp.
 When nil, S-up will increase."
@@ -11542,10 +11550,12 @@ nil or a string to be used for the todo mark." )
   (let* ((ct (org-current-time))
 	 (dct (decode-time ct))
 	 (ct1
-	  (if (and org-use-effective-time
-		   (< (nth 2 dct) org-extend-today-until))
-	      (encode-time 0 59 23 (1- (nth 3 dct)) (nth 4 dct) (nth 5 dct))
-	    ct)))
+	  (cond
+	   (org-use-last-clock-out-time-as-effective-time
+	    (or (org-clock-get-last-clock-out-time) ct))
+	   ((and org-use-effective-time (< (nth 2 dct) org-extend-today-until))
+	    (encode-time 0 59 23 (1- (nth 3 dct)) (nth 4 dct) (nth 5 dct)))
+	   (t ct))))
     ct1))
 
 (defun org-todo-yesterday (&optional arg)