1 ;;; todos.el --- major mode for editing TODO list files
3 ;; Copyright (C) 1997, 1999, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
4 ;; 2008, 2009 Free Software Foundation, Inc.
6 ;; Author: Oliver Seidel <privat@os10000.net>
7 ;; Maintainer: Stephen Berman <stephen.berman@gmx.net>
9 ;; Keywords: calendar, todo
11 ;; This file is part of GNU Emacs.
13 ;; GNU Emacs is free software: you can redistribute it and/or modify
14 ;; it under the terms of the GNU General Public License as published by
15 ;; the Free Software Foundation, either version 3 of the License, or
16 ;; (at your option) any later version.
18 ;; GNU Emacs is distributed in the hope that it will be useful,
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ;; GNU General Public License for more details.
23 ;; You should have received a copy of the GNU General Public License
24 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
26 ;; ---------------------------------------------------------------------------
32 ;; TODO is a major mode for EMACS which offers functionality to
33 ;; treat most lines in one buffer as a list of items one has to
34 ;; do. There are facilities to add new items, which are
35 ;; categorised, to edit or even delete items from the buffer.
36 ;; The buffer contents are currently compatible with the diary,
37 ;; so that the list of todos-items will show up in the FANCY diary
40 ;; Notice: Besides the major mode, this file also exports the
41 ;; function `todos-show' which will change to the one specific
42 ;; TODO file that has been specified in the todos-file-do
43 ;; variable. If this file does not conform to the TODO mode
44 ;; conventions, the todos-show function will add the appropriate
45 ;; header and footer. I don't anticipate this to cause much
46 ;; grief, but be warned, in case you attempt to read a plain text
49 ;; Preface, Quickstart Installation
51 ;; To get this to work, make emacs execute the line
53 ;; (autoload 'todos "todos"
54 ;; "Major mode for editing TODO lists." t)
55 ;; (autoload 'todos-show "todos"
56 ;; "Show TODO items." t)
57 ;; (autoload 'todos-insert-item "todos"
58 ;; "Add TODO item." t)
60 ;; You may now enter new items by typing "M-x todos-insert-item",
61 ;; or enter your TODO list file by typing "M-x todos-show".
63 ;; The TODO list file has a special format and some auxiliary
64 ;; information, which will be added by the todos-show function if
65 ;; it attempts to visit an un-initialised file. Hence it is
66 ;; recommended to use the todos-show function for the first time,
67 ;; in order to initialise the file, but it is not necessary
70 ;; As these commands are quite long to type, I would recommend
71 ;; the addition of two bindings to your to your global keymap. I
72 ;; personally have the following in my initialisation file:
74 ;; (global-set-key "\C-ct" 'todos-show) ; switch to TODO buffer
75 ;; (global-set-key "\C-ci" 'todos-insert-item) ; insert new item
77 ;; Note, however, that this recommendation has prompted some
78 ;; criticism, since the keys C-c LETTER are reserved for user
79 ;; functions. I believe my recommendation is acceptable, since
80 ;; the Emacs Lisp Manual *Tips* section also details that the
81 ;; mode itself should not bind any functions to those keys. The
82 ;; express aim of the above two bindings is to work outside the
83 ;; mode, which doesn't need the show function and offers a
84 ;; different binding for the insert function. They serve as
85 ;; shortcuts and are not even needed (since the TODO mode will be
86 ;; entered by visiting the TODO file, and later by switching to
89 ;; If you are an advanced user of this package, please consult
90 ;; the whole source code for autoloads, because there are several
91 ;; extensions that are not explicitly listed in the above quick
96 ;; This package will require the following packages to be
97 ;; available on the load-path:
104 ;; You will have the following facilities available:
106 ;; M-x todos-show will enter the todo list screen, here type
108 ;; + to go to next category
109 ;; - to go to previous category
110 ;; d to file the current entry, including a
111 ;; comment and timestamp
112 ;; e to edit the current entry
113 ;; E to edit a multi-line entry
114 ;; f to file the current entry, including a
115 ;; comment and timestamp
116 ;; i to insert a new entry, with prefix, omit category
117 ;; I to insert a new entry at current cursor position
118 ;; j jump to category
119 ;; k to kill the current entry
120 ;; l to lower the current entry's priority
121 ;; n for the next entry
122 ;; p for the previous entry
124 ;; q to save the list and exit the buffer
125 ;; r to raise the current entry's priority
126 ;; s to save the list
127 ;; S to save the list of top priorities
128 ;; t show top priority items for each category
130 ;; When you add a new entry, you are asked for the text and then
131 ;; for the category. I for example have categories for things
132 ;; that I want to do in the office (like mail my mum), that I
133 ;; want to do in town (like buy cornflakes) and things I want to
134 ;; do at home (move my suitcases). The categories can be
135 ;; selected with the cursor keys and if you type in the name of a
136 ;; category which didn't exist before, an empty category of the
137 ;; desired name will be added and filled with the new entry.
141 ;; Variable todos-prefix
143 ;; I would like to recommend that you use the prefix "*/*" (by
144 ;; leaving the variable 'todos-prefix' untouched) so that the
145 ;; diary displays each entry every day.
147 ;; To understand what I mean, please read the documentation that
148 ;; goes with the calendar since that will tell you how you can
149 ;; set up the fancy diary display and use the #include command to
150 ;; include your todo list file as part of your diary.
152 ;; If you have the diary package set up to usually display more
153 ;; than one day's entries at once, consider using
155 ;; "&%%(equal (calendar-current-date) date)"
157 ;; as the value of `todos-prefix'. Please note that this may slow
158 ;; down the processing of your diary file some.
160 ;; Carsten Dominik <dominik@strw.LeidenUniv.nl> suggested that
164 ;; might be nicer and to that effect a function has been declared
165 ;; further down in the code. You may wish to auto-load this.
167 ;; Carsten also writes that that *changing* the prefix after the
168 ;; todo list is already established is not as simple as changing
169 ;; the variable - the todo files have to be changed by hand.
171 ;; Variable todos-file-do
173 ;; This variable is fairly self-explanatory. You have to store
174 ;; your TODO list somewhere. This variable tells the package
175 ;; where to go and find this file.
177 ;; Variable todos-file-done
179 ;; Even when you're done, you may wish to retain the entries.
180 ;; Given that they're timestamped and you are offered to add a
181 ;; comment, this can make a useful diary of past events. It will
182 ;; even blend in with the EMACS diary package. So anyway, this
183 ;; variable holds the name of the file for the filed todos-items.
185 ;; Variable todos-file-top
187 ;; File storing the top priorities of your TODO list when
188 ;; todos-save-top-priorities is non-nil. Nice to include in your
189 ;; diary instead of the complete TODO list.
191 ;; Variable todos-mode-hook
193 ;; Just like other modes, too, this mode offers to call your
194 ;; functions before it goes about its business. This variable
195 ;; will be inspected for any functions you may wish to have
196 ;; called once the other TODO mode preparations have been
199 ;; Variable todos-insert-threshold
201 ;; Another nifty feature is the insertion accuracy. If you have
202 ;; 8 items in your TODO list, then you may get asked 4 questions
203 ;; by the binary insertion algorithm. However, you may not
204 ;; really have a need for such accurate priorities amongst your
205 ;; TODO items. If you now think about the binary insertion
206 ;; halving the size of the window each time, then the threshold
207 ;; is the window size at which it will stop. If you set the
208 ;; threshold to zero, the upper and lower bound will coincide at
209 ;; the end of the loop and you will insert your item just before
210 ;; that point. If you set the threshold to, e.g. 8, it will stop
211 ;; as soon as the window size drops below that amount and will
212 ;; insert the item in the approximate center of that window. I
213 ;; got the idea for this feature after reading a very helpful
214 ;; e-mail reply from Trey Jackson <trey@cs.berkeley.edu> who
215 ;; corrected some of my awful coding and pointed me towards some
216 ;; good reading. Thanks Trey!
220 ;; These originally were my ideas, but now also include all the
221 ;; suggestions that I included before forgetting them:
223 ;; o Fancy fonts for todo/top-priority buffer
224 ;; o Remove todos-prefix option in todos-top-priorities
226 ;; o Move entry from one category to another one
227 ;; o Entries which both have the generic */* prefix and a
228 ;; "deadline" entry which are understood by diary, indicating
229 ;; an event (unless marked by &)
230 ;; o The optional COUNT variable of todos-forward-item should be
231 ;; applied to the other functions performing similar tasks
232 ;; o Modularization could be done for repeated elements of
233 ;; the code, like the completing-read lines of code.
234 ;; o license / version function
235 ;; o export to diary file
236 ;; o todos-report-bug
238 ;; o elide multiline (as in bbdb, or, to a lesser degree, in
240 ;; o rewrite complete package to store data as lisp objects
241 ;; and have display modes for display, for diary export,
242 ;; etc. (Richard Stallman pointed out this is a bad idea)
243 ;; o so base todos.el on generic-mode.el instead
245 ;; History and Gossip
247 ;; Many thanks to all the ones who have contributed to the
248 ;; evolution of this package! I hope I have listed all of you
249 ;; somewhere in the documentation or at least in the RCS history!
251 ;; Enjoy this package and express your gratitude by sending nice
252 ;; things to my parents' address!
255 ;; (Lessingstr. 8, 65760 Eschborn, Federal Republic of Germany)
259 ;; (require 'time-stamp)
260 ;; (require 'calendar) ; required by diary-lib
263 ;; ---------------------------------------------------------------------------
265 ;;; Customizable options
267 "Maintain lists of todo items."
268 :link '(emacs-commentary-link "todos")
272 (defcustom todos-prefix "ยง" ; "*/*" FIXME ascii default
273 "String prefixed to todo items for visual distinction."
275 :initialize 'custom-initialize-default
276 :set 'todos-reset-prefix
279 ;; "TODO mode prefix for entries.
281 ;; This is useful in conjunction with `calendar' and `diary' if you use
283 ;; #include \"~/.todos-do\"
285 ;; in your diary file to include your todo list file as part of your
286 ;; diary. With the default value \"*/*\" the diary displays each entry
287 ;; every day and it may also be marked on every day of the calendar.
288 ;; Using \"&%%(equal (calendar-current-date) date)\" instead will only
289 ;; show and mark todo entries for today, but may slow down processing of
290 ;; the diary file somewhat."
294 (defcustom todos-number-prefix t
295 "Non-nil to show item prefixes as consecutively increasing integers."
297 :initialize 'custom-initialize-default
298 :set 'todos-reset-prefix
301 (defcustom todos-done-separator (make-string (window-width) ?-)
302 "String used to visual separate done from not done items.
303 Displayed in a before-string overlay by `todos-toggle-view-done-items'."
305 :initialize 'custom-initialize-default
306 :set 'todos-reset-separator
309 (defcustom todos-done-string "DONE "
310 "Identifying string appended to the front of done todos items."
312 ;; :initialize 'custom-initialize-default
316 (defcustom todos-show-with-done nil
317 "Non-nil to display done items in all categories."
321 ;; FIXME: use user-emacs-directory here and below
322 (defcustom todos-file-do (convert-standard-filename "~/.emacs.d/.todos-do")
323 "TODO mode list file."
327 (defcustom todos-files '((convert-standard-filename "~/.emacs.d/.todos"))
328 "List of Todos files."
332 (defcustom todos-archive-file (convert-standard-filename "~/.emacs.d/.todos-archive")
333 "File of finished Todos categories."
337 ;; (defcustom todos-file-done (convert-standard-filename "~/.emacs.d/.todos-done")
338 ;; "TODO mode archive file."
342 (defcustom todos-mode-hook nil
347 (defcustom todos-edit-mode-hook nil
348 "TODO Edit mode hooks."
352 ;; (defcustom todos-insert-threshold 0
353 ;; "TODO mode insertion accuracy.
355 ;; If you have 8 items in your TODO list, then you may get asked 4
356 ;; questions by the binary insertion algorithm. However, you may not
357 ;; really have a need for such accurate priorities amongst your TODO
358 ;; items. If you now think about the binary insertion halving the size
359 ;; of the window each time, then the threshold is the window size at
360 ;; which it will stop. If you set the threshold to zero, the upper and
361 ;; lower bound will coincide at the end of the loop and you will insert
362 ;; your item just before that point. If you set the threshold to,
363 ;; e.g. 8, it will stop as soon as the window size drops below that
364 ;; amount and will insert the item in the approximate center of that
369 (defcustom todos-categories-buffer "*TODOS Categories*"
370 "Name of buffer displayed by `todos-display-categories'"
374 (defcustom todos-archived-categories-buffer "*TODOS Archived Categories*"
375 "Name of buffer displayed by `todos-display-categories'"
379 (defcustom todos-edit-buffer " *TODO Edit*"
380 "TODO Edit buffer name."
384 (defcustom todos-file-top (convert-standard-filename "~/.todos-top")
385 "TODO mode top priorities file.
387 Not in TODO format, but diary compatible.
388 Automatically generated when `todos-save-top-priorities' is non-nil."
392 (defcustom todos-include-in-diary nil
393 "Non-nil to allow new Todo items to be included in the diary."
397 (defcustom todos-exclusion-start "["
398 "String prepended to item date to block diary inclusion."
401 ;; :initialize 'custom-initialize-default
402 ;; :set ; change in whole Todos file
405 (defcustom todos-exclusion-end "]"
406 "String appended to item date to match todos-exclusion-start."
409 ;; :initialize 'custom-initialize-default
410 ;; :set ; change in whole Todos file
413 (defcustom todos-print-function 'ps-print-buffer-with-faces
414 "Function to print the current buffer."
418 (defcustom todos-show-priorities 1
419 "Default number of priorities to show by \\[todos-top-priorities].
420 0 means show all entries."
424 (defcustom todos-print-priorities 0
425 "Default number of priorities to print by \\[todos-print].
426 0 means print all entries."
429 ;; (defcustom todos-remove-separator t
430 ;; "Non-nil to remove category separators in\
431 ;; \\[todos-top-priorities] and \\[todos-print]."
435 (defcustom todos-save-top-priorities-too t
436 "Non-nil makes `todos-save' automatically save top-priorities in `todos-file-top'."
440 (defcustom todos-completion-ignore-case t ;; FIXME: nil for release
441 "Non-nil means don't consider case significant in todos-completing-read."
445 (defcustom todos-add-time-string t
446 "Add current time to date string inserted in front of new items."
450 (defcustom todos-wrap-lines t
455 (defcustom todos-line-wrapping-function 'todos-wrap-and-indent
460 ;; ---------------------------------------------------------------------------
463 (defface todos-prefix-string
465 :inherit font-lock-constant-face
467 "Face for Todos prefix string."
474 "Face for Todos prefix string."
476 (defvar todos-date-face 'todos-date)
482 "Face for Todos prefix string."
484 (defvar todos-time-face 'todos-time)
488 :inherit font-lock-comment-face
490 "Face for done Todos item header string."
492 (defvar todos-done-face 'todos-done)
494 (defface todos-done-sep
496 :inherit font-lock-type-face
498 "Face for separator string bewteen done and not done Todos items."
500 (defvar todos-done-sep-face 'todos-done-sep)
502 (defvar todos-font-lock-keywords
504 '(todos-date-string-match 1 todos-date-face t)
505 '(todos-time-string-match 1 todos-time-face t)
506 '(todos-done-string-match 0 todos-done-face t)
507 '(todos-category-string-match 0 todos-done-sep-face t))
508 "Font-locking for Todos mode.")
510 ;; ---------------------------------------------------------------------------
512 ;;; Internal variables
513 (defvar todos-categories nil
516 (defvar todos-previous-line 0
517 "Previous line asked about.")
519 (defvar todos-previous-answer 0
520 "Previous answer got.")
522 (defvar todos-mode-map
523 (let ((map (make-keymap)))
524 (suppress-keymap map t)
525 ;; navigation commands
526 (define-key map "+" 'todos-forward-category)
527 (define-key map "-" 'todos-backward-category)
528 (define-key map "j" 'todos-jump-to-category)
529 (define-key map "n" 'todos-forward-item)
530 (define-key map "p" 'todos-backward-item)
531 (define-key map "S" 'todos-search)
533 (define-key map "C" 'todos-display-categories)
534 (define-key map "h" 'todos-highlight-item)
535 (define-key map "N" 'todos-toggle-item-numbering)
536 ;; (define-key map "" 'todos-toggle-display-date-time)
537 (define-key map "P" 'todos-print)
538 (define-key map "q" 'todos-quit)
539 (define-key map "s" 'todos-save)
540 (define-key map "v" 'todos-toggle-view-done-items)
541 (define-key map "Y" 'todos-diary-items)
542 ;; (define-key map "S" 'todos-save-top-priorities)
543 (define-key map "t" 'todos-top-priorities)
545 (define-key map "A" 'todos-add-category)
546 (define-key map "d" 'todos-item-done)
547 ;; (define-key map "" 'todos-archive-done-items)
548 (define-key map "D" 'todos-delete-category)
549 (define-key map "e" 'todos-edit-item)
550 (define-key map "E" 'todos-edit-multiline)
551 ;; (define-key map "" 'todos-change-date)
552 ;; (define-key map "f" 'todos-file-item)
553 (define-key map "ii" 'todos-insert-item)
554 (define-key map "ih" 'todos-insert-item-here)
555 (define-key map "ia" 'todos-insert-item-ask-date)
556 (define-key map "id" 'todos-insert-item-for-diary)
557 ;; (define-key map "in" 'todos-insert-item-no-time)
558 (define-key map "k" 'todos-delete-item)
559 (define-key map "l" 'todos-lower-item)
560 (define-key map "m" 'todos-move-item)
561 (define-key map "r" 'todos-raise-item)
562 (define-key map "R" 'todos-rename-category)
563 (define-key map "u" 'todos-item-undo)
564 (define-key map "y" 'todos-toggle-item-diary-inclusion)
565 ;; (define-key map "" 'todos-toggle-diary-inclusion)
567 "Todos mode keymap.")
569 (defvar todos-archive-mode-map
570 (let ((map (make-sparse-keymap)))
571 (suppress-keymap map t)
572 ;; navigation commands
573 (define-key map "+" 'todos-forward-category)
574 (define-key map "-" 'todos-backward-category)
575 (define-key map "j" 'todos-jump-to-category)
576 (define-key map "n" 'todos-forward-item)
577 (define-key map "p" 'todos-backward-item)
579 (define-key map "C" 'todos-display-categories)
580 (define-key map "h" 'todos-highlight-item)
581 (define-key map "N" 'todos-toggle-item-numbering)
582 ;; (define-key map "" 'todos-toggle-display-date-time)
583 (define-key map "P" 'todos-print)
584 (define-key map "q" 'todos-quit)
585 (define-key map "s" 'todos-save)
586 (define-key map "S" 'todos-search)
588 "Todos Archive mode keymap.")
590 (defvar todos-edit-mode-map
591 (let ((map (make-keymap)))
592 (define-key map "\C-c\C-q" 'todos-edit-quit)
594 "Todos Edit mode keymap.")
596 (defvar todos-category-number 0 "TODO category number.")
598 (defvar todos-tmp-buffer-name " *todo tmp*")
600 (defvar todos-category-beg "--==-- "
601 "Category start separator to be prepended onto category name.")
603 ;; ---------------------------------------------------------------------------
609 (defun todos-forward-category ()
610 "Go forward to TODO list of next category."
612 (setq todos-category-number
613 (mod (1+ todos-category-number) (length todos-categories)))
614 (todos-category-select))
616 (defun todos-backward-category ()
617 "Go back to TODO list of previous category."
619 (setq todos-category-number
620 (mod (1- todos-category-number) (length todos-categories)))
621 (todos-category-select))
623 ;; FIXME: Document that a non-existing name creates that category, and add
624 ;; y-or-n-p confirmation -- or eliminate this possibility?
625 (defun todos-jump-to-category ()
626 "Jump to a category. Default is previous category."
628 (let ((category (todos-completing-read)))
629 (if (string= "" category)
630 (setq category (nth todos-category-number todos-categories)))
631 (setq todos-category-number
632 (if (member category todos-categories)
633 (- (length todos-categories)
634 (length (member category todos-categories)))
635 (todos-add-category category)))
637 (todos-category-select)))
639 ;; FIXME ? todos-{backward,forward}-item skip over empty line between done and
640 ;; not done items (but todos-forward-item gets there when done items are not
642 (defun todos-backward-item (&optional count)
643 "Select previous entry of TODO list."
645 ;; FIXME ? this moves to bob if on the first item (but so does previous-line)
648 (re-search-backward (concat "^\\(\\[\\(" (regexp-quote todos-done-string)
649 "\\)?\\)?\\(" todos-date-pattern "\\)")
650 nil t (or count 1))))
652 (defun todos-forward-item (&optional count)
653 "Select COUNT-th next entry of TODO list."
655 (goto-char (line-end-position))
656 (if (re-search-forward (concat "^\\(\\[\\(" (regexp-quote todos-done-string)
657 "\\)?\\)?\\(" todos-date-pattern "\\)")
659 (goto-char (match-beginning 0))
660 (goto-char (point-max))))
662 ;; (defun todos-forward-item (&optional count)
663 ;; "Select COUNT-th next entry of TODO list."
665 ;; (let ((opoint (point))
666 ;; (done (save-excursion
667 ;; (if (re-search-forward (concat "\n\n\\\(\\["
668 ;; (regexp-quote todos-done-string)
670 ;; (match-beginning 1)))))
671 ;; ;; FIXME: can this be simplified?
672 ;; (if (looking-at (concat "^\\(\\[\\(" (regexp-quote todos-done-string) "\\)?\\)?"
673 ;; todos-date-pattern)) ; on item header
674 ;; (re-search-forward (concat "^\\(\\[\\(" (regexp-quote todos-done-string)
675 ;; "\\)?\\)?\\(" todos-date-pattern "\\)")
676 ;; nil t (if count (1+ count) 2))
677 ;; (re-search-forward (concat "^\\(\\[\\(" (regexp-quote todos-done-string)
678 ;; "\\)?\\)?\\(" todos-date-pattern "\\)")
679 ;; nil t (or count 1)))
680 ;; (cond ((save-excursion
681 ;; (goto-char opoint)
682 ;; (looking-at "^$")) ; between done and not done items
684 ;; ((and done (> (point) done))
685 ;; (forward-line -1)) ; FIXME: count ?
686 ;; ((eq (point) opoint) ; on last item
687 ;; (goto-char (point-max)))
689 ;; (goto-char (match-beginning 0))))))
691 (defvar todos-search-string nil
694 (defun todos-search ()
697 (let ((regex (read-from-minibuffer "Enter a search string (regexp): "))
701 (goto-char (point-min))
702 (while (and (setq found (re-search-forward regex nil t))
704 (goto-char (line-beginning-position))
705 (looking-at (concat "^" (regexp-quote todos-category-beg)))))
709 (setq found (match-beginning 0))
711 (when (looking-at (concat "^\\[" (regexp-quote todos-done-string)))
713 (re-search-backward (concat "^" (regexp-quote todos-category-beg)
715 (setq cat (match-string-no-properties 1))
716 (setq todos-category-number
717 (- (length todos-categories) (length (member cat todos-categories))))
718 (todos-category-select)
719 (when in-done (unless todos-show-with-done (todos-toggle-view-done-items)))
721 (todos-category-select)
723 (message "No match for \"%s\"" regex))))
727 (defun todos-display-categories ()
728 "Display an alphabetical list of clickable Todos category names.
729 Click or type RET on a category name to go to it."
731 (let ((categories (copy-sequence todos-categories))
732 (cat-alist (todos-categories-alist))
733 (len (todos-longest-category-name-length))
735 ;; alphabetize the list case insensitively
736 (setq categories (sort categories (lambda (s1 s2) (let ((cis1 (upcase s1))
738 (string< cis1 cis2)))))
739 (with-current-buffer (get-buffer-create todos-categories-buffer)
740 (switch-to-buffer (current-buffer))
742 (kill-all-local-variables)
743 (insert "Press a button to display the corresponding category.\n\n")
746 (let* ((catlen (length cat))
747 (catlen-odd (eq (logand catlen 1) 1)) ; oddp from cl.el
748 (padding (/ (- len catlen) 2)))
749 (insert-button (concat (make-string padding 32) cat
750 (make-string (if catlen-odd
757 (todos-jump-to-category-noninteractively ,cat)))
758 (insert (make-string 8 32)
760 (number-to-string (car (cadr (assoc cat cat-alist))))
762 (number-to-string (cdr (cadr (assoc cat cat-alist))))
767 ;; (eval-when-compile
768 ;; (require 'wid-edit))
769 ;; (with-current-buffer (get-buffer-create todos-categories-buffer)
770 ;; (switch-to-buffer (current-buffer))
772 ;; (kill-all-local-variables)
773 ;; (widget-insert "Press a button to display the corresponding category.\n\n")
774 ;; (setq beg (point))
775 ;; (mapc (lambda (cat)
776 ;; (widget-create 'push-button
777 ;; :notify (lambda (widget &rest ignore)
778 ;; (todos-jump-to-category-noninteractively
779 ;; (widget-get widget :value)))
782 ;; (widget-insert " (not done: "
783 ;; (number-to-string (car (cadr (assoc cat cat-alist))))
785 ;; (number-to-string (cdr (cadr (assoc cat cat-alist))))
788 ;; (use-local-map widget-keymap)
791 (defun todos-toggle-item-numbering ()
794 (todos-reset-prefix 'todos-number-prefix (not todos-number-prefix)))
796 (defun todos-toggle-view-done-items ()
799 (let ((beg (point-min))
800 (done-sep (if (string-match "^[[:space:]]*$" todos-done-separator)
802 (propertize (concat todos-done-separator "\n")
803 'face 'todos-done-sep)))
804 (todos-show-with-done nil)
809 (if (re-search-forward (concat "\n\\[" (regexp-quote todos-done-string))
812 (progn (setq end (match-beginning 0))
813 (narrow-to-region beg end))
815 (re-search-forward (concat "^" (regexp-quote todos-category-beg)) nil t)
816 (setq end (or (match-beginning 0) (point-max)))
818 (if (re-search-forward
819 (concat (if (eq beg done) "" "\n") ; no newline if no unfinished items
820 "\n\\(\\[" (regexp-quote todos-done-string) "\\)")
823 (let ((prefix (propertize
824 (concat (if todos-number-prefix "1" todos-prefix) " ")
825 'face 'todos-prefix-string))
827 (setq done (match-beginning 1))
828 (narrow-to-region beg end)
829 (todos-prefix-overlays)
830 ;; add non-empty separator overlay in front of prefix overlay on
832 (unless (string= done-sep todos-done-separator)
834 (remove-overlays done done)
835 ;; must make separator overlay after making prefix overlay to
836 ;; get the order separator before prefix
837 (setq ov-pref (make-overlay done done)
838 ov-done (make-overlay done done))
839 (overlay-put ov-pref 'before-string prefix)
840 (overlay-put ov-done 'before-string done-sep)))
841 ;; (when (setq ov (car (overlays-in done done)))
842 ;; (when (equal (overlay-get ov 'before-string) done-sep)
843 ;; (push ov todos-done-overlays)
844 ;; (delete-overlay ov)))
845 (todos-category-select)
846 (error "No done items in this category"))))))
848 (defun todos-view-archive (&optional cat)
851 (if (file-exists-p todos-archive-file)
853 (find-file todos-archive-file)
855 (if (member cat (todos-categories-list (current-buffer)))
856 (todos-jump-to-category-noninteractively cat)
857 (error "No archived items from this category"))
858 (todos-category-select)))
859 (error "There is currently no Todos archive")))
862 (defun todos-diary-items ()
863 "Display all todo items marked for diary inclusion."
865 (let ((bufname "*Todo diary entries*")
870 (copy-to-buffer bufname (point-min) (point-max))))
871 (with-current-buffer bufname
873 (goto-char (point-min))
875 (setq opoint (point))
876 (cond ((looking-at "\\[")
880 (concat "^" (regexp-quote todos-category-beg) ".*$")
881 (buffer-substring opoint (point)))
882 (kill-region opoint (+ opoint (match-beginning 0)))
883 (kill-region opoint (point)))))
887 (todos-forward-item))))
888 (goto-char (point-min))
890 (setq opoint (point))
891 (if (looking-at (regexp-quote todos-category-beg))
892 (when (progn (forward-line)
893 (or (looking-at (regexp-quote todos-category-beg))
894 ;; category has done but no unfinished items
895 (and (looking-at "^$") (forward-line))
897 (kill-region opoint (point)))
899 (make-local-variable 'font-lock-defaults)
900 (setq font-lock-defaults '(todos-font-lock-keywords t))
901 (font-lock-fontify-buffer)
902 (setq buffer-read-only t))
903 (display-buffer bufname)))
905 (defun todos-highlight-item ()
906 "Highlight the todo item the cursor is on."
908 (if hl-line-mode ; todos-highlight-item
912 ;; FIXME: make this a customizable option for whole Todos file
913 (defun todos-toggle-display-date-time ()
917 (goto-char (point-min))
918 (let ((ovs (overlays-in (point) (line-end-position)))
922 (if (equal (overlay-get ov 'display) "")
925 (setq ovs (cdr ovs))))
926 (if hidden (remove-overlays (point-min) (point-max) 'display "")
928 (re-search-forward (concat "^\\[?" todos-date-pattern
929 " \\(" diary-time-regexp "\\)?\\]? ")
930 ; FIXME: this space in header? ^
932 (setq ov (make-overlay (match-beginning 0) (match-end 0) nil t))
933 (overlay-put ov 'display "")
935 (todos-update-numbered-prefix))))
938 (defun todos-top-priorities (&optional nof-priorities category-pr-page show-done)
939 "List top priorities for each category.
941 Number of entries for each category is given by NOF-PRIORITIES which
942 defaults to \'todos-show-priorities\'.
944 If CATEGORY-PR-PAGE is non-nil, a page separator \'^L\' is inserted
945 between each category.
947 With non-nil SHOW-DONE, include done items in the listing."
950 (or nof-priorities (setq nof-priorities todos-show-priorities))
951 (if (listp nof-priorities) ;universal argument
952 (setq nof-priorities (car nof-priorities)))
953 (let ((todos-print-buffer-name todos-tmp-buffer-name)
954 (todos-category-break (if category-pr-page "
\f" ""))
961 (if (buffer-live-p (get-buffer todos-print-buffer-name))
962 (kill-buffer todos-print-buffer-name))
963 (copy-to-buffer todos-print-buffer-name (point-min) (point-max))))
964 (with-current-buffer todos-print-buffer-name
965 (goto-char (point-min))
966 (while (re-search-forward ;Find category start
967 (concat "^" (regexp-quote todos-category-beg))
969 (setq beg (+ (line-end-position) 1)) ;Start of first entry.
970 (setq end (if (re-search-forward todos-category-beg nil t)
975 (if (re-search-forward
977 (if (looking-at "^$") "" "\n") ; no unfinished items
978 "\n\\(\\[" (regexp-quote todos-done-string) "\\)")
983 (delete-region done end)
985 (narrow-to-region beg end) ;In case we have too few entries.
986 (goto-char (point-min))
987 (if (zerop nof-priorities) ;Traverse entries.
988 (goto-char end) ;All entries
989 (todos-forward-item nof-priorities))
991 (delete-region beg end)
993 (and (looking-at "
\f") (replace-match "")) ;Remove trailing form-feed.
994 (goto-char (point-min)) ;Due to display buffer
995 (make-local-variable 'font-lock-defaults)
996 (setq font-lock-defaults '(todos-font-lock-keywords t))
997 (font-lock-fontify-buffer)
998 (setq buffer-read-only t))
999 ;; Could have used switch-to-buffer as it has a norecord argument,
1000 ;; which is nice when we are called from e.g. todos-print.
1001 ;; Else we could have used pop-to-buffer.
1002 ;; (display-buffer todos-print-buffer-name)
1003 (display-buffer todos-print-buffer-name)
1004 (message "Type C-x 1 to remove %s window. M-C-v to scroll the help."
1005 todos-print-buffer-name)))
1010 (defun todos-add-category (&optional cat)
1011 "Add new category CAT to the TODO list."
1013 (let ((buffer-read-only)
1014 (buf (find-file-noselect todos-file-do t))
1015 (prompt "Category: "))
1016 (unless (zerop (buffer-size buf))
1017 (and (null todos-categories)
1018 (error "Error in %s: File is non-empty but contains no category"
1020 (unless cat (setq cat (read-from-minibuffer prompt)))
1021 (with-current-buffer buf
1022 ;; reject names that could induce bugs and confusion
1023 (while (and (cond ((string= "" cat)
1024 (setq prompt "Enter a non-empty category name: "))
1025 ((string-match "\\`\\s-+\\'" cat)
1026 (setq prompt "Enter a category name that is not only white space: "))
1027 ((member cat todos-categories)
1028 (setq prompt "Enter a non-existing category name: ")))
1029 (setq cat (read-from-minibuffer prompt))))
1030 ;; initialize a newly created Todo buffer for Todo mode
1031 (unless (file-exists-p todos-file-do) (todos-mode))
1032 (setq todos-categories (cons cat todos-categories))
1034 (goto-char (point-min))
1035 ;; make sure file does not begin with empty lines (shouldn't, but may be
1036 ;; added by mistake), otherwise new categories will contain them, so
1037 ;; won't be really empty
1038 (while (looking-at "^$") (kill-line))
1039 (insert todos-category-beg cat "\n")
1041 ;; properly display the newly added category
1042 (progn (setq todos-category-number 0) (todos-show))
1045 ;; FIXME: use function for category name choice here and in todos-add-category
1046 (defun todos-rename-category ()
1047 "Rename current Todos category."
1049 (let* ((buffer-read-only)
1050 (cat (nth todos-category-number todos-categories))
1051 (vec (vconcat todos-categories))
1052 (new (read-from-minibuffer (format "Rename category \"%s\" to: " cat)))
1054 (while (and (cond ((string= "" new)
1055 (setq prompt "Enter a non-empty category name: "))
1056 ((string-match "\\`\\s-+\\'" new)
1057 (setq prompt "Enter a category name that is not only white space: "))
1058 ((member new todos-categories)
1059 (setq prompt "Enter a non-existing category name: ")))
1060 (setq new (read-from-minibuffer prompt))))
1061 (aset vec todos-category-number new)
1062 (setq todos-categories (append vec nil))
1065 (re-search-backward (concat (regexp-quote todos-category-beg) "\\("
1066 (regexp-quote cat) "\\)\n") nil t)
1067 (replace-match new t t nil 1)
1068 (goto-char (point-min))
1069 (setq mode-line-buffer-identification
1070 (concat "Category: " new))))
1071 ;; (concat "Category: " (format "%18s" new)))))
1072 (todos-category-select))
1074 (defun todos-delete-category (&optional arg)
1075 "Delete current Todos category provided it is empty.
1076 With ARG non-nil delete the category unconditionally,
1077 i.e. including all existing entries."
1080 ;; FIXME: what about done items?
1081 (not (eq (point-max) (point-min))))
1082 (message "To delete a non-empty category, call the command with a prefix argument.")
1083 (let ((cat (nth todos-category-number todos-categories)) beg end)
1084 (when (y-or-n-p (concat "Permanently remove category \"" cat
1085 "\"" (and arg " and all its entries") "? "))
1086 (let ((buffer-read-only))
1088 (setq beg (re-search-backward (concat "^" (regexp-quote todos-category-beg)
1091 (re-search-forward (concat "\n\\("
1092 (regexp-quote todos-category-beg)
1094 (match-beginning 1)))
1095 (remove-overlays beg end)
1096 (kill-region beg end)
1097 (setq todos-categories (delete cat todos-categories))
1098 (todos-category-select)
1099 (message "Deleted category %s" cat))))))
1102 (defun todos-insert-item (&optional arg here date-time) ; FIXME revise docstring
1103 "Insert new TODO list item.
1105 With prefix argument ARG solicit the category, otherwise use the
1108 With non-nil argument HERE insert the new item directly above the
1109 item at point. If point is on an empty line, insert the new item
1112 If the value of TIME is `omit', insert the item without a time
1113 string; with the value `ask', solicit a time string; with any
1114 other value, add or omit the current time in accordance with
1115 `todos-add-time-string'."
1117 (unless (or (todos-done-item-p)
1118 (save-excursion (forward-line -1) (todos-done-item-p)))
1119 (if (not (derived-mode-p 'todos-mode)) (todos-show))
1120 (let* ((buffer-read-only)
1121 (date-string (cond ;; ((eq date-time 'omit) "")
1122 ((eq date-time 'ask)
1123 (read-from-minibuffer "Enter a date: "))
1124 ((eq date-time 'to-date)
1125 (with-current-buffer "*Calendar*"
1126 (calendar-date-string (calendar-cursor-to-date t) t t)))
1127 (t (calendar-date-string (calendar-current-date) t t))))
1128 (time-string (if todos-add-time-string
1129 (cond ((eq date-time 'omit) "")
1130 ((eq date-time 'ask)
1131 (read-from-minibuffer "Enter a clock time: "))
1132 (t (substring (current-time-string) 11 16)))
1134 (new-item (concat (unless todos-include-in-diary "[")
1135 date-string (unless (string= time-string "")
1136 (concat " " time-string))
1137 (unless todos-include-in-diary "]") " "
1138 (read-from-minibuffer "New TODO entry: ")))
1139 (current-category (nth todos-category-number todos-categories))
1140 (category (if arg (todos-completing-read) current-category)))
1142 (todos-insert-with-overlays new-item)
1143 (todos-add-item-non-interactively new-item category)))))
1145 (defun todos-insert-item-here (&optional date-time)
1146 "" ;FIXME add docstring
1148 (todos-insert-item nil t date-time))
1150 (defun todos-insert-item-no-time (&optional here)
1151 "" ;FIXME add docstring
1153 (todos-insert-item nil here 'omit))
1155 (defun todos-insert-item-ask-date (&optional here)
1156 "" ;FIXME add docstring
1158 (todos-insert-item nil here 'ask))
1160 (defun todos-insert-item-for-diary (&optional arg here date-time)
1163 (let ((todos-include-in-diary t))
1164 (todos-insert-item arg here date-time)))
1166 ;; FIXME: autoload when key-binding is defined in calendar.el
1167 (defun todos-insert-item-from-calendar ()
1170 (pop-to-buffer (file-name-nondirectory todos-file-do))
1172 (todos-insert-item t nil 'to-date))
1174 ;; FIXME: calendar is loaded before todos
1175 ;; (add-hook 'calendar-load-hook
1177 (define-key calendar-mode-map "it" 'todos-insert-item-from-calendar);))
1179 (defun todos-delete-item ()
1180 "Delete current TODO list entry."
1182 (if (> (count-lines (point-min) (point-max)) 0)
1183 (let* ((buffer-read-only)
1184 (todos-entry (todos-item-string-start))
1185 (todos-answer (y-or-n-p (concat "Permanently remove '"
1186 todos-entry "'? "))))
1189 (when (and (bolp) (eolp)
1190 ;; not if last item was deleted
1191 (< (point-min) (point-max)))
1192 (todos-backward-item))
1193 ;; FIXME: is todos-prefix-overlays part of if-sexp, and is it needed
1195 (if todos-number-prefix
1196 (todos-update-numbered-prefix)
1197 (todos-prefix-overlays))))
1198 (error "No TODO list entry to delete")))
1200 (defun todos-edit-item ()
1201 "Edit current TODO list entry."
1203 (let ((buffer-read-only)
1204 (item (todos-item-string))
1206 (if (todos-string-multiline-p item)
1207 (todos-edit-multiline)
1208 (let ((new (read-from-minibuffer "Edit: " item)))
1209 (while (not (string-match (concat "^\\[?" todos-date-pattern) new))
1210 (setq new (read-from-minibuffer "Item must start with a date: " new)))
1211 ;; If user moved point during editing, make sure it moves back.
1214 (todos-insert-with-overlays new)))))
1216 ;; FIXME: run todos-check-format on exiting buffer (or check for date string
1218 (defun todos-edit-multiline ()
1219 "Set up a buffer for editing a multiline TODO list entry."
1221 (let ((buffer-name (generate-new-buffer-name todos-edit-buffer)))
1223 (make-indirect-buffer
1224 (file-name-nondirectory todos-file-do) buffer-name))
1225 (message "To exit, simply kill this buffer and return to list.")
1227 (narrow-to-region (todos-item-start) (todos-item-end))))
1229 (defun todos-edit-quit ()
1232 (save-excursion (todos-category-select)))
1235 (defun todos-change-date (&optional event)
1239 calendar-view-diary-initially-flag
1243 (setq dmarker (point-marker)))
1245 (message "Put the cursor on the desired date in the Calendar and press `q'")
1247 (calendar-date-string (calendar-cursor-to-date t) t t))
1248 ;; (pop-to-buffer (file-name-nondirectory todos-file-do))
1250 (when (eq last-command 'calendar-exit)
1251 (goto-char (marker-position dmarker))
1252 (re-search-forward (concat "^\\[?\\(" todos-date-pattern "\\)\\]?")
1253 (line-end-position) t)
1254 (replace-match new-date nil nil nil 1))))
1256 (defun todos-raise-item ()
1257 "Raise priority of current entry."
1259 (unless (or (todos-done-item-p)
1260 (looking-at "^$")) ; between done and not done items
1261 (let (buffer-read-only)
1262 (if (> (count-lines (point-min) (point)) 0)
1263 (let ((item (todos-item-string)))
1265 (todos-backward-item)
1266 (todos-insert-with-overlays item))
1267 (error "No TODO list entry to raise")))))
1269 (defun todos-lower-item ()
1270 "Lower priority of current entry."
1272 (unless (or (todos-done-item-p)
1273 (looking-at "^$")) ; between done and not done items
1274 (let ((buffer-read-only)
1275 (done (save-excursion
1276 (if (re-search-forward (concat "\n\n\\\["
1277 (regexp-quote todos-done-string))
1281 (if (> (count-lines (point) done) 1)
1282 ;; Assume there is a final newline
1283 (let ((item (todos-item-string))
1286 (todos-forward-item)
1287 (todos-insert-with-overlays item))
1288 (error "No TODO list entry to lower")))))
1290 ;; FIXME: moves last not done item when point on empty line below it
1291 ;; (defun todos-move-item ()
1292 ;; "Move the current todo item to another, interactively named, category.
1294 ;; If the named category is not one of the current todo categories, then
1295 ;; it is created and the item becomes the first entry in that category."
1297 ;; (unless (or (todos-done-item-p)
1298 ;; (looking-at "^$")) ; between done and not done items
1299 ;; (let ((item (todos-item-string))
1300 ;; (category (todos-completing-read))
1302 ;; (setq (save-excursion (todos-item-start)))
1303 ;; (todos-remove-item)
1304 ;; ;; numbered prefix isn't cached (see todos-remove-item) so have to update
1305 ;; (if todos-number-prefix (todos-update-numbered-prefix))
1306 ;; (setq chgr (prepare-change-group))
1310 ;; (activate-change-group chgr)
1311 ;; (todos-add-item-non-interactively item category)
1314 ;; (accept-change-group chgr)
1315 ;; (cancel-change-group chgr))))))
1317 (defun todos-move-item ()
1318 "Move the current todo item to another, interactively named, category.
1320 If the named category is not one of the current todo categories, then
1321 it is created and the item becomes the first entry in that category."
1323 (unless (or (todos-done-item-p)
1324 (looking-at "^$")) ; between done and not done items
1325 (let ((buffer-read-only)
1326 (oldnum todos-category-number)
1327 (oldcat (nth todos-category-number todos-categories))
1328 (item (todos-item-string))
1329 (newcat (todos-completing-read))
1331 (orig-mrk (save-excursion (todos-item-start) (point-marker)))
1334 ;; numbered prefix isn't cached (see todos-remove-item) so have to update
1335 (if todos-number-prefix (todos-update-numbered-prefix))
1338 (todos-add-item-non-interactively item newcat)
1342 (goto-char orig-mrk)
1343 (todos-insert-with-overlays item)
1344 (setq todos-category-number oldnum)
1345 (todos-category-select)
1346 ;; FIXME: does this work?
1348 (set-marker orig-mrk nil)))))
1350 ;; (defun todos-file-item (&optional comment)
1351 ;; "File the current TODO list entry away, annotated with an optional COMMENT."
1352 ;; (interactive "sComment: ")
1353 ;; (or (> (count-lines (point-min) (point-max)) 0)
1354 ;; (error "No TODO list entry to file away"))
1355 ;; (let ((time-stamp-format todos-time-string-format))
1356 ;; (when (and comment (> (length comment) 0))
1357 ;; (goto-char (todos-item-end))
1359 ;; (if (save-excursion (beginning-of-line)
1360 ;; (looking-at (regexp-quote todos-prefix)))
1363 ;; "(" comment ")"))
1364 ;; (goto-char (todos-item-end))
1365 ;; (insert " [" (nth todos-category-number todos-categories) "]")
1366 ;; (goto-char (todos-item-start))
1367 ;; (let ((temp-point (point)))
1368 ;; (if (looking-at (regexp-quote todos-prefix))
1369 ;; (replace-match (time-stamp-string))
1370 ;; ;; Standard prefix -> timestamp
1371 ;; ;; Else prefix non-standard item start with timestamp
1372 ;; (insert (time-stamp-string)))
1373 ;; (append-to-file temp-point (1+ (todos-item-end)) todos-file-done)
1374 ;; (delete-region temp-point (1+ (todos-item-end))))
1375 ;; (todos-backward-item)
1378 (defun todos-item-done ()
1379 "Mark current item as done and move it to category's done section."
1381 (unless (or (todos-done-item-p)
1383 (let* ((buffer-read-only)
1384 (item (todos-item-string))
1385 (date-string (calendar-date-string (calendar-current-date) t t))
1386 (time-string (if todos-add-time-string
1387 (concat " " (substring (current-time-string) 11 16))
1389 (done-item (concat "[" todos-done-string date-string time-string "] " item))
1390 (items-end (point-max))
1397 (if (re-search-forward (concat "^" (regexp-quote todos-category-beg))
1401 ;; insert next done item at the top of the done items list
1402 (if (re-search-forward (concat "^\\[" (regexp-quote todos-done-string))
1404 (goto-char (match-beginning 0))
1405 ;; need empty line between done and not done items in order not to have
1406 ;; hanging todos-prefix when done items are hidden
1407 (goto-char next-cat)
1409 (todos-insert-with-overlays done-item)))
1412 (defun todos-archive-done-items ()
1413 "Archive the done items in the current category."
1415 (let ((archive (find-file-noselect todos-archive-file t))
1416 (cat (nth todos-category-number todos-categories))
1421 (re-search-forward (concat "^" (regexp-quote todos-category-beg)) nil t)
1422 (setq end (or (match-beginning 0) (point-max)))
1423 (re-search-backward (concat "^" (regexp-quote todos-category-beg)
1426 (if (not (re-search-forward (concat "\\[" (regexp-quote todos-done-string))
1428 (error "No done items in this category")
1429 (setq beg (match-beginning 0))
1430 (setq done (buffer-substring beg end))
1431 (with-current-buffer archive
1432 (goto-char (point-min))
1433 (if (re-search-forward (regexp-quote (concat "^" todos-category-beg cat))
1436 (insert todos-category-beg cat "\n"))
1438 (delete-region beg end)
1439 (remove-overlays beg end)
1441 (message "Done items archived."))
1443 ;; FIXME: undone item leaves item number overlay behind
1444 (defun todos-item-undo ()
1447 (when (todos-done-item-p)
1448 (let* ((buffer-read-only)
1449 (cat (nth todos-category-number todos-categories))
1452 (search-forward "] "))) ; end of done date string
1453 (item (buffer-substring start (todos-item-end))))
1455 (todos-add-item-non-interactively item cat))))
1457 (defun todos-toggle-item-diary-inclusion ()
1458 "" ;FIXME add docstring
1461 (let* ((buffer-read-only)
1462 (beg (todos-item-start))
1463 (lim (save-excursion (todos-item-end)))
1464 (end (save-excursion
1465 (or (todos-time-string-match lim)
1466 (todos-date-string-match lim)))))
1467 (if (looking-at "\\[") ; FIXME use todos-exclusion-start
1470 (search-forward "]" (1+ end) t) ; FIXME use todos-exclusion-end
1473 (insert "[") ; FIXME use todos-exclusion-start
1474 (goto-char (1+ end))
1475 (insert "]")))))) ; FIXME use todos-exclusion-end
1477 (defun todos-toggle-diary-inclusion (arg)
1478 "" ;FIXME add docstring
1482 (when (eq arg 2) (widen)) ;FIXME: don't toggle done items
1483 (when (or (eq arg 1) (eq arg 2))
1484 (goto-char (point-min))
1486 (re-search-forward (concat "^" (regexp-quote todos-category-beg)) nil t)
1488 (when (looking-at (regexp-quote todos-category-end)) (forward-line)))
1490 (todos-toggle-item-diary-inclusion)
1491 (todos-forward-item))))))
1493 (defun todos-save-top-priorities (&optional nof-priorities)
1494 "Save top priorities for each category in `todos-file-top'.
1496 Number of entries for each category is given by NOF-PRIORITIES which
1497 defaults to `todos-show-priorities'."
1499 (save-window-excursion
1502 (todos-top-priorities nof-priorities)
1503 (set-buffer todos-tmp-buffer-name)
1504 (write-file todos-file-top)
1505 (kill-this-buffer)))))
1508 (defun todos-print (&optional category-pr-page)
1509 "Print todo summary using `todos-print-function'.
1510 If CATEGORY-PR-PAGE is non-nil, a page separator `^L' is inserted
1511 between each category.
1513 Number of entries for each category is given by `todos-print-priorities'."
1515 (when (yes-or-no-p "Print Todos list? ")
1516 (save-window-excursion
1519 (todos-top-priorities todos-print-priorities
1521 (set-buffer todos-tmp-buffer-name)
1522 (and (funcall todos-print-function)
1524 (message "Todo printing done."))))))
1526 ;; ---------------------------------------------------------------------------
1528 ;;; Internal functions
1530 ;; "Jan\\|Feb\\|Mar\\|Apr\\|May\\|Jun\\|Jul\\|Aug\\|Sep\\|Oct\\|Nov\\|Dec")
1531 ;; (regexp-opt (list "1" "2" "3" "4" "5" "6" "7" "8" "9" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "20" "21" "22" "23" "24" "25" "26" "27" "28" "29" "30" "31")))
1533 ;; FIXME: use diary-date-forms instead?
1534 ;; (defun todos-date-string ()
1535 ;; "Return a regexp matching a diary date string."
1536 ;; (let ((month (regexp-opt (list "Jan" "Feb" "Mar" "Apr" "May" "Jun"
1537 ;; "Jul" "Aug" "Sep" "Oct" "Nov" "Dec")))
1538 ;; (day "[0-3]?[0-9]")
1539 ;; (year "[0-9]\\{4\\}"))
1540 ;; (concat month " " day ", " year)))
1542 ;; FIXME: use diary-time-regexp
1543 ;; (defun todos-time-string ()
1544 ;; "Return a regexp matching a diary time string."
1545 ;; "[0-9]?[0-9][:.][0-9]\\{2\\}")
1547 (defvar todos-date-nodayname-pattern
1549 (monthname (format "\\(%s\\|\\*\\)"
1550 (diary-name-pattern calendar-month-name-array
1551 calendar-month-abbrev-array t)))
1552 (month "\\([0-9]+\\|\\*\\)")
1553 (day "\\([0-9]+\\|\\*\\)")
1554 (year "-?\\([0-9]+\\|\\*\\)"))
1555 (mapconcat 'eval calendar-date-display-form ""))
1556 "Regular expression matching a Todos date header without day name.")
1558 ;; (defvar todos-dayname-pattern
1559 ;; (diary-name-pattern calendar-day-name-array nil t)
1560 ;; "Regular expression matching a day name in a Todos date header.")
1562 (defvar todos-dayname-date-pattern
1563 (let ((dayname (diary-name-pattern calendar-day-name-array nil t)))
1564 (concat dayname "\\(?:, " todos-date-nodayname-pattern "\\)?"))
1565 "Regular expression matching a Todos date header with day name.")
1567 (defvar todos-date-pattern
1568 (concat "\\(?:" todos-date-nodayname-pattern "\\)\\|"
1569 "\\(?:" todos-date-dayname-pattern "\\)")
1570 "Regular expression matching a Todos date header.")
1572 (defun todos-date-string-match (lim)
1573 "Find Todos date strings for font-locking."
1574 (re-search-forward (concat "^\\[?\\(" todos-date-pattern "\\)") lim t))
1576 (defun todos-time-string-match (lim)
1577 "Find Todos time strings for font-locking."
1578 (re-search-forward (concat "^\\[?\\(?:" todos-date-pattern "\\)"
1579 " \\(?1:" diary-time-regexp "\\)") lim t))
1581 (defun todos-done-string-match (lim)
1582 "Find Todos done headers for font-locking."
1583 (re-search-forward (concat "^\\[" (regexp-quote todos-done-string) "[^][]+]")
1586 (defun todos-category-string-match (lim)
1587 "Find Todos category headers for font-locking."
1588 (re-search-forward (concat "^" (regexp-quote todos-category-beg) ".*$")
1591 (defun todos-check-format ()
1592 "Signal an error if the current Todos file is ill-formatted."
1596 (goto-char (point-min))
1597 (let ((legit (concat "^\\(" (regexp-quote todos-category-beg) "\\)"
1598 "\\|\\(\\[?" todos-date-pattern "\\)"
1599 "\\|\\([ \t]+[^ \t]*\\)"
1602 (unless (looking-at legit)
1603 (error "Illegitimate Todos file format at line %d"
1604 (line-number-at-pos (point))))
1606 (message "This Todos file is well-formatted."))
1608 (defun todos-wrap-and-indent ()
1610 (make-local-variable 'word-wrap)
1612 (make-local-variable 'wrap-prefix)
1613 (setq wrap-prefix (make-string (+ 5 (length todos-prefix)) 32))
1614 (unless (member '(continuation) fringe-indicator-alist)
1615 (push '(continuation) fringe-indicator-alist)))
1617 (defun todos-reset-prefix (symbol value)
1618 "Set SYMBOL's value to VALUE, and ." ; FIXME
1619 (let ((oldvalue (symbol-value symbol)))
1620 (custom-set-default symbol value)
1621 (when (not (equal value oldvalue))
1622 (save-window-excursion
1626 (goto-char (point-min))
1628 (remove-overlays (point) (point)); 'before-string prefix)
1630 ;; activate the prefix setting (save-restriction does not help)
1633 ;; FIXME: rename and/or rewrite
1634 (defun todos-update-numbered-prefix ()
1635 "Update consecutive item numbering in the current category."
1637 (goto-char (point-min))
1639 (remove-overlays (point) (point) 'before-string)
1640 (todos-forward-item))
1643 (defvar todos-item-start-overlays nil "")
1645 ;; (defvar todos-done-overlays nil "")
1647 ;; (defun todos-check-overlay (prop)
1648 ;; "" ;FIXME add docstring
1649 ;; ;; (let ((ovlist (overlays-in (1- (point)) (1+ (point)))))
1650 ;; (let ((ovlist (overlays-in (point) (point))))
1651 ;; (when ovlist (overlay-get (car ovlist) prop))))
1653 (defun todos-prefix-overlays ()
1654 "" ;FIXME add docstring
1655 (when (or todos-number-prefix
1656 (not (string-match "^[[:space:]]*$" todos-prefix)))
1657 (let ((prefix (propertize (concat todos-prefix " ") 'face 'todos-prefix-string))
1661 (goto-char (point-min))
1662 (while (or (todos-date-string-match lim)
1663 (todos-done-string-match lim))
1664 (goto-char (match-beginning 0))
1665 (when todos-number-prefix
1667 ;; reset number for done items
1668 (if (or (looking-at (concat "\n\\[" (regexp-quote todos-done-string)))
1669 ;; if last not done item is multiline, then
1670 ;; todos-done-string-match skips empty line, so have
1672 (and (looking-at (concat "^\\[" (regexp-quote todos-done-string)))
1673 (looking-back "\n\n")))
1675 (setq prefix (propertize (concat (number-to-string num) " ")
1676 'face 'todos-prefix-string)))
1677 (or (and (setq ov-pref (car (overlays-in (point) (point))))
1678 (equal (overlay-get ov-pref 'before-string) prefix))
1679 (and (setq ov-pref (pop todos-item-start-overlays))
1680 (move-overlay ov-pref (point) (point)))
1681 (and (setq ov-pref (make-overlay (point) (point)))
1682 (overlay-put ov-pref 'before-string prefix)))
1685 ;; (defun todos-show-paren-hack ()
1686 ;; "Purge overlay duplication due to show-paren-mode."
1688 ;; (when show-paren-mode
1689 ;; (goto-char (point-min))
1690 ;; (while (not (eobp))
1691 ;; ;; (let ((ovlist (overlays-in (1- (point)) (1+ (point))))
1692 ;; (let ((ovlist (overlays-in (point) (point)))
1694 ;; (while (> (length ovlist) 1)
1695 ;; (setq ov (pop ovlist))
1696 ;; (delete-overlay ov)))
1698 ;; (if (and (bolp) (eolp))
1699 ;; ;; (let ((ovlist (overlays-in (1- (point)) (1+ (point)))))
1700 ;; (let ((ovlist (overlays-in (point) (point))))
1701 ;; (remove-overlays (1- (point)) (1+ (point))))))))
1703 (defun todos-reset-separator (symbol value)
1704 "Set SYMBOL's value to VALUE, and ." ; FIXME
1705 (let ((oldvalue (symbol-value symbol)))
1706 (custom-set-default symbol value)
1707 ;; (setq todos-done-overlays nil)
1708 (when (not (equal value oldvalue))
1709 (save-window-excursion
1712 (goto-char (point-min))
1713 (when (re-search-forward (concat "^\\[" (regexp-quote todos-done-string)) nil t)
1714 (remove-overlays (point) (point))))
1715 ;; activate the prefix setting (save-restriction does not help)
1718 ;; FIXME: use this; should be defsubst?
1719 (defun todos-current-category ()
1720 "Return the name of the current category."
1721 (nth todos-category-number todos-categories))
1723 (defun todos-category-select ()
1724 "Make TODO mode display the current category correctly."
1725 (let ((name (nth todos-category-number todos-categories)))
1726 (setq mode-line-buffer-identification (concat "Category: " name))
1728 (goto-char (point-min))
1729 (search-forward-regexp
1730 (concat "^" (regexp-quote (concat todos-category-beg name))
1732 (let ((begin (1+ (line-end-position)))
1733 (end (or (and (re-search-forward (concat "^" todos-category-beg) nil t)
1734 (match-beginning 0))
1736 (narrow-to-region begin end)
1737 (goto-char (point-min))))
1738 (todos-prefix-overlays)
1739 (let ((beg (point-min))
1740 (done-sep (if (string-match "^[[:space:]]*$" todos-done-separator)
1741 todos-done-separator
1742 (propertize (concat todos-done-separator "\n")
1743 'face 'todos-done-sep)))
1745 (when (re-search-forward (concat "\n\\(\\[" (regexp-quote todos-done-string)
1747 (setq done (match-beginning 1)
1748 end (match-beginning 0))
1749 (if todos-show-with-done
1750 ;; with an empty separator just display the done items
1751 (if (string= done-sep todos-done-separator)
1752 (narrow-to-region (point-min) (point-max))
1753 ;; else display the separator in an overlay in front of the prefix
1754 ;; overlay on first done item
1755 (let ((prefix (propertize
1756 (concat (if todos-number-prefix "1" todos-prefix) " ")
1757 'face 'todos-prefix-string)))
1759 (remove-overlays done done)
1760 ;; must make separator overlay after making prefix overlay to get
1761 ;; the order separator before prefix
1762 (setq ov-pref (make-overlay done done)
1763 ov-done (make-overlay done done))
1764 (overlay-put ov-pref 'before-string prefix)
1765 (overlay-put ov-done 'before-string done-sep)))
1767 (narrow-to-region (point-min) end))))
1768 (goto-char (point-min)))
1770 ;; FIXME: using numbering for priority instead of importance?
1772 (defun todos-add-item-non-interactively (new-item category)
1773 "Insert NEW-ITEM in TODO list as a new entry in CATEGORY."
1774 ;; FIXME: really need this? (and in save-excursion?)
1777 (if (string= "" category)
1778 (setq category (nth todos-category-number todos-categories)))
1779 (let ((cat-exists (member category todos-categories)))
1780 (setq todos-category-number
1782 (- (length todos-categories) (length cat-exists))
1783 (todos-add-category category))))
1784 ;; FIXME: really need this? (yes for todos-move-item, to show moved to category)
1785 (todos-show) ; now at point-min
1786 ;; (setq todos-previous-line 0)
1788 ;; (end (save-excursion
1789 ;; (goto-char (point-min))
1790 ;; (if (re-search-forward (concat "\n\n\\\(\\["
1791 ;; (regexp-quote todos-done-string)
1793 ;; (match-beginning 1)
1795 ;; (bottom (count-lines (point-min) end)))
1796 ;; (while (> (- bottom top) todos-insert-threshold)
1797 ;; (let* ((current (/ (+ top bottom) 2))
1798 ;; (answer (if (< current bottom)
1799 ;; (todos-more-important-p current) nil)))
1801 ;; (setq bottom current)
1802 ;; (setq top (1+ current)))))
1803 ;; (setq top (/ (+ top bottom) 2))
1804 ;; (goto-char (point-min))
1805 ;; (forward-line (1- top)))
1806 (unless (or (eq (point-min) (point-max)) ; no unfinished items
1807 (when (re-search-forward (concat "^\\["
1808 (regexp-quote todos-done-string))
1811 (bobp))) ; there are done items but no unfinished items
1812 (let* ((num-items (1+ (car (todos-count-items-in-category))))
1813 (priority (string-to-number (read-from-minibuffer
1814 (format "Set item priority (1-%d): "
1817 (while (cond ((not (integerp priority))
1818 (setq prompt "Priority must be an integer.\n"))
1820 (setq prompt "Priority cannot be higher than 1.\n"))
1821 ((> priority num-items)
1822 (setq prompt (format "Priority cannot be lower than %d.\n"
1825 (string-to-number (read-from-minibuffer
1827 (format "Set item priority (1-%d): "
1829 (goto-char (point-min))
1830 (todos-forward-item (1- priority))))
1831 (todos-insert-with-overlays new-item))
1833 (defun todos-jump-to-category-noninteractively (cat)
1834 (let ((bufname (buffer-name)))
1835 (cond ((string= bufname todos-categories-buffer)
1836 (switch-to-buffer (file-name-nondirectory todos-file-do)))
1837 ((string= bufname todos-archived-categories-buffer)
1838 ;; Is pop-to-buffer better for this case?
1839 (switch-to-buffer (file-name-nondirectory todos-archive-file))))
1840 (kill-buffer bufname))
1842 (goto-char (point-min))
1843 (setq todos-category-number (- (length todos-categories)
1844 (length (member cat todos-categories))))
1845 (todos-category-select))
1847 (defun todos-insert-with-overlays (item)
1848 "" ;FIXME add docstring
1849 ;; FIXME: breaks without narrowing, e.g. todos-item-done
1850 ;; (unless (and (bolp) (eolp)) (goto-char (todos-item-start)))
1852 (todos-backward-item)
1853 (if todos-number-prefix
1854 (todos-update-numbered-prefix)
1855 (todos-prefix-overlays)))
1857 ;; (defun todos-more-important-p (line)
1858 ;; "Ask whether entry is more important than the one at LINE."
1859 ;; (unless (equal todos-previous-line line)
1860 ;; (setq todos-previous-line line)
1861 ;; (goto-char (point-min))
1862 ;; (forward-line (1- todos-previous-line))
1863 ;; (let ((item (todos-item-string-start)))
1864 ;; (setq todos-previous-answer
1865 ;; (y-or-n-p (concat "More important than '" item "'? ")))))
1866 ;; todos-previous-answer)
1868 (defun todos-line-string ()
1869 "Return current line in buffer as a string."
1870 (buffer-substring (line-beginning-position) (line-end-position)))
1872 (defun todos-item-string-start ()
1873 "Return the start of this TODO list entry as a string."
1874 ;; Suitable for putting in the minibuffer when asking the user
1875 (let ((item (todos-item-string)))
1876 (if (> (length item) 60)
1877 (setq item (concat (substring item 0 56) "...")))
1880 (defun todos-item-start ()
1881 "Move to start of current TODO list item and return its position."
1882 (unless (or (looking-at "^$") ; last item or between done and not done
1883 (looking-at (regexp-quote todos-category-beg))) ; for todos-count-items
1884 (goto-char (line-beginning-position))
1885 (while (not (looking-at (concat "^\\(\\[\\(" (regexp-quote todos-done-string)
1886 "\\)?\\)?" todos-date-pattern)))
1890 (defun todos-item-end ()
1891 "Move to end of current TODO list item and return its position."
1892 (unless (looking-at "^$") ; last item or between done and not done
1893 (todos-forward-item)
1897 (defun todos-remove-item ()
1898 "Delete the current entry from the TODO list."
1899 (let* ((end (progn (todos-forward-item) (point)))
1900 (beg (progn (todos-backward-item) (point)))
1901 (ov-start (car (overlays-in beg beg))))
1903 ;; don't cache numbers, since they can be popped out of order in
1904 ;; todos-prefix-overlays
1905 (unless todos-number-prefix
1906 (push ov-start todos-item-start-overlays))
1907 (delete-overlay ov-start))
1908 (delete-region beg end)))
1910 (defun todos-item-string ()
1911 "Return current TODO list entry as a string."
1912 (buffer-substring (todos-item-start) (todos-item-end)))
1914 (defun todos-done-item-p ()
1918 (looking-at (concat "^\\[" (regexp-quote todos-done-string)))))
1920 (defun todos-count-items-in-category ()
1921 "Return number of not done and done items in current category."
1929 (re-search-forward (concat "^" (regexp-quote todos-category-beg)) nil t)
1930 (setq end (or (match-beginning 0) (point-max)))
1932 (while (> end (point))
1933 (if (todos-done-item-p)
1934 (setq done (1+ done))
1935 (setq not-done (1+ not-done)))
1936 (todos-forward-item)
1937 (when (and (not (> (point) end))
1940 ;; point is between done and not done items
1941 (setq not-done (1- not-done))))
1942 (cons not-done done)))))
1944 ;; FIXME: rename, since *-alist is by convention a variable name
1945 (defun todos-categories-alist ()
1946 "Return alist of categories and some of their properties.
1947 The properties are at least the numbers of the unfinished and
1948 done items in the category."
1949 (let (todos-categories-alist)
1953 (goto-char (point-min))
1958 (cond ((looking-at (concat (regexp-quote todos-category-beg)
1960 (setq not-done 0 done 0)
1961 (push (list (match-string-no-properties 1) (cons not-done done))
1962 todos-categories-alist))
1963 ((looking-at (concat "^\\[" (regexp-quote todos-done-string)))
1964 (setq done (1+ done))
1965 (setcdr (cadr (car todos-categories-alist)) done))
1966 ((looking-at (concat "^\\[?" todos-date-pattern))
1967 (setq not-done (1+ not-done))
1968 (setcar (cadr (car todos-categories-alist)) not-done)))
1970 todos-categories-alist))
1972 (defun todos-count-all-items ()
1974 (let ((unfinished 0)
1976 (dolist (l (todos-categories-alist))
1977 (setq unfinished (+ unfinished (car (cadr l)))
1978 done (+ done (cdr (cadr l)))))
1979 (cons unfinished done)))
1981 (defun todos-longest-category-name-length ()
1984 (dolist (c (todos-categories-alist) longest)
1985 (setq longest (max longest (length (car c)))))))
1987 (defun todos-string-count-lines (string)
1988 "Return the number of lines STRING spans."
1989 (length (split-string string "\n")))
1991 (defun todos-string-multiline-p (string)
1992 "Return non-nil if STRING spans several lines."
1993 (> (todos-string-count-lines string) 1))
1995 (defun todos-completing-read ()
1996 "Return a category name, with completion, for use in Todo mode."
1997 ;; allow SPC to insert spaces, for adding new category names with
1999 (let ((map minibuffer-local-completion-map))
2000 (define-key map " " nil)
2001 ;; make a copy of todos-categories in case history-delete-duplicates is
2002 ;; non-nil, which makes completing-read alter todos-categories
2003 (let* ((categories (copy-sequence todos-categories))
2004 (history (cons 'todos-categories (1+ todos-category-number)))
2005 (default (nth todos-category-number todos-categories))
2006 (completion-ignore-case todos-completion-ignore-case)
2007 (category (completing-read
2008 (concat "Category [" default "]: ")
2009 todos-categories nil nil nil history default)))
2010 ;; restore the original value of todos-categories
2011 (setq todos-categories categories)
2014 (defun todos-categories-list (buf)
2015 "Return a list of the Todo mode categories in buffer BUF."
2017 (with-current-buffer buf
2021 (goto-char (point-max))
2022 (while (re-search-backward (concat "^" (regexp-quote todos-category-beg)
2023 "\\(.*\\)\n") nil t)
2024 (push (match-string-no-properties 1) categories)))))
2027 ;; ---------------------------------------------------------------------------
2030 (easy-menu-define todos-menu todos-mode-map "Todo Menu"
2032 ["Next category" todos-forward-category t]
2033 ["Previous category" todos-backward-category t]
2034 ["Jump to category" todos-jump-to-category t]
2035 ["Show top priority items" todos-top-priorities t]
2036 ["Print categories" todos-print t]
2038 ["Edit item" todos-edit-item t]
2039 ["File item" todos-file-item t]
2040 ["Insert new item" todos-insert-item t]
2041 ["Insert item here" todos-insert-item-here t]
2042 ["Kill item" todos-delete-item t]
2044 ["Lower item priority" todos-lower-item t]
2045 ["Raise item priority" todos-raise-item t]
2047 ["Next item" todos-forward-item t]
2048 ["Previous item" todos-backward-item t]
2050 ["Save" todos-save t]
2051 ["Save Top Priorities" todos-save-top-priorities t]
2053 ["Quit" todos-quit t]
2056 ;; As calendar reads .todos-do before todos-mode is loaded.
2058 (defun todos-mode ()
2059 "Major mode for editing TODO lists.
2063 (kill-all-local-variables)
2064 (setq major-mode 'todos-mode)
2065 (setq mode-name "TODOS")
2066 (use-local-map todos-mode-map)
2067 (easy-menu-add todos-menu)
2068 (when todos-wrap-lines (funcall todos-line-wrapping-function))
2069 (make-local-variable 'font-lock-defaults)
2070 (setq font-lock-defaults '(todos-font-lock-keywords t))
2071 (make-local-variable 'hl-line-range-function)
2072 (setq hl-line-range-function
2073 (lambda() (when (todos-item-end)
2074 (cons (todos-item-start) (todos-item-end)))))
2075 ;; (add-hook 'post-command-hook 'todos-show-paren-hack nil t)
2076 (add-to-invisibility-spec 'todos)
2077 ;; FIXME: use this and let-bind in editing commands?
2078 (setq buffer-read-only t)
2079 (run-mode-hooks 'todos-mode-hook))
2081 (defun todos-archive-mode ()
2082 "Major mode for archived Todos categories.
2086 (kill-all-local-variables)
2087 (setq major-mode 'todos-archive-mode)
2088 (setq mode-name "TODOS Arch")
2089 (use-local-map todos-archive-mode-map)
2090 ;; (easy-menu-add todos-menu)
2091 (when todos-wrap-lines (funcall todos-line-wrapping-function))
2092 (make-local-variable 'font-lock-defaults)
2093 (setq font-lock-defaults '(todos-font-lock-keywords t))
2094 (make-local-variable 'hl-line-range-function)
2095 (setq hl-line-range-function
2096 (lambda() (when (todos-item-end)
2097 (cons (todos-item-start) (todos-item-end)))))
2098 ;; (add-hook 'post-command-hook 'todos-show-paren-hack nil t)
2099 (add-to-invisibility-spec 'todos)
2100 (run-mode-hooks 'todos-mode-hook))
2102 (defun todos-edit-mode ()
2103 "Major mode for editing items in the TODO list.
2105 \\{todos-edit-mode-map}"
2107 (setq major-mode 'todos-edit-mode)
2108 (setq mode-name "TODOS Edit")
2109 (use-local-map todos-edit-mode-map)
2110 (make-local-variable 'font-lock-defaults)
2111 (setq font-lock-defaults '(todos-font-lock-keywords t))
2112 (when todos-wrap-lines (funcall todos-line-wrapping-function)))
2114 (defun todos-save ()
2115 "Save the TODO list."
2120 ;; (if todos-save-top-priorities-too (todos-save-top-priorities)))
2123 (defun todos-quit ()
2124 "Done with TODO list for now."
2132 (defun todos-show ()
2135 ;; Make this a no-op if called interactively in narrowed Todos mode, since
2136 ;; it is in that case redundant, but in particular to work around the bug of
2137 ;; item prefix reduplication with show-paren-mode enabled.
2138 (unless (and (called-interactively-p)
2139 (eq major-mode 'todos-mode)
2140 (< (- ( point-max) (point-min)) (buffer-size)))
2141 ;; Call todos-initial-setup only if there is neither a Todo file nor
2142 ;; a corresponding unsaved buffer.
2143 (if (or (file-exists-p todos-file-do)
2144 (let* ((buf (get-buffer (file-name-nondirectory todos-file-do)))
2145 (bufname (buffer-file-name buf)))
2146 (equal (expand-file-name todos-file-do) bufname)))
2147 (find-file todos-file-do)
2148 (todos-initial-setup))
2149 (unless (eq major-mode 'todos-mode) (todos-mode))
2150 (unless todos-categories
2151 (setq todos-categories (todos-categories-list (buffer-name))))
2152 ;; (beginning-of-line)
2154 (todos-category-select)
2155 ;; (todos-show-paren-hack)
2158 (defun todos-initial-setup ()
2159 "Set up things to work properly in TODO mode."
2160 (find-file todos-file-do)
2163 (todos-add-category "Todos"))
2167 ;; arch-tag: 6fd91be5-776e-4464-a109-da4ea0e4e497
2168 ;;; todos.el ends here