Mercurial > emacs
comparison lisp/calendar/todo-mode.el @ 20193:ab4710f1f645
Harald Backer <harald.backer@fou.telenor.no> sent the following:
Added `todo-save-top-priorities' and option to automatically save top
priorities file when saving todo-file. Changed some default values.
Bug fixes.
author | Oliver Seidel <os10000@seidel-space.de> |
---|---|
date | Tue, 28 Oct 1997 20:03:27 +0000 |
parents | bc27487e43bc |
children | c7b847e97647 |
comparison
equal
deleted
inserted
replaced
20192:bc27487e43bc | 20193:ab4710f1f645 |
---|---|
2 | 2 |
3 ;; Copyright (C) 1997 Free Software Foundation, Inc. | 3 ;; Copyright (C) 1997 Free Software Foundation, Inc. |
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.23 1997/10/24 17:30:54 os10000 Exp os10000 $ | 7 ;; Version: $Id: todo-mode.el,v 1.24 1997/10/28 19:41:53 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. |
11 | 11 |
12 ;; GNU Emacs is free software; you can redistribute it and/or modify | 12 ;; GNU Emacs is free software; you can redistribute it and/or modify |
70 ;; | 70 ;; |
71 ;; Version | 71 ;; Version |
72 ;; | 72 ;; |
73 ;; Which version of todo-mode.el does this documentation refer to? | 73 ;; Which version of todo-mode.el does this documentation refer to? |
74 ;; | 74 ;; |
75 ;; $Id: todo-mode.el,v 1.23 1997/10/24 17:30:54 os10000 Exp os10000 $ | 75 ;; $Id: todo-mode.el,v 1.24 1997/10/28 19:41:53 os10000 Exp os10000 $ |
76 ;; | 76 ;; |
77 ;; Pre-Requisites | 77 ;; Pre-Requisites |
78 ;; | 78 ;; |
79 ;; This package will require the following packages to be | 79 ;; This package will require the following packages to be |
80 ;; available on the load-path: | 80 ;; available on the load-path: |
122 ;; p for the previous entry | 122 ;; p for the previous entry |
123 ;; P print | 123 ;; P print |
124 ;; q to save the list and exit the buffer | 124 ;; q to save the list and exit the buffer |
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 ;; t show top priority items for each category | 127 ;; S to save the list of top priorities |
128 ;; t show top priority items for each category | |
128 ;; | 129 ;; |
129 ;; 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 |
130 ;; for the category. I for example have categories for things | 131 ;; for the category. I for example have categories for things |
131 ;; that I want to do in the office (like mail my mum), that I | 132 ;; that I want to do in the office (like mail my mum), that I |
132 ;; want to do in town (like buy cornflakes) and things I want to | 133 ;; want to do in town (like buy cornflakes) and things I want to |
167 ;; Even when you're done, you may wish to retain the entries. | 168 ;; Even when you're done, you may wish to retain the entries. |
168 ;; Given that they're timestamped and you are offered to add a | 169 ;; Given that they're timestamped and you are offered to add a |
169 ;; comment, this can make a useful diary of past events. It will | 170 ;; comment, this can make a useful diary of past events. It will |
170 ;; even blend in with the EMACS diary package. So anyway, this | 171 ;; even blend in with the EMACS diary package. So anyway, this |
171 ;; variable holds the name of the file for the filed todo-items. | 172 ;; variable holds the name of the file for the filed todo-items. |
173 ;; | |
174 ;; Variable todo-file-top | |
175 ;; | |
176 ;; File storing the top priorities of your TODO list when | |
177 ;; todo-save-top-priorities is non-nil. Nice to include in your | |
178 ;; diary instead of the complete TODO list. | |
172 ;; | 179 ;; |
173 ;; Variable todo-mode-hook | 180 ;; Variable todo-mode-hook |
174 ;; | 181 ;; |
175 ;; Just like other modes, too, this mode offers to call your | 182 ;; Just like other modes, too, this mode offers to call your |
176 ;; functions before it goes about its business. This variable | 183 ;; functions before it goes about its business. This variable |
200 ;; Things to do | 207 ;; Things to do |
201 ;; | 208 ;; |
202 ;; These originally were my ideas, but now also include all the | 209 ;; These originally were my ideas, but now also include all the |
203 ;; suggestions that I included before forgetting them: | 210 ;; suggestions that I included before forgetting them: |
204 ;; | 211 ;; |
205 ;; o Automatic save of top-priorities to file, for inclusion in | |
206 ;; .diary, at save of .todo-do, ref. automatic save of .bbdb | |
207 ;; in gnus | |
208 ;; o Fancy fonts for todo/top-priority buffer | 212 ;; o Fancy fonts for todo/top-priority buffer |
209 ;; o Remove todo-prefix option in todo-top-priorities | 213 ;; o Remove todo-prefix option in todo-top-priorities |
210 ;; o Rename category | 214 ;; o Rename category |
211 ;; o Move entry from one category to another one | 215 ;; o Move entry from one category to another one |
212 ;; o Entries which both have the generic */* prefix and a | 216 ;; o Entries which both have the generic */* prefix and a |
243 ;; --------------------------------------------------------------------------- | 247 ;; --------------------------------------------------------------------------- |
244 | 248 |
245 ;;; Change Log: | 249 ;;; Change Log: |
246 | 250 |
247 ;; $Log: todo-mode.el,v $ | 251 ;; $Log: todo-mode.el,v $ |
252 ;; Revision 1.24 1997/10/28 19:41:53 os10000 | |
253 ;; Added fix from Frank Ridderbusch <ridderbusch.pad@sni.de>, | |
254 ;; an apostrophe was missing. | |
255 ;; | |
248 ;; Revision 1.23 1997/10/24 17:30:54 os10000 | 256 ;; Revision 1.23 1997/10/24 17:30:54 os10000 |
249 ;; Added three suggestions from Carsten | 257 ;; Added three suggestions from Carsten |
250 ;; Dominik <dominik@strw.LeidenUniv.nl>: | 258 ;; Dominik <dominik@strw.LeidenUniv.nl>: |
251 ;; | 259 ;; |
252 ;; - recommend autoloading instead of require | 260 ;; - recommend autoloading instead of require |
410 (defvar todo-file-done "~/.todo-done" "*TODO mode archive file.") | 418 (defvar todo-file-done "~/.todo-done" "*TODO mode archive file.") |
411 (defvar todo-mode-hook nil "*TODO mode hooks.") | 419 (defvar todo-mode-hook nil "*TODO mode hooks.") |
412 (defvar todo-edit-mode-hook nil "*TODO Edit mode hooks.") | 420 (defvar todo-edit-mode-hook nil "*TODO Edit mode hooks.") |
413 (defvar todo-insert-threshold 0 "*TODO mode insertion accuracy.") | 421 (defvar todo-insert-threshold 0 "*TODO mode insertion accuracy.") |
414 (defvar todo-edit-buffer " *TODO Edit*" "TODO Edit buffer name.") | 422 (defvar todo-edit-buffer " *TODO Edit*" "TODO Edit buffer name.") |
423 (defvar todo-file-top "~/.todo-top" | |
424 "*TODO mode top priorities file. | |
425 Not in TODO format, but diary compatible. | |
426 Automatically generated when `todo-save-top-priorities' is non-nil.") | |
415 | 427 |
416 (defvar todo-print-function 'ps-print-buffer-with-faces | 428 (defvar todo-print-function 'ps-print-buffer-with-faces |
417 "*Function to print the current buffer.") | 429 "*Function to print the current buffer.") |
418 (defvar todo-show-priorities 1 | 430 (defvar todo-show-priorities 1 |
419 "*Default number of priorities to show by | 431 "*Default number of priorities to show by |
422 "*Default number of priorities to print by | 434 "*Default number of priorities to print by |
423 \\[todo-print]. 0 means print all entries.") | 435 \\[todo-print]. 0 means print all entries.") |
424 (defvar todo-remove-separator t | 436 (defvar todo-remove-separator t |
425 "*Non-nil removes category separators in | 437 "*Non-nil removes category separators in |
426 \\[todo-top-priorities] and \\[todo-print].") | 438 \\[todo-top-priorities] and \\[todo-print].") |
427 | 439 (defvar todo-save-top-priorities-too t |
440 "*Non-nil makes todo-save automatically save top-priorities in | |
441 `todo-file-top'.") | |
428 | 442 |
429 ;; Thanks for the ISO time stamp format go to Karl Eichwalder <ke@suse.de> | 443 ;; Thanks for the ISO time stamp format go to Karl Eichwalder <ke@suse.de> |
430 ;; My format string for the appt.el package is "%3b %2d, %y, %02I:%02M%p". | 444 ;; My format string for the appt.el package is "%3b %2d, %y, %02I:%02M%p". |
431 ;; | 445 ;; |
432 (defvar todo-time-string-format | 446 (defvar todo-time-string-format |
433 "%:y-%02m-%02d %02H:%02M" | 447 "%:y-%02m-%02d %02H:%02M" |
434 "TODO mode time string format for done entries. | 448 "TODO mode time string format for done entries. |
435 For details see the variable `time-stamp-format'.") | 449 For details see the variable `time-stamp-format'.") |
436 | 450 |
437 (defvar todo-entry-prefix-function 'todo-entry-timestamp-initials | 451 (defvar todo-entry-prefix-function nil |
438 "*Function producing text to insert at start of todo entry.") | 452 "*Function producing text to insert at start of todo entry. |
453 | |
454 See `todo-entry-prefix-function' as an example: | |
455 (defun todo-entry-timestamp-initials () | |
456 \"Prepend timestamp and your initials to the head of a TODO entry.\" | |
457 (let ((time-stamp-format todo-time-string-format)) | |
458 (concat (time-stamp-string) \" \" todo-initials \": \"))) | |
459 ") | |
460 | |
439 (defvar todo-initials (or (getenv "INITIALS") (user-login-name)) | 461 (defvar todo-initials (or (getenv "INITIALS") (user-login-name)) |
440 "*Initials of todo item author.") | 462 "*Initials of todo item author.") |
441 | 463 |
442 (defun todo-entry-timestamp-initials () | 464 (defun todo-entry-timestamp-initials () |
465 "Prepend timestamp and your initials to the head of a TODO entry." | |
443 (let ((time-stamp-format todo-time-string-format)) | 466 (let ((time-stamp-format todo-time-string-format)) |
444 (concat (time-stamp-string) " " todo-initials ": "))) | 467 (concat (time-stamp-string) " " todo-initials ": "))) |
445 | 468 |
446 ;; --------------------------------------------------------------------------- | 469 ;; --------------------------------------------------------------------------- |
447 | 470 |
460 (defvar todo-previous-line 0 "Previous line that I asked about.") | 483 (defvar todo-previous-line 0 "Previous line that I asked about.") |
461 (defvar todo-previous-answer 0 "Previous answer that I got.") | 484 (defvar todo-previous-answer 0 "Previous answer that I got.") |
462 (defvar todo-mode-map nil "TODO mode keymap.") | 485 (defvar todo-mode-map nil "TODO mode keymap.") |
463 (defvar todo-category-number 0 "TODO category number.") | 486 (defvar todo-category-number 0 "TODO category number.") |
464 | 487 |
488 (defvar todo-tmp-buffer-name "*Tmp*") | |
465 | 489 |
466 (defvar todo-category-sep (make-string 75 ?-) | 490 (defvar todo-category-sep (make-string 75 ?-) |
467 "Category separator.") | 491 "Category separator.") |
468 (defvar todo-category-beg " --- " | 492 (defvar todo-category-beg " --- " |
469 "Category start separator to be prepended onto category name.") | 493 "Category start separator to be prepended onto category name.") |
494 (define-key map "p" 'todo-backward-item) | 518 (define-key map "p" 'todo-backward-item) |
495 (define-key map "P" 'todo-print) | 519 (define-key map "P" 'todo-print) |
496 (define-key map "q" 'todo-quit) | 520 (define-key map "q" 'todo-quit) |
497 (define-key map "r" 'todo-raise-item) | 521 (define-key map "r" 'todo-raise-item) |
498 (define-key map "s" 'todo-save) | 522 (define-key map "s" 'todo-save) |
523 (define-key map "S" 'todo-save-top-priorities) | |
499 (define-key map "t" 'todo-top-priorities) | 524 (define-key map "t" 'todo-top-priorities) |
500 (setq todo-mode-map map))) | 525 (setq todo-mode-map map))) |
501 | 526 |
502 (defun todo-category-select () | 527 (defun todo-category-select () |
503 "Make TODO mode display the current category correctly." | 528 "Make TODO mode display the current category correctly." |
547 (message "")) | 572 (message "")) |
548 (defalias 'todo-cmd-next 'todo-forward-item) | 573 (defalias 'todo-cmd-next 'todo-forward-item) |
549 | 574 |
550 (defun todo-save () "Save the TODO list." | 575 (defun todo-save () "Save the TODO list." |
551 (interactive) | 576 (interactive) |
552 (save-buffer)) | 577 (save-buffer) |
578 (if todo-save-top-priorities-too (todo-save-top-priorities)) | |
579 ) | |
553 (defalias 'todo-cmd-save 'todo-save) | 580 (defalias 'todo-cmd-save 'todo-save) |
554 | 581 |
555 (defun todo-quit () "Done with TODO list for now." | 582 (defun todo-quit () "Done with TODO list for now." |
556 (interactive) | 583 (interactive) |
557 (widen) | 584 (widen) |
558 (save-buffer) | 585 (todo-save) |
559 (message "") | 586 (message "") |
560 (bury-buffer)) | 587 (bury-buffer)) |
561 (defalias 'todo-cmd-done 'todo-quit) | 588 (defalias 'todo-cmd-done 'todo-quit) |
562 | 589 |
563 (defun todo-edit-item () "Edit current TODO list entry." | 590 (defun todo-edit-item () "Edit current TODO list entry." |
636 (goto-char (point-min)) | 663 (goto-char (point-min)) |
637 (forward-line (1- top)))) | 664 (forward-line (1- top)))) |
638 (beginning-of-line)) | 665 (beginning-of-line)) |
639 (insert new-item "\n") | 666 (insert new-item "\n") |
640 (todo-backward-item) | 667 (todo-backward-item) |
641 (save-buffer) | 668 (todo-save) |
642 (message ""))) | 669 (message ""))) |
643 | 670 |
644 ;;;### autoload | 671 ;;;### autoload |
645 (defun todo-insert-item (ARG) | 672 (defun todo-insert-item (ARG) |
646 "Insert new TODO list entry." | 673 "Insert new TODO list entry." |
647 (interactive "P") | 674 (interactive "P") |
648 (todo-show) | 675 (todo-show) |
649 (let* ((new-item (concat todo-prefix " " | 676 (let* ((new-item (concat todo-prefix " " |
650 (read-from-minibuffer | 677 (read-from-minibuffer |
651 "New TODO entry: " | 678 "New TODO entry: " |
652 (if todo-entry-prefix-function | 679 (if todo-entry-prefix-function |
653 (funcall todo-entry-prefix-function))))) | 680 (funcall todo-entry-prefix-function))))) |
654 (categories todo-categories) | 681 (categories todo-categories) |
655 (history (cons 'categories (1+ todo-category-number))) | 682 (history (cons 'categories (1+ todo-category-number))) |
656 (current-category (nth todo-category-number todo-categories)) | 683 (current-category (nth todo-category-number todo-categories)) |
657 (category | 684 (category |
658 (if ARG | 685 (if ARG |
659 current-category | 686 current-category |
660 (completing-read | 687 (completing-read |
661 (concat "Category [" | 688 (concat "Category [" |
662 current-category "]: ") | 689 current-category "]: ") |
663 (todo-category-alist) nil nil nil history)))) | 690 (todo-category-alist) nil nil nil history)))) |
664 (todo-add-item-non-interactively new-item category))) | 691 (todo-add-item-non-interactively new-item category))) |
665 | 692 |
666 (defalias 'todo-cmd-inst 'todo-insert-item) | 693 (defalias 'todo-cmd-inst 'todo-insert-item) |
667 | 694 |
668 (defun todo-more-important-p (line) | 695 (defun todo-more-important-p (line) |
762 | 789 |
763 (interactive "P") | 790 (interactive "P") |
764 (or nof-priorities (setq nof-priorities todo-show-priorities)) | 791 (or nof-priorities (setq nof-priorities todo-show-priorities)) |
765 (if (listp nof-priorities) ;universal argument | 792 (if (listp nof-priorities) ;universal argument |
766 (setq nof-priorities (car nof-priorities))) | 793 (setq nof-priorities (car nof-priorities))) |
767 (let ((todo-print-buffer-name "*Tmp*") | 794 (let ((todo-category-break (if category-pr-page "" "")) |
768 ;;(todo-print-category-number 0) | |
769 (todo-category-break (if category-pr-page "" "")) | |
770 (cat-end | 795 (cat-end |
771 (concat | 796 (concat |
772 (if todo-remove-separator | 797 (if todo-remove-separator |
773 (concat todo-category-end "\n" | 798 (concat todo-category-end "\n" |
774 (regexp-quote todo-prefix) " " todo-category-sep "\n") | 799 (regexp-quote todo-prefix) " " todo-category-sep "\n") |
776 beg end) | 801 beg end) |
777 (todo-show) | 802 (todo-show) |
778 (save-excursion | 803 (save-excursion |
779 (save-restriction | 804 (save-restriction |
780 (widen) | 805 (widen) |
781 (copy-to-buffer todo-print-buffer-name (point-min) (point-max)) | 806 (copy-to-buffer todo-tmp-buffer-name (point-min) (point-max)) |
782 (set-buffer todo-print-buffer-name) | 807 (set-buffer todo-tmp-buffer-name) |
783 (goto-char (point-min)) | 808 (goto-char (point-min)) |
784 (if (re-search-forward (regexp-quote todo-header) nil t) | 809 (if (re-search-forward (regexp-quote todo-header) nil t) |
785 (progn | 810 (progn |
786 (beginning-of-line 1) | 811 (beginning-of-line 1) |
787 (kill-line))) ;Remove mode line | 812 (kill-line))) ;Remove mode line |
798 (goto-char end) ;All entries | 823 (goto-char end) ;All entries |
799 (todo-forward-item nof-priorities)) | 824 (todo-forward-item nof-priorities)) |
800 (setq beg (point)) | 825 (setq beg (point)) |
801 (delete-region beg end) | 826 (delete-region beg end) |
802 (widen)) | 827 (widen)) |
828 (and (looking-at "") (replace-match "")) ;Remove trailing form-feed. | |
803 (goto-char (point-min)) ;Due to display buffer | 829 (goto-char (point-min)) ;Due to display buffer |
804 )) | 830 )) |
805 ;; Could have used switch-to-buffer as it has a norecord argument, | 831 ;; Could have used switch-to-buffer as it has a norecord argument, |
806 ;; which is nice when we are called from e.g. todo-print. | 832 ;; which is nice when we are called from e.g. todo-print. |
807 ;; Else we could have used pop-to-buffer should be used. | 833 ;; Else we could have used pop-to-buffer. |
808 (display-buffer todo-print-buffer-name) | 834 (display-buffer todo-tmp-buffer-name) |
809 ;;(switch-to-buffer todo-print-buffer-name t) | |
810 (message "Type C-x 1 to remove %s window. M-C-v to scroll the help." | 835 (message "Type C-x 1 to remove %s window. M-C-v to scroll the help." |
811 todo-print-buffer-name) | 836 todo-tmp-buffer-name) |
812 )) | 837 )) |
838 | |
839 ;;;###autoload | |
840 (defun todo-save-top-priorities (&optional nof-priorities) | |
841 "Save top priorities for each category in `todo-file-top'. | |
842 | |
843 Number of entries for each category is given by NOF-PRIORITIES which | |
844 defaults to `todo-show-priorities'." | |
845 (interactive "P") | |
846 (save-window-excursion | |
847 (save-excursion | |
848 (save-restriction | |
849 (todo-top-priorities nof-priorities) | |
850 (set-buffer todo-tmp-buffer-name) | |
851 (write-file todo-file-top) | |
852 (kill-this-buffer) | |
853 )))) | |
813 | 854 |
814 ;;;###autoload | 855 ;;;###autoload |
815 (defun todo-print (&optional category-pr-page) | 856 (defun todo-print (&optional category-pr-page) |
816 "Print todo summary using \\\[todo-print-function]. | 857 "Print todo summary using \\\[todo-print-function]. |
817 If CATEGORY-PR-PAGE is non-nil, a page separator \'^L\' is inserted | 858 If CATEGORY-PR-PAGE is non-nil, a page separator \'^L\' is inserted |
818 between each category. | 859 between each category. |
819 | 860 |
820 Number of entries for each category is given by | 861 Number of entries for each category is given by |
821 \'todo-print-priorities\'." | 862 \'todo-print-priorities\'." |
822 (interactive "P") | 863 (interactive "P") |
864 (if todo-print-function | |
865 (progn | |
823 (save-window-excursion | 866 (save-window-excursion |
824 (save-excursion | 867 (save-excursion |
825 (save-restriction | 868 (save-restriction |
826 (todo-top-priorities todo-print-priorities | 869 (todo-top-priorities todo-print-priorities |
827 category-pr-page) | 870 category-pr-page) |
828 (if todo-print-function | 871 (set-buffer todo-tmp-buffer-name) |
829 (progn | 872 (and (funcall todo-print-function) |
830 (funcall todo-print-function) | 873 (kill-this-buffer)) |
831 (message "Todo printing done.")) | 874 (message "Todo printing done.")) |
832 (message "") ; To get rid of message from | 875 ))) |
833 ; todo-top-priorities. | 876 (message "todo-print-function undefinded") |
834 ))))) | 877 )) |
835 | 878 |
836 (defun todo-jump-to-category () | 879 (defun todo-jump-to-category () |
837 "Jump to a category. Default is previous category." | 880 "Jump to a category. Default is previous category." |
838 (interactive) | 881 (interactive) |
839 (let* ((categories todo-categories) | 882 (let* ((categories todo-categories) |
953 "---" | 996 "---" |
954 ["Next item" todo-forward-item t] | 997 ["Next item" todo-forward-item t] |
955 ["Previous item" todo-backward-item t] | 998 ["Previous item" todo-backward-item t] |
956 "---" | 999 "---" |
957 ["Save" todo-save t] | 1000 ["Save" todo-save t] |
1001 ["Save Top Priorities" todo-save-top-priorities t] | |
958 "---" | 1002 "---" |
959 ["Quit" todo-quit t] | 1003 ["Quit" todo-quit t] |
960 )) | 1004 )) |
961 | 1005 |
962 ;; As calendar reads .todo-do before todo-mode is loaded. | 1006 ;; As calendar reads .todo-do before todo-mode is loaded. |