aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOliver Seidel1997-10-28 21:14:51 +0000
committerOliver Seidel1997-10-28 21:14:51 +0000
commit85b3b16644c40c90fb49f62944cfb47fbe2a5609 (patch)
treee6b6856643c96c13b2c7dfbf21e7e315183fd061
parentf1757bdd294a1122cac696d8070d05cf193c8984 (diff)
downloademacs-85b3b16644c40c90fb49f62944cfb47fbe2a5609.tar.gz
emacs-85b3b16644c40c90fb49f62944cfb47fbe2a5609.zip
Improvements sent in by Dave Love <d.love@dl.ac.uk>:
todo-mode.el: Doc fixes. Customization. (todo-add-item-non-interactively): New arg -- don't dynamically bind ARG. (todo-insert-item): Use it.
-rw-r--r--lisp/calendar/todo-mode.el245
1 files changed, 163 insertions, 82 deletions
diff --git a/lisp/calendar/todo-mode.el b/lisp/calendar/todo-mode.el
index 02e1057596f..721e312aeb9 100644
--- a/lisp/calendar/todo-mode.el
+++ b/lisp/calendar/todo-mode.el
@@ -4,7 +4,7 @@
4 4
5;; Author: Oliver.Seidel@cl.cam.ac.uk (was valid on Aug 2, 1997) 5;; Author: Oliver.Seidel@cl.cam.ac.uk (was valid on Aug 2, 1997)
6;; Created: 2 Aug 1997 6;; Created: 2 Aug 1997
7;; Version: $Id: todo-mode.el,v 1.24 1997/10/28 19:41:53 os10000 Exp os10000 $ 7;; Version: $Id: todo-mode.el,v 1.25 1997/10/28 20:03:27 os10000 Exp os10000 $
8;; Keywords: Categorised TODO list editor, todo-mode 8;; Keywords: Categorised TODO list editor, todo-mode
9 9
10;; This file is part of GNU Emacs. 10;; This file is part of GNU Emacs.
@@ -28,6 +28,25 @@
28 28
29;;; Commentary: 29;;; Commentary:
30 30
31;; Mode Description
32;;
33;; TODO is a major mode for EMACS which offers functionality to
34;; treat most lines in one buffer as a list of items one has to
35;; do. There are facilities to add new items, which are
36;; categorised, to edit or even delete items from the buffer.
37;; The buffer contents are currently compatible with the diary,
38;; so that the list of todo-items will show up in the FANCY diary
39;; mode.
40;;
41;; Notice: Besides the major mode, this file also exports the
42;; function `todo-show' which will change to the one specific
43;; TODO file that has been specified in the todo-file-do
44;; variable. If this file does not conform to the TODO mode
45;; conventions, the todo-show function will add the appropriate
46;; header and footer. I don't anticipate this to cause much
47;; grief, but be warned, in case you attempt to read a plain text
48;; file.
49;;
31;; Preface, Quickstart Installation 50;; Preface, Quickstart Installation
32;; 51;;
33;; To get this to work, make emacs execute the line 52;; To get this to work, make emacs execute the line
@@ -72,7 +91,7 @@
72;; 91;;
73;; Which version of todo-mode.el does this documentation refer to? 92;; Which version of todo-mode.el does this documentation refer to?
74;; 93;;
75;; $Id: todo-mode.el,v 1.24 1997/10/28 19:41:53 os10000 Exp os10000 $ 94;; $Id: todo-mode.el,v 1.25 1997/10/28 20:03:27 os10000 Exp os10000 $
76;; 95;;
77;; Pre-Requisites 96;; Pre-Requisites
78;; 97;;
@@ -82,25 +101,6 @@
82;; time-stamp 101;; time-stamp
83;; easymenu 102;; easymenu
84;; 103;;
85;; Mode Description
86;;
87;; TODO is a major mode for EMACS which offers functionality to
88;; treat most lines in one buffer as a list of items one has to
89;; do. There are facilities to add new items, which are
90;; categorised, to edit or even delete items from the buffer.
91;; The buffer contents are currently compatible with the diary,
92;; so that the list of todo-items will show up in the FANCY diary
93;; mode.
94;;
95;; Notice: Besides the major mode, this file also exports the
96;; function "todo-show" which will change to the one specific
97;; TODO file that has been specified in the todo-file-do
98;; variable. If this file does not conform to the TODO mode
99;; conventions, the todo-show function will add the appropriate
100;; header and footer. I don't anticipate this to cause much
101;; grief, but be warned, in case you attempt to read a plain text
102;; file.
103;;
104;; Operation 104;; Operation
105;; 105;;
106;; You will have the following facilities available: 106;; You will have the following facilities available:
@@ -125,7 +125,7 @@
125;; r to raise the current entry's priority 125;; r to raise the current entry's priority
126;; s to save the list 126;; s to save the list
127;; S to save the list of top priorities 127;; S to save the list of top priorities
128;; t show top priority items for each category 128;; t show top priority items for each category
129;; 129;;
130;; When you add a new entry, you are asked for the text and then 130;; When you add a new entry, you are asked for the text and then
131;; for the category. I for example have categories for things 131;; for the category. I for example have categories for things
@@ -196,7 +196,7 @@
196;; is the window size at which it will stop. If you set the 196;; is the window size at which it will stop. If you set the
197;; threshhold to zero, the upper and lower bound will coincide at 197;; threshhold to zero, the upper and lower bound will coincide at
198;; the end of the loop and you will insert your item just before 198;; the end of the loop and you will insert your item just before
199;; that point. If you set the threshhold to i.e. 8, it will stop 199;; that point. If you set the threshhold to, e.g. 8, it will stop
200;; as soon as the window size drops below that amount and will 200;; as soon as the window size drops below that amount and will
201;; insert the item in the approximate centre of that window. I 201;; insert the item in the approximate centre of that window. I
202;; got the idea for this feature after reading a very helpful 202;; got the idea for this feature after reading a very helpful
@@ -249,6 +249,12 @@
249;;; Change Log: 249;;; Change Log:
250 250
251;; $Log: todo-mode.el,v $ 251;; $Log: todo-mode.el,v $
252;; Revision 1.25 1997/10/28 20:03:27 os10000
253;; Harald Backer <harald.backer@fou.telenor.no> sent the following:
254;; Added `todo-save-top-priorities' and option to automatically save top
255;; priorities file when saving todo-file. Changed some default values.
256;; Bug fixes.
257;;
252;; Revision 1.24 1997/10/28 19:41:53 os10000 258;; Revision 1.24 1997/10/28 19:41:53 os10000
253;; Added fix from Frank Ridderbusch <ridderbusch.pad@sni.de>, 259;; Added fix from Frank Ridderbusch <ridderbusch.pad@sni.de>,
254;; an apostrophe was missing. 260;; an apostrophe was missing.
@@ -411,55 +417,124 @@
411 417
412;;; Code: 418;;; Code:
413 419
420(eval-and-compile ; Removable for installation in
421 ; Emacs 20.
422 (condition-case ()
423 (require 'custom)
424 (error nil))
425 (if (and (featurep 'custom) (fboundp 'custom-declare-variable))
426 nil ;; We've got what we needed
427 ;; We have the old custom-library, hack around it!
428 (defmacro defgroup (&rest args)
429 nil)
430 (defmacro defcustom (var value doc &rest args)
431 (` (defvar (, var) (, value) (, doc))))))
432
414;; User-configurable variables: 433;; User-configurable variables:
415 434
416(defvar todo-prefix "*/*" "*TODO mode prefix for entries.") 435(defgroup todo nil
417(defvar todo-file-do "~/.todo-do" "*TODO mode list file.") 436 "Maintain a list of todo items."
418(defvar todo-file-done "~/.todo-done" "*TODO mode archive file.") 437 :group 'calendar)
419(defvar todo-mode-hook nil "*TODO mode hooks.") 438
420(defvar todo-edit-mode-hook nil "*TODO Edit mode hooks.") 439(defcustom todo-prefix "*/*"
421(defvar todo-insert-threshold 0 "*TODO mode insertion accuracy.") 440 "*TODO mode prefix for entries.
441
442This is useful in conjunction with `calendar' and `diary' if you use
443
444#include \"~/.todo-do\"
445
446in your diary file to include your todo list file as part of your
447diary. With the default value \"*/*\" the diary displays each entry
448every day and it may also be marked on every day of the calendar.
449Using \"&%%(equal (calendar-current-date) date)\" instead will only
450show and mark todo entreis for today, but may slow down processing of
451the diary file somewhat."
452 :type 'string
453 :group 'todo)
454(defcustom todo-file-do "~/.todo-do"
455 "*TODO mode list file."
456 :type 'file
457 :group 'todo)
458(defcustom todo-file-done "~/.todo-done"
459 "*TODO mode archive file."
460 :type 'file
461 :group 'todo)
462(defcustom todo-mode-hook nil
463 "*TODO mode hooks."
464 :type 'hook
465 :group 'todo)
466(defcustom todo-edit-mode-hook nil
467 "*TODO Edit mode hooks."
468 :type 'hook
469 :group 'todo)
470(defcustom todo-insert-threshold 0
471 "*TODO mode insertion accuracy.
472
473If you have 8 items in your TODO list, then you may get asked 4
474questions by the binary insertion algorithm. However, you may not
475really have a need for such accurate priorities amongst your TODO
476items. If you now think about the binary insertion halfing the size
477of the window each time, then the threshhold is the window size at
478which it will stop. If you set the threshhold to zero, the upper and
479lower bound will coincide at the end of the loop and you will insert
480your item just before that point. If you set the threshhold to,
481e.g. 8, it will stop as soon as the window size drops below that
482amount and will insert the item in the approximate centre of that
483window."
484 :type 'integer
485 :group 'todo)
422(defvar todo-edit-buffer " *TODO Edit*" "TODO Edit buffer name.") 486(defvar todo-edit-buffer " *TODO Edit*" "TODO Edit buffer name.")
423(defvar todo-file-top "~/.todo-top" 487(defcustom todo-file-top "~/.todo-top"
424 "*TODO mode top priorities file. 488 "*TODO mode top priorities file.
489
425Not in TODO format, but diary compatible. 490Not in TODO format, but diary compatible.
426Automatically generated when `todo-save-top-priorities' is non-nil.") 491Automatically generated when `todo-save-top-priorities' is non-nil."
427 492 :type 'string
428(defvar todo-print-function 'ps-print-buffer-with-faces 493 :group 'todo)
429 "*Function to print the current buffer.") 494
430(defvar todo-show-priorities 1 495(defcustom todo-print-function 'ps-print-buffer-with-faces
431 "*Default number of priorities to show by 496 "*Function to print the current buffer."
432 \\[todo-top-priorities]. 0 means show all entries.") 497 :type 'symbol
433(defvar todo-print-priorities 0 498 :group 'todo)
434 "*Default number of priorities to print by 499(defcustom todo-show-priorities 1
435 \\[todo-print]. 0 means print all entries.") 500 "*Default number of priorities to show by \\[todo-top-priorities].
436(defvar todo-remove-separator t 5010 means show all entries."
437 "*Non-nil removes category separators in 502 :type 'integer
438 \\[todo-top-priorities] and \\[todo-print].") 503 :group 'todo)
439(defvar todo-save-top-priorities-too t 504(defcustom todo-print-priorities 0
505 "*Default number of priorities to print by \\[todo-print].
5060 means print all entries."
507 :type 'integer
508 :group 'todo)
509(defcustom todo-remove-separator t
510 "*Non-nil to remove category separators in\
511\\[todo-top-priorities] and \\[todo-print]."
512 :type 'boolean
513 :group 'todo)
514(defcustom todo-save-top-priorities-too t
440 "*Non-nil makes todo-save automatically save top-priorities in 515 "*Non-nil makes todo-save automatically save top-priorities in
441`todo-file-top'.") 516`todo-file-top'."
517 :type 'boolean
518 :group 'todo)
442 519
443;; Thanks for the ISO time stamp format go to Karl Eichwalder <ke@suse.de> 520;; Thanks for the ISO time stamp format go to Karl Eichwalder <ke@suse.de>
444;; My format string for the appt.el package is "%3b %2d, %y, %02I:%02M%p". 521;; My format string for the appt.el package is "%3b %2d, %y, %02I:%02M%p".
445;; 522;;
446(defvar todo-time-string-format 523(defcustom todo-time-string-format
447 "%:y-%02m-%02d %02H:%02M" 524 "%:y-%02m-%02d %02H:%02M"
448 "TODO mode time string format for done entries. 525 "*TODO mode time string format for done entries.
449For details see the variable `time-stamp-format'.") 526For details see the variable `time-stamp-format'."
450 527 :type 'string
451(defvar todo-entry-prefix-function nil 528 :group 'todo)
452 "*Function producing text to insert at start of todo entry. 529
453 530(defcustom todo-entry-prefix-function 'todo-entry-timestamp-initials
454See `todo-entry-prefix-function' as an example: 531 "*Function producing text to insert at start of todo entry."
455(defun todo-entry-timestamp-initials () 532 :type 'symbol
456 \"Prepend timestamp and your initials to the head of a TODO entry.\" 533 :group 'todo)
457 (let ((time-stamp-format todo-time-string-format)) 534(defcustom todo-initials (or (getenv "INITIALS") (user-login-name))
458 (concat (time-stamp-string) \" \" todo-initials \": \"))) 535 "*Initials of todo item author."
459") 536 :type 'string
460 537 :group 'todo)
461(defvar todo-initials (or (getenv "INITIALS") (user-login-name))
462 "*Initials of todo item author.")
463 538
464(defun todo-entry-timestamp-initials () 539(defun todo-entry-timestamp-initials ()
465 "Prepend timestamp and your initials to the head of a TODO entry." 540 "Prepend timestamp and your initials to the head of a TODO entry."
@@ -478,8 +553,9 @@ See `todo-entry-prefix-function' as an example:
478;; Set up some helpful context ... 553;; Set up some helpful context ...
479 554
480(defvar todo-categories nil "TODO categories.") 555(defvar todo-categories nil "TODO categories.")
481(defvar todo-cats nil "Old variable for holding the 556(defvar todo-cats nil
482TODO categories. Use `todo-categories' instead.") 557 "Old variable for holding the TODO categories.
558Use `todo-categories' instead.")
483(defvar todo-previous-line 0 "Previous line that I asked about.") 559(defvar todo-previous-line 0 "Previous line that I asked about.")
484(defvar todo-previous-answer 0 "Previous answer that I got.") 560(defvar todo-previous-answer 0 "Previous answer that I got.")
485(defvar todo-mode-map nil "TODO mode keymap.") 561(defvar todo-mode-map nil "TODO mode keymap.")
@@ -562,7 +638,7 @@ TODO categories. Use `todo-categories' instead.")
562(defalias 'todo-cmd-prev 'todo-backward-item) 638(defalias 'todo-cmd-prev 'todo-backward-item)
563 639
564(defun todo-forward-item (&optional count) 640(defun todo-forward-item (&optional count)
565 "Select Nth next entry of TODO list." 641 "Select COUNT-th next entry of TODO list."
566 (interactive "P") 642 (interactive "P")
567 (if (listp count) (setq count (car count))) 643 (if (listp count) (setq count (car count)))
568 (end-of-line) 644 (end-of-line)
@@ -611,7 +687,8 @@ TODO categories. Use `todo-categories' instead.")
611 (narrow-to-region (todo-item-start) (todo-item-end)))) 687 (narrow-to-region (todo-item-start) (todo-item-end))))
612 688
613;;;### autoload 689;;;### autoload
614(defun todo-add-category (cat) "Add a new category to the TODO list." 690(defun todo-add-category (cat)
691 "Add new category CAT to the TODO list."
615 (interactive) 692 (interactive)
616 (save-window-excursion 693 (save-window-excursion
617 (setq todo-categories (cons cat todo-categories)) 694 (setq todo-categories (cons cat todo-categories))
@@ -634,8 +711,8 @@ TODO categories. Use `todo-categories' instead.")
634 0) 711 0)
635 712
636;;;### autoload 713;;;### autoload
637(defun todo-add-item-non-interactively (new-item category) 714(defun todo-add-item-non-interactively (new-item category ARG)
638 "Insert new TODO list entry." 715 "Insert NEW-ITEM in TODO list as a new entry in CATEGORY."
639 (save-excursion 716 (save-excursion
640 (todo-show) 717 (todo-show)
641 (if (string= "" category) 718 (if (string= "" category)
@@ -670,25 +747,27 @@ TODO categories. Use `todo-categories' instead.")
670 747
671;;;### autoload 748;;;### autoload
672(defun todo-insert-item (ARG) 749(defun todo-insert-item (ARG)
673 "Insert new TODO list entry." 750 "Insert new TODO list entry.
751With a prefix argument solicit the category, otherwise use the current
752category."
674 (interactive "P") 753 (interactive "P")
675 (todo-show) 754 (todo-show)
676 (let* ((new-item (concat todo-prefix " " 755 (let* ((new-item (concat todo-prefix " "
677 (read-from-minibuffer 756 (read-from-minibuffer
678 "New TODO entry: " 757 "New TODO entry: "
679 (if todo-entry-prefix-function 758 (if todo-entry-prefix-function
680 (funcall todo-entry-prefix-function))))) 759 (funcall todo-entry-prefix-function)))))
681 (categories todo-categories) 760 (categories todo-categories)
682 (history (cons 'categories (1+ todo-category-number))) 761 (history (cons 'categories (1+ todo-category-number)))
683 (current-category (nth todo-category-number todo-categories)) 762 (current-category (nth todo-category-number todo-categories))
684 (category 763 (category
685 (if ARG 764 (if ARG
686 current-category 765 current-category
687 (completing-read 766 (completing-read
688 (concat "Category [" 767 (concat "Category ["
689 current-category "]: ") 768 current-category "]: ")
690 (todo-category-alist) nil nil nil history)))) 769 (todo-category-alist) nil nil nil history))))
691 (todo-add-item-non-interactively new-item category))) 770 (todo-add-item-non-interactively new-item category ARG)))
692 771
693(defalias 'todo-cmd-inst 'todo-insert-item) 772(defalias 'todo-cmd-inst 'todo-insert-item)
694 773
@@ -791,7 +870,9 @@ between each category."
791 (or nof-priorities (setq nof-priorities todo-show-priorities)) 870 (or nof-priorities (setq nof-priorities todo-show-priorities))
792 (if (listp nof-priorities) ;universal argument 871 (if (listp nof-priorities) ;universal argument
793 (setq nof-priorities (car nof-priorities))) 872 (setq nof-priorities (car nof-priorities)))
794 (let ((todo-category-break (if category-pr-page " " "")) 873 (let ((todo-print-buffer-name "*Tmp*")
874 ;;(todo-print-category-number 0)
875 (todo-category-break (if category-pr-page " " ""))
795 (cat-end 876 (cat-end
796 (concat 877 (concat
797 (if todo-remove-separator 878 (if todo-remove-separator
@@ -803,8 +884,8 @@ between each category."
803 (save-excursion 884 (save-excursion
804 (save-restriction 885 (save-restriction
805 (widen) 886 (widen)
806 (copy-to-buffer todo-tmp-buffer-name (point-min) (point-max)) 887 (copy-to-buffer todo-print-buffer-name (point-min) (point-max))
807 (set-buffer todo-tmp-buffer-name) 888 (set-buffer todo-print-buffer-name)
808 (goto-char (point-min)) 889 (goto-char (point-min))
809 (if (re-search-forward (regexp-quote todo-header) nil t) 890 (if (re-search-forward (regexp-quote todo-header) nil t)
810 (progn 891 (progn
@@ -831,9 +912,9 @@ between each category."
831 ;; Could have used switch-to-buffer as it has a norecord argument, 912 ;; Could have used switch-to-buffer as it has a norecord argument,
832 ;; which is nice when we are called from e.g. todo-print. 913 ;; which is nice when we are called from e.g. todo-print.
833 ;; Else we could have used pop-to-buffer. 914 ;; Else we could have used pop-to-buffer.
834 (display-buffer todo-tmp-buffer-name) 915 (display-buffer todo-print-buffer-name)
835 (message "Type C-x 1 to remove %s window. M-C-v to scroll the help." 916 (message "Type C-x 1 to remove %s window. M-C-v to scroll the help."
836 todo-tmp-buffer-name) 917 todo-print-buffer-name)
837 )) 918 ))
838 919
839;;;###autoload 920;;;###autoload
@@ -931,11 +1012,11 @@ Number of entries for each category is given by
931 (length (split-string string "\n"))) 1012 (length (split-string string "\n")))
932 1013
933(defun todo-string-multiline-p (string) 1014(defun todo-string-multiline-p (string)
934 "Returns non-nil if STRING spans several lines" 1015 "Return non-nil if STRING spans several lines."
935 (> (todo-string-count-lines string) 1)) 1016 (> (todo-string-count-lines string) 1))
936 1017
937(defun todo-category-alist () 1018(defun todo-category-alist ()
938 "Generate an alist fro use in `completing-read' from `todo-categories'" 1019 "Generate an alist for use in `completing-read' from `todo-categories'."
939 (mapcar (lambda (cat) (cons cat nil)) 1020 (mapcar (lambda (cat) (cons cat nil))
940 todo-categories)) 1021 todo-categories))
941 1022