From 0af51333343da7fae9c34454ce2a9a4ec9612817 Mon Sep 17 00:00:00 2001 From: Carsten Dominik Date: Fri, 7 Aug 2009 11:00:16 +0200 Subject: [PATCH] Mark running clock in the agenda. If the entry currently being clocked is present in the agenda, mark it. --- lisp/ChangeLog | 13 +++++++++++++ lisp/org-agenda.el | 21 +++++++++++++++++++++ lisp/org-clock.el | 7 +++++++ lisp/org-faces.el | 5 +++++ lisp/org.el | 2 ++ 5 files changed, 48 insertions(+) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 74392024d..b64c162c5 100755 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,18 @@ 2009-08-07 Carsten Dominik + * org-clock.el (org-clock-save-markers-for-cut-and-paste): Also + cheeeeeck the hd marker + (org-clock-in): Also set the hd marker. + (org-clock-out): Also set the hd marker. + (org-clock-cancel): Reset markers. + + * org.el (org-clock-hd-marker): New marker. + + * org-faces.el (org-agenda-clocking): New face. + + * org-agenda.el (org-agenda-mark-clocking-task): New function. + (org-finalize-agenda): call `org-agenda-mark-clocking-task'. + * org.el (org-modules): Add org-track.el. * org-agenda.el (org-agenda-bulk-marked-p): New function. diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el index f9fa65989..234dc6f57 100644 --- a/lisp/org-agenda.el +++ b/lisp/org-agenda.el @@ -2420,12 +2420,33 @@ bind it in the options section.") (org-agenda-fontify-priorities)) (when (and org-agenda-dim-blocked-tasks org-blocker-hook) (org-agenda-dim-blocked-tasks)) + (org-agenda-mark-clocking-task) (run-hooks 'org-finalize-agenda-hook) (setq org-agenda-type (get-text-property (point) 'org-agenda-type)) (when (get 'org-agenda-filter :preset-filter) (org-agenda-filter-apply org-agenda-filter)) ))) +(defun org-agenda-mark-clocking-task () + "Mark the current clock entry in the agenda if it is present." + (mapc (lambda (o) + (if (eq (org-overlay-get o 'type) 'org-agenda-clocking) + (org-delete-overlay o))) + (org-overlays-in (point-min) (point-max))) + (when (marker-buffer org-clock-hd-marker) + (save-excursion + (goto-char (point-min)) + (let (s ov) + (while (setq s (next-single-property-change (point) 'org-hd-marker)) + (goto-char s) + (when (equal (get-text-property (point) 'org-hd-marker) + org-clock-hd-marker) + (setq ov (org-make-overlay (point-at-bol) (1+ (point-at-eol)))) + (org-overlay-put ov 'type 'org-agenda-clocking) + (org-overlay-put ov 'face 'org-agenda-clocking) + (org-overlay-put ov 'help-echo + "The clock is running in this item"))))))) + (defun org-agenda-fontify-priorities () "Make highest priority lines bold, and lowest italic." (interactive) diff --git a/lisp/org-clock.el b/lisp/org-clock.el index 04d2d9621..7262ec70b 100644 --- a/lisp/org-clock.el +++ b/lisp/org-clock.el @@ -277,6 +277,7 @@ of a different task.") (defun org-clock-save-markers-for-cut-and-paste (beg end) "Save relative positions of markers in region." (org-check-and-save-marker org-clock-marker beg end) + (org-check-and-save-marker org-clock-hd-marker beg end) (org-check-and-save-marker org-clock-default-task beg end) (org-check-and-save-marker org-clock-interrupted-task beg end) (mapc (lambda (m) (org-check-and-save-marker m beg end)) @@ -592,6 +593,9 @@ the clocking selection, associated with the letter `d'." (setq ts (org-insert-time-stamp org-clock-start-time 'with-hm 'inactive)))) (move-marker org-clock-marker (point) (buffer-base-buffer)) + (move-marker org-clock-hd-marker + (save-excursion (org-back-to-heading t) (point)) + (buffer-base-buffer)) (or global-mode-string (setq global-mode-string '(""))) (or (memq 'org-mode-line-string global-mode-string) (setq global-mode-string @@ -765,6 +769,7 @@ If there is no running clock, throw an error, unless FAIL-QUIETLY is set." (and (looking-at "\n") (> (point-max) (1+ (point))) (delete-char 1))) (move-marker org-clock-marker nil) + (move-marker org-clock-hd-marker nil) (when org-log-note-clock-out (org-add-log-setup 'clock-out nil nil nil nil (concat "# Task: " (org-get-heading t) "\n\n"))) @@ -802,6 +807,8 @@ If there is no running clock, throw an error, unless FAIL-QUIETLY is set." (set-buffer (marker-buffer org-clock-marker)) (goto-char org-clock-marker) (delete-region (1- (point-at-bol)) (point-at-eol))) + (move-marker 'org-clock-marker nil) + (move-marker 'org-clock-hd-marker nil) (setq global-mode-string (delq 'org-mode-line-string global-mode-string)) (force-mode-line-update) diff --git a/lisp/org-faces.el b/lisp/org-faces.el index 9eea2287b..9b868ee2a 100644 --- a/lisp/org-faces.el +++ b/lisp/org-faces.el @@ -498,6 +498,11 @@ changes." (when (fboundp 'set-face-attribute) (set-face-attribute 'org-agenda-date-today nil :weight 'bold :italic 't))) +(unless (facep 'org-agenda-clocking) + (copy-face 'secondary-selection 'org-agenda-clocking) + (set-face-doc-string 'org-agenda-clocking + "Face marking the current clock item in the agenda.")) + (unless (facep 'org-agenda-date-weekend) (copy-face 'org-agenda-date 'org-agenda-date-weekend) (set-face-doc-string 'org-agenda-date-weekend diff --git a/lisp/org.el b/lisp/org.el index 636ff5730..8b8ac2b86 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -3086,6 +3086,8 @@ 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.") +(defvar org-clock-hd-marker (make-marker) + "Marker recording the last clock-in, but the headline position.") (defun org-clock-is-active () "Return non-nil if clock is currently running. The return value is actually the clock marker."