From a7a842457dd927df9eabc756c4c573720a3a7aa9 Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Wed, 11 Aug 2010 16:10:14 +0200 Subject: [PATCH] Rebind org-agenda-clock-goto to `J' in the agenda. * org-agenda.el (org-agenda-clock-goto): Use `\C-c\C-x\C-j' for `org-clock-goto' and `J' for `org-agenda-clock-goto'. If the heading currently clocked in is not listed in the agenda, display this entry in another buffer. If there is no running clock, display a help message. * org-clock.el (org-clock-set-current): append the filename after the heading. --- lisp/org-agenda.el | 11 ++++++++--- lisp/org-clock.el | 5 ++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el index 72f67cd7d..3f7260928 100644 --- a/lisp/org-agenda.el +++ b/lisp/org-agenda.el @@ -1666,8 +1666,8 @@ The following commands are available: (org-defkey org-agenda-mode-map "O" 'org-agenda-clock-out) (org-defkey org-agenda-mode-map "\C-c\C-x\C-x" 'org-agenda-clock-cancel) (org-defkey org-agenda-mode-map "X" 'org-agenda-clock-cancel) -(org-defkey org-agenda-mode-map "\C-c\C-x\C-j" 'org-agenda-clock-goto) -(org-defkey org-agenda-mode-map "J" 'org-clock-goto) +(org-defkey org-agenda-mode-map "\C-c\C-x\C-j" 'org-clock-goto) +(org-defkey org-agenda-mode-map "J" 'org-agenda-clock-goto) (org-defkey org-agenda-mode-map "+" 'org-agenda-priority-up) (org-defkey org-agenda-mode-map "-" 'org-agenda-priority-down) (org-defkey org-agenda-mode-map [(shift up)] 'org-agenda-priority-up) @@ -7150,7 +7150,12 @@ The cursor may be at a date in the calendar, or in the Org agenda." (if (eq (overlay-get o 'type) 'org-agenda-clocking) (setq pos (overlay-start o)))) (overlays-in (point-min) (point-max))) - (if pos (goto-char pos)))) + (cond (pos (goto-char pos)) + ;; If the currently clocked entry is not in the agenda + ;; buffer, we visit it in another window: + (org-clock-current-task + (org-switch-to-buffer-other-window (org-clock-goto))) + (t (message "No running clock, use `C-c C-x C-j' to jump to the most recent one"))))) (defun org-agenda-diary-entry-in-org-file () "Make a diary entry in the file `org-agenda-diary-file'." diff --git a/lisp/org-clock.el b/lisp/org-clock.el index 92c29f6a4..fb22c2525 100644 --- a/lisp/org-clock.el +++ b/lisp/org-clock.el @@ -1097,7 +1097,10 @@ the clocking selection, associated with the letter `d'." "Task currently clocked in.") (defun org-clock-set-current () "Set `org-clock-current-task' to the task currently clocked in." - (setq org-clock-current-task (nth 4 (org-heading-components)))) + (setq org-clock-current-task + (concat (nth 4 (org-heading-components)) + " (" (file-name-nondirectory (buffer-file-name)) ")"))) + (defun org-clock-delete-current () "Reset `org-clock-current-task' to nil." (setq org-clock-current-task nil))