Function: todo-top-priorities

todo-top-priorities is an interactive and byte-compiled function defined in otodo-mode.el.gz.

Signature

(todo-top-priorities &optional NOF-PRIORITIES CATEGORY-PR-PAGE INTERACTIVE)

Documentation

List top priorities for each category.

Number of entries for each category is given by NOF-PRIORITIES which defaults to todo-show-priorities.

If CATEGORY-PR-PAGE is non-nil, a page separator ^L is inserted between each category. INTERACTIVE should be non-nil if this function is called interactively.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/obsolete/otodo-mode.el.gz
;; ---------------------------------------------------------------------------

;; Utility functions:


;;;###autoload
(defun todo-top-priorities (&optional nof-priorities category-pr-page
                                      interactive)
  "List top priorities for each category.

Number of entries for each category is given by NOF-PRIORITIES which
defaults to `todo-show-priorities'.

If CATEGORY-PR-PAGE is non-nil, a page separator `^L' is inserted
between each category.
INTERACTIVE should be non-nil if this function is called interactively."

  (interactive "P\ni\nP")
  (or nof-priorities (setq nof-priorities todo-show-priorities))
  (if (listp nof-priorities)            ;universal argument
      (setq nof-priorities (car nof-priorities)))
  (let ((todo-print-buffer-name todo-tmp-buffer-name)
        ;;(todo-print-category-number 0)
        (todo-category-break (if category-pr-page "" ""))
        (cat-end
         (concat
          (if todo-remove-separator
              (concat todo-category-end "\n"
                      (regexp-quote todo-prefix) " " todo-category-sep "\n")
            (concat todo-category-end "\n"))))
        beg end)
    (save-excursion
      (todo-show)
      (save-restriction
	(save-current-buffer
	  (widen)
	  (copy-to-buffer todo-print-buffer-name (point-min) (point-max))
	  (set-buffer todo-print-buffer-name)
	  (goto-char (point-min))
	  (when (re-search-forward (regexp-quote todo-header) nil t)
	    (beginning-of-line 1)
	    (delete-region (point) (line-end-position)))
	  (while (re-search-forward       ;Find category start
		  (regexp-quote (concat todo-prefix todo-category-beg))
		  nil t)
	    (setq beg (+ (line-end-position) 1)) ;Start of first entry.
	    (re-search-forward cat-end nil t)
	    (setq end (match-beginning 0))
	    (replace-match todo-category-break)
	    (narrow-to-region beg end)    ;In case we have too few entries.
	    (goto-char (point-min))
	    (if (zerop nof-priorities)      ;Traverse entries.
		(goto-char end)            ;All entries
	      (todo-forward-item nof-priorities))
	    (setq beg (point))
	    (delete-region beg end)
	    (widen))
	  (and (looking-at "") (replace-match "")) ;Remove trailing form-feed.
	  (goto-char (point-min))         ;Due to display buffer
	  )))
    (when interactive (display-buffer todo-print-buffer-name))
    (message "Type C-x 1 to remove %s window.  M-C-v to scroll the help."
             todo-print-buffer-name)))