aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Berman2013-06-21 16:02:39 +0200
committerStephen Berman2013-06-21 16:02:39 +0200
commit4fe738d374d68aad467ff3329510c64bf3fcbd15 (patch)
tree75fdc1366642f3684f0691174e24656d374ab987
parent03e6d46963d5fa9105f55416bf81cd6d1b57b8b5 (diff)
downloademacs-4fe738d374d68aad467ff3329510c64bf3fcbd15.tar.gz
emacs-4fe738d374d68aad467ff3329510c64bf3fcbd15.zip
* todo-mode.el: Clean up doc strings, comments and prompt strings,
mainly by changing "Todo" to "todo" when it is not part of a mode name or does not begin a sentence.
-rw-r--r--lisp/calendar/ChangeLog6
-rw-r--r--lisp/calendar/todo-mode.el336
2 files changed, 172 insertions, 170 deletions
diff --git a/lisp/calendar/ChangeLog b/lisp/calendar/ChangeLog
index 411a2fcae3f..c5cf042abcc 100644
--- a/lisp/calendar/ChangeLog
+++ b/lisp/calendar/ChangeLog
@@ -1,5 +1,11 @@
12013-06-21 Stephen Berman <stephen.berman@gmx.net> 12013-06-21 Stephen Berman <stephen.berman@gmx.net>
2 2
3 * todo-mode.el: Clean up doc strings, comments and prompt strings,
4 mainly by changing "Todo" to "todo" when it is not part of a mode
5 name or does not begin a sentence.
6
72013-06-21 Stephen Berman <stephen.berman@gmx.net>
8
3 * todo-mode.el: Offer to convert legacy file. Update commentary. 9 * todo-mode.el: Offer to convert legacy file. Update commentary.
4 (todo-show): If a legacy file is found and no new todo file 10 (todo-show): If a legacy file is found and no new todo file
5 exists, offer to convert it and show it. Restore autoload cookie. 11 exists, offer to convert it and show it. Restore autoload cookie.
diff --git a/lisp/calendar/todo-mode.el b/lisp/calendar/todo-mode.el
index e3b92950797..1f0d7c7a4f3 100644
--- a/lisp/calendar/todo-mode.el
+++ b/lisp/calendar/todo-mode.el
@@ -80,11 +80,11 @@
80(require 'cl-lib) 80(require 'cl-lib)
81 81
82;; ----------------------------------------------------------------------------- 82;; -----------------------------------------------------------------------------
83;;; Setting up Todo files, categories, and items 83;;; Setting up todo files, categories, and items
84;; ----------------------------------------------------------------------------- 84;; -----------------------------------------------------------------------------
85 85
86(defcustom todo-directory (locate-user-emacs-file "todo/") 86(defcustom todo-directory (locate-user-emacs-file "todo/")
87 "Directory where user's Todo files are saved." 87 "Directory where user's todo files are saved."
88 :type 'directory 88 :type 'directory
89 :group 'todo) 89 :group 'todo)
90 90
@@ -110,13 +110,13 @@ makes it return the value of the variable `todo-archives'."
110 :group 'todo) 110 :group 'todo)
111 111
112(defvar todo-files (funcall todo-files-function) 112(defvar todo-files (funcall todo-files-function)
113 "List of truenames of user's Todo files.") 113 "List of truenames of user's todo files.")
114 114
115(defvar todo-archives (funcall todo-files-function t) 115(defvar todo-archives (funcall todo-files-function t)
116 "List of truenames of user's Todo archives.") 116 "List of truenames of user's todo archives.")
117 117
118(defvar todo-visited nil 118(defvar todo-visited nil
119 "List of Todo files visited in this session by `todo-show'. 119 "List of todo files visited in this session by `todo-show'.
120Used to determine initial display according to the value of 120Used to determine initial display according to the value of
121`todo-show-first'.") 121`todo-show-first'.")
122 122
@@ -124,23 +124,23 @@ Used to determine initial display according to the value of
124 "List of file names of live Todo mode buffers.") 124 "List of file names of live Todo mode buffers.")
125 125
126(defvar todo-global-current-todo-file nil 126(defvar todo-global-current-todo-file nil
127 "Variable holding name of current Todo file. 127 "Variable holding name of current todo file.
128Used by functions called from outside of Todo mode to visit the 128Used by functions called from outside of Todo mode to visit the
129current Todo file rather than the default Todo file (i.e. when 129current todo file rather than the default todo file (i.e. when
130users option `todo-show-current-file' is non-nil).") 130users option `todo-show-current-file' is non-nil).")
131 131
132(defvar todo-current-todo-file nil 132(defvar todo-current-todo-file nil
133 "Variable holding the name of the currently active Todo file.") 133 "Variable holding the name of the currently active todo file.")
134 134
135(defvar todo-categories nil 135(defvar todo-categories nil
136 "Alist of categories in the current Todo file. 136 "Alist of categories in the current todo file.
137The elements are cons cells whose car is a category name and 137The elements are cons cells whose car is a category name and
138whose cdr is a vector of the category's item counts. These are, 138whose cdr is a vector of the category's item counts. These are,
139in order, the numbers of todo items, of todo items included in 139in order, the numbers of todo items, of todo items included in
140the Diary, of done items and of archived items.") 140the Diary, of done items and of archived items.")
141 141
142(defvar todo-category-number 1 142(defvar todo-category-number 1
143 "Variable holding the number of the current Todo category. 143 "Variable holding the number of the current todo category.
144Todo categories are numbered starting from 1.") 144Todo categories are numbered starting from 1.")
145 145
146(defvar todo-categories-with-marks nil 146(defvar todo-categories-with-marks nil
@@ -228,7 +228,7 @@ The final element is \"*\", indicating an unspecified month.")
228 (year "-?\\(?9:[0-9]+\\|\\*\\)")) 228 (year "-?\\(?9:[0-9]+\\|\\*\\)"))
229 (mapconcat 'eval calendar-date-display-form "")) 229 (mapconcat 'eval calendar-date-display-form ""))
230 "\\)")) 230 "\\)"))
231 "Regular expression matching a Todo date header.") 231 "Regular expression matching a todo item date header.")
232 232
233;; By itself this matches anything, because of the `?'; however, it's only 233;; By itself this matches anything, because of the `?'; however, it's only
234;; used in the context of `todo-date-pattern' (but Emacs Lisp lacks 234;; used in the context of `todo-date-pattern' (but Emacs Lisp lacks
@@ -252,7 +252,7 @@ The final element is \"*\", indicating an unspecified month.")
252(defconst todo-item-start (concat "\\(" todo-date-string-start "\\|" 252(defconst todo-item-start (concat "\\(" todo-date-string-start "\\|"
253 todo-done-string-start "\\)" 253 todo-done-string-start "\\)"
254 todo-date-pattern) 254 todo-date-pattern)
255 "String identifying start of a Todo item.") 255 "String identifying start of a todo item.")
256 256
257;; ----------------------------------------------------------------------------- 257;; -----------------------------------------------------------------------------
258;;; Todo mode display options 258;;; Todo mode display options
@@ -281,17 +281,17 @@ These reflect the priorities of the items in each category."
281 281
282(defun todo-mode-line-control (cat) 282(defun todo-mode-line-control (cat)
283 "Return a mode line control for todo or archive file buffers. 283 "Return a mode line control for todo or archive file buffers.
284Argument CAT is the name of the current Todo category. 284Argument CAT is the name of the current todo category.
285This function is the value of the user variable 285This function is the value of the user variable
286`todo-mode-line-function'." 286`todo-mode-line-function'."
287 (let ((file (todo-short-file-name todo-current-todo-file))) 287 (let ((file (todo-short-file-name todo-current-todo-file)))
288 (format "%s category %d: %s" file todo-category-number cat))) 288 (format "%s category %d: %s" file todo-category-number cat)))
289 289
290(defcustom todo-mode-line-function 'todo-mode-line-control 290(defcustom todo-mode-line-function 'todo-mode-line-control
291 "Function that returns a mode line control for Todo buffers. 291 "Function that returns a mode line control for Todo mode buffers.
292The function expects one argument holding the name of the current 292The function expects one argument holding the name of the current
293Todo category. The resulting control becomes the local value of 293todo category. The resulting control becomes the local value of
294`mode-line-buffer-identification' in each Todo buffer." 294`mode-line-buffer-identification' in each Todo mode buffer."
295 :type 'function 295 :type 'function
296 :group 'todo-display) 296 :group 'todo-display)
297 297
@@ -370,7 +370,7 @@ shown in the Fancy Diary display."
370 (((class color) (min-colors 16) (background dark)) (:foreground "Aquamarine")) 370 (((class color) (min-colors 16) (background dark)) (:foreground "Aquamarine"))
371 (((class color) (min-colors 8)) (:foreground "magenta")) 371 (((class color) (min-colors 8)) (:foreground "magenta"))
372 (t (:weight bold :underline t))) 372 (t (:weight bold :underline t)))
373 "Face for Todo prefix or numerical priority string." 373 "Face for todo item prefix or numerical priority string."
374 :group 'todo-faces) 374 :group 'todo-faces)
375 375
376(defface todo-top-priority 376(defface todo-top-priority
@@ -385,7 +385,7 @@ shown in the Fancy Diary display."
385 (((class color) (min-colors 8) (background light)) :foreground "red") 385 (((class color) (min-colors 8) (background light)) :foreground "red")
386 (((class color) (min-colors 8) (background dark)) :foreground "yellow") 386 (((class color) (min-colors 8) (background dark)) :foreground "yellow")
387 (t :slant italic)) 387 (t :slant italic))
388 "Face for top priority Todo item numerical priority string. 388 "Face for top priority todo item numerical priority string.
389The item's priority number string has this face if the number is 389The item's priority number string has this face if the number is
390less than or equal the category's top priority setting." 390less than or equal the category's top priority setting."
391 :group 'todo-faces) 391 :group 'todo-faces)
@@ -405,12 +405,12 @@ less than or equal the category's top priority setting."
405 405
406(defface todo-date 406(defface todo-date
407 '((t :inherit diary)) 407 '((t :inherit diary))
408 "Face for the date string of a Todo item." 408 "Face for the date string of a todo item."
409 :group 'todo-faces) 409 :group 'todo-faces)
410 410
411(defface todo-time 411(defface todo-time
412 '((t :inherit diary-time)) 412 '((t :inherit diary-time))
413 "Face for the time string of a Todo item." 413 "Face for the time string of a todo item."
414 :group 'todo-faces) 414 :group 'todo-faces)
415 415
416(defface todo-diary-expired 416(defface todo-diary-expired
@@ -440,7 +440,7 @@ less than or equal the category's top priority setting."
440 (((class color) (min-colors 16) (background dark)) :foreground "LightSteelBlue") 440 (((class color) (min-colors 16) (background dark)) :foreground "LightSteelBlue")
441 (((class color) (min-colors 8)) :foreground "blue" :weight bold) 441 (((class color) (min-colors 8)) :foreground "blue" :weight bold)
442 (t :weight bold)) 442 (t :weight bold))
443 "Face for separator string bewteen done and not done Todo items." 443 "Face for separator string bewteen done and not done todo items."
444 :group 'todo-faces) 444 :group 'todo-faces)
445 445
446(defface todo-done 446(defface todo-done
@@ -453,7 +453,7 @@ less than or equal the category's top priority setting."
453 (((class color) (min-colors 16) (background dark)) :foreground "Cyan") 453 (((class color) (min-colors 16) (background dark)) :foreground "Cyan")
454 (((class color) (min-colors 8)) :foreground "cyan" :weight bold) 454 (((class color) (min-colors 8)) :foreground "cyan" :weight bold)
455 (t :weight bold)) 455 (t :weight bold))
456 "Face for done Todo item header string." 456 "Face for done todo item header string."
457 :group 'todo-faces) 457 :group 'todo-faces)
458 458
459(defface todo-comment 459(defface todo-comment
@@ -475,7 +475,7 @@ less than or equal the category's top priority setting."
475 (((class color) (min-colors 8) (background dark)) 475 (((class color) (min-colors 8) (background dark))
476 :foreground "yellow") 476 :foreground "yellow")
477 (t :weight bold :slant italic)) 477 (t :weight bold :slant italic))
478 "Face for comments appended to done Todo items." 478 "Face for comments appended to done todo items."
479 :group 'todo-faces) 479 :group 'todo-faces)
480 480
481(defface todo-search 481(defface todo-search
@@ -565,14 +565,14 @@ less than or equal the category's top priority setting."
565 565
566(defcustom todo-visit-files-commands (list 'find-file 'dired-find-file) 566(defcustom todo-visit-files-commands (list 'find-file 'dired-find-file)
567 "List of file finding commands for `todo-display-as-todo-file'. 567 "List of file finding commands for `todo-display-as-todo-file'.
568Invoking these commands to visit a Todo or Todo Archive file 568Invoking these commands to visit a todo file or todo archive file
569calls `todo-show' or `todo-find-archive', so that the file is 569calls `todo-show' or `todo-find-archive', so that the file is
570displayed correctly." 570displayed correctly."
571 :type '(repeat function) 571 :type '(repeat function)
572 :group 'todo) 572 :group 'todo)
573 573
574(defun todo-short-file-name (file) 574(defun todo-short-file-name (file)
575 "Return short form of Todo FILE. 575 "Return the short form of todo file FILE's name.
576This lacks the extension and directory components." 576This lacks the extension and directory components."
577 (when (stringp file) 577 (when (stringp file)
578 (file-name-sans-extension (file-name-nondirectory file)))) 578 (file-name-sans-extension (file-name-nondirectory file))))
@@ -586,7 +586,7 @@ This lacks the extension and directory components."
586 :group 'todo) 586 :group 'todo)
587 587
588(defcustom todo-show-current-file t 588(defcustom todo-show-current-file t
589 "Non-nil to make `todo-show' visit the current Todo file. 589 "Non-nil to make `todo-show' visit the current todo file.
590Otherwise, `todo-show' always visits `todo-default-todo-file'." 590Otherwise, `todo-show' always visits `todo-default-todo-file'."
591 :type 'boolean 591 :type 'boolean
592 :initialize 'custom-initialize-default 592 :initialize 'custom-initialize-default
@@ -608,12 +608,12 @@ Otherwise, `todo-show' always visits `todo-default-todo-file'."
608 :group 'todo-edit) 608 :group 'todo-edit)
609 609
610(defcustom todo-initial-file "Todo" 610(defcustom todo-initial-file "Todo"
611 "Default file name offered on adding first Todo file." 611 "Default file name offered on adding first todo file."
612 :type 'string 612 :type 'string
613 :group 'todo) 613 :group 'todo)
614 614
615(defcustom todo-initial-category "Todo" 615(defcustom todo-initial-category "Todo"
616 "Default category name offered on initializing a new Todo file." 616 "Default category name offered on initializing a new todo file."
617 :type 'string 617 :type 'string
618 :group 'todo) 618 :group 'todo)
619 619
@@ -644,14 +644,14 @@ file was last visited.
644If you call this command before you have created any todo file in 644If you call this command before you have created any todo file in
645the current format, and you have an todo file in old format, it 645the current format, and you have an todo file in old format, it
646will ask you whether to convert that file and show it. 646will ask you whether to convert that file and show it.
647Otherwise, calling this command before any Todo file exists 647Otherwise, calling this command before any todo file exists
648prompts for a file name and an initial category (defaulting to 648prompts for a file name and an initial category (defaulting to
649`todo-initial-file' and `todo-initial-category'), creates both of 649`todo-initial-file' and `todo-initial-category'), creates both of
650these, visits the file and displays the category, and if option 650these, visits the file and displays the category, and if option
651`todo-add-item-if-new-category' is non-nil (the default), prompts 651`todo-add-item-if-new-category' is non-nil (the default), prompts
652for the first item. 652for the first item.
653 653
654The first invocation of this command on an existing Todo file 654The first invocation of this command on an existing todo file
655interacts with the option `todo-show-first': if its value is 655interacts with the option `todo-show-first': if its value is
656`first' (the default), show the first category in the file; if 656`first' (the default), show the first category in the file; if
657its value is `table', show the table of categories in the file; 657its value is `table', show the table of categories in the file;
@@ -667,7 +667,7 @@ items. With non-nil user option `todo-show-with-done' both todo
667and done items are always shown on visiting a category. 667and done items are always shown on visiting a category.
668 668
669Invoking this command in Todo Archive mode visits the 669Invoking this command in Todo Archive mode visits the
670corresponding Todo file, displaying the corresponding category." 670corresponding todo file, displaying the corresponding category."
671 (interactive "P") 671 (interactive "P")
672 (catch 'shown 672 (catch 'shown
673 ;; If there is a legacy todo file but no todo file in the current 673 ;; If there is a legacy todo file but no todo file in the current
@@ -689,9 +689,9 @@ corresponding Todo file, displaying the corresponding category."
689 todo-archive-mode 689 todo-archive-mode
690 todo-filtered-items-mode)))) 690 todo-filtered-items-mode))))
691 (if (funcall todo-files-function) 691 (if (funcall todo-files-function)
692 (todo-read-file-name "Choose a Todo file to visit: " 692 (todo-read-file-name "Choose a todo file to visit: "
693 nil t) 693 nil t)
694 (user-error "There are no Todo files"))) 694 (user-error "There are no todo files")))
695 ((and (eq major-mode 'todo-archive-mode) 695 ((and (eq major-mode 'todo-archive-mode)
696 ;; Called noninteractively via todo-quit 696 ;; Called noninteractively via todo-quit
697 ;; to jump to corresponding category in 697 ;; to jump to corresponding category in
@@ -748,11 +748,11 @@ corresponding Todo file, displaying the corresponding category."
748 (eq todo-show-first 'first)) 748 (eq todo-show-first 'first))
749 (set-window-buffer (selected-window) 749 (set-window-buffer (selected-window)
750 (set-buffer (find-file-noselect file 'nowarn))) 750 (set-buffer (find-file-noselect file 'nowarn)))
751 ;; When quitting archive file, show corresponding category in 751 ;; When quitting an archive file, show the corresponding
752 ;; Todo file, if it exists. 752 ;; category in the corresponding todo file, if it exists.
753 (when (assoc cat todo-categories) 753 (when (assoc cat todo-categories)
754 (setq todo-category-number (todo-category-number cat))) 754 (setq todo-category-number (todo-category-number cat)))
755 ;; If this is a new Todo file, add its first category. 755 ;; If this is a new todo file, add its first category.
756 (when (zerop (buffer-size)) 756 (when (zerop (buffer-size))
757 (let (cat-added) 757 (let (cat-added)
758 (unwind-protect 758 (unwind-protect
@@ -781,7 +781,7 @@ corresponding Todo file, displaying the corresponding category."
781 (add-to-list 'todo-visited file)))) 781 (add-to-list 'todo-visited file))))
782 782
783(defun todo-save () 783(defun todo-save ()
784 "Save the current Todo file." 784 "Save the current todo file."
785 (interactive) 785 (interactive)
786 (cond ((eq major-mode 'todo-filtered-items-mode) 786 (cond ((eq major-mode 'todo-filtered-items-mode)
787 (todo-check-filtered-items-file) 787 (todo-check-filtered-items-file)
@@ -842,7 +842,7 @@ todo file."
842 :group 'todo-display) 842 :group 'todo-display)
843 843
844(defun todo-forward-category (&optional back) 844(defun todo-forward-category (&optional back)
845 "Visit the numerically next category in this Todo file. 845 "Visit the numerically next category in this todo file.
846If the current category is the highest numbered, visit the first 846If the current category is the highest numbered, visit the first
847category. With non-nil argument BACK, visit the numerically 847category. With non-nil argument BACK, visit the numerically
848previous category (the highest numbered one, if the current 848previous category (the highest numbered one, if the current
@@ -861,7 +861,7 @@ category is the first)."
861 (goto-char (point-min))) 861 (goto-char (point-min)))
862 862
863(defun todo-backward-category () 863(defun todo-backward-category ()
864 "Visit the numerically previous category in this Todo file. 864 "Visit the numerically previous category in this todo file.
865If the current category is the highest numbered, visit the first 865If the current category is the highest numbered, visit the first
866category." 866category."
867 (interactive) 867 (interactive)
@@ -870,12 +870,12 @@ category."
870(defvar todo-categories-buffer) 870(defvar todo-categories-buffer)
871 871
872(defun todo-jump-to-category (&optional file where) 872(defun todo-jump-to-category (&optional file where)
873 "Prompt for a category in a Todo file and jump to it. 873 "Prompt for a category in a todo file and jump to it.
874 874
875With non-nil FILE (interactively a prefix argument), prompt for a 875With non-nil FILE (interactively a prefix argument), prompt for a
876specific Todo file and choose (with TAB completion) a category 876specific todo file and choose (with TAB completion) a category
877in it to jump to; otherwise, choose and jump to any category in 877in it to jump to; otherwise, choose and jump to any category in
878either the current Todo file or a file in 878either the current todo file or a file in
879`todo-category-completions-files'. 879`todo-category-completions-files'.
880 880
881Also accept a non-existing category name and ask whether to add a 881Also accept a non-existing category name and ask whether to add a
@@ -946,8 +946,8 @@ it moves point to the first done item; but if called with point
946on the last todo item without a prefix argument, it moves point 946on the last todo item without a prefix argument, it moves point
947the the empty line above the done items separator." 947the the empty line above the done items separator."
948 (interactive "p") 948 (interactive "p")
949 ;; It's not worth the trouble to allow prefix arg value < 1, since we have 949 ;; It's not worth the trouble to allow prefix arg value < 1, since
950 ;; the corresponding command. 950 ;; we have the corresponding command.
951 (cond ((and current-prefix-arg (< count 1)) 951 (cond ((and current-prefix-arg (< count 1))
952 (user-error "The prefix argument must be a positive number")) 952 (user-error "The prefix argument must be a positive number"))
953 (current-prefix-arg 953 (current-prefix-arg
@@ -969,8 +969,8 @@ empty line above the done items separator."
969 (interactive "p") 969 (interactive "p")
970 ;; Avoid moving to bob if on the first item but not at bob. 970 ;; Avoid moving to bob if on the first item but not at bob.
971 (when (> (line-number-at-pos) 1) 971 (when (> (line-number-at-pos) 1)
972 ;; It's not worth the trouble to allow prefix arg value < 1, since we have 972 ;; It's not worth the trouble to allow prefix arg value < 1, since
973 ;; the corresponding command. 973 ;; we have the corresponding command.
974 (cond ((and current-prefix-arg (< count 1)) 974 (cond ((and current-prefix-arg (< count 1))
975 (user-error "The prefix argument must be a positive number")) 975 (user-error "The prefix argument must be a positive number"))
976 (current-prefix-arg 976 (current-prefix-arg
@@ -1063,13 +1063,13 @@ the the original date-time string."
1063;; ----------------------------------------------------------------------------- 1063;; -----------------------------------------------------------------------------
1064 1064
1065(defun todo-add-file () 1065(defun todo-add-file ()
1066 "Name and initialize a new Todo file. 1066 "Name and initialize a new todo file.
1067Interactively, prompt for a category and display it, and if 1067Interactively, prompt for a category and display it, and if
1068option `todo-add-item-if-new-category' is non-nil (the default), 1068option `todo-add-item-if-new-category' is non-nil (the default),
1069prompt for the first item. 1069prompt for the first item.
1070Noninteractively, return the name of the new file." 1070Noninteractively, return the name of the new file."
1071 (interactive) 1071 (interactive)
1072 (let ((prompt (concat "Enter name of new Todo file " 1072 (let ((prompt (concat "Enter name of new todo file "
1073 "(TAB or SPC to see current names): ")) 1073 "(TAB or SPC to see current names): "))
1074 file) 1074 file)
1075 (setq file (todo-read-file-name prompt)) 1075 (setq file (todo-read-file-name prompt))
@@ -1109,17 +1109,17 @@ this command should be used with caution."
1109 "validity and return to Todo mode.\n")))) 1109 "validity and return to Todo mode.\n"))))
1110 1110
1111(defun todo-add-category (&optional file cat) 1111(defun todo-add-category (&optional file cat)
1112 "Add a new category to a Todo file. 1112 "Add a new category to a todo file.
1113 1113
1114Called interactively with prefix argument FILE, prompt for a file 1114Called interactively with prefix argument FILE, prompt for a file
1115and then for a new category to add to that file, otherwise prompt 1115and then for a new category to add to that file, otherwise prompt
1116just for a category to add to the current Todo file. After 1116just for a category to add to the current todo file. After
1117adding the category, visit it in Todo mode and if option 1117adding the category, visit it in Todo mode and if option
1118`todo-add-item-if-new-category' is non-nil (the default), prompt 1118`todo-add-item-if-new-category' is non-nil (the default), prompt
1119for the first item. 1119for the first item.
1120 1120
1121Non-interactively, add category CAT to file FILE; if FILE is nil, 1121Non-interactively, add category CAT to file FILE; if FILE is nil,
1122add CAT to the current Todo file. After adding the category, 1122add CAT to the current todo file. After adding the category,
1123return the new category number." 1123return the new category number."
1124 (interactive "P") 1124 (interactive "P")
1125 (let (catfil file0) 1125 (let (catfil file0)
@@ -1159,7 +1159,7 @@ return the new category number."
1159 num)))) 1159 num))))
1160 1160
1161(defun todo-rename-category () 1161(defun todo-rename-category ()
1162 "Rename current Todo category. 1162 "Rename current todo category.
1163If this file has an archive containing this category, rename the 1163If this file has an archive containing this category, rename the
1164category there as well." 1164category there as well."
1165 (interactive) 1165 (interactive)
@@ -1190,7 +1190,7 @@ category there as well."
1190 (save-excursion (todo-category-select))) 1190 (save-excursion (todo-category-select)))
1191 1191
1192(defun todo-delete-category (&optional arg) 1192(defun todo-delete-category (&optional arg)
1193 "Delete current Todo category provided it is empty. 1193 "Delete current todo category provided it is empty.
1194With ARG non-nil delete the category unconditionally, 1194With ARG non-nil delete the category unconditionally,
1195i.e. including all existing todo and done items." 1195i.e. including all existing todo and done items."
1196 (interactive "P") 1196 (interactive "P")
@@ -1241,7 +1241,7 @@ i.e. including all existing todo and done items."
1241 (set-buffer-modified-p nil) 1241 (set-buffer-modified-p nil)
1242 (delete-file file) 1242 (delete-file file)
1243 (kill-buffer) 1243 (kill-buffer)
1244 (message "Deleted Todo file %s." file)) 1244 (message "Deleted todo file %s." file))
1245 (setq todo-categories (delete (assoc cat todo-categories) 1245 (setq todo-categories (delete (assoc cat todo-categories)
1246 todo-categories)) 1246 todo-categories))
1247 (todo-update-categories-sexp) 1247 (todo-update-categories-sexp)
@@ -1252,7 +1252,7 @@ i.e. including all existing todo and done items."
1252 (message "Deleted category %s." cat))))))) 1252 (message "Deleted category %s." cat)))))))
1253 1253
1254(defun todo-move-category () 1254(defun todo-move-category ()
1255 "Move current category to a different Todo file. 1255 "Move current category to a different todo file.
1256If current category has archived items, also move those to the 1256If current category has archived items, also move those to the
1257archive of the file moved to, creating it if it does not exist." 1257archive of the file moved to, creating it if it does not exist."
1258 (interactive) 1258 (interactive)
@@ -1263,7 +1263,7 @@ archive of the file moved to, creating it if it does not exist."
1263 (let* ((ofile todo-current-todo-file) 1263 (let* ((ofile todo-current-todo-file)
1264 (cat (todo-current-category)) 1264 (cat (todo-current-category))
1265 (nfile (todo-read-file-name 1265 (nfile (todo-read-file-name
1266 "Choose a Todo file to move this category to: " nil t)) 1266 "Choose a todo file to move this category to: " nil t))
1267 (archive (concat (file-name-sans-extension ofile) ".toda")) 1267 (archive (concat (file-name-sans-extension ofile) ".toda"))
1268 (buffers (append (list ofile) 1268 (buffers (append (list ofile)
1269 (unless (zerop (todo-get-count 'archived cat)) 1269 (unless (zerop (todo-get-count 'archived cat))
@@ -1315,7 +1315,7 @@ archive of the file moved to, creating it if it does not exist."
1315 (funcall todo-files-function t)) 1315 (funcall todo-files-function t))
1316 (setq new (read-from-minibuffer prompt)) 1316 (setq new (read-from-minibuffer prompt))
1317 (setq new (todo-validate-name new 'category)))) 1317 (setq new (todo-validate-name new 'category))))
1318 ;; Replace old with new name in Todo and archive files. 1318 ;; Replace old with new name in todo and archive files.
1319 (when new 1319 (when new
1320 (goto-char (point-max)) 1320 (goto-char (point-max))
1321 (re-search-backward 1321 (re-search-backward
@@ -1360,10 +1360,10 @@ archive of the file moved to, creating it if it does not exist."
1360(defun todo-merge-category (&optional file) 1360(defun todo-merge-category (&optional file)
1361 "Merge current category into another existing category. 1361 "Merge current category into another existing category.
1362 1362
1363With prefix argument FILE, prompt for a specific Todo file and 1363With prefix argument FILE, prompt for a specific todo file and
1364choose (with TAB completion) a category in it to merge into; 1364choose (with TAB completion) a category in it to merge into;
1365otherwise, choose and merge into a category in either the 1365otherwise, choose and merge into a category in either the
1366current Todo file or a file in `todo-category-completions-files'. 1366current todo file or a file in `todo-category-completions-files'.
1367 1367
1368After merging, the current category's todo and done items are 1368After merging, the current category's todo and done items are
1369appended to the chosen goal category's todo and done items, 1369appended to the chosen goal category's todo and done items,
@@ -1501,12 +1501,12 @@ category."
1501;; ----------------------------------------------------------------------------- 1501;; -----------------------------------------------------------------------------
1502 1502
1503(defcustom todo-include-in-diary nil 1503(defcustom todo-include-in-diary nil
1504 "Non-nil to allow new Todo items to be included in the diary." 1504 "Non-nil to allow new todo items to be included in the diary."
1505 :type 'boolean 1505 :type 'boolean
1506 :group 'todo-edit) 1506 :group 'todo-edit)
1507 1507
1508(defcustom todo-diary-nonmarking nil 1508(defcustom todo-diary-nonmarking nil
1509 "Non-nil to insert new Todo diary items as nonmarking by default. 1509 "Non-nil to insert new todo diary items as nonmarking by default.
1510This appends `diary-nonmarking-symbol' to the front of an item on 1510This appends `diary-nonmarking-symbol' to the front of an item on
1511insertion provided it doesn't begin with `todo-nondiary-marker'." 1511insertion provided it doesn't begin with `todo-nondiary-marker'."
1512 :type 'boolean 1512 :type 'boolean
@@ -1514,7 +1514,7 @@ insertion provided it doesn't begin with `todo-nondiary-marker'."
1514 1514
1515(defcustom todo-always-add-time-string nil 1515(defcustom todo-always-add-time-string nil
1516 "Non-nil adds current time to a new item's date header by default. 1516 "Non-nil adds current time to a new item's date header by default.
1517When the Todo insertion commands have a non-nil \"maybe-notime\" 1517When the todo insertion commands have a non-nil \"maybe-notime\"
1518argument, this reverses the effect of 1518argument, this reverses the effect of
1519`todo-always-add-time-string': if t, these commands omit the 1519`todo-always-add-time-string': if t, these commands omit the
1520current time, if nil, they include it." 1520current time, if nil, they include it."
@@ -1624,8 +1624,8 @@ marking of the next N items."
1624 1624
1625(defun todo-basic-insert-item (&optional arg diary nonmarking date-type time 1625(defun todo-basic-insert-item (&optional arg diary nonmarking date-type time
1626 region-or-here) 1626 region-or-here)
1627 "Insert a new Todo item into a category. 1627 "Insert a new todo item into a category.
1628This is the function from which the generated Todo item 1628This is the function from which the generated Todo mode item
1629insertion commands derive. 1629insertion commands derive.
1630 1630
1631The generated commands have mnenomic key bindings based on the 1631The generated commands have mnenomic key bindings based on the
@@ -1645,10 +1645,10 @@ is not given by HERE but by prompting.
1645In command invocations, ARG is passed as a prefix argument as 1645In command invocations, ARG is passed as a prefix argument as
1646follows. With no prefix argument, add the item to the current 1646follows. With no prefix argument, add the item to the current
1647category; with one prefix argument (`C-u'), prompt for a category 1647category; with one prefix argument (`C-u'), prompt for a category
1648from the current Todo file; with two prefix arguments (`C-u C-u'), 1648from the current todo file; with two prefix arguments (`C-u C-u'),
1649first prompt for a Todo file, then a category in that file. If 1649first prompt for a todo file, then a category in that file. If
1650a non-existing category is entered, ask whether to add it to the 1650a non-existing category is entered, ask whether to add it to the
1651Todo file; if answered affirmatively, add the category and 1651todo file; if answered affirmatively, add the category and
1652insert the item there. 1652insert the item there.
1653 1653
1654The remaining arguments are set or left nil by the generated item 1654The remaining arguments are set or left nil by the generated item
@@ -1778,11 +1778,11 @@ the new item:
1778 (find-file-noselect file 'nowarn) 1778 (find-file-noselect file 'nowarn)
1779 (set-window-buffer (selected-window) 1779 (set-window-buffer (selected-window)
1780 (set-buffer (find-buffer-visiting file))) 1780 (set-buffer (find-buffer-visiting file)))
1781 ;; If this command was invoked outside of a Todo buffer, the 1781 ;; If this command was invoked outside of a Todo mode buffer,
1782 ;; call to todo-current-category above returned nil. If we 1782 ;; the call to todo-current-category above returned nil. If
1783 ;; just entered Todo mode now, then cat was set to the file's 1783 ;; we just entered Todo mode now, then cat was set to the
1784 ;; first category, but if todo-mode was already enabled, cat 1784 ;; file's first category, but if todo-mode was already
1785 ;; did not get set, so we have to set it explicitly. 1785 ;; enabled, cat did not get set, so we have to do that.
1786 (unless cat 1786 (unless cat
1787 (setq cat (todo-current-category))) 1787 (setq cat (todo-current-category)))
1788 (setq todo-current-todo-file file) 1788 (setq todo-current-todo-file file)
@@ -1966,7 +1966,7 @@ the item at point."
1966 (if ov (delete-overlay ov))))) 1966 (if ov (delete-overlay ov)))))
1967 1967
1968(defun todo-edit-item (&optional arg) 1968(defun todo-edit-item (&optional arg)
1969 "Edit the Todo item at point. 1969 "Edit the todo item at point.
1970With non-nil prefix argument ARG, include the item's date/time 1970With non-nil prefix argument ARG, include the item's date/time
1971header, making it also editable; otherwise, include only the item 1971header, making it also editable; otherwise, include only the item
1972content. 1972content.
@@ -2010,7 +2010,7 @@ minibuffer; otherwise, edit it in Todo Edit mode."
2010 (move-to-column item-beg)))))) 2010 (move-to-column item-beg))))))
2011 2011
2012(defun todo-edit-multiline-item () 2012(defun todo-edit-multiline-item ()
2013 "Edit current Todo item in Todo Edit mode. 2013 "Edit current todo item in Todo Edit mode.
2014Use of newlines invokes `todo-indent' to insure compliance with 2014Use of newlines invokes `todo-indent' to insure compliance with
2015the format of Diary entries." 2015the format of Diary entries."
2016 (interactive) 2016 (interactive)
@@ -2031,9 +2031,9 @@ lines are indented by `todo-indent-to-here' to conform to diary
2031format. 2031format.
2032 2032
2033If the whole file was in Todo Edit mode, check before returning 2033If the whole file was in Todo Edit mode, check before returning
2034whether the file is still a valid Todo file and if so, also 2034whether the file is still a valid todo file and if so, also
2035recalculate the Todo categories sexp, in case changes were made 2035recalculate the todo file's categories sexp, in case changes were
2036in the number or names of categories." 2036made in the number or names of categories."
2037 (interactive) 2037 (interactive)
2038 (if (> (buffer-size) (- (point-max) (point-min))) 2038 (if (> (buffer-size) (- (point-max) (point-min)))
2039 ;; We got here via `e m'. 2039 ;; We got here via `e m'.
@@ -2578,15 +2578,15 @@ meaning to raise or lower the item's priority by one."
2578If there are marked items, move all of these; otherwise, move 2578If there are marked items, move all of these; otherwise, move
2579the item at point. 2579the item at point.
2580 2580
2581With prefix argument FILE, prompt for a specific Todo file and 2581With prefix argument FILE, prompt for a specific todo file and
2582choose (with TAB completion) a category in it to move the item or 2582choose (with TAB completion) a category in it to move the item or
2583items to; otherwise, choose and move to any category in either 2583items to; otherwise, choose and move to any category in either
2584the current Todo file or one of the files in 2584the current todo file or one of the files in
2585`todo-category-completions-files'. If the chosen category is 2585`todo-category-completions-files'. If the chosen category is
2586not an existing categories, then it is created and the item(s) 2586not an existing categories, then it is created and the item(s)
2587become(s) the first entry/entries in that category. 2587become(s) the first entry/entries in that category.
2588 2588
2589With moved Todo items, prompt to set the priority in the category 2589With moved todo items, prompt to set the priority in the category
2590moved to (with multiple todo items, the one that had the highest 2590moved to (with multiple todo items, the one that had the highest
2591priority in the category moved from gets the new priority and the 2591priority in the category moved from gets the new priority and the
2592rest of the moved todo items are inserted in sequence below it). 2592rest of the moved todo items are inserted in sequence below it).
@@ -2948,7 +2948,7 @@ comments without asking."
2948;; ----------------------------------------------------------------------------- 2948;; -----------------------------------------------------------------------------
2949 2949
2950(defun todo-find-archive (&optional ask) 2950(defun todo-find-archive (&optional ask)
2951 "Visit the archive of the current Todo category, if it exists. 2951 "Visit the archive of the current todo category, if it exists.
2952If the category has no archived items, prompt to visit the 2952If the category has no archived items, prompt to visit the
2953archive anyway. If there is no archive for this file or with 2953archive anyway. If there is no archive for this file or with
2954non-nil argument ASK, prompt to visit another archive. 2954non-nil argument ASK, prompt to visit another archive.
@@ -2970,7 +2970,7 @@ displayed."
2970 "visit another archive? ")) 2970 "visit another archive? "))
2971 'other-archive)))) 2971 'other-archive))))
2972 (when (eq place 'other-archive) 2972 (when (eq place 'other-archive)
2973 (setq archive (todo-read-file-name "Choose a Todo archive: " t t))) 2973 (setq archive (todo-read-file-name "Choose a todo archive: " t t)))
2974 (when (and (eq place 'this-archive) (zerop count)) 2974 (when (and (eq place 'this-archive) (zerop count))
2975 (setq place (when (todo-y-or-n-p 2975 (setq place (when (todo-y-or-n-p
2976 (concat "This category has no archived items;" 2976 (concat "This category has no archived items;"
@@ -3134,7 +3134,7 @@ If there are marked items, unarchive all of these; otherwise,
3134unarchive the item at point. 3134unarchive the item at point.
3135 3135
3136Unarchived items are restored as done items to the corresponding 3136Unarchived items are restored as done items to the corresponding
3137category in the Todo file, inserted at the top of done items 3137category in the todo file, inserted at the top of done items
3138section. If all items in the archive category have been 3138section. If all items in the archive category have been
3139restored, the category is deleted from the archive. If this was 3139restored, the category is deleted from the archive. If this was
3140the only category in the archive, the archive file is deleted." 3140the only category in the archive, the archive file is deleted."
@@ -3220,7 +3220,7 @@ the only category in the archive, the archive file is deleted."
3220 (setq todo-categories (delete (assoc cat todo-categories) 3220 (setq todo-categories (delete (assoc cat todo-categories)
3221 todo-categories)) 3221 todo-categories))
3222 (todo-update-categories-sexp)))) 3222 (todo-update-categories-sexp))))
3223 ;; Visit category in Todo file and show restored done items. 3223 ;; Visit category in todo file and show restored done items.
3224 (let ((tfile (buffer-file-name tbuf)) 3224 (let ((tfile (buffer-file-name tbuf))
3225 (todo-show-with-done t)) 3225 (todo-show-with-done t))
3226 (set-window-buffer (selected-window) 3226 (set-window-buffer (selected-window)
@@ -3230,7 +3230,7 @@ the only category in the archive, the archive file is deleted."
3230 (message "Items unarchived."))))) 3230 (message "Items unarchived.")))))
3231 3231
3232(defun todo-jump-to-archive-category (&optional file) 3232(defun todo-jump-to-archive-category (&optional file)
3233 "Prompt for a category in a Todo archive and jump to it. 3233 "Prompt for a category in a todo archive and jump to it.
3234With prefix argument FILE, prompt for an archive and choose (with 3234With prefix argument FILE, prompt for an archive and choose (with
3235TAB completion) a category in it to jump to; otherwise, choose 3235TAB completion) a category in it to jump to; otherwise, choose
3236and jump to any category in the current archive." 3236and jump to any category in the current archive."
@@ -3384,12 +3384,12 @@ decreasing or increasing its number."
3384 (forward-char col)))))) 3384 (forward-char col))))))
3385 3385
3386(defun todo-raise-category () 3386(defun todo-raise-category ()
3387 "Raise priority of category at point in Todo Categories buffer." 3387 "Raise priority of category at point in the table of categories."
3388 (interactive) 3388 (interactive)
3389 (todo-set-category-number 'raise)) 3389 (todo-set-category-number 'raise))
3390 3390
3391(defun todo-lower-category () 3391(defun todo-lower-category ()
3392 "Lower priority of category at point in Todo Categories buffer." 3392 "Lower priority of category at point in the table of categories."
3393 (interactive) 3393 (interactive)
3394 (todo-set-category-number 'lower)) 3394 (todo-set-category-number 'lower))
3395 3395
@@ -3638,7 +3638,7 @@ which is the value of the user option
3638 (let ((archive (member todo-current-todo-file todo-archives)) 3638 (let ((archive (member todo-current-todo-file todo-archives))
3639 buffer-read-only) 3639 buffer-read-only)
3640 (erase-buffer) 3640 (erase-buffer)
3641 (insert (format (concat "Category counts for Todo " 3641 (insert (format (concat "Category counts for todo "
3642 (if archive "archive" "file") 3642 (if archive "archive" "file")
3643 " \"%s\".") 3643 " \"%s\".")
3644 (todo-short-file-name todo-current-todo-file))) 3644 (todo-short-file-name todo-current-todo-file)))
@@ -3709,7 +3709,7 @@ which is the value of the user option
3709;; ----------------------------------------------------------------------------- 3709;; -----------------------------------------------------------------------------
3710 3710
3711(defun todo-search () 3711(defun todo-search ()
3712 "Search for a regular expression in this Todo file. 3712 "Search for a regular expression in this todo file.
3713The search runs through the whole file and encompasses all and 3713The search runs through the whole file and encompasses all and
3714only todo and done items; it excludes category names. Multiple 3714only todo and done items; it excludes category names. Multiple
3715matches are shown sequentially, highlighted in `todo-search' 3715matches are shown sequentially, highlighted in `todo-search'
@@ -3824,7 +3824,7 @@ See `todo-set-top-priorities' for more details."
3824 3824
3825(defun todo-filter-top-priorities (&optional arg) 3825(defun todo-filter-top-priorities (&optional arg)
3826 "Display a list of top priority items from different categories. 3826 "Display a list of top priority items from different categories.
3827The categories can be any of those in the current Todo file. 3827The categories can be any of those in the current todo file.
3828 3828
3829With numerical prefix ARG show at most ARG top priority items 3829With numerical prefix ARG show at most ARG top priority items
3830from each category. With `C-u' as prefix argument show the 3830from each category. With `C-u' as prefix argument show the
@@ -3832,7 +3832,7 @@ numbers of top priority items specified by category in
3832`todo-top-priorities-overrides', if this has an entry for the file(s); 3832`todo-top-priorities-overrides', if this has an entry for the file(s);
3833otherwise show `todo-top-priorities' items per category in the 3833otherwise show `todo-top-priorities' items per category in the
3834file(s). With no prefix argument, if a top priorities file for 3834file(s). With no prefix argument, if a top priorities file for
3835the current Todo file has previously been saved (see 3835the current todo file has previously been saved (see
3836`todo-save-filtered-items-buffer'), visit this file; if there is 3836`todo-save-filtered-items-buffer'), visit this file; if there is
3837no such file, build the list as with prefix argument `C-u'. 3837no such file, build the list as with prefix argument `C-u'.
3838 3838
@@ -3852,7 +3852,7 @@ from each category in each file. With `C-u' as prefix argument
3852show the numbers of top priority items specified in 3852show the numbers of top priority items specified in
3853`todo-top-priorities-overrides', if this is non-nil; otherwise show 3853`todo-top-priorities-overrides', if this is non-nil; otherwise show
3854`todo-top-priorities' items per category. With no prefix 3854`todo-top-priorities' items per category. With no prefix
3855argument, if a top priorities file for the chosen Todo files 3855argument, if a top priorities file for the chosen todo files
3856exists (see `todo-save-filtered-items-buffer'), visit this file; 3856exists (see `todo-save-filtered-items-buffer'), visit this file;
3857if there is no such file, do the same as with prefix argument 3857if there is no such file, do the same as with prefix argument
3858`C-u'." 3858`C-u'."
@@ -3861,10 +3861,10 @@ if there is no such file, do the same as with prefix argument
3861 3861
3862(defun todo-filter-diary-items (&optional arg) 3862(defun todo-filter-diary-items (&optional arg)
3863 "Display a list of todo diary items from different categories. 3863 "Display a list of todo diary items from different categories.
3864The categories can be any of those in the current Todo file. 3864The categories can be any of those in the current todo file.
3865 3865
3866Called with no prefix ARG, if a diary items file for the current 3866Called with no prefix ARG, if a diary items file for the current
3867Todo file has previously been saved (see 3867todo file has previously been saved (see
3868`todo-save-filtered-items-buffer'), visit this file; if there is 3868`todo-save-filtered-items-buffer'), visit this file; if there is
3869no such file, build the list of diary items. Called with a 3869no such file, build the list of diary items. Called with a
3870prefix argument, build the list even if there is a saved file of 3870prefix argument, build the list even if there is a saved file of
@@ -3879,7 +3879,7 @@ in `todo-filter-files', or if this nil, in the files chosen from
3879a file selection dialog that pops up in this case. 3879a file selection dialog that pops up in this case.
3880 3880
3881Called with no prefix ARG, if a diary items file for the chosen 3881Called with no prefix ARG, if a diary items file for the chosen
3882Todo files has previously been saved (see 3882todo files has previously been saved (see
3883`todo-save-filtered-items-buffer'), visit this file; if there is 3883`todo-save-filtered-items-buffer'), visit this file; if there is
3884no such file, build the list of diary items. Called with a 3884no such file, build the list of diary items. Called with a
3885prefix argument, build the list even if there is a saved file of 3885prefix argument, build the list even if there is a saved file of
@@ -3889,13 +3889,13 @@ diary items."
3889 3889
3890(defun todo-filter-regexp-items (&optional arg) 3890(defun todo-filter-regexp-items (&optional arg)
3891 "Prompt for a regular expression and display items that match it. 3891 "Prompt for a regular expression and display items that match it.
3892The matches can be from any categories in the current Todo file 3892The matches can be from any categories in the current todo file
3893and with non-nil option `todo-filter-done-items', can include 3893and with non-nil option `todo-filter-done-items', can include
3894not only todo items but also done items, including those in 3894not only todo items but also done items, including those in
3895Archive files. 3895Archive files.
3896 3896
3897Called with no prefix ARG, if a regexp items file for the current 3897Called with no prefix ARG, if a regexp items file for the current
3898Todo file has previously been saved (see 3898todo file has previously been saved (see
3899`todo-save-filtered-items-buffer'), visit this file; if there is 3899`todo-save-filtered-items-buffer'), visit this file; if there is
3900no such file, build the list of regexp items. Called with a 3900no such file, build the list of regexp items. Called with a
3901prefix argument, build the list even if there is a saved file of 3901prefix argument, build the list even if there is a saved file of
@@ -3913,7 +3913,7 @@ only todo items but also done items, including those in Archive
3913files. 3913files.
3914 3914
3915Called with no prefix ARG, if a regexp items file for the current 3915Called with no prefix ARG, if a regexp items file for the current
3916Todo file has previously been saved (see 3916todo file has previously been saved (see
3917`todo-save-filtered-items-buffer'), visit this file; if there is 3917`todo-save-filtered-items-buffer'), visit this file; if there is
3918no such file, build the list of regexp items. Called with a 3918no such file, build the list of regexp items. Called with a
3919prefix argument, build the list even if there is a saved file of 3919prefix argument, build the list even if there is a saved file of
@@ -4101,12 +4101,12 @@ the values of FILTER and FILE-LIST."
4101 (with-temp-buffer 4101 (with-temp-buffer
4102 (when (and todo-filter-done-items (eq filter 'regexp)) 4102 (when (and todo-filter-done-items (eq filter 'regexp))
4103 ;; If there is a corresponding archive file for the 4103 ;; If there is a corresponding archive file for the
4104 ;; Todo file, insert it first and add identifiers for 4104 ;; todo file, insert it first and add identifiers for
4105 ;; todo-go-to-source-item. 4105 ;; todo-go-to-source-item.
4106 (let ((arch (concat (file-name-sans-extension f) ".toda"))) 4106 (let ((arch (concat (file-name-sans-extension f) ".toda")))
4107 (when (file-exists-p arch) 4107 (when (file-exists-p arch)
4108 (insert-file-contents arch) 4108 (insert-file-contents arch)
4109 ;; Delete Todo archive file categories sexp. 4109 ;; Delete todo archive file's categories sexp.
4110 (delete-region (line-beginning-position) 4110 (delete-region (line-beginning-position)
4111 (1+ (line-end-position))) 4111 (1+ (line-end-position)))
4112 (save-excursion 4112 (save-excursion
@@ -4126,7 +4126,7 @@ the values of FILTER and FILE-LIST."
4126 (insert "(archive) ")) 4126 (insert "(archive) "))
4127 (forward-line)))))) 4127 (forward-line))))))
4128 (insert-file-contents f) 4128 (insert-file-contents f)
4129 ;; Delete Todo file categories sexp. 4129 ;; Delete todo file's categories sexp.
4130 (delete-region (line-beginning-position) (1+ (line-end-position))) 4130 (delete-region (line-beginning-position) (1+ (line-end-position)))
4131 (let (fnum) 4131 (let (fnum)
4132 ;; Unless the number of top priorities to show was 4132 ;; Unless the number of top priorities to show was
@@ -4238,7 +4238,7 @@ the values of FILTER and FILE-LIST."
4238 "Set number of top priorities shown by `todo-filter-top-priorities'. 4238 "Set number of top priorities shown by `todo-filter-top-priorities'.
4239With non-nil ARG, set the number only for the current Todo 4239With non-nil ARG, set the number only for the current Todo
4240category; otherwise, set the number for all categories in the 4240category; otherwise, set the number for all categories in the
4241current Todo file. 4241current todo file.
4242 4242
4243Calling this function via either of the commands 4243Calling this function via either of the commands
4244`todo-set-top-priorities-in-file' or 4244`todo-set-top-priorities-in-file' or
@@ -4274,7 +4274,7 @@ set the user customizable option `todo-top-priorities-overrides'."
4274 (todo-prefix-overlays))) 4274 (todo-prefix-overlays)))
4275 4275
4276(defun todo-find-item (str) 4276(defun todo-find-item (str)
4277 "Search for filtered item STR in its saved Todo file. 4277 "Search for filtered item STR in its saved todo file.
4278Return the list (FOUND FILE CAT), where CAT and FILE are the 4278Return the list (FOUND FILE CAT), where CAT and FILE are the
4279item's category and file, and FOUND is a cons cell if the search 4279item's category and file, and FOUND is a cons cell if the search
4280succeeds, whose car is the start of the item in FILE and whose 4280succeeds, whose car is the start of the item in FILE and whose
@@ -4399,7 +4399,7 @@ If the file already exists, overwrite it only on confirmation."
4399 (write-file filename t))) 4399 (write-file filename t)))
4400 4400
4401;; ----------------------------------------------------------------------------- 4401;; -----------------------------------------------------------------------------
4402;;; Printing Todo buffers 4402;;; Printing Todo mode buffers
4403;; ----------------------------------------------------------------------------- 4403;; -----------------------------------------------------------------------------
4404 4404
4405(defcustom todo-print-buffer-function 'ps-print-buffer-with-faces 4405(defcustom todo-print-buffer-function 'ps-print-buffer-with-faces
@@ -4408,10 +4408,10 @@ If the file already exists, overwrite it only on confirmation."
4408 :group 'todo) 4408 :group 'todo)
4409 4409
4410(defvar todo-print-buffer "*Todo Print*" 4410(defvar todo-print-buffer "*Todo Print*"
4411 "Name of buffer containing printable Todo text.") 4411 "Name of buffer with printable version of Todo mode buffer.")
4412 4412
4413(defun todo-print-buffer (&optional to-file) 4413(defun todo-print-buffer (&optional to-file)
4414 "Produce a printable version of the current Todo buffer. 4414 "Produce a printable version of the current Todo mode buffer.
4415This converts overlays and soft line wrapping and, depending on 4415This converts overlays and soft line wrapping and, depending on
4416the value of `todo-print-buffer-function', includes faces. With 4416the value of `todo-print-buffer-function', includes faces. With
4417non-nil argument TO-FILE write the printable version to a file; 4417non-nil argument TO-FILE write the printable version to a file;
@@ -4461,7 +4461,7 @@ otherwise, send it to the default printer."
4461 (kill-buffer buf))) 4461 (kill-buffer buf)))
4462 4462
4463(defun todo-print-buffer-to-file () 4463(defun todo-print-buffer-to-file ()
4464 "Save printable version of this Todo buffer to a file." 4464 "Save printable version of this Todo mode buffer to a file."
4465 (interactive) 4465 (interactive)
4466 (todo-print-buffer t)) 4466 (todo-print-buffer t))
4467 4467
@@ -4473,14 +4473,14 @@ otherwise, send it to the default printer."
4473 (concat "\\(?1:[0-9]\\{4\\}\\)-\\(?2:[0-9]\\{2\\}\\)-" 4473 (concat "\\(?1:[0-9]\\{4\\}\\)-\\(?2:[0-9]\\{2\\}\\)-"
4474 "\\(?3:[0-9]\\{2\\}\\) \\(?4:[0-9]\\{2\\}:[0-9]\\{2\\}\\)") 4474 "\\(?3:[0-9]\\{2\\}\\) \\(?4:[0-9]\\{2\\}:[0-9]\\{2\\}\\)")
4475 "Regexp matching legacy todo-mode.el item date-time strings. 4475 "Regexp matching legacy todo-mode.el item date-time strings.
4476In order for `todo-convert-legacy-files' to correctly convert this 4476In order for `todo-convert-legacy-files' to correctly convert
4477string to the current Todo format, the regexp must contain four 4477this string to the current Todo mode format, the regexp must
4478explicitly numbered groups (see `(elisp) Regexp Backslash'), 4478contain four explicitly numbered groups (see `(elisp) Regexp
4479where group 1 matches a string for the year, group 2 a string for 4479Backslash'), where group 1 matches a string for the year, group 2
4480the month, group 3 a string for the day and group 4 a string for 4480a string for the month, group 3 a string for the day and group 4
4481the time. The default value converts date-time strings built 4481a string for the time. The default value converts date-time
4482using the default value of `todo-time-string-format' from 4482strings built using the default value of
4483todo-mode.el." 4483`todo-time-string-format' from todo-mode.el."
4484 :type 'regexp 4484 :type 'regexp
4485 :group 'todo) 4485 :group 'todo)
4486 4486
@@ -4498,10 +4498,10 @@ Helper function for `todo-convert-legacy-files'."
4498 (when time (concat " " time))))) 4498 (when time (concat " " time)))))
4499 4499
4500(defun todo-convert-legacy-files () 4500(defun todo-convert-legacy-files ()
4501 "Convert legacy Todo files to the current Todo format. 4501 "Convert legacy todo files to the current Todo mode format.
4502The old-style files named by the variables `todo-file-do' and 4502The old-style files named by the variables `todo-file-do' and
4503`todo-file-done' from the old package are converted to the new 4503`todo-file-done' from the old package are converted to the new
4504format and saved (the latter as a Todo Archive file) with a new 4504format and saved (the latter as a todo archive file) with a new
4505name in `todo-directory'. See also the documentation string of 4505name in `todo-directory'. See also the documentation string of
4506`todo-legacy-date-time-regexp' for further details." 4506`todo-legacy-date-time-regexp' for further details."
4507 (interactive) 4507 (interactive)
@@ -4519,7 +4519,7 @@ name in `todo-directory'. See also the documentation string of
4519 todo-prefix-tem) 4519 todo-prefix-tem)
4520 ;; Convert `todo-file-do'. 4520 ;; Convert `todo-file-do'.
4521 (if (not (file-exists-p todo-file-do-tem)) 4521 (if (not (file-exists-p todo-file-do-tem))
4522 (message "No legacy Todo file exists") 4522 (message "No legacy todo file exists")
4523 (let ((default "todo-do-conv") 4523 (let ((default "todo-do-conv")
4524 file archive-sexp) 4524 file archive-sexp)
4525 (with-temp-buffer 4525 (with-temp-buffer
@@ -4656,7 +4656,7 @@ name in `todo-directory'. See also the documentation string of
4656 (line-beginning-position) 4656 (line-beginning-position)
4657 (line-end-position))))) 4657 (line-end-position)))))
4658 (setq file (concat (file-name-sans-extension file) ".todo")) 4658 (setq file (concat (file-name-sans-extension file) ".todo"))
4659 ;; Update categories sexp of converted Todo file again, adding 4659 ;; Update categories sexp of converted todo file again, adding
4660 ;; counts of archived items. 4660 ;; counts of archived items.
4661 (with-temp-buffer 4661 (with-temp-buffer
4662 (insert-file-contents file) 4662 (insert-file-contents file)
@@ -4682,14 +4682,14 @@ name in `todo-directory'. See also the documentation string of
4682 (todo-show)))))) 4682 (todo-show))))))
4683 4683
4684;; ----------------------------------------------------------------------------- 4684;; -----------------------------------------------------------------------------
4685;;; Utility functions for Todo files, categories and items 4685;;; Utility functions for todo files, categories and items
4686;; ----------------------------------------------------------------------------- 4686;; -----------------------------------------------------------------------------
4687 4687
4688(defun todo-absolute-file-name (name &optional type) 4688(defun todo-absolute-file-name (name &optional type)
4689 "Return the absolute file name of short Todo file NAME. 4689 "Return the absolute file name of short todo file NAME.
4690With TYPE `archive' or `top' return the absolute file name of the 4690With TYPE `archive' or `top' return the absolute file name of the
4691short Todo Archive or Top Priorities file name, respectively." 4691short todo archive or top priorities file name, respectively."
4692 ;; NOP if there is no Todo file yet (i.e. don't concatenate nil). 4692 ;; No-op if there is no todo file yet (i.e. don't concatenate nil).
4693 (when name 4693 (when name
4694 (file-truename 4694 (file-truename
4695 (concat todo-directory name 4695 (concat todo-directory name
@@ -4700,7 +4700,7 @@ short Todo Archive or Top Priorities file name, respectively."
4700 (t ".todo")))))) 4700 (t ".todo"))))))
4701 4701
4702(defun todo-category-number (cat) 4702(defun todo-category-number (cat)
4703 "Return the number of category CAT in this Todo file. 4703 "Return the number of category CAT in this todo file.
4704The buffer-local variable `todo-category-number' holds this 4704The buffer-local variable `todo-category-number' holds this
4705number as its value." 4705number as its value."
4706 (let ((categories (mapcar 'car todo-categories))) 4706 (let ((categories (mapcar 'car todo-categories)))
@@ -4814,7 +4814,7 @@ With nil or omitted CATEGORY, default to the current category."
4814 (prin1 todo-categories (current-buffer)))))) 4814 (prin1 todo-categories (current-buffer))))))
4815 4815
4816(defun todo-make-categories-list (&optional force) 4816(defun todo-make-categories-list (&optional force)
4817 "Return an alist of Todo categories and their item counts. 4817 "Return an alist of todo categories and their item counts.
4818With non-nil argument FORCE parse the entire file to build the 4818With non-nil argument FORCE parse the entire file to build the
4819list; otherwise, get the value by reading the sexp at the top of 4819list; otherwise, get the value by reading the sexp at the top of
4820the file." 4820the file."
@@ -4885,19 +4885,20 @@ the file."
4885 todo-categories) 4885 todo-categories)
4886 4886
4887(defun todo-repair-categories-sexp () 4887(defun todo-repair-categories-sexp ()
4888 "Repair corrupt Todo categories sexp. 4888 "Repair corrupt todo file categories sexp.
4889This should only be needed as a consequence of careless manual 4889This should only be needed as a consequence of careless manual
4890editing or a bug in todo.el. 4890editing or a bug in todo.el.
4891 4891
4892*Warning*: Calling this command restores the category order to 4892*Warning*: Calling this command restores the category order to
4893the list element order in the Todo categories sexp, so any order 4893the list element order in the todo file categories sexp, so any
4894changes made in Todo Categories mode will have to be made again." 4894order changes made in Todo Categories mode will have to be made
4895again."
4895 (interactive) 4896 (interactive)
4896 (let ((todo-categories (todo-make-categories-list t))) 4897 (let ((todo-categories (todo-make-categories-list t)))
4897 (todo-update-categories-sexp))) 4898 (todo-update-categories-sexp)))
4898 4899
4899(defun todo-check-format () 4900(defun todo-check-format ()
4900 "Signal an error if the current Todo file is ill-formatted. 4901 "Signal an error if the current todo file is ill-formatted.
4901Otherwise return t. Display a message if the file is well-formed 4902Otherwise return t. Display a message if the file is well-formed
4902but the categories sexp differs from the current value of 4903but the categories sexp differs from the current value of
4903`todo-categories'." 4904`todo-categories'."
@@ -4927,7 +4928,7 @@ but the categories sexp differs from the current value of
4927 "\\|\\(" todo-done-string-start "\\)"))) 4928 "\\|\\(" todo-done-string-start "\\)")))
4928 (while (not (eobp)) 4929 (while (not (eobp))
4929 (unless (looking-at legit) 4930 (unless (looking-at legit)
4930 (user-error "Illegitimate Todo file format at line %d" 4931 (user-error "Illegitimate todo file format at line %d"
4931 (line-number-at-pos (point)))) 4932 (line-number-at-pos (point))))
4932 (forward-line))) 4933 (forward-line)))
4933 ;; Warn user if categories sexp has changed. 4934 ;; Warn user if categories sexp has changed.
@@ -4941,7 +4942,7 @@ but the categories sexp differs from the current value of
4941 t) 4942 t)
4942 4943
4943(defun todo-item-start () 4944(defun todo-item-start ()
4944 "Move to start of current Todo item and return its position." 4945 "Move to start of current todo item and return its position."
4945 (unless (or 4946 (unless (or
4946 ;; Buffer is empty (invocation possible e.g. via todo-forward-item 4947 ;; Buffer is empty (invocation possible e.g. via todo-forward-item
4947 ;; from todo-filter-items when processing category with no todo 4948 ;; from todo-filter-items when processing category with no todo
@@ -4962,7 +4963,7 @@ but the categories sexp differs from the current value of
4962 (point))) 4963 (point)))
4963 4964
4964(defun todo-item-end () 4965(defun todo-item-end ()
4965 "Move to end of current Todo item and return its position." 4966 "Move to end of current todo item and return its position."
4966 ;; Items cannot end with a blank line. 4967 ;; Items cannot end with a blank line.
4967 (unless (looking-at "^$") 4968 (unless (looking-at "^$")
4968 (let* ((done (todo-done-item-p)) 4969 (let* ((done (todo-done-item-p))
@@ -5152,7 +5153,7 @@ Overrides `diary-goto-entry'."
5152 "Non-nil if this item begins with `todo-item-mark'. 5153 "Non-nil if this item begins with `todo-item-mark'.
5153In that case, return the item's prefix overlay." 5154In that case, return the item's prefix overlay."
5154 (let* ((ov (todo-get-overlay 'prefix)) 5155 (let* ((ov (todo-get-overlay 'prefix))
5155 ;; If an item insertion command is called on a Todo file 5156 ;; If an item insertion command is called on a todo file
5156 ;; before it is visited, it has no prefix overlays yet, so 5157 ;; before it is visited, it has no prefix overlays yet, so
5157 ;; check for this. 5158 ;; check for this.
5158 (pref (when ov (overlay-get ov 'before-string))) 5159 (pref (when ov (overlay-get ov 'before-string)))
@@ -5290,15 +5291,14 @@ The elements of ARGLIST may be atoms or lists."
5290 (setq l (append v nil)))) 5291 (setq l (append v nil))))
5291 (setq new (append new (list l)))) 5292 (setq new (append new (list l))))
5292 new) 5293 new)
5293 "List of all argument lists for Todo item insertion commands.") 5294 "List of all argument lists for Todo mode item insertion commands.")
5294 5295
5295(defun todo-insertion-command-name (arglist) 5296(defun todo-insertion-command-name (arglist)
5296 "Generate Todo item insertion command name from ARGLIST." 5297 "Generate Todo mode item insertion command name from ARGLIST."
5297 (replace-regexp-in-string 5298 (replace-regexp-in-string
5298 "-\\_>" "" 5299 "-\\_>" ""
5299 (replace-regexp-in-string 5300 (replace-regexp-in-string
5300 "-+" "-" 5301 "-+" "-"
5301 ;; (concat "todo-item-insert-"
5302 (concat "todo-insert-item-" 5302 (concat "todo-insert-item-"
5303 (mapconcat (lambda (e) (if e (symbol-name e))) arglist "-"))))) 5303 (mapconcat (lambda (e) (if e (symbol-name e))) arglist "-")))))
5304 5304
@@ -5306,10 +5306,10 @@ The elements of ARGLIST may be atoms or lists."
5306 (mapcar (lambda (l) 5306 (mapcar (lambda (l)
5307 (todo-insertion-command-name l)) 5307 (todo-insertion-command-name l))
5308 todo-insertion-commands-args) 5308 todo-insertion-commands-args)
5309 "List of names of Todo item insertion commands.") 5309 "List of names of Todo mode item insertion commands.")
5310 5310
5311(defmacro todo-define-insertion-command (&rest args) 5311(defmacro todo-define-insertion-command (&rest args)
5312 "Generate item insertion command definitions from ARGS." 5312 "Generate Todo mode item insertion command definitions from ARGS."
5313 (let ((name (intern (todo-insertion-command-name args))) 5313 (let ((name (intern (todo-insertion-command-name args)))
5314 (arg0 (nth 0 args)) 5314 (arg0 (nth 0 args))
5315 (arg1 (nth 1 args)) 5315 (arg1 (nth 1 args))
@@ -5317,7 +5317,7 @@ The elements of ARGLIST may be atoms or lists."
5317 (arg3 (nth 3 args)) 5317 (arg3 (nth 3 args))
5318 (arg4 (nth 4 args))) 5318 (arg4 (nth 4 args)))
5319 `(defun ,name (&optional arg &rest args) 5319 `(defun ,name (&optional arg &rest args)
5320 "Todo item insertion command generated from ARGS. 5320 "Todo mode item insertion command generated from ARGS.
5321For descriptions of the individual arguments, their values, and 5321For descriptions of the individual arguments, their values, and
5322their relation to key bindings, see `todo-basic-insert-item'." 5322their relation to key bindings, see `todo-basic-insert-item'."
5323 (interactive (list current-prefix-arg)) 5323 (interactive (list current-prefix-arg))
@@ -5327,7 +5327,7 @@ their relation to key bindings, see `todo-basic-insert-item'."
5327 (mapcar (lambda (c) 5327 (mapcar (lambda (c)
5328 (eval `(todo-define-insertion-command ,@c))) 5328 (eval `(todo-define-insertion-command ,@c)))
5329 todo-insertion-commands-args) 5329 todo-insertion-commands-args)
5330 "List of Todo item insertion commands.") 5330 "List of Todo mode item insertion commands.")
5331 5331
5332(defvar todo-insertion-commands-arg-key-list 5332(defvar todo-insertion-commands-arg-key-list
5333 '(("diary" "y" "yy") 5333 '(("diary" "y" "yy")
@@ -5338,7 +5338,7 @@ their relation to key bindings, see `todo-basic-insert-item'."
5338 ("time" "t" "tt") 5338 ("time" "t" "tt")
5339 ("here" "h" "h") 5339 ("here" "h" "h")
5340 ("region" "r" "r")) 5340 ("region" "r" "r"))
5341 "List of mappings of insertion command arguments to key sequences.") 5341 "List of mappings of item insertion command arguments to key sequences.")
5342 5342
5343(defun todo-insertion-key-bindings (map) 5343(defun todo-insertion-key-bindings (map)
5344 "Generate key binding definitions for item insertion keymap MAP." 5344 "Generate key binding definitions for item insertion keymap MAP."
@@ -5401,8 +5401,8 @@ or, with non-nil ARCHIVE, the current archive file."
5401 (dolist (f files listall) 5401 (dolist (f files listall)
5402 (with-current-buffer (find-file-noselect f 'nowarn) 5402 (with-current-buffer (find-file-noselect f 'nowarn)
5403 ;; Ensure category is properly displayed in case user 5403 ;; Ensure category is properly displayed in case user
5404 ;; switches to file via a non-Todo command. And if done 5404 ;; switches to file via a non-Todo mode command. And if
5405 ;; items in category are visible, keep them visible. 5405 ;; done items in category are visible, keep them visible.
5406 (let ((done todo-show-with-done)) 5406 (let ((done todo-show-with-done))
5407 (when (> (buffer-size) (- (point-max) (point-min))) 5407 (when (> (buffer-size) (- (point-max) (point-min)))
5408 (save-excursion 5408 (save-excursion
@@ -5426,11 +5426,11 @@ or, with non-nil ARCHIVE, the current archive file."
5426 listf))))) 5426 listf)))))
5427 5427
5428(defun todo-read-file-name (prompt &optional archive mustmatch) 5428(defun todo-read-file-name (prompt &optional archive mustmatch)
5429 "Choose and return the name of a Todo file, prompting with PROMPT. 5429 "Choose and return the name of a todo file, prompting with PROMPT.
5430 5430
5431Show completions with TAB or SPC; the names are shown in short 5431Show completions with TAB or SPC; the names are shown in short
5432form but the absolute truename is returned. With non-nil ARCHIVE 5432form but the absolute truename is returned. With non-nil ARCHIVE
5433return the absolute truename of a Todo archive file. With non-nil 5433return the absolute truename of a todo archive file. With non-nil
5434MUSTMATCH the name of an existing file must be chosen; 5434MUSTMATCH the name of an existing file must be chosen;
5435otherwise, a new file name is allowed." 5435otherwise, a new file name is allowed."
5436 (let* ((completion-ignore-case todo-completion-ignore-case) 5436 (let* ((completion-ignore-case todo-completion-ignore-case)
@@ -5563,7 +5563,7 @@ TYPE can be either of the symbols `file' or `category'."
5563 (if files 5563 (if files
5564 "Enter a non-empty file name: " 5564 "Enter a non-empty file name: "
5565 ;; Empty string passed by todo-show to 5565 ;; Empty string passed by todo-show to
5566 ;; prompt for initial Todo file. 5566 ;; prompt for initial todo file.
5567 (concat "Initial file name [" 5567 (concat "Initial file name ["
5568 todo-initial-file "]: "))) 5568 todo-initial-file "]: ")))
5569 ((eq type 'category) 5569 ((eq type 'category)
@@ -5571,7 +5571,7 @@ TYPE can be either of the symbols `file' or `category'."
5571 "Enter a non-empty category name: " 5571 "Enter a non-empty category name: "
5572 ;; Empty string passed by todo-show to 5572 ;; Empty string passed by todo-show to
5573 ;; prompt for initial category of a new 5573 ;; prompt for initial category of a new
5574 ;; Todo file. 5574 ;; todo file.
5575 (concat "Initial category name [" 5575 (concat "Initial category name ["
5576 todo-initial-category "]: ")))))) 5576 todo-initial-category "]: "))))))
5577 ((string-match "\\`\\s-+\\'" name) 5577 ((string-match "\\`\\s-+\\'" name)
@@ -5626,13 +5626,9 @@ number of the last the day of the month."
5626 (completion-ignore-case todo-completion-ignore-case)) 5626 (completion-ignore-case todo-completion-ignore-case))
5627 (setq monthname (completing-read 5627 (setq monthname (completing-read
5628 "Month name (RET for current month, * for any month): " 5628 "Month name (RET for current month, * for any month): "
5629 ;; (mapcar 'list (append marray nil))
5630 mlist nil t nil nil 5629 mlist nil t nil nil
5631 (calendar-month-name (calendar-extract-month 5630 (calendar-month-name (calendar-extract-month
5632 (calendar-current-date)) t)) 5631 (calendar-current-date)) t))
5633 ;; month (cdr (assoc-string
5634 ;; monthname (calendar-make-alist marray nil nil
5635 ;; abbrevs))))))
5636 month (1+ (- (length mlist) 5632 month (1+ (- (length mlist)
5637 (length (or (member monthname mlist) 5633 (length (or (member monthname mlist)
5638 (member monthname mablist)))))) 5634 (member monthname mablist))))))
@@ -5859,7 +5855,7 @@ the empty string (i.e., no time string)."
5859 (hl-line-mode -1))))))))) 5855 (hl-line-mode -1)))))))))
5860 5856
5861(defun todo-reevaluate-filelist-defcustoms () 5857(defun todo-reevaluate-filelist-defcustoms ()
5862 "Reevaluate defcustoms that provide choice list of Todo files." 5858 "Reevaluate defcustoms that provide choice list of todo files."
5863 (custom-set-default 'todo-default-todo-file 5859 (custom-set-default 'todo-default-todo-file
5864 (symbol-value 'todo-default-todo-file)) 5860 (symbol-value 'todo-default-todo-file))
5865 (todo-reevaluate-default-file-defcustom) 5861 (todo-reevaluate-default-file-defcustom)
@@ -5871,7 +5867,7 @@ the empty string (i.e., no time string)."
5871 5867
5872(defun todo-reevaluate-default-file-defcustom () 5868(defun todo-reevaluate-default-file-defcustom ()
5873 "Reevaluate defcustom of `todo-default-todo-file'. 5869 "Reevaluate defcustom of `todo-default-todo-file'.
5874Called after adding or deleting a Todo file." 5870Called after adding or deleting a todo file."
5875 (eval (defcustom todo-default-todo-file (car (funcall todo-files-function)) 5871 (eval (defcustom todo-default-todo-file (car (funcall todo-files-function))
5876 "Todo file visited by first session invocation of `todo-show'." 5872 "Todo file visited by first session invocation of `todo-show'."
5877 :type `(radio ,@(mapcar (lambda (f) (list 'const f)) 5873 :type `(radio ,@(mapcar (lambda (f) (list 'const f))
@@ -5881,7 +5877,7 @@ Called after adding or deleting a Todo file."
5881 5877
5882(defun todo-reevaluate-category-completions-files-defcustom () 5878(defun todo-reevaluate-category-completions-files-defcustom ()
5883 "Reevaluate defcustom of `todo-category-completions-files'. 5879 "Reevaluate defcustom of `todo-category-completions-files'.
5884Called after adding or deleting a Todo file." 5880Called after adding or deleting a todo file."
5885 (eval (defcustom todo-category-completions-files nil 5881 (eval (defcustom todo-category-completions-files nil
5886 "List of files for building `todo-read-category' completions." 5882 "List of files for building `todo-read-category' completions."
5887 :type `(set ,@(mapcar (lambda (f) (list 'const f)) 5883 :type `(set ,@(mapcar (lambda (f) (list 'const f))
@@ -5891,7 +5887,7 @@ Called after adding or deleting a Todo file."
5891 5887
5892(defun todo-reevaluate-filter-files-defcustom () 5888(defun todo-reevaluate-filter-files-defcustom ()
5893 "Reevaluate defcustom of `todo-filter-files'. 5889 "Reevaluate defcustom of `todo-filter-files'.
5894Called after adding or deleting a Todo file." 5890Called after adding or deleting a todo file."
5895 (eval (defcustom todo-filter-files nil 5891 (eval (defcustom todo-filter-files nil
5896 "List of files for multifile item filtering." 5892 "List of files for multifile item filtering."
5897 :type `(set ,@(mapcar (lambda (f) (list 'const f)) 5893 :type `(set ,@(mapcar (lambda (f) (list 'const f))
@@ -5904,7 +5900,7 @@ Called after adding or deleting a Todo file."
5904;; ----------------------------------------------------------------------------- 5900;; -----------------------------------------------------------------------------
5905 5901
5906(defun todo-nondiary-marker-matcher (lim) 5902(defun todo-nondiary-marker-matcher (lim)
5907 "Search for Todo nondiary markers within LIM for font-locking." 5903 "Search for todo item nondiary markers within LIM for font-locking."
5908 (re-search-forward (concat "^\\(?1:" (regexp-quote todo-nondiary-start) "\\)" 5904 (re-search-forward (concat "^\\(?1:" (regexp-quote todo-nondiary-start) "\\)"
5909 todo-date-pattern "\\(?: " diary-time-regexp 5905 todo-date-pattern "\\(?: " diary-time-regexp
5910 "\\)?\\(?2:" (regexp-quote todo-nondiary-end) "\\)") 5906 "\\)?\\(?2:" (regexp-quote todo-nondiary-end) "\\)")
@@ -5916,12 +5912,12 @@ Called after adding or deleting a Todo file."
5916 "\\)" todo-date-pattern) lim t)) 5912 "\\)" todo-date-pattern) lim t))
5917 5913
5918(defun todo-date-string-matcher (lim) 5914(defun todo-date-string-matcher (lim)
5919 "Search for Todo date string within LIM for font-locking." 5915 "Search for todo item date string within LIM for font-locking."
5920 (re-search-forward 5916 (re-search-forward
5921 (concat todo-date-string-start "\\(?1:" todo-date-pattern "\\)") lim t)) 5917 (concat todo-date-string-start "\\(?1:" todo-date-pattern "\\)") lim t))
5922 5918
5923(defun todo-time-string-matcher (lim) 5919(defun todo-time-string-matcher (lim)
5924 "Search for Todo time string within LIM for font-locking." 5920 "Search for todo item time string within LIM for font-locking."
5925 (re-search-forward (concat todo-date-string-start todo-date-pattern 5921 (re-search-forward (concat todo-date-string-start todo-date-pattern
5926 " \\(?1:" diary-time-regexp "\\)") lim t)) 5922 " \\(?1:" diary-time-regexp "\\)") lim t))
5927 5923
@@ -5940,18 +5936,18 @@ Called after adding or deleting a Todo file."
5940 (todo-diary-expired-matcher lim))))) 5936 (todo-diary-expired-matcher lim)))))
5941 5937
5942(defun todo-done-string-matcher (lim) 5938(defun todo-done-string-matcher (lim)
5943 "Search for Todo done header within LIM for font-locking." 5939 "Search for done todo item header within LIM for font-locking."
5944 (re-search-forward (concat todo-done-string-start 5940 (re-search-forward (concat todo-done-string-start
5945 "[^][]+]") 5941 "[^][]+]")
5946 lim t)) 5942 lim t))
5947 5943
5948(defun todo-comment-string-matcher (lim) 5944(defun todo-comment-string-matcher (lim)
5949 "Search for Todo done comment within LIM for font-locking." 5945 "Search for done todo item comment within LIM for font-locking."
5950 (re-search-forward (concat "\\[\\(?1:" todo-comment-string "\\):") 5946 (re-search-forward (concat "\\[\\(?1:" todo-comment-string "\\):")
5951 lim t)) 5947 lim t))
5952 5948
5953(defun todo-category-string-matcher-1 (lim) 5949(defun todo-category-string-matcher-1 (lim)
5954 "Search for Todo category name within LIM for font-locking. 5950 "Search for todo category name within LIM for font-locking.
5955This is for fontifying category and file names appearing in Todo 5951This is for fontifying category and file names appearing in Todo
5956Filtered Items mode following done items." 5952Filtered Items mode following done items."
5957 (if (eq major-mode 'todo-filtered-items-mode) 5953 (if (eq major-mode 'todo-filtered-items-mode)
@@ -5964,7 +5960,7 @@ Filtered Items mode following done items."
5964 lim t))) 5960 lim t)))
5965 5961
5966(defun todo-category-string-matcher-2 (lim) 5962(defun todo-category-string-matcher-2 (lim)
5967 "Search for Todo category name within LIM for font-locking. 5963 "Search for todo category name within LIM for font-locking.
5968This is for fontifying category and file names appearing in Todo 5964This is for fontifying category and file names appearing in Todo
5969Filtered Items mode following todo (not done) items." 5965Filtered Items mode following todo (not done) items."
5970 (if (eq major-mode 'todo-filtered-items-mode) 5966 (if (eq major-mode 'todo-filtered-items-mode)
@@ -6229,20 +6225,20 @@ Filtered Items mode following todo (not done) items."
6229;; ----------------------------------------------------------------------------- 6225;; -----------------------------------------------------------------------------
6230 6226
6231(defun todo-show-current-file () 6227(defun todo-show-current-file ()
6232 "Visit current instead of default Todo file with `todo-show'. 6228 "Visit current instead of default todo file with `todo-show'.
6233This function is added to `pre-command-hook' when user option 6229This function is added to `pre-command-hook' when user option
6234`todo-show-current-file' is set to non-nil." 6230`todo-show-current-file' is set to non-nil."
6235 (setq todo-global-current-todo-file todo-current-todo-file)) 6231 (setq todo-global-current-todo-file todo-current-todo-file))
6236 6232
6237(defun todo-display-as-todo-file () 6233(defun todo-display-as-todo-file ()
6238 "Show Todo files correctly when visited from outside of Todo mode." 6234 "Show todo files correctly when visited from outside of Todo mode."
6239 (and (member this-command todo-visit-files-commands) 6235 (and (member this-command todo-visit-files-commands)
6240 (= (- (point-max) (point-min)) (buffer-size)) 6236 (= (- (point-max) (point-min)) (buffer-size))
6241 (member major-mode '(todo-mode todo-archive-mode)) 6237 (member major-mode '(todo-mode todo-archive-mode))
6242 (todo-category-select))) 6238 (todo-category-select)))
6243 6239
6244(defun todo-add-to-buffer-list () 6240(defun todo-add-to-buffer-list ()
6245 "Add name of just visited Todo file to `todo-file-buffers'. 6241 "Add name of just visited todo file to `todo-file-buffers'.
6246This function is added to `find-file-hook' in Todo mode." 6242This function is added to `find-file-hook' in Todo mode."
6247 (let ((filename (file-truename (buffer-file-name)))) 6243 (let ((filename (file-truename (buffer-file-name))))
6248 (when (member filename todo-files) 6244 (when (member filename todo-files)
@@ -6258,7 +6254,7 @@ This function is added to `post-command-hook' in Todo mode."
6258 6254
6259(defun todo-reset-global-current-todo-file () 6255(defun todo-reset-global-current-todo-file ()
6260 "Update the value of `todo-global-current-todo-file'. 6256 "Update the value of `todo-global-current-todo-file'.
6261This becomes the latest existing Todo file or, if there is none, 6257This becomes the latest existing todo file or, if there is none,
6262the value of `todo-default-todo-file'. 6258the value of `todo-default-todo-file'.
6263This function is added to `kill-buffer-hook' in Todo mode." 6259This function is added to `kill-buffer-hook' in Todo mode."
6264 (let ((filename (file-truename (buffer-file-name)))) 6260 (let ((filename (file-truename (buffer-file-name))))
@@ -6304,7 +6300,7 @@ Added to `window-configuration-change-hook' in `todo-mode'."
6304(put 'todo-mode 'mode-class 'special) 6300(put 'todo-mode 'mode-class 'special)
6305 6301
6306(define-derived-mode todo-mode special-mode "Todo" 6302(define-derived-mode todo-mode special-mode "Todo"
6307 "Major mode for displaying, navigating and editing Todo lists. 6303 "Major mode for displaying, navigating and editing todo lists.
6308 6304
6309\\{todo-mode-map}" 6305\\{todo-mode-map}"
6310 ;; (easy-menu-add todo-menu) 6306 ;; (easy-menu-add todo-menu)
@@ -6330,7 +6326,7 @@ Added to `window-configuration-change-hook' in `todo-mode'."
6330;; If todo-mode is parent, all todo-mode key bindings appear to be 6326;; If todo-mode is parent, all todo-mode key bindings appear to be
6331;; available in todo-archive-mode (e.g. shown by C-h m). 6327;; available in todo-archive-mode (e.g. shown by C-h m).
6332(define-derived-mode todo-archive-mode special-mode "Todo-Arch" 6328(define-derived-mode todo-archive-mode special-mode "Todo-Arch"
6333 "Major mode for archived Todo categories. 6329 "Major mode for archived todo categories.
6334 6330
6335\\{todo-archive-mode-map}" 6331\\{todo-archive-mode-map}"
6336 (todo-modes-set-1) 6332 (todo-modes-set-1)
@@ -6360,7 +6356,7 @@ Added to `window-configuration-change-hook' in `todo-mode'."
6360 (setq-local todo-categories cats))) 6356 (setq-local todo-categories cats)))
6361 6357
6362(define-derived-mode todo-edit-mode text-mode "Todo-Ed" 6358(define-derived-mode todo-edit-mode text-mode "Todo-Ed"
6363 "Major mode for editing multiline Todo items. 6359 "Major mode for editing multiline todo items.
6364 6360
6365\\{todo-edit-mode-map}" 6361\\{todo-edit-mode-map}"
6366 (todo-modes-set-1) 6362 (todo-modes-set-1)
@@ -6370,7 +6366,7 @@ Added to `window-configuration-change-hook' in `todo-mode'."
6370(put 'todo-categories-mode 'mode-class 'special) 6366(put 'todo-categories-mode 'mode-class 'special)
6371 6367
6372(define-derived-mode todo-categories-mode special-mode "Todo-Cats" 6368(define-derived-mode todo-categories-mode special-mode "Todo-Cats"
6373 "Major mode for displaying and editing Todo categories. 6369 "Major mode for displaying and editing todo categories.
6374 6370
6375\\{todo-categories-mode-map}" 6371\\{todo-categories-mode-map}"
6376 (todo-mode-external-set)) 6372 (todo-mode-external-set))