1
0
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-11-22 07:09:47 +00:00

Mark running clock in the agenda.

If the entry currently being clocked is present in the agenda, mark it.
This commit is contained in:
Carsten Dominik 2009-08-07 11:00:16 +02:00
parent 295491a5e8
commit 0af5133334
5 changed files with 48 additions and 0 deletions

View File

@ -1,5 +1,18 @@
2009-08-07 Carsten Dominik <carsten.dominik@gmail.com>
* 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.

View File

@ -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)

View File

@ -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)

View File

@ -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

View File

@ -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."