Function: todo-prefix-overlays
todo-prefix-overlays is a byte-compiled function defined in
todo-mode.el.gz.
Signature
(todo-prefix-overlays)
Documentation
Update the prefix overlays of the current category's items.
The overlay's value is the string todo-prefix or with non-nil
todo-number-prefix an integer in the sequence from 1 to
the number of todo or done items in the category indicating the
item's priority. Todo and done items are numbered independently
of each other.
Source Code
;; Defined in /usr/src/emacs/lisp/calendar/todo-mode.el.gz
(defun todo-prefix-overlays ()
"Update the prefix overlays of the current category's items.
The overlay's value is the string `todo-prefix' or with non-nil
`todo-number-prefix' an integer in the sequence from 1 to
the number of todo or done items in the category indicating the
item's priority. Todo and done items are numbered independently
of each other."
(let ((num 0)
(cat-tp (or (cdr (assoc-string
(todo-current-category)
(nth 2 (assoc-string todo-current-todo-file
todo-top-priorities-overrides))))
(nth 1 (assoc-string todo-current-todo-file
todo-top-priorities-overrides))
todo-top-priorities))
done prefix)
(save-excursion
(goto-char (point-min))
(while (not (eobp))
(when (or (todo-date-string-matcher (line-end-position))
(todo-done-string-matcher (line-end-position)))
(goto-char (match-beginning 0))
(setq num (1+ num))
;; Reset number to 1 for first done item.
(when (and (eq major-mode 'todo-mode)
(looking-at todo-done-string-start)
(looking-back (concat "^"
(regexp-quote todo-category-done)
"\n")
(line-beginning-position 0)))
(setq num 1
done t))
(setq prefix (concat (propertize
(if todo-number-prefix
(number-to-string num)
todo-prefix)
'face
;; Prefix of top priority items has a
;; distinct face in Todo mode.
(if (and (eq major-mode 'todo-mode)
(not done)
(<= num cat-tp))
'todo-top-priority
'todo-prefix-string))
" "))
(let ((ov (todo-get-overlay 'prefix))
(marked (todo-marked-item-p)))
;; Prefix overlay must be at a single position so its
;; bounds aren't changed when (re)moving an item.
(unless ov (setq ov (make-overlay (point) (point))))
(overlay-put ov 'todo 'prefix)
(overlay-put ov 'before-string (if marked
(concat todo-item-mark prefix)
prefix))))
(forward-line)))))