浏览代码

Add new parameter to the `org-clock-out' command

(org-clock-out): Accept new third parameter `at-time', which permits a
clock to be clocked out at a specific time.  Note that no attempt is
made to verify that the clock out time is later than the clock in time.
John Wiegley 15 年之前
父节点
当前提交
63fbf2aab8
共有 2 个文件被更改,包括 7 次插入2 次删除
  1. 4 0
      lisp/ChangeLog
  2. 3 2
      lisp/org-clock.el

+ 4 - 0
lisp/ChangeLog

@@ -3,6 +3,10 @@
 	* org-clock.el (org-clock-in): Before creating
 	`org-clock-mode-line-timer', check to make sure an older timer is
 	not currently running.
+	(org-clock-out): Accept new third parameter `at-time', which
+	permits a clock to be clocked out at a specific time.  Note that
+	no attempt is made to verify that the clock out time is later than
+	the clock in time.
 
 	* org.el (org-files-list): New utility function for returning a
 	list of all open org-mode buffers, plus all files used to build

+ 3 - 2
lisp/org-clock.el

@@ -751,7 +751,7 @@ line and position cursor in that line."
 	    (and (re-search-forward org-property-end-re nil t)
 		 (goto-char (match-beginning 0))))))))
 
-(defun org-clock-out (&optional fail-quietly)
+(defun org-clock-out (&optional fail-quietly at-time)
   "Stop the currently running clock.
 If there is no running clock, throw an error, unless FAIL-QUIETLY is set."
   (interactive)
@@ -772,7 +772,8 @@ If there is no running clock, throw an error, unless FAIL-QUIETLY is set."
 	  (goto-char (match-end 0))
 	  (delete-region (point) (point-at-eol))
 	  (insert "--")
-	  (setq te (org-insert-time-stamp (current-time) 'with-hm 'inactive))
+	  (setq te (org-insert-time-stamp (or at-time (current-time))
+					  'with-hm 'inactive))
 	  (setq s (- (org-float-time (apply 'encode-time (org-parse-time-string te)))
 		     (org-float-time (apply 'encode-time (org-parse-time-string ts))))
 		h (floor (/ s 3600))