aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Berman2014-05-23 18:54:35 +0200
committerStephen Berman2014-05-23 18:54:35 +0200
commit903204bb53d1c05a9726316134e145d8bd34664e (patch)
tree32f17f5475e9ab9e96746c458e9b5f103290b3d3
parent15ad4013c44d19125fde6bbb704797d4a7a185b3 (diff)
downloademacs-903204bb53d1c05a9726316134e145d8bd34664e.tar.gz
emacs-903204bb53d1c05a9726316134e145d8bd34664e.zip
todo-mode.el: Remove dependence on auto-mode-alist.
* calendar/todo-mode.el: Remove dependence on auto-mode-alist, to avoid errors when trying to create or visit a file foo.todo located outside to todo-directory, and to allow having such files without them being tied to Todo mode. (todo-show, todo-move-category, todo-merge-category, todo-find-archive) (todo-archive-done-item, todo-find-filtered-items-file) (todo-filter-items, todo-find-item, todo-diary-goto-entry) (todo-category-completions, todo-read-category): When visiting a Todo file, make sure we're in the right mode and the buffer local variables are set. (todo-make-categories-list, todo-reset-nondiary-marker) (todo-reset-done-string, todo-reset-comment-string): After processing all Todo files, kill the buffers of those files that weren't being visited before the processing. (todo-display-as-todo-file, todo-add-to-buffer-list) (todo-visit-files-commands): Comment out. (todo-modes-set-3, todo-mode): Comment out additions to find-file-hook. (auto-mode-alist): Remove add-to-list calls making Todo file extensions unrestrictedly tied to Todo modes. * doc/misc/todo-mode.texi: Update in light of changes due to bug#17482. Replace numerous mistaken uses of literal quotes with proper Texinfo markup. (Todo Mode Entry Points): Comment out reference to using find-file or Dired to visit Todo files, since this has been disabled (bug#17482).
-rw-r--r--doc/misc/ChangeLog8
-rw-r--r--doc/misc/todo-mode.texi89
-rw-r--r--lisp/ChangeLog22
-rw-r--r--lisp/calendar/todo-mode.el220
4 files changed, 206 insertions, 133 deletions
diff --git a/doc/misc/ChangeLog b/doc/misc/ChangeLog
index ded23868c79..63e2cf728ff 100644
--- a/doc/misc/ChangeLog
+++ b/doc/misc/ChangeLog
@@ -1,3 +1,11 @@
12014-05-23 Stephen Berman <stephen.berman@gmx.net>
2
3 * todo-mode.texi: Update in light of changes due to bug#17482.
4 Replace numerous mistaken uses of literal quotes with proper
5 Texinfo markup.
6 (Todo Mode Entry Points): Comment out reference to using find-file
7 or Dired to visit Todo files, since this has been disabled (bug#17482).
8
12014-05-06 Michael Albinus <michael.albinus@gmx.de> 92014-05-06 Michael Albinus <michael.albinus@gmx.de>
2 10
3 * tramp.texi (Frequently Asked Questions): Mention HISTFILE 11 * tramp.texi (Frequently Asked Questions): Mention HISTFILE
diff --git a/doc/misc/todo-mode.texi b/doc/misc/todo-mode.texi
index ad97e608156..44ea7fbf06e 100644
--- a/doc/misc/todo-mode.texi
+++ b/doc/misc/todo-mode.texi
@@ -258,15 +258,15 @@ are @kbd{C-c t} for @code{todo-show}, @kbd{C-c j} for
258@code{todo-insert-item}, since these commands are bound to @kbd{t}, 258@code{todo-insert-item}, since these commands are bound to @kbd{t},
259@kbd{j} and @kbd{i}, respectively, in Todo mode. 259@kbd{j} and @kbd{i}, respectively, in Todo mode.
260 260
261You can also visit a Todo file via @code{find-file} or Dired, like any 261@c You can also visit a Todo file via @code{find-file} or Dired, like any
262other file, and since Emacs recognizes it, the buffer will automatically 262@c other file, and since Emacs recognizes it, the buffer will automatically
263be in the appropriate Todo mode. Moreover, as long as the command you 263@c be in the appropriate Todo mode. Moreover, as long as the command you
264use to visit the file is listed in the option 264@c use to visit the file is listed in the option
265@code{todo-visit-files-commands} (which by default contains 265@c @code{todo-visit-files-commands} (which by default contains
266@code{find-file} and @code{dired-find-file}), it will also correctly 266@c @code{find-file} and @code{dired-find-file}), it will also correctly
267display the file's first category on first visiting the file (otherwise 267@c display the file's first category on first visiting the file (otherwise
268you have to use one of the commands for navigating between categories in 268@c you have to use one of the commands for navigating between categories in
269order to get a proper display). 269@c order to get a proper display).
270 270
271You can leave Todo mode by typing @kbd{q} (@code{todo-quit}), which 271You can leave Todo mode by typing @kbd{q} (@code{todo-quit}), which
272buries the current todo file buffer. Doing this also saves any changes 272buries the current todo file buffer. Doing this also saves any changes
@@ -295,7 +295,7 @@ for the shift key for capitalization and the raw prefix argument
295number key. 295number key.
296 296
297The predefined key bindings in Todo are more or less mnemonic. As a 297The predefined key bindings in Todo are more or less mnemonic. As a
298rule, key sequences beginning with @kbd{C} (capital `C', not the 298rule, key sequences beginning with @kbd{C} (capital @samp{C}, not the
299control key) are bound to commands applying to categories, sequences 299control key) are bound to commands applying to categories, sequences
300beginning with @kbd{F} apply to (non-archive) file-level commands, and 300beginning with @kbd{F} apply to (non-archive) file-level commands, and
301those beginning with @kbd{A} apply to archives (a special type of Todo 301those beginning with @kbd{A} apply to archives (a special type of Todo
@@ -669,9 +669,9 @@ down, i.e., lowering their priority, by one.
669@samp{region} (@kbd{r}): Use the text of the selected region as the 669@samp{region} (@kbd{r}): Use the text of the selected region as the
670text of the new item, and insert this in accordance with the item 670text of the new item, and insert this in accordance with the item
671insertion options and other parameters passed. If the option 671insertion options and other parameters passed. If the option
672`todo-use-only-highlighted-region' is non-nil, then use the region 672@code{todo-use-only-highlighted-region} is non-nil, then use the
673only when it is highlighted; otherwise, use the region regardless of 673region only when it is highlighted; otherwise, use the region
674highlighting. 674regardless of highlighting.
675@end enumerate 675@end enumerate
676 676
677Note that the parameters are divided into five numbered groups; within 677Note that the parameters are divided into five numbered groups; within
@@ -715,9 +715,9 @@ Press a key (so far `i y'): y=>diary:GO! @{ c=>calendar d=>date n=>dayname @} t
715@noindent Notice that the pair @samp{k=>nonmarking} is now absent, since it 715@noindent Notice that the pair @samp{k=>nonmarking} is now absent, since it
716belongs to the same group as the selected pair @samp{y=>diary}, hence 716belongs to the same group as the selected pair @samp{y=>diary}, hence
717is no longer available for this sequence. Since @kbd{y} is a 717is no longer available for this sequence. Since @kbd{y} is a
718continuation key, it is still available, but now the string ":GO!" is 718continuation key, it is still available, but now the string
719appended to the pair to remind you that pressing this key again will 719@samp{:GO!} is appended to the pair to remind you that pressing this
720complete the sequence. 720key again will complete the sequence.
721 721
722 722
723 723
@@ -821,10 +821,10 @@ otherwise it enters the empty string (i.e., no time string).
821 821
822@noindent 822@noindent
823Editing the text of a lengthy item in the minibuffer can be 823Editing the text of a lengthy item in the minibuffer can be
824inconvenient; therefore, if you type `e e' or `e h' on an item whose 824inconvenient; therefore, if you type @kbd{e e} or @kbd{e h} on an item
825text contains more than one logical line, the effect is the same as if 825whose text contains more than one logical line, the effect is the same
826you had typed `e m', that is, you switch a special buffer in Todo Edit 826as if you had typed @kbd{e m}, that is, you switch a special buffer in
827mode. 827Todo Edit mode.
828 828
829When you pass any of the parameters of the preceding group, except for 829When you pass any of the parameters of the preceding group, except for
830the @samp{date} parameter, this completes the item editing invocation 830the @samp{date} parameter, this completes the item editing invocation
@@ -916,10 +916,10 @@ invocation:
916Press a key (so far `e d'): f=>full c=>calendar a=>today n=>dayname y=>year m=>month d=>daynum 916Press a key (so far `e d'): f=>full c=>calendar a=>today n=>dayname y=>year m=>month d=>daynum
917@end example 917@end example
918 918
919In addition to the item-level invocations `e y', to change the current 919In addition to the item-level invocations @kbd{e y}, to change the
920item's diary inclusion status, and `e k', to change the current item's 920current item's diary inclusion status, and @kbd{e k}, to change the
921calendar marking status, Todo mode also has two related category-level 921current item's calendar marking status, Todo mode also has two related
922commands: 922category-level commands:
923 923
924@table @kbd 924@table @kbd
925 925
@@ -932,7 +932,7 @@ category.
932@end table 932@end table
933 933
934@noindent 934@noindent
935Like `e k', `C e k' automatically removes @code{todo-nondiary-marker} 935Like @kbd{e k}, @kbd{C e k} automatically removes @code{todo-nondiary-marker}
936from all items it is present on, since only diary items can bear 936from all items it is present on, since only diary items can bear
937@code{diary-nonmarking-symbol}. 937@code{diary-nonmarking-symbol}.
938 938
@@ -944,7 +944,7 @@ to be toggles, but to have the same effect on all items in the
944category, and take a prefix argument to reverse the effect. (If you 944category, and take a prefix argument to reverse the effect. (If you
945really want to toggle the diary-inclusion and calendar-marking status 945really want to toggle the diary-inclusion and calendar-marking status
946of all items in the category, you can do this by marking all the items 946of all items in the category, you can do this by marking all the items
947and then invoking `e y' or `e k', @pxref{Marked Items}). 947and then invoking @kbd{e y} or @kbd{e k}, @pxref{Marked Items}).
948 948
949@node Relocating and Removing Items, , Editing Item Headers and Text, Item Editing 949@node Relocating and Removing Items, , Editing Item Headers and Text, Item Editing
950@subsection Relocating and Removing Items 950@subsection Relocating and Removing Items
@@ -1050,14 +1050,15 @@ Archive Mode}).
1050 1050
1051@anchor{todo-item-done} 1051@anchor{todo-item-done}
1052@item d 1052@item d
1053This command (@code{todo-item-done}) removes the todo item at point from 1053This command (@code{todo-item-done}) removes the todo item at point
1054the todo list, appends to the original header a header consisting of 1054from the todo list, appends to the original header a header consisting
1055@code{todo-done-string} (by default ``DONE '') and the current date, and 1055of @code{todo-done-string} (by default @samp{DONE }) and the current
1056if @code{todo-always-add-time-string} is enabled, also the current time, 1056date, and if @code{todo-always-add-time-string} is enabled, also the
1057and adds the resulting done item to the top of the done items section of 1057current time, and adds the resulting done item to the top of the done
1058the category. Invoked with a prefix argument, it also prompts you to 1058items section of the category. Invoked with a prefix argument, it
1059enter a comment, which is appended to the end of the done item, prefixed 1059also prompts you to enter a comment, which is appended to the end of
1060with @code{todo-comment-string} (by default ``COMMENT: ''). 1060the done item, prefixed with @code{todo-comment-string} (by default
1061@samp{COMMENT: }).
1061@end table 1062@end table
1062 1063
1063A category's done items section is located below the last todo (i.e., 1064A category's done items section is located below the last todo (i.e.,
@@ -1255,7 +1256,7 @@ category in the archive, the archive file is also automatically deleted.
1255 1256
1256Since it is natural to visit an archive from the corresponding todo 1257Since it is natural to visit an archive from the corresponding todo
1257file, it would be convenient to easily return to the todo file when you 1258file, it would be convenient to easily return to the todo file when you
1258have finished browsing the archive. If you type `q' to quit Todo 1259have finished browsing the archive. If you type @kbd{q} to quit Todo
1259Archive mode, this switches to the corresponding todo file and shows the 1260Archive mode, this switches to the corresponding todo file and shows the
1260todo category corresponding to the archive category you were just 1261todo category corresponding to the archive category you were just
1261visiting. 1262visiting.
@@ -1396,13 +1397,13 @@ to sort by archived item counts.
1396 1397
1397Each row of the table is also buttonized; pressing one of these exits 1398Each row of the table is also buttonized; pressing one of these exits
1398the buffer (killing it), returns to the buffer of the file from which 1399the buffer (killing it), returns to the buffer of the file from which
1399you had invoked `F c', and displays the category that was named in the 1400you had invoked @kbd{F c}, and displays the category that was named in
1400row button you pressed (i.e., pressing this button jumps to that 1401the row button you pressed (i.e., pressing this button jumps to that
1401category). However, if the category named in the row is in a todo file 1402category). However, if the category named in the row is in a todo
1402and all of its items have been archived, and you have enabled the option 1403file and all of its items have been archived, and you have enabled the
1403@code{todo-skip-archived-categories}, then pressing the button jumps to 1404option @code{todo-skip-archived-categories}, then pressing the button
1404the archive category instead of the empty todo category. You can 1405jumps to the archive category instead of the empty todo category. You
1405recognize such categories by their items counts in the table---all 1406can recognize such categories by their items counts in the table---all
1406columns but the archived one have counts of zero---and in addition, 1407columns but the archived one have counts of zero---and in addition,
1407their lines in the table are also distinguished from the others by a 1408their lines in the table are also distinguished from the others by a
1408different face (@pxref{Faces}). 1409different face (@pxref{Faces}).
@@ -1586,7 +1587,7 @@ todo file, and the latter sets the number of top priorities for the
1586current category. To exclude a category or file from filtering by @kbd{F t t} 1587current category. To exclude a category or file from filtering by @kbd{F t t}
1587and @kbd{F t m}, set the number to @samp{0}. 1588and @kbd{F t m}, set the number to @samp{0}.
1588@item 1589@item
1589You can invoke `F t t' and `F t m' with a numeric prefix argument, 1590You can invoke @kbd{F t t} and @kbd{F t m} with a numeric prefix argument,
1590which specifies the number of top priorities in each category just for 1591which specifies the number of top priorities in each category just for
1591this invocation, overriding both @code{todo-top-priorities-overrides} and 1592this invocation, overriding both @code{todo-top-priorities-overrides} and
1592@code{todo-top-priorities}. 1593@code{todo-top-priorities}.
@@ -1681,7 +1682,7 @@ use the values of @code{todo-top-priorities-overrides} or
1681Aside from explicitly invoking an item filtering command to display a 1682Aside from explicitly invoking an item filtering command to display a
1682saved list of items filtered by a given method from given todo files, 1683saved list of items filtered by a given method from given todo files,
1683there are two other ways to visit a saved file of filtered items. You 1684there are two other ways to visit a saved file of filtered items. You
1684can invoke a command similar to `find-file': 1685can invoke a command similar to @code{find-file}:
1685 1686
1686@table @kbd 1687@table @kbd
1687@item F f 1688@item F f
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 57cf0490fea..1d450e3d5d5 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,25 @@
12014-05-23 Stephen Berman <stephen.berman@gmx.net>
2
3 * calendar/todo-mode.el: Remove dependence on auto-mode-alist,
4 to avoid errors when trying to create or visit a file foo.todo
5 located outside to todo-directory, and to allow having such files
6 without them being tied to Todo mode (bug#17482).
7 (todo-show, todo-move-category, todo-merge-category, todo-find-archive)
8 (todo-archive-done-item, todo-find-filtered-items-file)
9 (todo-filter-items, todo-find-item, todo-diary-goto-entry)
10 (todo-category-completions, todo-read-category): When visiting a
11 Todo file, make sure we're in the right mode and the buffer local
12 variables are set.
13 (todo-make-categories-list, todo-reset-nondiary-marker)
14 (todo-reset-done-string, todo-reset-comment-string): After
15 processing all Todo files, kill the buffers of those files that
16 weren't being visited before the processing.
17 (todo-display-as-todo-file, todo-add-to-buffer-list)
18 (todo-visit-files-commands): Comment out.
19 (todo-modes-set-3, todo-mode): Comment out additions to find-file-hook.
20 (auto-mode-alist): Remove add-to-list calls making Todo file
21 extensions unrestrictedly tied to Todo modes.
22
12014-05-23 Stefan Monnier <monnier@iro.umontreal.ca> 232014-05-23 Stefan Monnier <monnier@iro.umontreal.ca>
2 24
3 * emacs-lisp/nadvice.el (advice--member-p): Change second arg. 25 * emacs-lisp/nadvice.el (advice--member-p): Change second arg.
diff --git a/lisp/calendar/todo-mode.el b/lisp/calendar/todo-mode.el
index 1b15317ffc6..ab2ab3e4cb8 100644
--- a/lisp/calendar/todo-mode.el
+++ b/lisp/calendar/todo-mode.el
@@ -566,13 +566,13 @@ less than or equal the category's top priority setting."
566;;; Entering and exiting 566;;; Entering and exiting
567;; ----------------------------------------------------------------------------- 567;; -----------------------------------------------------------------------------
568 568
569(defcustom todo-visit-files-commands (list 'find-file 'dired-find-file) 569;; (defcustom todo-visit-files-commands (list 'find-file 'dired-find-file)
570 "List of file finding commands for `todo-display-as-todo-file'. 570;; "List of file finding commands for `todo-display-as-todo-file'.
571Invoking these commands to visit a todo file or todo archive file 571;; Invoking these commands to visit a todo file or todo archive file
572calls `todo-show' or `todo-find-archive', so that the file is 572;; calls `todo-show' or `todo-find-archive', so that the file is
573displayed correctly." 573;; displayed correctly."
574 :type '(repeat function) 574;; :type '(repeat function)
575 :group 'todo) 575;; :group 'todo)
576 576
577(defun todo-short-file-name (file) 577(defun todo-short-file-name (file)
578 "Return the short form of todo file FILE's name. 578 "Return the short form of todo file FILE's name.
@@ -740,9 +740,12 @@ corresponding todo file, displaying the corresponding category."
740 "Choose a regexp items file: " 740 "Choose a regexp items file: "
741 rxf) 'regexp)))))) 741 rxf) 'regexp))))))
742 (if (file-exists-p fi-file) 742 (if (file-exists-p fi-file)
743 (set-window-buffer 743 (progn
744 (selected-window) 744 (set-window-buffer
745 (set-buffer (find-file-noselect fi-file 'nowarn))) 745 (selected-window)
746 (set-buffer (find-file-noselect fi-file 'nowarn)))
747 (unless (derived-mode-p 'todo-filtered-items-mode)
748 (todo-filtered-items-mode)))
746 (message "There is no %s file for %s" 749 (message "There is no %s file for %s"
747 (cond ((eq todo-show-first 'top) 750 (cond ((eq todo-show-first 'top)
748 "top priorities") 751 "top priorities")
@@ -757,6 +760,9 @@ corresponding todo file, displaying the corresponding category."
757 (unless (todo-check-file file) (throw 'end nil)) 760 (unless (todo-check-file file) (throw 'end nil))
758 (set-window-buffer (selected-window) 761 (set-window-buffer (selected-window)
759 (set-buffer (find-file-noselect file 'nowarn))) 762 (set-buffer (find-file-noselect file 'nowarn)))
763 (if (equal (file-name-extension (buffer-file-name)) "toda")
764 (unless (derived-mode-p 'todo-archive-mode) (todo-archive-mode))
765 (unless (derived-mode-p 'todo-mode) (todo-mode)))
760 ;; When quitting an archive file, show the corresponding 766 ;; When quitting an archive file, show the corresponding
761 ;; category in the corresponding todo file, if it exists. 767 ;; category in the corresponding todo file, if it exists.
762 (when (assoc cat todo-categories) 768 (when (assoc cat todo-categories)
@@ -1449,6 +1455,10 @@ the archive of the file moved to, creating it if it does not exist."
1449 (if (member buf (funcall todo-files-function t)) 1455 (if (member buf (funcall todo-files-function t))
1450 (concat (file-name-sans-extension nfile) ".toda") 1456 (concat (file-name-sans-extension nfile) ".toda")
1451 nfile)) 1457 nfile))
1458 (if (equal (file-name-extension (buffer-file-name)) "toda")
1459 (unless (derived-mode-p 'todo-archive-mode)
1460 (todo-archive-mode))
1461 (unless (derived-mode-p 'todo-mode) (todo-mode)))
1452 (let* ((nfile-short (todo-short-file-name nfile)) 1462 (let* ((nfile-short (todo-short-file-name nfile))
1453 (prompt (concat 1463 (prompt (concat
1454 (format "Todo file \"%s\" already has " 1464 (format "Todo file \"%s\" already has "
@@ -1564,6 +1574,7 @@ archive file and the source category is deleted."
1564 (done-count (todo-get-count 'done cat))) 1574 (done-count (todo-get-count 'done cat)))
1565 ;; Merge into goal todo category. 1575 ;; Merge into goal todo category.
1566 (with-current-buffer (get-buffer (find-file-noselect gfile)) 1576 (with-current-buffer (get-buffer (find-file-noselect gfile))
1577 (unless (derived-mode-p 'todo-mode) (todo-mode))
1567 (widen) 1578 (widen)
1568 (goto-char (point-min)) 1579 (goto-char (point-min))
1569 (let ((buffer-read-only nil)) 1580 (let ((buffer-read-only nil))
@@ -2995,6 +3006,7 @@ displayed."
2995 (when place 3006 (when place
2996 (set-window-buffer (selected-window) 3007 (set-window-buffer (selected-window)
2997 (set-buffer (find-file-noselect archive))) 3008 (set-buffer (find-file-noselect archive)))
3009 (unless (derived-mode-p 'todo-archive-mode) (todo-archive-mode))
2998 (if (member place '(other-archive other-cat)) 3010 (if (member place '(other-archive other-cat))
2999 (setq todo-category-number 1) 3011 (setq todo-category-number 1)
3000 (todo-category-number cat)) 3012 (todo-category-number cat))
@@ -3070,6 +3082,7 @@ this category does not exist in the archive, it is created."
3070 (if (not (or marked all item)) 3082 (if (not (or marked all item))
3071 (throw 'end (message "Only done items can be archived")) 3083 (throw 'end (message "Only done items can be archived"))
3072 (with-current-buffer archive 3084 (with-current-buffer archive
3085 (unless (derived-mode-p 'todo-archive-mode) (todo-archive-mode))
3073 (let (buffer-read-only) 3086 (let (buffer-read-only)
3074 (widen) 3087 (widen)
3075 (goto-char (point-min)) 3088 (goto-char (point-min))
@@ -3091,12 +3104,12 @@ this category does not exist in the archive, it is created."
3091 (todo-update-categories-sexp) 3104 (todo-update-categories-sexp)
3092 ;; If archive is new, save to file now (with 3105 ;; If archive is new, save to file now (with
3093 ;; write-region to avoid prompt for file to save to) 3106 ;; write-region to avoid prompt for file to save to)
3094 ;; to update todo-archives, and to let auto-mode-alist 3107 ;; to update todo-archives, and set the mode for
3095 ;; take effect below on visiting the archive. 3108 ;; visiting the archive below.
3096 (unless (nth 7 (file-attributes afile)) 3109 (unless (nth 7 (file-attributes afile))
3097 (write-region nil nil afile t t) 3110 (write-region nil nil afile t t)
3098 (setq todo-archives (funcall todo-files-function t)) 3111 (setq todo-archives (funcall todo-files-function t))
3099 (kill-buffer)))) 3112 (todo-archive-mode))))
3100 (with-current-buffer tbuf 3113 (with-current-buffer tbuf
3101 (cond 3114 (cond
3102 (all 3115 (all
@@ -3957,7 +3970,9 @@ regexp items."
3957 (setq file (completing-read "Choose a filtered items file: " 3970 (setq file (completing-read "Choose a filtered items file: "
3958 falist nil t nil nil (car falist))) 3971 falist nil t nil nil (car falist)))
3959 (setq file (cdr (assoc-string file falist))) 3972 (setq file (cdr (assoc-string file falist)))
3960 (find-file file))) 3973 (find-file file)
3974 (unless (derived-mode-p 'todo-filtered-items-mode)
3975 (todo-filtered-items-mode))))
3961 3976
3962(defun todo-go-to-source-item () 3977(defun todo-go-to-source-item ()
3963 "Display the file and category of the filtered item at point." 3978 "Display the file and category of the filtered item at point."
@@ -4088,6 +4103,8 @@ multifile commands for further details."
4088 (completing-read "Choose a regexp items file: " 4103 (completing-read "Choose a regexp items file: "
4089 rxf) 'regexp)))) 4104 rxf) 'regexp))))
4090 (find-file fname) 4105 (find-file fname)
4106 (unless (derived-mode-p 'todo-filtered-items-mode)
4107 (todo-filtered-items-mode))
4091 (todo-prefix-overlays) 4108 (todo-prefix-overlays)
4092 (todo-check-filtered-items-file)) 4109 (todo-check-filtered-items-file))
4093 (t 4110 (t
@@ -4341,6 +4358,9 @@ its priority has changed, and `same' otherwise."
4341 todo-global-current-todo-file))) 4358 todo-global-current-todo-file)))
4342 (find-file-noselect file) 4359 (find-file-noselect file)
4343 (with-current-buffer (find-buffer-visiting file) 4360 (with-current-buffer (find-buffer-visiting file)
4361 (if archive
4362 (unless (derived-mode-p 'todo-archive-mode) (todo-archive-mode))
4363 (unless (derived-mode-p 'todo-mode) (todo-mode)))
4344 (save-restriction 4364 (save-restriction
4345 (widen) 4365 (widen)
4346 (goto-char (point-min)) 4366 (goto-char (point-min))
@@ -4917,23 +4937,28 @@ the file."
4917 ;; Make sure to include newly created archives, e.g. due to 4937 ;; Make sure to include newly created archives, e.g. due to
4918 ;; todo-move-category. 4938 ;; todo-move-category.
4919 (when (member archive (funcall todo-files-function t)) 4939 (when (member archive (funcall todo-files-function t))
4920 (let ((archive-count 0)) 4940 (let ((archive-count 0)
4921 (with-current-buffer (find-file-noselect archive) 4941 (visiting (find-buffer-visiting archive)))
4922 (widen) 4942 (with-current-buffer (or visiting
4923 (goto-char (point-min)) 4943 (find-file-noselect archive))
4924 (when (re-search-forward 4944 (save-excursion
4925 (concat "^" (regexp-quote todo-category-beg) 4945 (save-restriction
4926 cat "$") 4946 (widen)
4927 (point-max) t) 4947 (goto-char (point-min))
4928 (forward-line) 4948 (when (re-search-forward
4929 (while (not (or (looking-at 4949 (concat "^" (regexp-quote todo-category-beg)
4930 (concat 4950 cat "$")
4931 (regexp-quote todo-category-beg) 4951 (point-max) t)
4932 "\\(.*\\)\n")) 4952 (forward-line)
4933 (eobp))) 4953 (while (not (or (looking-at
4934 (when (looking-at todo-done-string-start) 4954 (concat
4935 (setq archive-count (1+ archive-count))) 4955 (regexp-quote todo-category-beg)
4936 (forward-line)))) 4956 "\\(.*\\)\n"))
4957 (eobp)))
4958 (when (looking-at todo-done-string-start)
4959 (setq archive-count (1+ archive-count)))
4960 (forward-line)))))
4961 (unless visiting (kill-buffer)))
4937 (todo-update-count 'archived archive-count cat)))) 4962 (todo-update-count 'archived archive-count cat))))
4938 ((looking-at todo-done-string-start) 4963 ((looking-at todo-done-string-start)
4939 (todo-update-count 'done 1 cat)) 4964 (todo-update-count 'done 1 cat))
@@ -5157,6 +5182,11 @@ Overrides `diary-goto-entry'."
5157 (if (not (and (file-exists-p file) 5182 (if (not (and (file-exists-p file)
5158 (find-file-other-window file))) 5183 (find-file-other-window file)))
5159 (message "Unable to locate this diary entry") 5184 (message "Unable to locate this diary entry")
5185 ;; If it's a Todo file, make sure it's in Todo mode.
5186 (when (and (equal (file-name-directory (file-truename file))
5187 (file-truename todo-directory))
5188 (not (derived-mode-p 'todo-mode)))
5189 (todo-mode))
5160 (when (eq major-mode 'todo-mode) (widen)) 5190 (when (eq major-mode 'todo-mode) (widen))
5161 (goto-char (point-min)) 5191 (goto-char (point-min))
5162 (when (re-search-forward (format "%s.*\\(%s\\)" date content) nil t) 5192 (when (re-search-forward (format "%s.*\\(%s\\)" date content) nil t)
@@ -5596,6 +5626,9 @@ have been removed."
5596 (add-to-list 'files curfile)) 5626 (add-to-list 'files curfile))
5597 (dolist (f files listall) 5627 (dolist (f files listall)
5598 (with-current-buffer (find-file-noselect f 'nowarn) 5628 (with-current-buffer (find-file-noselect f 'nowarn)
5629 (if archive
5630 (unless (derived-mode-p 'todo-archive-mode) (todo-archive-mode))
5631 (unless (derived-mode-p 'todo-mode) (todo-mode)))
5599 ;; Ensure category is properly displayed in case user 5632 ;; Ensure category is properly displayed in case user
5600 ;; switches to file via a non-Todo mode command. And if 5633 ;; switches to file via a non-Todo mode command. And if
5601 ;; done items in category are visible, keep them visible. 5634 ;; done items in category are visible, keep them visible.
@@ -5681,6 +5714,7 @@ categories from `todo-category-completions-files'."
5681 (categories (cond (file0 5714 (categories (cond (file0
5682 (with-current-buffer 5715 (with-current-buffer
5683 (find-file-noselect file0 'nowarn) 5716 (find-file-noselect file0 'nowarn)
5717 (unless (derived-mode-p 'todo-mode) (todo-mode))
5684 (let ((todo-current-todo-file file0)) 5718 (let ((todo-current-todo-file file0))
5685 todo-categories))) 5719 todo-categories)))
5686 ((and add (not file)) 5720 ((and add (not file))
@@ -5960,23 +5994,28 @@ the empty string (i.e., no time string)."
5960 (regexp-quote diary-nonmarking-symbol) "\\)?")) 5994 (regexp-quote diary-nonmarking-symbol) "\\)?"))
5961 (when (not (equal value oldvalue)) 5995 (when (not (equal value oldvalue))
5962 (dolist (f files) 5996 (dolist (f files)
5963 (with-current-buffer (find-file-noselect f) 5997 (let ((buf (find-buffer-visiting f)))
5964 (let (buffer-read-only) 5998 (with-current-buffer (find-file-noselect f)
5965 (widen) 5999 (let (buffer-read-only)
5966 (goto-char (point-min)) 6000 (widen)
5967 (while (not (eobp)) 6001 (goto-char (point-min))
5968 (if (re-search-forward 6002 (while (not (eobp))
5969 (concat "^\\(" todo-done-string-start "[^][]+] \\)?" 6003 (if (re-search-forward
5970 "\\(?1:" (regexp-quote (car oldvalue)) 6004 (concat "^\\(" todo-done-string-start "[^][]+] \\)?"
5971 "\\)" todo-date-pattern "\\( " 6005 "\\(?1:" (regexp-quote (car oldvalue))
5972 diary-time-regexp "\\)?\\(?2:" 6006 "\\)" todo-date-pattern "\\( "
5973 (regexp-quote (cadr oldvalue)) "\\)") 6007 diary-time-regexp "\\)?\\(?2:"
5974 nil t) 6008 (regexp-quote (cadr oldvalue)) "\\)")
5975 (progn 6009 nil t)
5976 (replace-match (nth 0 value) t t nil 1) 6010 (progn
5977 (replace-match (nth 1 value) t t nil 2)) 6011 (replace-match (nth 0 value) t t nil 1)
5978 (forward-line))) 6012 (replace-match (nth 1 value) t t nil 2))
5979 (todo-category-select))))))) 6013 (forward-line)))
6014 (if buf
6015 (when (derived-mode-p 'todo-mode 'todo-archive-mode)
6016 (todo-category-select))
6017 (save-buffer)
6018 (kill-buffer)))))))))
5980 6019
5981(defun todo-reset-done-separator-string (symbol value) 6020(defun todo-reset-done-separator-string (symbol value)
5982 "The :set function for `todo-done-separator-string'." 6021 "The :set function for `todo-done-separator-string'."
@@ -6004,18 +6043,23 @@ the empty string (i.e., no time string)."
6004 (concat "^\\[" (regexp-quote todo-done-string))) 6043 (concat "^\\[" (regexp-quote todo-done-string)))
6005 (when (not (equal value oldvalue)) 6044 (when (not (equal value oldvalue))
6006 (dolist (f files) 6045 (dolist (f files)
6007 (with-current-buffer (find-file-noselect f) 6046 (let ((buf (find-buffer-visiting f)))
6008 (let (buffer-read-only) 6047 (with-current-buffer (find-file-noselect f)
6009 (widen) 6048 (let (buffer-read-only)
6010 (goto-char (point-min)) 6049 (widen)
6011 (while (not (eobp)) 6050 (goto-char (point-min))
6012 (if (re-search-forward 6051 (while (not (eobp))
6013 (concat "^" (regexp-quote todo-nondiary-start) 6052 (if (re-search-forward
6014 "\\(" (regexp-quote oldvalue) "\\)") 6053 (concat "^" (regexp-quote todo-nondiary-start)
6015 nil t) 6054 "\\(" (regexp-quote oldvalue) "\\)")
6016 (replace-match value t t nil 1) 6055 nil t)
6017 (forward-line))) 6056 (replace-match value t t nil 1)
6018 (todo-category-select))))))) 6057 (forward-line)))
6058 (if buf
6059 (when (derived-mode-p 'todo-mode 'todo-archive-mode)
6060 (todo-category-select))
6061 (save-buffer)
6062 (kill-buffer)))))))))
6019 6063
6020(defun todo-reset-comment-string (symbol value) 6064(defun todo-reset-comment-string (symbol value)
6021 "The :set function for user option `todo-comment-string'." 6065 "The :set function for user option `todo-comment-string'."
@@ -6025,19 +6069,23 @@ the empty string (i.e., no time string)."
6025 (custom-set-default symbol value) 6069 (custom-set-default symbol value)
6026 (when (not (equal value oldvalue)) 6070 (when (not (equal value oldvalue))
6027 (dolist (f files) 6071 (dolist (f files)
6028 (with-current-buffer (find-file-noselect f) 6072 (let ((buf (find-buffer-visiting f)))
6029 (let (buffer-read-only) 6073 (with-current-buffer (find-file-noselect f)
6030 (save-excursion 6074 (let (buffer-read-only)
6031 (widen) 6075 (widen)
6032 (goto-char (point-min)) 6076 (goto-char (point-min))
6033 (while (not (eobp)) 6077 (while (not (eobp))
6034 (if (re-search-forward 6078 (if (re-search-forward
6035 (concat 6079 (concat "\\[\\(" (regexp-quote oldvalue)
6036 "\\[\\(" (regexp-quote oldvalue) "\\): [^]]*\\]") 6080 "\\): [^]]*\\]")
6037 nil t) 6081 nil t)
6038 (replace-match value t t nil 1) 6082 (replace-match value t t nil 1)
6039 (forward-line))) 6083 (forward-line)))
6040 (todo-category-select)))))))) 6084 (if buf
6085 (when (derived-mode-p 'todo-mode 'todo-archive-mode)
6086 (todo-category-select))
6087 (save-buffer)
6088 (kill-buffer)))))))))
6041 6089
6042(defun todo-reset-highlight-item (symbol value) 6090(defun todo-reset-highlight-item (symbol value)
6043 "The :set function for user option `todo-highlight-item'." 6091 "The :set function for user option `todo-highlight-item'."
@@ -6435,20 +6483,20 @@ Added to `pre-command-hook' in Todo mode when user option
6435`todo-show-current-file' is set to non-nil." 6483`todo-show-current-file' is set to non-nil."
6436 (setq todo-global-current-todo-file todo-current-todo-file)) 6484 (setq todo-global-current-todo-file todo-current-todo-file))
6437 6485
6438(defun todo-display-as-todo-file () 6486;; (defun todo-display-as-todo-file ()
6439 "Show todo files correctly when visited from outside of Todo mode. 6487;; "Show todo files correctly when visited from outside of Todo mode.
6440Added to `find-file-hook' in Todo mode and Todo Archive mode." 6488;; Added to `find-file-hook' in Todo mode and Todo Archive mode."
6441 (and (member this-command todo-visit-files-commands) 6489;; (and (member this-command todo-visit-files-commands)
6442 (= (- (point-max) (point-min)) (buffer-size)) 6490;; (= (- (point-max) (point-min)) (buffer-size))
6443 (member major-mode '(todo-mode todo-archive-mode)) 6491;; (member major-mode '(todo-mode todo-archive-mode))
6444 (todo-category-select))) 6492;; (todo-category-select)))
6445 6493
6446(defun todo-add-to-buffer-list () 6494;; (defun todo-add-to-buffer-list ()
6447 "Add name of just visited todo file to `todo-file-buffers'. 6495;; "Add name of just visited todo file to `todo-file-buffers'.
6448This function is added to `find-file-hook' in Todo mode." 6496;; This function is added to `find-file-hook' in Todo mode."
6449 (let ((filename (file-truename (buffer-file-name)))) 6497;; (let ((filename (file-truename (buffer-file-name))))
6450 (when (member filename todo-files) 6498;; (when (member filename todo-files)
6451 (add-to-list 'todo-file-buffers filename)))) 6499;; (add-to-list 'todo-file-buffers filename))))
6452 6500
6453(defun todo-update-buffer-list () 6501(defun todo-update-buffer-list ()
6454 "Make current Todo mode buffer file car of `todo-file-buffers'. 6502 "Make current Todo mode buffer file car of `todo-file-buffers'.
@@ -6503,7 +6551,8 @@ Added to `window-configuration-change-hook' in Todo mode."
6503 "Make some settings that apply to multiple Todo modes." 6551 "Make some settings that apply to multiple Todo modes."
6504 (setq-local todo-categories (todo-set-categories)) 6552 (setq-local todo-categories (todo-set-categories))
6505 (setq-local todo-category-number 1) 6553 (setq-local todo-category-number 1)
6506 (add-hook 'find-file-hook 'todo-display-as-todo-file nil t)) 6554 ;; (add-hook 'find-file-hook 'todo-display-as-todo-file nil t)
6555 )
6507 6556
6508(put 'todo-mode 'mode-class 'special) 6557(put 'todo-mode 'mode-class 'special)
6509 6558
@@ -6522,7 +6571,7 @@ Added to `window-configuration-change-hook' in Todo mode."
6522 (setq-local todo-current-todo-file (file-truename (buffer-file-name)))) 6571 (setq-local todo-current-todo-file (file-truename (buffer-file-name))))
6523 (setq-local todo-show-done-only nil) 6572 (setq-local todo-show-done-only nil)
6524 (setq-local todo-categories-with-marks nil) 6573 (setq-local todo-categories-with-marks nil)
6525 (add-hook 'find-file-hook 'todo-add-to-buffer-list nil t) 6574 ;; (add-hook 'find-file-hook 'todo-add-to-buffer-list nil t)
6526 (add-hook 'post-command-hook 'todo-update-buffer-list nil t) 6575 (add-hook 'post-command-hook 'todo-update-buffer-list nil t)
6527 (when todo-show-current-file 6576 (when todo-show-current-file
6528 (add-hook 'pre-command-hook 'todo-show-current-file nil t)) 6577 (add-hook 'pre-command-hook 'todo-show-current-file nil t))
@@ -6591,13 +6640,6 @@ Added to `window-configuration-change-hook' in Todo mode."
6591 (todo-modes-set-1) 6640 (todo-modes-set-1)
6592 (todo-modes-set-2)) 6641 (todo-modes-set-2))
6593 6642
6594;;;###autoload
6595(add-to-list 'auto-mode-alist '("\\.todo\\'" . todo-mode))
6596;;;###autoload
6597(add-to-list 'auto-mode-alist '("\\.toda\\'" . todo-archive-mode))
6598;;;###autoload
6599(add-to-list 'auto-mode-alist '("\\.tod[tyr]\\'" . todo-filtered-items-mode))
6600
6601;; ----------------------------------------------------------------------------- 6643;; -----------------------------------------------------------------------------
6602(provide 'todo-mode) 6644(provide 'todo-mode)
6603 6645