ソースを参照

Clock: Make `C-c C-x C-j' jump to most recently clocked task as well.

If there is no running clock, this command will go to the most
recently clocked task.
Carsten Dominik 16 年 前
コミット
654e629ed9
2 ファイル変更22 行追加10 行削除
  1. 5 0
      lisp/ChangeLog
  2. 17 10
      lisp/org-clock.el

+ 5 - 0
lisp/ChangeLog

@@ -1,3 +1,8 @@
+2009-04-21  Carsten Dominik  <carsten.dominik@gmail.com>
+
+	* org-clock.el (org-clock-goto): Go to recently clocked task if no
+	clock is running.
+
 2009-04-21  Carsten Dominik  <carsten.dominik@gmail.com>
 
 	* org.el (org-update-parent-todo-statistics): Check for

+ 17 - 10
lisp/org-clock.el

@@ -529,23 +529,30 @@ If there is no running clock, throw an error, unless FAIL-QUIETLY is set."
   (message "Clock canceled"))
 
 (defun org-clock-goto (&optional select)
-  "Go to the currently clocked-in entry.
-With prefix arg SELECT, offer recently clocked tasks."
+  "Go to the currently clocked-in entry, or to the most recently clocked one.
+With prefix arg SELECT, offer recently clocked tasks for selection."
   (interactive "P")
-  (let ((m (if select
-	       (org-clock-select-task "Select task to go to: ")
-	     org-clock-marker)))
-    (if (not (marker-buffer m))
-	(if select
-	    (error "No task selected")
-	  (error "No active clock")))
+  (let* ((recent nil)
+	 (m (cond
+	     (select
+	      (or (org-clock-select-task "Select task to go to: ")
+		  (error "No task selected")))
+	     ((marker-buffer org-clock-marker) org-clock-marker)
+	     ((and (car org-clock-history)
+		   (marker-buffer (car org-clock-history)))
+	      (setq recent t)
+	      (car org-clock-history))
+	     (t (error "No active or recent clock task")))))
     (switch-to-buffer (marker-buffer m))
     (if (or (< m (point-min)) (> m (point-max))) (widen))
     (goto-char m)
     (org-show-entry)
     (org-back-to-heading)
     (org-cycle-hide-drawers 'children)
-    (recenter)))
+    (recenter)
+    (if recent
+	(message "No running clock, this is the most recently clocked task"))))
+
 
 (defvar org-clock-file-total-minutes nil
   "Holds the file total time in minutes, after a call to `org-clock-sum'.")