@code{todo-insert-item}, since these commands are bound to @kbd{t},
@kbd{j} and @kbd{i}, respectively, in Todo mode.
-You can also visit a Todo file via @code{find-file} or Dired, like any
-other file, and since Emacs recognizes it, the buffer will automatically
-be in the appropriate Todo mode. Moreover, as long as the command you
-use to visit the file is listed in the option
-@code{todo-visit-files-commands} (which by default contains
-@code{find-file} and @code{dired-find-file}), it will also correctly
-display the file's first category on first visiting the file (otherwise
-you have to use one of the commands for navigating between categories in
-order to get a proper display).
+@c You can also visit a Todo file via @code{find-file} or Dired, like any
+@c other file, and since Emacs recognizes it, the buffer will automatically
+@c be in the appropriate Todo mode. Moreover, as long as the command you
+@c use to visit the file is listed in the option
+@c @code{todo-visit-files-commands} (which by default contains
+@c @code{find-file} and @code{dired-find-file}), it will also correctly
+@c display the file's first category on first visiting the file (otherwise
+@c you have to use one of the commands for navigating between categories in
+@c order to get a proper display).
You can leave Todo mode by typing @kbd{q} (@code{todo-quit}), which
buries the current todo file buffer. Doing this also saves any changes
number key.
The predefined key bindings in Todo are more or less mnemonic. As a
-rule, key sequences beginning with @kbd{C} (capital `C', not the
+rule, key sequences beginning with @kbd{C} (capital @samp{C}, not the
control key) are bound to commands applying to categories, sequences
beginning with @kbd{F} apply to (non-archive) file-level commands, and
those beginning with @kbd{A} apply to archives (a special type of Todo
@samp{region} (@kbd{r}): Use the text of the selected region as the
text of the new item, and insert this in accordance with the item
insertion options and other parameters passed. If the option
-`todo-use-only-highlighted-region' is non-nil, then use the region
-only when it is highlighted; otherwise, use the region regardless of
-highlighting.
+@code{todo-use-only-highlighted-region} is non-nil, then use the
+region only when it is highlighted; otherwise, use the region
+regardless of highlighting.
@end enumerate
Note that the parameters are divided into five numbered groups; within
@noindent Notice that the pair @samp{k=>nonmarking} is now absent, since it
belongs to the same group as the selected pair @samp{y=>diary}, hence
is no longer available for this sequence. Since @kbd{y} is a
-continuation key, it is still available, but now the string ":GO!" is
-appended to the pair to remind you that pressing this key again will
-complete the sequence.
+continuation key, it is still available, but now the string
+@samp{:GO!} is appended to the pair to remind you that pressing this
+key again will complete the sequence.
@noindent
Editing the text of a lengthy item in the minibuffer can be
-inconvenient; therefore, if you type `e e' or `e h' on an item whose
-text contains more than one logical line, the effect is the same as if
-you had typed `e m', that is, you switch a special buffer in Todo Edit
-mode.
+inconvenient; therefore, if you type @kbd{e e} or @kbd{e h} on an item
+whose text contains more than one logical line, the effect is the same
+as if you had typed @kbd{e m}, that is, you switch a special buffer in
+Todo Edit mode.
When you pass any of the parameters of the preceding group, except for
the @samp{date} parameter, this completes the item editing invocation
Press a key (so far `e d'): f=>full c=>calendar a=>today n=>dayname y=>year m=>month d=>daynum
@end example
-In addition to the item-level invocations `e y', to change the current
-item's diary inclusion status, and `e k', to change the current item's
-calendar marking status, Todo mode also has two related category-level
-commands:
+In addition to the item-level invocations @kbd{e y}, to change the
+current item's diary inclusion status, and @kbd{e k}, to change the
+current item's calendar marking status, Todo mode also has two related
+category-level commands:
@table @kbd
@end table
@noindent
-Like `e k', `C e k' automatically removes @code{todo-nondiary-marker}
+Like @kbd{e k}, @kbd{C e k} automatically removes @code{todo-nondiary-marker}
from all items it is present on, since only diary items can bear
@code{diary-nonmarking-symbol}.
category, and take a prefix argument to reverse the effect. (If you
really want to toggle the diary-inclusion and calendar-marking status
of all items in the category, you can do this by marking all the items
-and then invoking `e y' or `e k', @pxref{Marked Items}).
+and then invoking @kbd{e y} or @kbd{e k}, @pxref{Marked Items}).
@node Relocating and Removing Items, , Editing Item Headers and Text, Item Editing
@subsection Relocating and Removing Items
@anchor{todo-item-done}
@item d
-This command (@code{todo-item-done}) removes the todo item at point from
-the todo list, appends to the original header a header consisting of
-@code{todo-done-string} (by default ``DONE '') and the current date, and
-if @code{todo-always-add-time-string} is enabled, also the current time,
-and adds the resulting done item to the top of the done items section of
-the category. Invoked with a prefix argument, it also prompts you to
-enter a comment, which is appended to the end of the done item, prefixed
-with @code{todo-comment-string} (by default ``COMMENT: '').
+This command (@code{todo-item-done}) removes the todo item at point
+from the todo list, appends to the original header a header consisting
+of @code{todo-done-string} (by default @samp{DONE }) and the current
+date, and if @code{todo-always-add-time-string} is enabled, also the
+current time, and adds the resulting done item to the top of the done
+items section of the category. Invoked with a prefix argument, it
+also prompts you to enter a comment, which is appended to the end of
+the done item, prefixed with @code{todo-comment-string} (by default
+@samp{COMMENT: }).
@end table
A category's done items section is located below the last todo (i.e.,
Since it is natural to visit an archive from the corresponding todo
file, it would be convenient to easily return to the todo file when you
-have finished browsing the archive. If you type `q' to quit Todo
+have finished browsing the archive. If you type @kbd{q} to quit Todo
Archive mode, this switches to the corresponding todo file and shows the
todo category corresponding to the archive category you were just
visiting.
Each row of the table is also buttonized; pressing one of these exits
the buffer (killing it), returns to the buffer of the file from which
-you had invoked `F c', and displays the category that was named in the
-row button you pressed (i.e., pressing this button jumps to that
-category). However, if the category named in the row is in a todo file
-and all of its items have been archived, and you have enabled the option
-@code{todo-skip-archived-categories}, then pressing the button jumps to
-the archive category instead of the empty todo category. You can
-recognize such categories by their items counts in the table---all
+you had invoked @kbd{F c}, and displays the category that was named in
+the row button you pressed (i.e., pressing this button jumps to that
+category). However, if the category named in the row is in a todo
+file and all of its items have been archived, and you have enabled the
+option @code{todo-skip-archived-categories}, then pressing the button
+jumps to the archive category instead of the empty todo category. You
+can recognize such categories by their items counts in the table---all
columns but the archived one have counts of zero---and in addition,
their lines in the table are also distinguished from the others by a
different face (@pxref{Faces}).
current category. To exclude a category or file from filtering by @kbd{F t t}
and @kbd{F t m}, set the number to @samp{0}.
@item
-You can invoke `F t t' and `F t m' with a numeric prefix argument,
+You can invoke @kbd{F t t} and @kbd{F t m} with a numeric prefix argument,
which specifies the number of top priorities in each category just for
this invocation, overriding both @code{todo-top-priorities-overrides} and
@code{todo-top-priorities}.
Aside from explicitly invoking an item filtering command to display a
saved list of items filtered by a given method from given todo files,
there are two other ways to visit a saved file of filtered items. You
-can invoke a command similar to `find-file':
+can invoke a command similar to @code{find-file}:
@table @kbd
@item F f
;;; Entering and exiting
;; -----------------------------------------------------------------------------
-(defcustom todo-visit-files-commands (list 'find-file 'dired-find-file)
- "List of file finding commands for `todo-display-as-todo-file'.
-Invoking these commands to visit a todo file or todo archive file
-calls `todo-show' or `todo-find-archive', so that the file is
-displayed correctly."
- :type '(repeat function)
- :group 'todo)
+;; (defcustom todo-visit-files-commands (list 'find-file 'dired-find-file)
+;; "List of file finding commands for `todo-display-as-todo-file'.
+;; Invoking these commands to visit a todo file or todo archive file
+;; calls `todo-show' or `todo-find-archive', so that the file is
+;; displayed correctly."
+;; :type '(repeat function)
+;; :group 'todo)
(defun todo-short-file-name (file)
"Return the short form of todo file FILE's name.
"Choose a regexp items file: "
rxf) 'regexp))))))
(if (file-exists-p fi-file)
- (set-window-buffer
- (selected-window)
- (set-buffer (find-file-noselect fi-file 'nowarn)))
+ (progn
+ (set-window-buffer
+ (selected-window)
+ (set-buffer (find-file-noselect fi-file 'nowarn)))
+ (unless (derived-mode-p 'todo-filtered-items-mode)
+ (todo-filtered-items-mode)))
(message "There is no %s file for %s"
(cond ((eq todo-show-first 'top)
"top priorities")
(unless (todo-check-file file) (throw 'end nil))
(set-window-buffer (selected-window)
(set-buffer (find-file-noselect file 'nowarn)))
+ (if (equal (file-name-extension (buffer-file-name)) "toda")
+ (unless (derived-mode-p 'todo-archive-mode) (todo-archive-mode))
+ (unless (derived-mode-p 'todo-mode) (todo-mode)))
;; When quitting an archive file, show the corresponding
;; category in the corresponding todo file, if it exists.
(when (assoc cat todo-categories)
(if (member buf (funcall todo-files-function t))
(concat (file-name-sans-extension nfile) ".toda")
nfile))
+ (if (equal (file-name-extension (buffer-file-name)) "toda")
+ (unless (derived-mode-p 'todo-archive-mode)
+ (todo-archive-mode))
+ (unless (derived-mode-p 'todo-mode) (todo-mode)))
(let* ((nfile-short (todo-short-file-name nfile))
(prompt (concat
(format "Todo file \"%s\" already has "
(done-count (todo-get-count 'done cat)))
;; Merge into goal todo category.
(with-current-buffer (get-buffer (find-file-noselect gfile))
+ (unless (derived-mode-p 'todo-mode) (todo-mode))
(widen)
(goto-char (point-min))
(let ((buffer-read-only nil))
(when place
(set-window-buffer (selected-window)
(set-buffer (find-file-noselect archive)))
+ (unless (derived-mode-p 'todo-archive-mode) (todo-archive-mode))
(if (member place '(other-archive other-cat))
(setq todo-category-number 1)
(todo-category-number cat))
(if (not (or marked all item))
(throw 'end (message "Only done items can be archived"))
(with-current-buffer archive
+ (unless (derived-mode-p 'todo-archive-mode) (todo-archive-mode))
(let (buffer-read-only)
(widen)
(goto-char (point-min))
(todo-update-categories-sexp)
;; If archive is new, save to file now (with
;; write-region to avoid prompt for file to save to)
- ;; to update todo-archives, and to let auto-mode-alist
- ;; take effect below on visiting the archive.
+ ;; to update todo-archives, and set the mode for
+ ;; visiting the archive below.
(unless (nth 7 (file-attributes afile))
(write-region nil nil afile t t)
(setq todo-archives (funcall todo-files-function t))
- (kill-buffer))))
+ (todo-archive-mode))))
(with-current-buffer tbuf
(cond
(all
(setq file (completing-read "Choose a filtered items file: "
falist nil t nil nil (car falist)))
(setq file (cdr (assoc-string file falist)))
- (find-file file)))
+ (find-file file)
+ (unless (derived-mode-p 'todo-filtered-items-mode)
+ (todo-filtered-items-mode))))
(defun todo-go-to-source-item ()
"Display the file and category of the filtered item at point."
(completing-read "Choose a regexp items file: "
rxf) 'regexp))))
(find-file fname)
+ (unless (derived-mode-p 'todo-filtered-items-mode)
+ (todo-filtered-items-mode))
(todo-prefix-overlays)
(todo-check-filtered-items-file))
(t
todo-global-current-todo-file)))
(find-file-noselect file)
(with-current-buffer (find-buffer-visiting file)
+ (if archive
+ (unless (derived-mode-p 'todo-archive-mode) (todo-archive-mode))
+ (unless (derived-mode-p 'todo-mode) (todo-mode)))
(save-restriction
(widen)
(goto-char (point-min))
;; Make sure to include newly created archives, e.g. due to
;; todo-move-category.
(when (member archive (funcall todo-files-function t))
- (let ((archive-count 0))
- (with-current-buffer (find-file-noselect archive)
- (widen)
- (goto-char (point-min))
- (when (re-search-forward
- (concat "^" (regexp-quote todo-category-beg)
- cat "$")
- (point-max) t)
- (forward-line)
- (while (not (or (looking-at
- (concat
- (regexp-quote todo-category-beg)
- "\\(.*\\)\n"))
- (eobp)))
- (when (looking-at todo-done-string-start)
- (setq archive-count (1+ archive-count)))
- (forward-line))))
+ (let ((archive-count 0)
+ (visiting (find-buffer-visiting archive)))
+ (with-current-buffer (or visiting
+ (find-file-noselect archive))
+ (save-excursion
+ (save-restriction
+ (widen)
+ (goto-char (point-min))
+ (when (re-search-forward
+ (concat "^" (regexp-quote todo-category-beg)
+ cat "$")
+ (point-max) t)
+ (forward-line)
+ (while (not (or (looking-at
+ (concat
+ (regexp-quote todo-category-beg)
+ "\\(.*\\)\n"))
+ (eobp)))
+ (when (looking-at todo-done-string-start)
+ (setq archive-count (1+ archive-count)))
+ (forward-line)))))
+ (unless visiting (kill-buffer)))
(todo-update-count 'archived archive-count cat))))
((looking-at todo-done-string-start)
(todo-update-count 'done 1 cat))
(if (not (and (file-exists-p file)
(find-file-other-window file)))
(message "Unable to locate this diary entry")
+ ;; If it's a Todo file, make sure it's in Todo mode.
+ (when (and (equal (file-name-directory (file-truename file))
+ (file-truename todo-directory))
+ (not (derived-mode-p 'todo-mode)))
+ (todo-mode))
(when (eq major-mode 'todo-mode) (widen))
(goto-char (point-min))
(when (re-search-forward (format "%s.*\\(%s\\)" date content) nil t)
(add-to-list 'files curfile))
(dolist (f files listall)
(with-current-buffer (find-file-noselect f 'nowarn)
+ (if archive
+ (unless (derived-mode-p 'todo-archive-mode) (todo-archive-mode))
+ (unless (derived-mode-p 'todo-mode) (todo-mode)))
;; Ensure category is properly displayed in case user
;; switches to file via a non-Todo mode command. And if
;; done items in category are visible, keep them visible.
(categories (cond (file0
(with-current-buffer
(find-file-noselect file0 'nowarn)
+ (unless (derived-mode-p 'todo-mode) (todo-mode))
(let ((todo-current-todo-file file0))
todo-categories)))
((and add (not file))
(regexp-quote diary-nonmarking-symbol) "\\)?"))
(when (not (equal value oldvalue))
(dolist (f files)
- (with-current-buffer (find-file-noselect f)
- (let (buffer-read-only)
- (widen)
- (goto-char (point-min))
- (while (not (eobp))
- (if (re-search-forward
- (concat "^\\(" todo-done-string-start "[^][]+] \\)?"
- "\\(?1:" (regexp-quote (car oldvalue))
- "\\)" todo-date-pattern "\\( "
- diary-time-regexp "\\)?\\(?2:"
- (regexp-quote (cadr oldvalue)) "\\)")
- nil t)
- (progn
- (replace-match (nth 0 value) t t nil 1)
- (replace-match (nth 1 value) t t nil 2))
- (forward-line)))
- (todo-category-select)))))))
+ (let ((buf (find-buffer-visiting f)))
+ (with-current-buffer (find-file-noselect f)
+ (let (buffer-read-only)
+ (widen)
+ (goto-char (point-min))
+ (while (not (eobp))
+ (if (re-search-forward
+ (concat "^\\(" todo-done-string-start "[^][]+] \\)?"
+ "\\(?1:" (regexp-quote (car oldvalue))
+ "\\)" todo-date-pattern "\\( "
+ diary-time-regexp "\\)?\\(?2:"
+ (regexp-quote (cadr oldvalue)) "\\)")
+ nil t)
+ (progn
+ (replace-match (nth 0 value) t t nil 1)
+ (replace-match (nth 1 value) t t nil 2))
+ (forward-line)))
+ (if buf
+ (when (derived-mode-p 'todo-mode 'todo-archive-mode)
+ (todo-category-select))
+ (save-buffer)
+ (kill-buffer)))))))))
(defun todo-reset-done-separator-string (symbol value)
"The :set function for `todo-done-separator-string'."
(concat "^\\[" (regexp-quote todo-done-string)))
(when (not (equal value oldvalue))
(dolist (f files)
- (with-current-buffer (find-file-noselect f)
- (let (buffer-read-only)
- (widen)
- (goto-char (point-min))
- (while (not (eobp))
- (if (re-search-forward
- (concat "^" (regexp-quote todo-nondiary-start)
- "\\(" (regexp-quote oldvalue) "\\)")
- nil t)
- (replace-match value t t nil 1)
- (forward-line)))
- (todo-category-select)))))))
+ (let ((buf (find-buffer-visiting f)))
+ (with-current-buffer (find-file-noselect f)
+ (let (buffer-read-only)
+ (widen)
+ (goto-char (point-min))
+ (while (not (eobp))
+ (if (re-search-forward
+ (concat "^" (regexp-quote todo-nondiary-start)
+ "\\(" (regexp-quote oldvalue) "\\)")
+ nil t)
+ (replace-match value t t nil 1)
+ (forward-line)))
+ (if buf
+ (when (derived-mode-p 'todo-mode 'todo-archive-mode)
+ (todo-category-select))
+ (save-buffer)
+ (kill-buffer)))))))))
(defun todo-reset-comment-string (symbol value)
"The :set function for user option `todo-comment-string'."
(custom-set-default symbol value)
(when (not (equal value oldvalue))
(dolist (f files)
- (with-current-buffer (find-file-noselect f)
- (let (buffer-read-only)
- (save-excursion
+ (let ((buf (find-buffer-visiting f)))
+ (with-current-buffer (find-file-noselect f)
+ (let (buffer-read-only)
(widen)
(goto-char (point-min))
(while (not (eobp))
(if (re-search-forward
- (concat
- "\\[\\(" (regexp-quote oldvalue) "\\): [^]]*\\]")
+ (concat "\\[\\(" (regexp-quote oldvalue)
+ "\\): [^]]*\\]")
nil t)
(replace-match value t t nil 1)
(forward-line)))
- (todo-category-select))))))))
+ (if buf
+ (when (derived-mode-p 'todo-mode 'todo-archive-mode)
+ (todo-category-select))
+ (save-buffer)
+ (kill-buffer)))))))))
(defun todo-reset-highlight-item (symbol value)
"The :set function for user option `todo-highlight-item'."
`todo-show-current-file' is set to non-nil."
(setq todo-global-current-todo-file todo-current-todo-file))
-(defun todo-display-as-todo-file ()
- "Show todo files correctly when visited from outside of Todo mode.
-Added to `find-file-hook' in Todo mode and Todo Archive mode."
- (and (member this-command todo-visit-files-commands)
- (= (- (point-max) (point-min)) (buffer-size))
- (member major-mode '(todo-mode todo-archive-mode))
- (todo-category-select)))
-
-(defun todo-add-to-buffer-list ()
- "Add name of just visited todo file to `todo-file-buffers'.
-This function is added to `find-file-hook' in Todo mode."
- (let ((filename (file-truename (buffer-file-name))))
- (when (member filename todo-files)
- (add-to-list 'todo-file-buffers filename))))
+;; (defun todo-display-as-todo-file ()
+;; "Show todo files correctly when visited from outside of Todo mode.
+;; Added to `find-file-hook' in Todo mode and Todo Archive mode."
+;; (and (member this-command todo-visit-files-commands)
+;; (= (- (point-max) (point-min)) (buffer-size))
+;; (member major-mode '(todo-mode todo-archive-mode))
+;; (todo-category-select)))
+
+;; (defun todo-add-to-buffer-list ()
+;; "Add name of just visited todo file to `todo-file-buffers'.
+;; This function is added to `find-file-hook' in Todo mode."
+;; (let ((filename (file-truename (buffer-file-name))))
+;; (when (member filename todo-files)
+;; (add-to-list 'todo-file-buffers filename))))
(defun todo-update-buffer-list ()
"Make current Todo mode buffer file car of `todo-file-buffers'.
"Make some settings that apply to multiple Todo modes."
(setq-local todo-categories (todo-set-categories))
(setq-local todo-category-number 1)
- (add-hook 'find-file-hook 'todo-display-as-todo-file nil t))
+ ;; (add-hook 'find-file-hook 'todo-display-as-todo-file nil t)
+ )
(put 'todo-mode 'mode-class 'special)
(setq-local todo-current-todo-file (file-truename (buffer-file-name))))
(setq-local todo-show-done-only nil)
(setq-local todo-categories-with-marks nil)
- (add-hook 'find-file-hook 'todo-add-to-buffer-list nil t)
+ ;; (add-hook 'find-file-hook 'todo-add-to-buffer-list nil t)
(add-hook 'post-command-hook 'todo-update-buffer-list nil t)
(when todo-show-current-file
(add-hook 'pre-command-hook 'todo-show-current-file nil t))
(todo-modes-set-1)
(todo-modes-set-2))
-;;;###autoload
-(add-to-list 'auto-mode-alist '("\\.todo\\'" . todo-mode))
-;;;###autoload
-(add-to-list 'auto-mode-alist '("\\.toda\\'" . todo-archive-mode))
-;;;###autoload
-(add-to-list 'auto-mode-alist '("\\.tod[tyr]\\'" . todo-filtered-items-mode))
-
;; -----------------------------------------------------------------------------
(provide 'todo-mode)