summaryrefslogtreecommitdiff
path: root/lisp/calendar
diff options
context:
space:
mode:
authorOliver Seidel <os10000@seidel-space.de>1997-10-17 15:41:57 +0000
committerOliver Seidel <os10000@seidel-space.de>1997-10-17 15:41:57 +0000
commit8e31ab90ff9e98e993a8f5a5d12c8c48f9d3a584 (patch)
tree3cee203dd6b1b108e50df7b3e9a35f6df25744a0 /lisp/calendar
parent7e81b4be19116ee5129c6e3546a29735669b2dbe (diff)
downloademacs-8e31ab90ff9e98e993a8f5a5d12c8c48f9d3a584.tar.gz
Thanks to Harald Backer <harald.backer@fou.telenor.no>, we now have
the following facilities available: Added todo-print, todo-top-priorities and todo-jump with matching variables; Parameterized todo-header, todo-category-beg, todo-category-end and todo-category-sep; Added autoload comments; todo-category-select: Modified regexp to make category names unique; todo-forward-item: Added optional COUNT vaiable; todo-insert-item: Rewrote completing read entry. Also, check out the extended list of things left to be done to this package at the end of the documentation!
Diffstat (limited to 'lisp/calendar')
-rw-r--r--lisp/calendar/todo-mode.el487
1 files changed, 355 insertions, 132 deletions
diff --git a/lisp/calendar/todo-mode.el b/lisp/calendar/todo-mode.el
index 078bbd1dfd1..cb7e020fc26 100644
--- a/lisp/calendar/todo-mode.el
+++ b/lisp/calendar/todo-mode.el
@@ -4,7 +4,7 @@
;; Author: Oliver.Seidel@cl.cam.ac.uk (was valid on Aug 2, 1997)
;; Created: 2 Aug 1997
-;; Version: $Id: todo-mode.el,v 1.18 1997/10/15 17:18:11 os10000 Exp os10000 $
+;; Version: $Id: todo-mode.el,v 1.19 1997/10/16 21:21:16 os10000 Exp os10000 $
;; Keywords: Categorised TODO list editor, todo-mode
;; This file is part of GNU Emacs.
@@ -30,64 +30,83 @@
;; Preface, Quickstart Installation
;;
-;; To get this to work, make emacs execute the line
+;; To get this to work, make emacs execute the line
;;
-;; (require 'todo-mode) ;; load the TODO package
+;; (require 'todo-mode) ;; load the TODO package
;;
-;; You may now enter new items by typing "M-x todo-insert-item", or enter
-;; your the TODO list file by typing "M-x todo-show".
+;; If you don't like "require", do as Harald Backer prescribes:
;;
-;; The TODO list file has a special format and some auxiliary
-;; information, which will be added by the todo-show function if it
-;; attempts to visit an un-initialised file. Hence it is
-;; recommended to use the todo-show function for the first time, in
-;; order to initialise the file, but it is not necessary
-;; afterwards.
+;; "I don't like require statements as they slow down startup
+;; emacs. As I include .todo-do in diary and start calendar
+;; at startup of emacs, the mode indicator of .todo-do will
+;; make emacs fail, unless the following is defined:"
;;
-;; As these commands are quite long to type, I would recommend the
-;; addition of two bindings to your to your global keymap. I
-;; personally have the following in my initialisation file:
+;; (autoload 'todo-mode "todo-mode"
+;; "Major mode for editing TODO lists." t)
;;
-;; (global-set-key "\C-ct" 'todo-show) ;; switch to TODO buffer
+;; You may now enter new items by typing "M-x todo-insert-item",
+;; or enter your TODO list file by typing "M-x todo-show".
+;;
+;; The TODO list file has a special format and some auxiliary
+;; information, which will be added by the todo-show function if
+;; it attempts to visit an un-initialised file. Hence it is
+;; recommended to use the todo-show function for the first time,
+;; in order to initialise the file, but it is not necessary
+;; afterwards.
+;;
+;; As these commands are quite long to type, I would recommend
+;; the addition of two bindings to your to your global keymap. I
+;; personally have the following in my initialisation file:
+;;
+;; (global-set-key "\C-ct" 'todo-show) ;; switch to TODO buffer
;; (global-set-key "\C-ci" 'todo-insert-item) ;; insert new item
;;
-;; Note, however, that this recommendation has prompted some
-;; criticism, since the keys C-c LETTER are reserved for user
-;; functions. I believe my recommendation is acceptable, since the
-;; Emacs Lisp Manual *Tips* section also details that the mode itself
-;; should not bind any functions to those keys. The express aim of
-;; the above two bindings is to work outside the mode, which doesn't
-;; need the show function and offers a different binding for the
-;; insert function. They serve as shortcuts and are not even needed
-;; (since the TODO mode will be entered by visiting the TODO file, and
-;; later by switching to its buffer).
+;; Note, however, that this recommendation has prompted some
+;; criticism, since the keys C-c LETTER are reserved for user
+;; functions. I believe my recommendation is acceptable, since
+;; the Emacs Lisp Manual *Tips* section also details that the
+;; mode itself should not bind any functions to those keys. The
+;; express aim of the above two bindings is to work outside the
+;; mode, which doesn't need the show function and offers a
+;; different binding for the insert function. They serve as
+;; shortcuts and are not even needed (since the TODO mode will be
+;; entered by visiting the TODO file, and later by switching to
+;; its buffer).
+;;
+;; Version
;;
-;; Pre-Requisites
+;; Which version of todo-mode.el does this documentation refer to?
;;
-;; This package will require the following packages to be available on
-;; the load-path:
+;; $Id:$
;;
-;; time-stamp
+;; Pre-Requisites
+;;
+;; This package will require the following packages to be
+;; available on the load-path:
+;;
+;; time-stamp
;; easymenu
;;
-;; Mode Description
+;; Mode Description
;;
-;; TODO is a major mode for EMACS which offers functionality to treat
-;; most lines in one buffer as a list of items one has to do. There
-;; are facilities to add new items, which are categorised, to edit or
-;; even delete items from the buffer. The buffer contents are
-;; currently compatible with the diary, so that the list of todo-items
-;; will show up in the FANCY diary mode.
+;; TODO is a major mode for EMACS which offers functionality to
+;; treat most lines in one buffer as a list of items one has to
+;; do. There are facilities to add new items, which are
+;; categorised, to edit or even delete items from the buffer.
+;; The buffer contents are currently compatible with the diary,
+;; so that the list of todo-items will show up in the FANCY diary
+;; mode.
;;
-;; Notice: Besides the major mode, this file also exports the function
-;; "todo-show" which will change to the one specific TODO file that
-;; has been specified in the todo-file-do variable. If this file does
-;; not conform to the TODO mode conventions, the todo-show function
-;; will add the appropriate header and footer. I don't anticipate
-;; this to cause much grief, but be warned, in case you attempt to
-;; read a plain text file.
+;; Notice: Besides the major mode, this file also exports the
+;; function "todo-show" which will change to the one specific
+;; TODO file that has been specified in the todo-file-do
+;; variable. If this file does not conform to the TODO mode
+;; conventions, the todo-show function will add the appropriate
+;; header and footer. I don't anticipate this to cause much
+;; grief, but be warned, in case you attempt to read a plain text
+;; file.
;;
-;; Operation
+;; Operation
;;
;; You will have the following facilities available:
;;
@@ -95,119 +114,158 @@
;;
;; + to go to next category
;; - to go to previous category
+;; d to file the current entry, including a
+;; comment and timestamp
;; e to edit the current entry
;; f to file the current entry, including a
;; comment and timestamp
;; i to insert a new entry
+;; j jump to category
;; k to kill the current entry
;; l to lower the current entry's priority
;; n for the next entry
;; p for the previous entry
+;; P print
;; q to save the list and exit the buffer
;; r to raise the current entry's priority
;; s to save the list
+;; t show top priority items for each category
;;
-;; When you add a new entry, you are asked for the text and then for
-;; the category. I for example have categories for things that I want
-;; to do in the office (like mail my mum), that I want to do in town
-;; (like buy cornflakes) and things I want to do at home (move my
-;; suitcases). The categories can be selected with the cursor keys
-;; and if you type in the name of a category which didn't exist
-;; before, an empty category of the desired name will be added and
-;; filled with the new entry.
+;; When you add a new entry, you are asked for the text and then
+;; for the category. I for example have categories for things
+;; that I want to do in the office (like mail my mum), that I
+;; want to do in town (like buy cornflakes) and things I want to
+;; do at home (move my suitcases). The categories can be
+;; selected with the cursor keys and if you type in the name of a
+;; category which didn't exist before, an empty category of the
+;; desired name will be added and filled with the new entry.
;;
;; Configuration
;;
;; Variable todo-prefix
;;
;; I would like to recommend that you use the prefix "*/*" (by
-;; leaving the variable 'todo-prefix' untouched) so that the diary
-;; displays each entry every day.
+;; leaving the variable 'todo-prefix' untouched) so that the
+;; diary displays each entry every day.
;;
-;; To understand what I mean, please read the documentation that goes
-;; with the calendar since that will tell you how you can set up the
-;; fancy diary display and use the #include command to include your
-;; todo list file as part of your diary.
+;; To understand what I mean, please read the documentation that
+;; goes with the calendar since that will tell you how you can
+;; set up the fancy diary display and use the #include command to
+;; include your todo list file as part of your diary.
;;
-;; If you have the diary package set up to usually display more than
-;; one day's entries at once, consider using
+;; If you have the diary package set up to usually display more
+;; than one day's entries at once, consider using
;;
;; "&%%(equal (calendar-current-date) date)"
;;
-;; as the value of `todo-prefix'. Please note that this may slow down
-;; the processing of your diary file some.
+;; as the value of `todo-prefix'. Please note that this may slow
+;; down the processing of your diary file some.
;;
;; Variable todo-file-do
;;
-;; This variable is fairly self-explanatory. You have to store your TODO
-;; list somewhere. This variable tells the package where to go and find
-;; this file.
+;; This variable is fairly self-explanatory. You have to store
+;; your TODO list somewhere. This variable tells the package
+;; where to go and find this file.
;;
;; Variable todo-file-done
;;
-;; Even when you're done, you may wish to retain the entries. Given
-;; that they're timestamped and you are offered to add a comment, this
-;; can make a useful diary of past events. It will even blend in with
-;; the EMACS diary package. So anyway, this variable holds the name
-;; of the file for the filed todo-items.
+;; Even when you're done, you may wish to retain the entries.
+;; Given that they're timestamped and you are offered to add a
+;; comment, this can make a useful diary of past events. It will
+;; even blend in with the EMACS diary package. So anyway, this
+;; variable holds the name of the file for the filed todo-items.
;;
;; Variable todo-mode-hook
;;
-;; Just like other modes, too, this mode offers to call your functions
-;; before it goes about its business. This variable will be inspected
-;; for any functions you may wish to have called once the other TODO
-;; mode preparations have been completed.
-;;
-;; Variables todo-insert-threshold
-;;
-;; Another nifty feature is the insertion accuracy. If you have 8
-;; items in your TODO list, then you may get asked 4 questions by the
-;; binary insertion algorithm. However, you may not really have a
-;; need for such accurate priorities amongst your TODO items. If you
-;; now think about the binary insertion halfing the size of the window
-;; each time, then the threshhold is the window size at which it will
-;; stop. If you set the threshhold to zero, the upper and lower bound
-;; will coincide at the end of the loop and you will insert your item
-;; just before that point. If you set the threshhold to i.e. 8, it
-;; will stop as soon as the window size drops below that amount and
-;; will insert the item in the approximate centre of that window. I
-;; got the idea for this feature after reading a very helpful e-mail
-;; reply from Trey Jackson <trey@cs.berkeley.edu> who corrected some
-;; of my awful coding and pointed me towards some good reading.
-;; Thanks Trey!
+;; Just like other modes, too, this mode offers to call your
+;; functions before it goes about its business. This variable
+;; will be inspected for any functions you may wish to have
+;; called once the other TODO mode preparations have been
+;; completed.
+;;
+;; Variable todo-insert-threshold
+;;
+;; Another nifty feature is the insertion accuracy. If you have
+;; 8 items in your TODO list, then you may get asked 4 questions
+;; by the binary insertion algorithm. However, you may not
+;; really have a need for such accurate priorities amongst your
+;; TODO items. If you now think about the binary insertion
+;; halfing the size of the window each time, then the threshhold
+;; is the window size at which it will stop. If you set the
+;; threshhold to zero, the upper and lower bound will coincide at
+;; the end of the loop and you will insert your item just before
+;; that point. If you set the threshhold to i.e. 8, it will stop
+;; as soon as the window size drops below that amount and will
+;; insert the item in the approximate centre of that window. I
+;; got the idea for this feature after reading a very helpful
+;; e-mail reply from Trey Jackson <trey@cs.berkeley.edu> who
+;; corrected some of my awful coding and pointed me towards some
+;; good reading. Thanks Trey!
;;
;; Things to do
;;
-;; o licence / version function
+;; These originally were my ideas, but now also include all the
+;; suggestions that I included before forgetting them:
+;;
+;; o Automatic save of top-priorities to file, for inclusion in
+;; .diary, at save of .todo-do, ref. automatic save of .bbdb
+;; in gnus
+;; o Fancy fonts for todo/top-priority buffer
+;; o Remove todo-prefix option in todo-top-priorities
+;; o Rename category
+;; o Move entry from one category to another one
+;; o Entries which both have the generic */* prefix and a
+;; "deadline" entry which are understood by diary, indicating
+;; an event (unless marked by &)
+;; o The optional COUNT variable of todo-forward-item should be
+;; applied to the other functions performing similar tasks
+;; o Modularization could be done for repeaded elements of
+;; the code, like the completing-read lines of code.
+;; o license / version function
;; o export to diary file
;; o todo-report-bug
;; o GNATS support
-;; o elide multiline
-;; o rewrite complete package to store data as lisp objects and have
-;; display modes for display, for diary export, etc.
-;; (Richard Stallman pointed out this is a bad idea)
-;; o base todo-mode.el on generic-mode.el instead
+;; o elide multiline (as in bbdb, or, to a lesser degree, in
+;; outline mode)
+;; o rewrite complete package to store data as lisp objects
+;; and have display modes for display, for diary export,
+;; etc. (Richard Stallman pointed out this is a bad idea)
+;; o so base todo-mode.el on generic-mode.el instead
;;
-;; History and Gossip
+;; History and Gossip
;;
-;; Many thanks to all the ones who have contributed to the evolution
-;; of this package! I hope I have listed all of you somewhere in the
-;; documentation or at least in the RCS history!
+;; Many thanks to all the ones who have contributed to the
+;; evolution of this package! I hope I have listed all of you
+;; somewhere in the documentation or at least in the RCS history!
;;
-;; Enjoy this package and express your gratitude by sending nice things
-;; to my parents' address!
+;; Enjoy this package and express your gratitude by sending nice
+;; things to my parents' address!
;;
;; Oliver Seidel
-;; (O Seidel, Lessingstr. 8, 65760 Eschborn, Federal Republic of Germany)
+;; (Lessingstr. 8, 65760 Eschborn, Federal Republic of Germany)
;;
;; ---------------------------------------------------------------------------
-;; ---------------------------------------------------------------------------
-
;;; Change Log:
;; $Log: todo-mode.el,v $
+;; Revision 1.19 1997/10/16 21:21:16 os10000
+;; Jari Aalto <jari.aalto@poboxes.com> writes:
+;;
+;; I just downloaded your package and after reading the docs I
+;; decided to do some reformatting. Hope you don't mind. Now
+;; they are in such a format that the html page can be
+;; automatically generated from the source file. As an example, I
+;; generated the attached page using the following command:
+;; ripdoc.pls < todo-mode.el | t2html.pls -a "Oliver.Seidel" -e \
+;; Oliver.Seidel@cl.cam.ac.uk -simple
+;;
+;; And of course I appreciate it. Jari's stuff can be found at:
+;; ftp://cs.uta.fi/pub/ssjaaa/, while I'm making the rev 1.18 page
+;; available at http://www.cl.cam.ac.uk/users/os10000/doc/todo-mode.html
+;; (That link will be valid until 10/1998 or slightly longer.)
+;;
;; Revision 1.18 1997/10/15 17:18:11 os10000
;; Everything seems to work in Harald Melands Emacs 20.02 and
;; my Emacs 19.34. Beware of the spelling in some of the
@@ -310,6 +368,19 @@
(defvar todo-insert-threshold 0 "*TODO mode insertion accuracy.")
(defvar todo-edit-buffer " *TODO Edit*" "TODO Edit buffer name.")
+(defvar todo-print-function 'ps-print-buffer-with-faces
+ "*Function to print the current buffer.")
+(defvar todo-show-priorities 1
+ "*Default number of priorities to show by
+ \\[todo-top-priorities]. 0 means show all entries.")
+(defvar todo-print-priorities 0
+ "*Default number of priorities to print by
+ \\[todo-print]. 0 means print all entries.")
+(defvar todo-remove-separator t
+ "*Non-nil removes category separators in
+ \\[todo-top-priorities] and \\[todo-print].")
+
+
;; Thanks for the ISO time stamp format go to Karl Eichwalder <ke@suse.de>
;; My format string for the appt.el package is "%3b %2d, %y, %02I:%02M%p".
;;
@@ -318,6 +389,15 @@
"TODO mode time string format for done entries.
For details see the variable `time-stamp-format'.")
+(defvar todo-entry-prefix-function 'todo-entry-timestamp-initials
+ "*Function producing text to insert at start of todo entry.")
+(defvar todo-initials (or (getenv "INITIALS") (user-login-name))
+ "*Initials of todo item author.")
+
+(defun todo-entry-timestamp-initials ()
+ (let ((time-stamp-format todo-time-string-format))
+ (concat (time-stamp-string) " " todo-initials ": ")))
+
;; ---------------------------------------------------------------------------
;; Get some outside help ...
@@ -330,13 +410,25 @@ For details see the variable `time-stamp-format'.")
;; Set up some helpful context ...
(defvar todo-categories nil "TODO categories.")
-(defvar todo-cats nil
- "Old variable for holding the TODO categories. Use `todo-categories' instead.")
+(defvar todo-cats nil "Old variable for holding the
+TODO categories. Use `todo-categories' instead.")
(defvar todo-previous-line 0 "Previous line that I asked about.")
(defvar todo-previous-answer 0 "Previous answer that I got.")
(defvar todo-mode-map nil "TODO mode keymap.")
(defvar todo-category-number 0 "TODO category number.")
+
+(defvar todo-category-sep (make-string 75 ?-)
+ "Category separator.")
+(defvar todo-category-beg " --- "
+ "Category start separator to be prepended onto category name.")
+(defvar todo-category-end "--- End"
+ "Separator after a category.")
+(defvar todo-header "-*- mode: todo; "
+ "Header of todo files.")
+
+
+
;; ---------------------------------------------------------------------------
(if todo-mode-map
@@ -347,15 +439,19 @@ For details see the variable `time-stamp-format'.")
(define-key map "-" 'todo-backward-category)
(define-key map "e" 'todo-edit-item)
(define-key map "E" 'todo-edit-multiline)
+ (define-key map "d" 'todo-file-item) ;done/delete
(define-key map "f" 'todo-file-item)
(define-key map "i" 'todo-insert-item)
+ (define-key map "j" 'todo-jump-to-category)
(define-key map "k" 'todo-delete-item)
(define-key map "l" 'todo-lower-item)
(define-key map "n" 'todo-forward-item)
(define-key map "p" 'todo-backward-item)
+ (define-key map "P" 'todo-print)
(define-key map "q" 'todo-quit)
(define-key map "r" 'todo-raise-item)
(define-key map "s" 'todo-save)
+ (define-key map "t" 'todo-top-priorities)
(setq todo-mode-map map)))
(defun todo-category-select ()
@@ -366,9 +462,11 @@ For details see the variable `time-stamp-format'.")
(widen)
(goto-char (point-min))
(search-forward-regexp
- (concat "^" (regexp-quote (concat todo-prefix " --- " name))))
+ (concat "^"
+ (regexp-quote (concat todo-prefix todo-category-beg name))
+ "$"))
(let ((begin (1+ (point-at-eol))))
- (search-forward-regexp "^--- End")
+ (search-forward-regexp (concat "^" todo-category-end))
(narrow-to-region begin (point-at-bol))
(goto-char (point-min)))))
(defalias 'todo-cat-slct 'todo-category-select)
@@ -393,10 +491,13 @@ For details see the variable `time-stamp-format'.")
(message ""))
(defalias 'todo-cmd-prev 'todo-backward-item)
-(defun todo-forward-item () "Select next entry of TODO list."
- (interactive)
+(defun todo-forward-item (&optional count)
+ "Select Nth next entry of TODO list."
+ (interactive "P")
+ (if (listp count) (setq count (car count)))
(end-of-line)
- (search-forward-regexp (concat "^" (regexp-quote todo-prefix)) nil 'goto-end)
+ (search-forward-regexp (concat "^" (regexp-quote todo-prefix))
+ nil 'goto-end count)
(beginning-of-line)
(message ""))
(defalias 'todo-cmd-next 'todo-forward-item)
@@ -430,12 +531,14 @@ For details see the variable `time-stamp-format'.")
"Set up a buffer for editing a multiline TODO list entry."
(interactive)
(let ((buffer-name (generate-new-buffer-name todo-edit-buffer)))
- (switch-to-buffer (make-indirect-buffer (file-name-nondirectory todo-file-do)
- buffer-name))
+ (switch-to-buffer
+ (make-indirect-buffer
+ (file-name-nondirectory todo-file-do) buffer-name))
(message "To exit, simply kill this buffer and return to list.")
(todo-edit-mode)
(narrow-to-region (todo-item-start) (todo-item-end))))
+;;;### autoload
(defun todo-add-category (cat) "Add a new category to the TODO list."
(interactive)
(save-window-excursion
@@ -452,21 +555,29 @@ For details see the variable `time-stamp-format'.")
(kill-line)))
(insert (format "todo-categories: %S; -*-" todo-categories))
(forward-char 1)
- (insert (format "%s --- %s\n--- End\n%s %s\n"
- todo-prefix cat todo-prefix (make-string 75 ?-))))
+ (insert (format "%s%s%s\n%s\n%s %s\n"
+ todo-prefix todo-category-beg cat
+ todo-category-end
+ todo-prefix todo-category-sep)))
0)
+;;;### autoload
(defun todo-insert-item ()
"Insert new TODO list entry."
(interactive)
(let* ((new-item (concat todo-prefix " "
- (read-from-minibuffer "New TODO entry: ")))
+ (read-from-minibuffer
+ "New TODO entry: "
+ (if todo-entry-prefix-function
+ (funcall todo-entry-prefix-function)))))
(categories todo-categories)
(history (cons 'categories (1+ todo-category-number)))
- (category (completing-read "Category: "
- (todo-category-alist) nil nil
- (nth todo-category-number todo-categories)
- history)))
+ (category (completing-read
+ (concat "Category ["
+ (nth todo-category-number todo-categories) "]: ")
+ (todo-category-alist) nil nil nil history)))
+ (if (string= "" category)
+ (setq category (nth todo-category-number todo-categories)))
(let ((cat-exists (member category todo-categories)))
(setq todo-category-number
(if cat-exists
@@ -534,7 +645,8 @@ For details see the variable `time-stamp-format'.")
(defun todo-lower-item () "Lower priority of current entry."
(interactive)
- (if (> (count-lines (point) (point-max)) 1) ; Assume there is a final newline
+ (if (> (count-lines (point) (point-max)) 1)
+ ;; Assume there is a final newline
(let ((item (todo-item-string)))
(todo-remove-item)
(todo-forward-item)
@@ -552,16 +664,18 @@ For details see the variable `time-stamp-format'.")
(if (> (length comment) 0)
(progn
(goto-char (todo-item-end))
- (insert (if (save-excursion (beginning-of-line)
- (looking-at (regexp-quote todo-prefix)))
- " "
- "\n\t")
- "(" (nth todo-category-number todo-categories) ": "
- comment ")\n")))
+ (insert
+ (if (save-excursion (beginning-of-line)
+ (looking-at (regexp-quote todo-prefix)))
+ " "
+ "\n\t")
+ "(" (nth todo-category-number todo-categories) ": "
+ comment ")\n")))
(goto-char (todo-item-start))
(let ((temp-point (point)))
(if (looking-at (regexp-quote todo-prefix))
- (replace-match (time-stamp-string)) ; Standard prefix -> timestamp
+ (replace-match (time-stamp-string))
+ ;; Standard prefix -> timestamp
;; Else prefix non-standard item start with timestamp
(insert (time-stamp-string)))
(append-to-file temp-point (todo-item-end) todo-file-done)
@@ -574,6 +688,108 @@ For details see the variable `time-stamp-format'.")
;; Utility functions:
+
+;;;###autoload
+(defun todo-top-priorities (&optional nof-priorities category-pr-page)
+ "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 "P")
+ (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 "*Tmp*")
+ ;;(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)
+ (todo-show)
+ (save-excursion
+ (save-restriction
+ (widen)
+ (copy-to-buffer todo-print-buffer-name (point-min) (point-max))
+ (set-buffer todo-print-buffer-name)
+ (goto-char (point-min))
+ (if (re-search-forward (regexp-quote todo-header) nil t)
+ (progn
+ (beginning-of-line 1)
+ (kill-line))) ;Remove mode line
+ (while (re-search-forward ;Find category start
+ (regexp-quote (concat todo-prefix todo-category-beg))
+ nil t)
+ (setq beg (+ (point-at-eol) 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 (= 0 nof-priorities) ;Traverse entries.
+ (goto-char end) ;All entries
+ (todo-forward-item nof-priorities))
+ (setq beg (point))
+ (delete-region beg end)
+ (widen))
+ (goto-char (point-min)) ;Due to display buffer
+ ))
+ ;; Could have used switch-to-buffer as it has a norecord argument,
+ ;; which is nice when we are called from e.g. todo-print.
+ ;; Else we could have used pop-to-buffer should be used.
+ (display-buffer todo-print-buffer-name)
+ ;;(switch-to-buffer todo-print-buffer-name t)
+ (message "Type C-x 1 to remove %s window. M-C-v to scroll the help."
+ todo-print-buffer-name)
+ ))
+
+;;;###autoload
+(defun todo-print (&optional category-pr-page)
+ "Print todo summary using \\\[todo-print-function].
+If CATEGORY-PR-PAGE is non-nil, a page separator \'^L\' is inserted
+between each category.
+
+Number of entries for each category is given by
+\'todo-print-priorities\'."
+ (interactive "P")
+ (save-window-excursion
+ (save-excursion
+ (save-restriction
+ (todo-top-priorities todo-print-priorities
+ category-pr-page)
+ (if todo-print-function
+ (progn
+ (funcall todo-print-function)
+ (message "Todo printing done."))
+ (message "") ; To get rid of message from
+ ; todo-top-priorities.
+ )))))
+
+(defun todo-jump-to-category ()
+ "Jump to a category. Default is previous category."
+ (interactive)
+ (let* ((categories todo-categories)
+ (history (cons 'categories (1+ todo-category-number)))
+ (category (completing-read
+ (concat "Category ["
+ (nth todo-category-number todo-categories) "]: ")
+ (todo-category-alist) nil nil nil history)))
+ (if (string= "" category)
+ (setq category (nth todo-category-number todo-categories)))
+ (setq todo-category-number
+ (if (member category todo-categories)
+ (- (length todo-categories)
+ (length (member category todo-categories)))
+ (todo-add-category category)))
+ (todo-show)))
+
(defun todo-line-string () "Return current line in buffer as a string."
(buffer-substring (point-at-bol) (point-at-eol)))
@@ -596,7 +812,8 @@ For details see the variable `time-stamp-format'.")
(defun todo-item-end () "Return point at end of current TODO list item."
(save-excursion
(end-of-line)
- (search-forward-regexp (concat "^" (regexp-quote todo-prefix)) nil 'goto-end)
+ (search-forward-regexp
+ (concat "^" (regexp-quote todo-prefix)) nil 'goto-end)
(1- (point-at-bol))))
(defun todo-remove-item () "Delete the current entry from the TODO list."
@@ -661,6 +878,9 @@ If SEPARATORS is absent, it defaults to \"[ \\f\\t\\n\\r\\v]+\"."
'("Todo"
["Next category" todo-forward-category t]
["Previous category" todo-backward-category t]
+ ["Jump to category" todo-jump-to-category t]
+ ["Show top priority items" todo-top-priorities t]
+ ["Print categories" todo-print t]
"---"
["Edit item" todo-edit-item t]
["File item" todo-file-item t]
@@ -678,6 +898,8 @@ If SEPARATORS is absent, it defaults to \"[ \\f\\t\\n\\r\\v]+\"."
["Quit" todo-quit t]
))
+;; As calendar reads .todo-do before todo-mode is loaded.
+;;;### autoload
(defun todo-mode () "Major mode for editing TODO lists.\n\n\\{todo-mode-map}"
(interactive)
(setq major-mode 'todo-mode)
@@ -693,6 +915,7 @@ If SEPARATORS is absent, it defaults to \"[ \\f\\t\\n\\r\\v]+\"."
(setq mode-name "TODO Edit")
(run-hooks 'todo-edit-mode-hook))
+;;;### autoload
(defun todo-show () "Show TODO list."
(interactive)
(if (file-exists-p todo-file-do)