diff options
| author | Oliver Seidel | 1997-10-28 20:03:27 +0000 |
|---|---|---|
| committer | Oliver Seidel | 1997-10-28 20:03:27 +0000 |
| commit | f1757bdd294a1122cac696d8070d05cf193c8984 (patch) | |
| tree | 712f9fe74fd443d493638f54deb3d2cd1921a33d | |
| parent | e05e3850a08841cfb201ca4712e00eb4091cc3af (diff) | |
| download | emacs-f1757bdd294a1122cac696d8070d05cf193c8984.tar.gz emacs-f1757bdd294a1122cac696d8070d05cf193c8984.zip | |
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.
| -rw-r--r-- | lisp/calendar/todo-mode.el | 110 |
1 files changed, 77 insertions, 33 deletions
diff --git a/lisp/calendar/todo-mode.el b/lisp/calendar/todo-mode.el index 21293466d94..02e1057596f 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.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. |
| @@ -72,7 +72,7 @@ | |||
| 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 | ;; |
| @@ -124,7 +124,8 @@ | |||
| 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 |
| @@ -170,6 +171,12 @@ | |||
| 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. |
| 172 | ;; | 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. | ||
| 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 |
| @@ -202,9 +209,6 @@ | |||
| 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 |
| @@ -245,6 +249,10 @@ | |||
| 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>: |
| @@ -412,6 +420,10 @@ | |||
| 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.") |
| @@ -424,7 +436,9 @@ | |||
| 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". |
| @@ -434,12 +448,21 @@ | |||
| 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 | ||
| @@ -462,6 +485,7 @@ TODO categories. Use `todo-categories' instead.") | |||
| 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.") |
| @@ -496,6 +520,7 @@ TODO categories. Use `todo-categories' instead.") | |||
| 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 | ||
| @@ -549,13 +574,15 @@ TODO categories. Use `todo-categories' instead.") | |||
| 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) |
| @@ -638,7 +665,7 @@ TODO categories. Use `todo-categories' instead.") | |||
| 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 |
| @@ -649,18 +676,18 @@ TODO categories. Use `todo-categories' instead.") | |||
| 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) |
| @@ -764,9 +791,7 @@ between each category." | |||
| 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 |
| @@ -778,8 +803,8 @@ between each category." | |||
| 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 |
| @@ -800,18 +825,34 @@ between each category." | |||
| 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 | )) |
| 813 | 838 | ||
| 814 | ;;;###autoload | 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 | )))) | ||
| 854 | |||
| 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 |
| @@ -820,18 +861,20 @@ between each category. | |||
| 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." |
| @@ -955,6 +998,7 @@ If SEPARATORS is absent, it defaults to \"[ \\f\\t\\n\\r\\v]+\"." | |||
| 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 | )) |