diff options
| author | Stephen Berman | 2013-05-11 00:57:47 +0200 |
|---|---|---|
| committer | Stephen Berman | 2013-05-11 00:57:47 +0200 |
| commit | caa229d50ae09275af0453c44458a00c1c7d110c (patch) | |
| tree | 4e2392fa459074b999ac3121de3b51d0baa146f9 | |
| parent | 1171e4321c9b3a32793934eb83f8c3dc88378dae (diff) | |
| download | emacs-caa229d50ae09275af0453c44458a00c1c7d110c.tar.gz emacs-caa229d50ae09275af0453c44458a00c1c7d110c.zip | |
* todos.el: Rename numerous commands and defcustoms and adjust all
uses, change numerous key bindings, make some basic commands
noninteractive and use them to define the commands, unify
archiving commands.
(todos-directory): Rename from todos-files-directory.
(todos-print-buffer-function): Rename from todos-print-function.
(todos-number-prefix): Rename from todos-number-priorities.
(todos-top-priorities-overrides): Rename from todos-priorities-rules.
(todos-top-priorities): Rename from todos-show-priorities.
(todos-insertion-command-name, todos-insertion-key-bindings):
Use "todos-insert-item-".
(todos-key-bindings, todos-archive-mode-map)
(todos-categories-mode-map, todos-filtered-items-mode-map):
Adjust to renamed commands, make bindings more systematic,
reorder entries.
(todos-show-categories-table): Rename from todos-display-categories.
(todos-sort-categories-alphabetically-or-by-priority): Rename from
todos-display-categories-alphabetically-or-by-priority.
(todos-sort-categories-by-todo): Rename from
todos-display-categories-sorted-by-todo.
(todos-sort-categories-by-diary): Rename from
todos-display-categories-sorted-by-diary.
(todos-sort-categories-by-done): Rename from
todos-display-categories-sorted-by-done.
(todos-sort-categories-by-archived): Rename from
todos-display-categories-sorted-by-archived.
(todos-print-buffer): Rename function from todos-print.
(todos-print-buffer-to-file): Rename from todos-print-to-file.
(todos-go-to-source-item): Rename from todos-jump-to-item.
(todos-forward-item, todos-backward-item): Remove interactive form
and move most of doc string and prefix argument error checking to...
(todos-next-item, todos-previous-item): ...these new commands,
which use the preceding functions.
(todos-next-button): Rename from todos-forward-button.
(todos-previous-button): Rename from todos-backward-button.
(todos-toggle-prefix-numbers): Rename from
todos-hide-show-item-numbering.
(todos-toggle-view-done-items): Rename from todos-hide-show-done-items.
(todos-toggle-view-done-only): Rename from todos-show-done-only.
(todos-toggle-item-highlighting): Rename from todos-highlight-item.
(todos-toggle-item-header): Rename from todos-hide-show-date-time.
(todos-toggle-mark-item): Rename from todos-mark-unmark-item.
(todos-filter-top-priorities): Rename from todos-top-priorities.
(todos-filter-top-priorities-multifile): Rename from
todos-top-priorities-multifile.
(todos-filter-diary-items): Rename from todos-diary-items.
(todos-filter-diary-items-multifile): Rename from
todos-diary-items-multifile.
(todos-filter-regexp-items): Rename from todos-regexp-items.
(todos-filter-regexp-items-multifile): Rename from
todos-regexp-items-multifile.
(todos-insert-item-1): Remove interactive form, since
todos-insert-item is generated like other item insertion commands.
(todos-edit-file): Rename from todos-edit-multiline.
(todos-item-undone): Rename from todos-item-undo.
(todos-archive-done-item): Add raw prefix spec to interactive form
and use it to test for archiving all done items in category;
reorder tests in function body accordingly.
(todos-archive-category-done-items): Remove.
| -rw-r--r-- | lisp/calendar/ChangeLog | 62 | ||||
| -rw-r--r-- | lisp/calendar/todos.el | 630 |
2 files changed, 385 insertions, 307 deletions
diff --git a/lisp/calendar/ChangeLog b/lisp/calendar/ChangeLog index 2619ef72a54..10b2d750344 100644 --- a/lisp/calendar/ChangeLog +++ b/lisp/calendar/ChangeLog | |||
| @@ -1,3 +1,65 @@ | |||
| 1 | 2013-05-10 Stephen Berman <stephen.berman@gmx.net> | ||
| 2 | |||
| 3 | * todos.el: Rename numerous commands and defcustoms and adjust all | ||
| 4 | uses, change numerous key bindings, make some basic commands | ||
| 5 | noninteractive and use them to define the commands, unify | ||
| 6 | archiving commands. | ||
| 7 | (todos-directory): Rename from todos-files-directory. | ||
| 8 | (todos-print-buffer-function): Rename from todos-print-function. | ||
| 9 | (todos-number-prefix): Rename from todos-number-priorities. | ||
| 10 | (todos-top-priorities-overrides): Rename from todos-priorities-rules. | ||
| 11 | (todos-top-priorities): Rename from todos-show-priorities. | ||
| 12 | (todos-insertion-command-name, todos-insertion-key-bindings): | ||
| 13 | Use "todos-insert-item-". | ||
| 14 | (todos-key-bindings, todos-archive-mode-map) | ||
| 15 | (todos-categories-mode-map, todos-filtered-items-mode-map): | ||
| 16 | Adjust to renamed commands, make bindings more systematic, | ||
| 17 | reorder entries. | ||
| 18 | (todos-show-categories-table): Rename from todos-display-categories. | ||
| 19 | (todos-sort-categories-alphabetically-or-by-priority): Rename from | ||
| 20 | todos-display-categories-alphabetically-or-by-priority. | ||
| 21 | (todos-sort-categories-by-todo): Rename from | ||
| 22 | todos-display-categories-sorted-by-todo. | ||
| 23 | (todos-sort-categories-by-diary): Rename from | ||
| 24 | todos-display-categories-sorted-by-diary. | ||
| 25 | (todos-sort-categories-by-done): Rename from | ||
| 26 | todos-display-categories-sorted-by-done. | ||
| 27 | (todos-sort-categories-by-archived): Rename from | ||
| 28 | todos-display-categories-sorted-by-archived. | ||
| 29 | (todos-print-buffer): Rename function from todos-print. | ||
| 30 | (todos-print-buffer-to-file): Rename from todos-print-to-file. | ||
| 31 | (todos-go-to-source-item): Rename from todos-jump-to-item. | ||
| 32 | (todos-forward-item, todos-backward-item): Remove interactive form | ||
| 33 | and move most of doc string and prefix argument error checking to... | ||
| 34 | (todos-next-item, todos-previous-item): ...these new commands, | ||
| 35 | which use the preceding functions. | ||
| 36 | (todos-next-button): Rename from todos-forward-button. | ||
| 37 | (todos-previous-button): Rename from todos-backward-button. | ||
| 38 | (todos-toggle-prefix-numbers): Rename from | ||
| 39 | todos-hide-show-item-numbering. | ||
| 40 | (todos-toggle-view-done-items): Rename from todos-hide-show-done-items. | ||
| 41 | (todos-toggle-view-done-only): Rename from todos-show-done-only. | ||
| 42 | (todos-toggle-item-highlighting): Rename from todos-highlight-item. | ||
| 43 | (todos-toggle-item-header): Rename from todos-hide-show-date-time. | ||
| 44 | (todos-toggle-mark-item): Rename from todos-mark-unmark-item. | ||
| 45 | (todos-filter-top-priorities): Rename from todos-top-priorities. | ||
| 46 | (todos-filter-top-priorities-multifile): Rename from | ||
| 47 | todos-top-priorities-multifile. | ||
| 48 | (todos-filter-diary-items): Rename from todos-diary-items. | ||
| 49 | (todos-filter-diary-items-multifile): Rename from | ||
| 50 | todos-diary-items-multifile. | ||
| 51 | (todos-filter-regexp-items): Rename from todos-regexp-items. | ||
| 52 | (todos-filter-regexp-items-multifile): Rename from | ||
| 53 | todos-regexp-items-multifile. | ||
| 54 | (todos-insert-item-1): Remove interactive form, since | ||
| 55 | todos-insert-item is generated like other item insertion commands. | ||
| 56 | (todos-edit-file): Rename from todos-edit-multiline. | ||
| 57 | (todos-item-undone): Rename from todos-item-undo. | ||
| 58 | (todos-archive-done-item): Add raw prefix spec to interactive form | ||
| 59 | and use it to test for archiving all done items in category; | ||
| 60 | reorder tests in function body accordingly. | ||
| 61 | (todos-archive-category-done-items): Remove. | ||
| 62 | |||
| 1 | 2013-04-27 Stephen Berman <stephen.berman@gmx.net> | 63 | 2013-04-27 Stephen Berman <stephen.berman@gmx.net> |
| 2 | 64 | ||
| 3 | * todos.el (todos-edit-multiline-item): Make a no-op when point is | 65 | * todos.el (todos-edit-multiline-item): Make a no-op when point is |
diff --git a/lisp/calendar/todos.el b/lisp/calendar/todos.el index 24a39cf136d..e203949c10a 100644 --- a/lisp/calendar/todos.el +++ b/lisp/calendar/todos.el | |||
| @@ -40,7 +40,7 @@ | |||
| 40 | :version "24.2" | 40 | :version "24.2" |
| 41 | :group 'calendar) | 41 | :group 'calendar) |
| 42 | 42 | ||
| 43 | (defcustom todos-files-directory (locate-user-emacs-file "todos/") | 43 | (defcustom todos-directory (locate-user-emacs-file "todos/") |
| 44 | "Directory where user's Todos files are saved." | 44 | "Directory where user's Todos files are saved." |
| 45 | :type 'directory | 45 | :type 'directory |
| 46 | :group 'todos) | 46 | :group 'todos) |
| @@ -48,12 +48,12 @@ | |||
| 48 | (defun todos-files (&optional archives) | 48 | (defun todos-files (&optional archives) |
| 49 | "Default value of `todos-files-function'. | 49 | "Default value of `todos-files-function'. |
| 50 | This returns the case-insensitive alphabetically sorted list of | 50 | This returns the case-insensitive alphabetically sorted list of |
| 51 | file truenames in `todos-files-directory' with the extension | 51 | file truenames in `todos-directory' with the extension |
| 52 | \".todo\". With non-nil ARCHIVES return the list of archive file | 52 | \".todo\". With non-nil ARCHIVES return the list of archive file |
| 53 | truenames (those with the extension \".toda\")." | 53 | truenames (those with the extension \".toda\")." |
| 54 | (let ((files (if (file-exists-p todos-files-directory) | 54 | (let ((files (if (file-exists-p todos-directory) |
| 55 | (mapcar 'file-truename | 55 | (mapcar 'file-truename |
| 56 | (directory-files todos-files-directory t | 56 | (directory-files todos-directory t |
| 57 | (if archives "\.toda$" "\.todo$") t))))) | 57 | (if archives "\.toda$" "\.todo$") t))))) |
| 58 | (sort files (lambda (s1 s2) (let ((cis1 (upcase s1)) | 58 | (sort files (lambda (s1 s2) (let ((cis1 (upcase s1)) |
| 59 | (cis2 (upcase s2))) | 59 | (cis2 (upcase s2))) |
| @@ -162,8 +162,8 @@ means prompt user and omit comment only on confirmation." | |||
| 162 | (const :tag "Ask" ask)) | 162 | (const :tag "Ask" ask)) |
| 163 | :group 'todos) | 163 | :group 'todos) |
| 164 | 164 | ||
| 165 | (defcustom todos-print-function 'ps-print-buffer-with-faces | 165 | (defcustom todos-print-buffer-function 'ps-print-buffer-with-faces |
| 166 | "Function called to print buffer content; see `todos-print'." | 166 | "Function called to print buffer content; see `todos-print-buffer'." |
| 167 | :type 'symbol | 167 | :type 'symbol |
| 168 | :group 'todos) | 168 | :group 'todos) |
| 169 | 169 | ||
| @@ -203,7 +203,7 @@ todo-mode.el." | |||
| 203 | :set 'todos-reset-prefix | 203 | :set 'todos-reset-prefix |
| 204 | :group 'todos-mode-display) | 204 | :group 'todos-mode-display) |
| 205 | 205 | ||
| 206 | (defcustom todos-number-priorities t | 206 | (defcustom todos-number-prefix t |
| 207 | "Non-nil to prefix items with consecutively increasing integers. | 207 | "Non-nil to prefix items with consecutively increasing integers. |
| 208 | These reflect the priorities of the items in each category." | 208 | These reflect the priorities of the items in each category." |
| 209 | :type 'boolean | 209 | :type 'boolean |
| @@ -212,7 +212,7 @@ These reflect the priorities of the items in each category." | |||
| 212 | :group 'todos-mode-display) | 212 | :group 'todos-mode-display) |
| 213 | 213 | ||
| 214 | (defun todos-reset-prefix (symbol value) | 214 | (defun todos-reset-prefix (symbol value) |
| 215 | "The :set function for `todos-prefix' and `todos-number-priorities'." | 215 | "The :set function for `todos-prefix' and `todos-number-prefix'." |
| 216 | (let ((oldvalue (symbol-value symbol)) | 216 | (let ((oldvalue (symbol-value symbol)) |
| 217 | (files todos-file-buffers)) | 217 | (files todos-file-buffers)) |
| 218 | (custom-set-default symbol value) | 218 | (custom-set-default symbol value) |
| @@ -352,7 +352,7 @@ Moving by category todos or archive file (with | |||
| 352 | \\[todos-forward-category] and \\[todos-backward-category]) skips | 352 | \\[todos-forward-category] and \\[todos-backward-category]) skips |
| 353 | categories that contain only archived items. Other commands | 353 | categories that contain only archived items. Other commands |
| 354 | still recognize these categories. In Todos Categories | 354 | still recognize these categories. In Todos Categories |
| 355 | mode (reached with \\[todos-display-categories]) these categories | 355 | mode (reached with \\[todos-show-categories-table]) these categories |
| 356 | shown in `todos-archived-only' face and clicking them in Todos | 356 | shown in `todos-archived-only' face and clicking them in Todos |
| 357 | Categories mode visits the archived categories." | 357 | Categories mode visits the archived categories." |
| 358 | :type 'boolean | 358 | :type 'boolean |
| @@ -366,7 +366,7 @@ Categories mode visits the archived categories." | |||
| 366 | :group 'todos-mode-display) | 366 | :group 'todos-mode-display) |
| 367 | 367 | ||
| 368 | (defun todos-reset-highlight-item (symbol value) | 368 | (defun todos-reset-highlight-item (symbol value) |
| 369 | "The :set function for `todos-highlight-item'." | 369 | "The :set function for `todos-toggle-item-highlighting'." |
| 370 | (let ((oldvalue (symbol-value symbol)) | 370 | (let ((oldvalue (symbol-value symbol)) |
| 371 | (files (append todos-files todos-archives))) | 371 | (files (append todos-files todos-archives))) |
| 372 | (custom-set-default symbol value) | 372 | (custom-set-default symbol value) |
| @@ -498,8 +498,8 @@ current time, if nil, they include it." | |||
| 498 | :version "24.2" | 498 | :version "24.2" |
| 499 | :group 'todos) | 499 | :group 'todos) |
| 500 | 500 | ||
| 501 | (defcustom todos-priorities-rules nil | 501 | (defcustom todos-top-priorities-overrides nil ;FIXME: doc string |
| 502 | "List of rules giving how many items `todos-top-priorities' shows. | 502 | "List of rules giving how many items `todos-filter-top-priorities' shows. |
| 503 | This variable should be set interactively by | 503 | This variable should be set interactively by |
| 504 | `\\[todos-set-top-priorities-in-file]' or | 504 | `\\[todos-set-top-priorities-in-file]' or |
| 505 | `\\[todos-set-top-priorities-in-category]'. | 505 | `\\[todos-set-top-priorities-in-category]'. |
| @@ -513,10 +513,8 @@ items in that category, which overrides NUM." | |||
| 513 | :type 'sexp | 513 | :type 'sexp |
| 514 | :group 'todos-filtered) | 514 | :group 'todos-filtered) |
| 515 | 515 | ||
| 516 | ;; FIXME: rename to todos-top-priorities AFTER renaming command | 516 | (defcustom todos-top-priorities 1 |
| 517 | ;; todos-top-priorities to todos-filter-top-priorities | 517 | "Default number of top priorities shown by `todos-filter-top-priorities'." |
| 518 | (defcustom todos-show-priorities 1 | ||
| 519 | "Default number of top priorities shown by `todos-top-priorities'." | ||
| 520 | :type 'integer | 518 | :type 'integer |
| 521 | :group 'todos-filtered) | 519 | :group 'todos-filtered) |
| 522 | 520 | ||
| @@ -996,7 +994,7 @@ Todos categories are numbered starting from 1.") | |||
| 996 | 994 | ||
| 997 | (defvar todos-show-done-only nil | 995 | (defvar todos-show-done-only nil |
| 998 | "If non-nil display only done items in current category. | 996 | "If non-nil display only done items in current category. |
| 999 | Set by the command `todos-show-done-only' and used by | 997 | Set by the command `todos-toggle-view-done-only' and used by |
| 1000 | `todos-category-select'.") | 998 | `todos-category-select'.") |
| 1001 | 999 | ||
| 1002 | (defun todos-reset-and-enable-done-separator () | 1000 | (defun todos-reset-and-enable-done-separator () |
| @@ -1057,7 +1055,7 @@ short Todos Archive or Top Priorities file name, respectively." | |||
| 1057 | ;; NOP if there is no Todos file yet (i.e. don't concatenate nil). | 1055 | ;; NOP if there is no Todos file yet (i.e. don't concatenate nil). |
| 1058 | (when name | 1056 | (when name |
| 1059 | (file-truename | 1057 | (file-truename |
| 1060 | (concat todos-files-directory name | 1058 | (concat todos-directory name |
| 1061 | (cond ((eq type 'archive) ".toda") | 1059 | (cond ((eq type 'archive) ".toda") |
| 1062 | ((eq type 'top) ".todt") | 1060 | ((eq type 'top) ".todt") |
| 1063 | ((eq type 'diary) ".tody") | 1061 | ((eq type 'diary) ".tody") |
| @@ -1561,9 +1559,10 @@ The final element is \"*\", indicating an unspecified month.") | |||
| 1561 | (defun todos-marked-item-p () | 1559 | (defun todos-marked-item-p () |
| 1562 | "Non-nil if this item begins with `todos-item-mark'. | 1560 | "Non-nil if this item begins with `todos-item-mark'. |
| 1563 | In that case, return the item's prefix overlay." | 1561 | In that case, return the item's prefix overlay." |
| 1564 | ;; If a todos-item-insert command is called on a Todos file before | ||
| 1565 | ;; it is visited, it has no prefix overlays, so conditionalize: | ||
| 1566 | (let* ((ov (todos-get-overlay 'prefix)) | 1562 | (let* ((ov (todos-get-overlay 'prefix)) |
| 1563 | ;; If an item insertion command is called on a Todos file | ||
| 1564 | ;; before it is visited, it has no prefix overlays yet, so | ||
| 1565 | ;; check for this. | ||
| 1567 | (pref (when ov (overlay-get ov 'before-string))) | 1566 | (pref (when ov (overlay-get ov 'before-string))) |
| 1568 | (marked (when pref | 1567 | (marked (when pref |
| 1569 | (string-match (concat "^" (regexp-quote todos-item-mark)) | 1568 | (string-match (concat "^" (regexp-quote todos-item-mark)) |
| @@ -1586,7 +1585,7 @@ The final element is \"*\", indicating an unspecified month.") | |||
| 1586 | (defun todos-prefix-overlays () | 1585 | (defun todos-prefix-overlays () |
| 1587 | "Update the prefix overlays of the current category's items. | 1586 | "Update the prefix overlays of the current category's items. |
| 1588 | The overlay's value is the string `todos-prefix' or with non-nil | 1587 | The overlay's value is the string `todos-prefix' or with non-nil |
| 1589 | `todos-number-priorities' an integer in the sequence from 1 to | 1588 | `todos-number-prefix' an integer in the sequence from 1 to |
| 1590 | the number of todo or done items in the category indicating the | 1589 | the number of todo or done items in the category indicating the |
| 1591 | item's priority. Todo and done items are numbered independently | 1590 | item's priority. Todo and done items are numbered independently |
| 1592 | of each other." | 1591 | of each other." |
| @@ -1594,8 +1593,8 @@ of each other." | |||
| 1594 | (cat-tp (or (cdr (assoc-string | 1593 | (cat-tp (or (cdr (assoc-string |
| 1595 | (todos-current-category) | 1594 | (todos-current-category) |
| 1596 | (nth 2 (assoc-string todos-current-todos-file | 1595 | (nth 2 (assoc-string todos-current-todos-file |
| 1597 | todos-priorities-rules)))) | 1596 | todos-top-priorities-overrides)))) |
| 1598 | todos-show-priorities)) | 1597 | todos-top-priorities)) |
| 1599 | done prefix) | 1598 | done prefix) |
| 1600 | (save-excursion | 1599 | (save-excursion |
| 1601 | (goto-char (point-min)) | 1600 | (goto-char (point-min)) |
| @@ -1612,7 +1611,7 @@ of each other." | |||
| 1612 | (setq num 1 | 1611 | (setq num 1 |
| 1613 | done t)) | 1612 | done t)) |
| 1614 | (setq prefix (concat (propertize | 1613 | (setq prefix (concat (propertize |
| 1615 | (if todos-number-priorities | 1614 | (if todos-number-prefix |
| 1616 | (number-to-string num) | 1615 | (number-to-string num) |
| 1617 | todos-prefix) | 1616 | todos-prefix) |
| 1618 | 'face | 1617 | 'face |
| @@ -1652,11 +1651,11 @@ otherwise, a new file name is allowed." | |||
| 1652 | (unless files | 1651 | (unless files |
| 1653 | ;; Trigger prompt for initial file. | 1652 | ;; Trigger prompt for initial file. |
| 1654 | "")))) | 1653 | "")))) |
| 1655 | (unless (file-exists-p todos-files-directory) | 1654 | (unless (file-exists-p todos-directory) |
| 1656 | (make-directory todos-files-directory)) | 1655 | (make-directory todos-directory)) |
| 1657 | (unless mustmatch | 1656 | (unless mustmatch |
| 1658 | (setq file (todos-validate-name file 'file))) | 1657 | (setq file (todos-validate-name file 'file))) |
| 1659 | (setq file (file-truename (concat todos-files-directory file | 1658 | (setq file (file-truename (concat todos-directory file |
| 1660 | (if archive ".toda" ".todo")))))) | 1659 | (if archive ".toda" ".todo")))))) |
| 1661 | 1660 | ||
| 1662 | (defun todos-read-category (prompt &optional match-type file) | 1661 | (defun todos-read-category (prompt &optional match-type file) |
| @@ -1933,7 +1932,7 @@ the empty string (i.e., no time string)." | |||
| 1933 | (setq todos-multiple-filter-files | 1932 | (setq todos-multiple-filter-files |
| 1934 | (mapcar (lambda (f) | 1933 | (mapcar (lambda (f) |
| 1935 | (file-truename | 1934 | (file-truename |
| 1936 | (concat todos-files-directory | 1935 | (concat todos-directory |
| 1937 | f ".todo"))) | 1936 | f ".todo"))) |
| 1938 | (widget-value | 1937 | (widget-value |
| 1939 | todos-multiple-filter-files-widget))) | 1938 | todos-multiple-filter-files-widget))) |
| @@ -1956,8 +1955,8 @@ is nil, visit an appropriate file containing the list of filtered | |||
| 1956 | items; if there is no such file, or with non-nil NEW, build the | 1955 | items; if there is no such file, or with non-nil NEW, build the |
| 1957 | list and display it. | 1956 | list and display it. |
| 1958 | 1957 | ||
| 1959 | See the document strings of the commands `todos-top-priorities', | 1958 | See the document strings of the commands `todos-filter-top-priorities', |
| 1960 | `todos-diary-items', `todos-regexp-items', and those of the | 1959 | `todos-filter-diary-items', `todos-filter-regexp-items', and those of the |
| 1961 | corresponding multifile commands for further details. " | 1960 | corresponding multifile commands for further details. " |
| 1962 | (let* ((top (eq filter 'top)) | 1961 | (let* ((top (eq filter 'top)) |
| 1963 | (diary (eq filter 'diary)) | 1962 | (diary (eq filter 'diary)) |
| @@ -1974,13 +1973,13 @@ corresponding multifile commands for further details. " | |||
| 1974 | (fname (if (equal flist 'quit) | 1973 | (fname (if (equal flist 'quit) |
| 1975 | ;; Pressed `cancel' in t-m-f-f file selection dialog. | 1974 | ;; Pressed `cancel' in t-m-f-f file selection dialog. |
| 1976 | (keyboard-quit) | 1975 | (keyboard-quit) |
| 1977 | (concat todos-files-directory | 1976 | (concat todos-directory |
| 1978 | (mapconcat 'todos-short-file-name flist "-") | 1977 | (mapconcat 'todos-short-file-name flist "-") |
| 1979 | (cond (top ".todt") | 1978 | (cond (top ".todt") |
| 1980 | (diary ".tody") | 1979 | (diary ".tody") |
| 1981 | (regexp ".todr"))))) | 1980 | (regexp ".todr"))))) |
| 1982 | (rxfiles (when regexp | 1981 | (rxfiles (when regexp |
| 1983 | (directory-files todos-files-directory t ".*\\.todr$" t))) | 1982 | (directory-files todos-directory t ".*\\.todr$" t))) |
| 1984 | (file-exists (or (file-exists-p fname) rxfiles))) | 1983 | (file-exists (or (file-exists-p fname) rxfiles))) |
| 1985 | (cond ((and top new (natnump new)) | 1984 | (cond ((and top new (natnump new)) |
| 1986 | (todos-filter-items-1 (cons 'top new) flist)) | 1985 | (todos-filter-items-1 (cons 'top new) flist)) |
| @@ -2003,7 +2002,7 @@ corresponding multifile commands for further details. " | |||
| 2003 | (defun todos-filter-items-1 (filter file-list) | 2002 | (defun todos-filter-items-1 (filter file-list) |
| 2004 | "Internal subroutine called by `todos-filter-items'. | 2003 | "Internal subroutine called by `todos-filter-items'. |
| 2005 | The values of FILTER and FILE-LIST are passed from the caller." | 2004 | The values of FILTER and FILE-LIST are passed from the caller." |
| 2006 | (let ((num (if (consp filter) (cdr filter) todos-show-priorities)) | 2005 | (let ((num (if (consp filter) (cdr filter) todos-top-priorities)) |
| 2007 | (buf (get-buffer-create todos-filtered-items-buffer)) | 2006 | (buf (get-buffer-create todos-filtered-items-buffer)) |
| 2008 | (multifile (> (length file-list) 1)) | 2007 | (multifile (> (length file-list) 1)) |
| 2009 | regexp fname bufstr cat beg end done) | 2008 | regexp fname bufstr cat beg end done) |
| @@ -2026,7 +2025,7 @@ The values of FILTER and FILE-LIST are passed from the caller." | |||
| 2026 | (with-temp-buffer | 2025 | (with-temp-buffer |
| 2027 | (when (and todos-filter-done-items (eq filter 'regexp)) | 2026 | (when (and todos-filter-done-items (eq filter 'regexp)) |
| 2028 | ;; If there is a corresponding archive file for the Todos file, | 2027 | ;; If there is a corresponding archive file for the Todos file, |
| 2029 | ;; insert it first and add identifiers for todos-jump-to-item. | 2028 | ;; insert it first and add identifiers for todos-go-to-source-item. |
| 2030 | (let ((arch (concat (file-name-sans-extension f) ".toda"))) | 2029 | (let ((arch (concat (file-name-sans-extension f) ".toda"))) |
| 2031 | (when (file-exists-p arch) | 2030 | (when (file-exists-p arch) |
| 2032 | (insert-file-contents arch) | 2031 | (insert-file-contents arch) |
| @@ -2055,11 +2054,11 @@ The values of FILTER and FILE-LIST are passed from the caller." | |||
| 2055 | (let (fnum) | 2054 | (let (fnum) |
| 2056 | ;; Unless the number of top priorities to show was | 2055 | ;; Unless the number of top priorities to show was |
| 2057 | ;; passed by the caller, the file-wide value from | 2056 | ;; passed by the caller, the file-wide value from |
| 2058 | ;; `todos-priorities-rules', if non-nil, overrides | 2057 | ;; `todos-top-priorities-overrides', if non-nil, overrides |
| 2059 | ;; `todos-show-priorities'. | 2058 | ;; `todos-top-priorities'. |
| 2060 | (unless (consp filter) | 2059 | (unless (consp filter) |
| 2061 | (setq fnum (or (nth 1 (assoc f todos-priorities-rules)) | 2060 | (setq fnum (or (nth 1 (assoc f todos-top-priorities-overrides)) |
| 2062 | todos-show-priorities))) | 2061 | todos-top-priorities))) |
| 2063 | (while (re-search-forward | 2062 | (while (re-search-forward |
| 2064 | (concat "^" (regexp-quote todos-category-beg) "\\(.+\\)\n") | 2063 | (concat "^" (regexp-quote todos-category-beg) "\\(.+\\)\n") |
| 2065 | nil t) | 2064 | nil t) |
| @@ -2067,12 +2066,12 @@ The values of FILTER and FILE-LIST are passed from the caller." | |||
| 2067 | (let (cnum) | 2066 | (let (cnum) |
| 2068 | ;; Unless the number of top priorities to show was | 2067 | ;; Unless the number of top priorities to show was |
| 2069 | ;; passed by the caller, the category-wide value | 2068 | ;; passed by the caller, the category-wide value |
| 2070 | ;; from `todos-priorities-rules', if non-nil, | 2069 | ;; from `todos-top-priorities-overrides', if non-nil, |
| 2071 | ;; overrides a non-nil file-wide value from | 2070 | ;; overrides a non-nil file-wide value from |
| 2072 | ;; `todos-priorities-rules' as well as | 2071 | ;; `todos-top-priorities-overrides' as well as |
| 2073 | ;; `todos-show-priorities'. | 2072 | ;; `todos-top-priorities'. |
| 2074 | (unless (consp filter) | 2073 | (unless (consp filter) |
| 2075 | (let ((cats (nth 2 (assoc f todos-priorities-rules)))) | 2074 | (let ((cats (nth 2 (assoc f todos-top-priorities-overrides)))) |
| 2076 | (setq cnum (or (cdr (assoc cat cats)) fnum)))) | 2075 | (setq cnum (or (cdr (assoc cat cats)) fnum)))) |
| 2077 | (delete-region (match-beginning 0) (match-end 0)) | 2076 | (delete-region (match-beginning 0) (match-end 0)) |
| 2078 | (setq beg (point)) ; First item in the current category. | 2077 | (setq beg (point)) ; First item in the current category. |
| @@ -2159,7 +2158,7 @@ The values of FILTER and FILE-LIST are passed from the caller." | |||
| 2159 | (goto-char (point-min))))) | 2158 | (goto-char (point-min))))) |
| 2160 | 2159 | ||
| 2161 | (defun todos-set-top-priorities (&optional arg) | 2160 | (defun todos-set-top-priorities (&optional arg) |
| 2162 | "Set number of top priorities shown by `todos-top-priorities'. | 2161 | "Set number of top priorities shown by `todos-filter-top-priorities'. |
| 2163 | With non-nil ARG, set the number only for the current Todos | 2162 | With non-nil ARG, set the number only for the current Todos |
| 2164 | category; otherwise, set the number for all categories in the | 2163 | category; otherwise, set the number for all categories in the |
| 2165 | current Todos file. | 2164 | current Todos file. |
| @@ -2167,15 +2166,15 @@ current Todos file. | |||
| 2167 | Calling this function via either of the commands | 2166 | Calling this function via either of the commands |
| 2168 | `todos-set-top-priorities-in-file' or | 2167 | `todos-set-top-priorities-in-file' or |
| 2169 | `todos-set-top-priorities-in-category' is the recommended way to | 2168 | `todos-set-top-priorities-in-category' is the recommended way to |
| 2170 | set the user customizable option `todos-priorities-rules'." | 2169 | set the user customizable option `todos-top-priorities-overrides'." |
| 2171 | (let* ((cat (todos-current-category)) | 2170 | (let* ((cat (todos-current-category)) |
| 2172 | (file todos-current-todos-file) | 2171 | (file todos-current-todos-file) |
| 2173 | (rules todos-priorities-rules) | 2172 | (rules todos-top-priorities-overrides) |
| 2174 | (frule (assoc-string file rules)) | 2173 | (frule (assoc-string file rules)) |
| 2175 | (crule (assoc-string cat (nth 2 frule))) | 2174 | (crule (assoc-string cat (nth 2 frule))) |
| 2176 | (crules (nth 2 frule)) | 2175 | (crules (nth 2 frule)) |
| 2177 | (cur (or (if arg (cdr crule) (nth 1 frule)) | 2176 | (cur (or (if arg (cdr crule) (nth 1 frule)) |
| 2178 | todos-show-priorities)) | 2177 | todos-top-priorities)) |
| 2179 | (prompt (if arg (concat "Number of top priorities in this category" | 2178 | (prompt (if arg (concat "Number of top priorities in this category" |
| 2180 | " (currently %d): ") | 2179 | " (currently %d): ") |
| 2181 | (concat "Default number of top priorities per category" | 2180 | (concat "Default number of top priorities per category" |
| @@ -2194,7 +2193,7 @@ set the user customizable option `todos-priorities-rules'." | |||
| 2194 | (list file cur nrule) | 2193 | (list file cur nrule) |
| 2195 | nrule) | 2194 | nrule) |
| 2196 | (delete frule rules))) | 2195 | (delete frule rules))) |
| 2197 | (customize-save-variable 'todos-priorities-rules rules) | 2196 | (customize-save-variable 'todos-top-priorities-overrides rules) |
| 2198 | (todos-prefix-overlays))) | 2197 | (todos-prefix-overlays))) |
| 2199 | 2198 | ||
| 2200 | (defconst todos-filtered-items-buffer "Todos filtered items" | 2199 | (defconst todos-filtered-items-buffer "Todos filtered items" |
| @@ -2241,7 +2240,7 @@ its priority has changed, and `same' otherwise." | |||
| 2241 | (while (search-backward filcat nil t) | 2240 | (while (search-backward filcat nil t) |
| 2242 | (setq tpriority (1+ tpriority))))) | 2241 | (setq tpriority (1+ tpriority))))) |
| 2243 | (setq file (if file | 2242 | (setq file (if file |
| 2244 | (concat todos-files-directory (substring file 0 -1) | 2243 | (concat todos-directory (substring file 0 -1) |
| 2245 | (if archive ".toda" ".todo")) | 2244 | (if archive ".toda" ".todo")) |
| 2246 | (if archive | 2245 | (if archive |
| 2247 | (concat (file-name-sans-extension | 2246 | (concat (file-name-sans-extension |
| @@ -2323,7 +2322,7 @@ its priority has changed, and `same' otherwise." | |||
| 2323 | (let ((prompt (concat "Enter a short identifying string" | 2322 | (let ((prompt (concat "Enter a short identifying string" |
| 2324 | " to make this file name unique: "))) | 2323 | " to make this file name unique: "))) |
| 2325 | (setq filename-base (concat filename-base "-" (read-string prompt))))) | 2324 | (setq filename-base (concat filename-base "-" (read-string prompt))))) |
| 2326 | (concat todos-files-directory filename-base | 2325 | (concat todos-directory filename-base |
| 2327 | (cond (top-priorities ".todt") | 2326 | (cond (top-priorities ".todt") |
| 2328 | (diary-items ".tody") | 2327 | (diary-items ".tody") |
| 2329 | (regexp-items ".todr")))))) | 2328 | (regexp-items ".todr")))))) |
| @@ -2686,23 +2685,23 @@ which is the value of the user option | |||
| 2686 | (setq l (append v nil)))) | 2685 | (setq l (append v nil)))) |
| 2687 | (setq new (append new (list l)))) | 2686 | (setq new (append new (list l)))) |
| 2688 | new) | 2687 | new) |
| 2689 | "List of all argument lists for Todos insertion commands.") | 2688 | "List of all argument lists for Todos item insertion commands.") |
| 2690 | 2689 | ||
| 2691 | (defun todos-insertion-command-name (arglist) | 2690 | (defun todos-insertion-command-name (arglist) |
| 2692 | "Generate Todos insertion command name from ARGLIST." | 2691 | "Generate Todos item insertion command name from ARGLIST." |
| 2693 | (replace-regexp-in-string | 2692 | (replace-regexp-in-string |
| 2694 | "-\\_>" "" | 2693 | "-\\_>" "" |
| 2695 | (replace-regexp-in-string | 2694 | (replace-regexp-in-string |
| 2696 | "-+" "-" | 2695 | "-+" "-" |
| 2697 | (concat "todos-item-insert-" | 2696 | ;; (concat "todos-item-insert-" |
| 2698 | ;; (concat "todos-insert-item-" | 2697 | (concat "todos-insert-item-" |
| 2699 | (mapconcat (lambda (e) (if e (symbol-name e))) arglist "-"))))) | 2698 | (mapconcat (lambda (e) (if e (symbol-name e))) arglist "-"))))) |
| 2700 | 2699 | ||
| 2701 | (defvar todos-insertion-commands-names | 2700 | (defvar todos-insertion-commands-names |
| 2702 | (mapcar (lambda (l) | 2701 | (mapcar (lambda (l) |
| 2703 | (todos-insertion-command-name l)) | 2702 | (todos-insertion-command-name l)) |
| 2704 | todos-insertion-commands-args) | 2703 | todos-insertion-commands-args) |
| 2705 | "List of names of Todos insertion commands.") | 2704 | "List of names of Todos item insertion commands.") |
| 2706 | 2705 | ||
| 2707 | (defmacro todos-define-insertion-command (&rest args) | 2706 | (defmacro todos-define-insertion-command (&rest args) |
| 2708 | (let ((name (intern (todos-insertion-command-name args))) | 2707 | (let ((name (intern (todos-insertion-command-name args))) |
| @@ -2714,13 +2713,13 @@ which is the value of the user option | |||
| 2714 | `(defun ,name (&optional arg &rest args) | 2713 | `(defun ,name (&optional arg &rest args) |
| 2715 | "Todos item insertion command generated from ARGS." | 2714 | "Todos item insertion command generated from ARGS." |
| 2716 | (interactive (list current-prefix-arg)) | 2715 | (interactive (list current-prefix-arg)) |
| 2717 | (todos-insert-item arg ',arg0 ',arg1 ',arg2 ',arg3 ',arg4)))) | 2716 | (todos-insert-item-1 arg ',arg0 ',arg1 ',arg2 ',arg3 ',arg4)))) |
| 2718 | 2717 | ||
| 2719 | (defvar todos-insertion-commands | 2718 | (defvar todos-insertion-commands |
| 2720 | (mapcar (lambda (c) | 2719 | (mapcar (lambda (c) |
| 2721 | (eval `(todos-define-insertion-command ,@c))) | 2720 | (eval `(todos-define-insertion-command ,@c))) |
| 2722 | todos-insertion-commands-args) | 2721 | todos-insertion-commands-args) |
| 2723 | "List of Todos insertion commands.") | 2722 | "List of Todos item insertion commands.") |
| 2724 | 2723 | ||
| 2725 | (defvar todos-insertion-commands-arg-key-list | 2724 | (defvar todos-insertion-commands-arg-key-list |
| 2726 | '(("diary" "y" "yy") | 2725 | '(("diary" "y" "yy") |
| @@ -2731,10 +2730,10 @@ which is the value of the user option | |||
| 2731 | ("time" "t" "tt") | 2730 | ("time" "t" "tt") |
| 2732 | ("here" "h" "h") | 2731 | ("here" "h" "h") |
| 2733 | ("region" "r" "r")) | 2732 | ("region" "r" "r")) |
| 2734 | "") | 2733 | "") ;FIXME |
| 2735 | 2734 | ||
| 2736 | (defun todos-insertion-key-bindings (map) | 2735 | (defun todos-insertion-key-bindings (map) |
| 2737 | "" | 2736 | "" ;FIXME |
| 2738 | (dolist (c todos-insertion-commands) | 2737 | (dolist (c todos-insertion-commands) |
| 2739 | (let* ((key "") | 2738 | (let* ((key "") |
| 2740 | (cname (symbol-name c))) | 2739 | (cname (symbol-name c))) |
| @@ -2747,8 +2746,8 @@ which is the value of the user option | |||
| 2747 | (if (string-match (concat (regexp-quote arg) ".+") cname) | 2746 | (if (string-match (concat (regexp-quote arg) ".+") cname) |
| 2748 | (setq key (concat key key1))))) | 2747 | (setq key (concat key key1))))) |
| 2749 | todos-insertion-commands-arg-key-list) | 2748 | todos-insertion-commands-arg-key-list) |
| 2750 | (if (string-match (concat (regexp-quote "todos-item-insert") "\\_>") cname) | 2749 | ;; (if (string-match (concat (regexp-quote "todos-item-insert") "\\_>") cname) |
| 2751 | ;; (if (string-match (concat (regexp-quote "todos-insert-item") "\\_>") cname) | 2750 | (if (string-match (concat (regexp-quote "todos-insert-item") "\\_>") cname) |
| 2752 | (setq key (concat key "i"))) | 2751 | (setq key (concat key "i"))) |
| 2753 | (define-key map key c)))) | 2752 | (define-key map key c)))) |
| 2754 | 2753 | ||
| @@ -2757,83 +2756,80 @@ which is the value of the user option | |||
| 2757 | (todos-insertion-key-bindings map) | 2756 | (todos-insertion-key-bindings map) |
| 2758 | (define-key map "p" 'todos-copy-item) | 2757 | (define-key map "p" 'todos-copy-item) |
| 2759 | map) | 2758 | map) |
| 2760 | "Keymap for Todos mode insertion commands.") | 2759 | "Keymap for Todos mode item insertion commands.") |
| 2761 | 2760 | ||
| 2762 | ;; --------------------------------------------------------------------------- | 2761 | ;; --------------------------------------------------------------------------- |
| 2763 | ;;; Key maps and menus | 2762 | ;;; Key maps and menus |
| 2764 | 2763 | ||
| 2765 | (defvar todos-key-bindings | 2764 | (defvar todos-key-bindings |
| 2766 | `( | 2765 | `( |
| 2767 | ;; display | ||
| 2768 | ("Cd" . todos-display-categories) ;FIXME: Fc todos-file-categories? | ||
| 2769 | ("H" . todos-highlight-item) | ||
| 2770 | ("N" . todos-hide-show-item-numbering) | ||
| 2771 | ("D" . todos-hide-show-date-time) | ||
| 2772 | ("*" . todos-mark-unmark-item) | ||
| 2773 | ("C*" . todos-mark-category) | ||
| 2774 | ("Cu" . todos-unmark-category) | ||
| 2775 | ("PP" . todos-print) | ||
| 2776 | ("PF" . todos-print-to-file) | ||
| 2777 | ("v" . todos-hide-show-done-items) | ||
| 2778 | ("V" . todos-show-done-only) | ||
| 2779 | ("As" . todos-show-archive) | 2766 | ("As" . todos-show-archive) |
| 2780 | ("Ac" . todos-choose-archive) | 2767 | ("Ac" . todos-choose-archive) |
| 2781 | ;; ("Y" . todos-diary-items) | 2768 | ("Ad" . todos-archive-done-item) |
| 2782 | ("Fe" . todos-edit-multiline) | 2769 | ("C*" . todos-mark-category) |
| 2783 | ("Fh" . todos-highlight-item) | 2770 | ("Cu" . todos-unmark-category) |
| 2784 | ("Fn" . todos-hide-show-item-numbering) | 2771 | ("Cv" . todos-toggle-view-done-items) |
| 2785 | ("Fd" . todos-hide-show-date-time) | 2772 | ("v" . todos-toggle-view-done-items) |
| 2786 | ("Ftt" . todos-top-priorities) | ||
| 2787 | ("Ftm" . todos-top-priorities-multifile) | ||
| 2788 | ("Fts" . todos-set-top-priorities-in-file) | ||
| 2789 | ("Cts" . todos-set-top-priorities-in-category) | ||
| 2790 | ("Fyy" . todos-diary-items) | ||
| 2791 | ("Fym" . todos-diary-items-multifile) | ||
| 2792 | ("Fxx" . todos-regexp-items) | ||
| 2793 | ("Fxm" . todos-regexp-items-multifile) | ||
| 2794 | ;; navigation | ||
| 2795 | ("f" . todos-forward-category) | ||
| 2796 | ("b" . todos-backward-category) | ||
| 2797 | ("t" . todos-show) | ||
| 2798 | ("j" . todos-jump-to-category) | ||
| 2799 | ("n" . todos-forward-item) | ||
| 2800 | ("p" . todos-backward-item) | ||
| 2801 | ("S" . todos-search) | ||
| 2802 | ("X" . todos-clear-matches) | ||
| 2803 | ;; editing | ||
| 2804 | ("Fa" . todos-add-file) | ||
| 2805 | ("Ca" . todos-add-category) | 2773 | ("Ca" . todos-add-category) |
| 2806 | ("Cr" . todos-rename-category) | 2774 | ("Cr" . todos-rename-category) |
| 2807 | ("Cg" . todos-merge-category) | 2775 | ("Cg" . todos-merge-category) |
| 2808 | ("Cm" . todos-move-category) | 2776 | ("Cm" . todos-move-category) |
| 2809 | ("Ck" . todos-delete-category) | 2777 | ("Ck" . todos-delete-category) |
| 2810 | ("d" . todos-item-done) | 2778 | ("Cts" . todos-set-top-priorities-in-category) |
| 2779 | ("Cey" . todos-edit-category-diary-inclusion) | ||
| 2780 | ("Cek" . todos-edit-category-diary-nonmarking) | ||
| 2781 | ("Fa" . todos-add-file) | ||
| 2782 | ("Fc" . todos-show-categories-table) | ||
| 2783 | ("Fh" . todos-toggle-item-header) | ||
| 2784 | ("h" . todos-toggle-item-header) | ||
| 2785 | ("Fe" . todos-edit-file) | ||
| 2786 | ("FH" . todos-toggle-item-highlighting) | ||
| 2787 | ("H" . todos-toggle-item-highlighting) | ||
| 2788 | ("FN" . todos-toggle-prefix-numbers) | ||
| 2789 | ("N" . todos-toggle-prefix-numbers) | ||
| 2790 | ("FV" . todos-toggle-view-done-only) | ||
| 2791 | ("V" . todos-toggle-view-done-only) | ||
| 2792 | ("Ftt" . todos-filter-top-priorities) | ||
| 2793 | ("Ftm" . todos-filter-top-priorities-multifile) | ||
| 2794 | ("Fts" . todos-set-top-priorities-in-file) | ||
| 2795 | ("Fyy" . todos-filter-diary-items) | ||
| 2796 | ("Fym" . todos-filter-diary-items-multifile) | ||
| 2797 | ("Frr" . todos-filter-regexp-items) | ||
| 2798 | ("Frm" . todos-filter-regexp-items-multifile) | ||
| 2799 | ("PB" . todos-print-buffer) | ||
| 2800 | ("PF" . todos-print-buffer-to-file) | ||
| 2801 | ("S" . todos-search) | ||
| 2802 | ("X" . todos-clear-matches) | ||
| 2811 | ("ee" . todos-edit-item) | 2803 | ("ee" . todos-edit-item) |
| 2812 | ("em" . todos-edit-multiline-item) | 2804 | ("em" . todos-edit-multiline-item) |
| 2813 | ("eh" . todos-edit-item-header) | 2805 | ("edt" . todos-edit-item-header) |
| 2814 | ("edc" . todos-edit-item-date-from-calendar) | 2806 | ("edc" . todos-edit-item-date-from-calendar) |
| 2815 | ("edt" . todos-edit-item-date-to-today) | 2807 | ("eda" . todos-edit-item-date-to-today) |
| 2816 | ("edn" . todos-edit-item-date-day-name) | 2808 | ("edn" . todos-edit-item-date-day-name) |
| 2817 | ("edy" . todos-edit-item-date-year) | 2809 | ("edy" . todos-edit-item-date-year) |
| 2818 | ("edm" . todos-edit-item-date-month) | 2810 | ("edm" . todos-edit-item-date-month) |
| 2819 | ("edd" . todos-edit-item-date-day) | 2811 | ("edd" . todos-edit-item-date-day) |
| 2820 | ("et" . todos-edit-item-time) | 2812 | ("et" . todos-edit-item-time) |
| 2821 | ("eyy" . todos-edit-item-diary-inclusion) | 2813 | ("eyy" . todos-edit-item-diary-inclusion) |
| 2822 | ;; ("" . todos-edit-category-diary-inclusion) | 2814 | ("eyk" . todos-edit-item-diary-nonmarking) |
| 2823 | ("eyn" . todos-edit-item-diary-nonmarking) | ||
| 2824 | ;;("" . todos-edit-category-diary-nonmarking) | ||
| 2825 | ("ec" . todos-done-item-add-edit-or-delete-comment) | 2815 | ("ec" . todos-done-item-add-edit-or-delete-comment) |
| 2816 | ("b" . todos-backward-category) | ||
| 2817 | ("d" . todos-item-done) | ||
| 2818 | ("f" . todos-forward-category) | ||
| 2826 | ("i" . ,todos-insertion-map) | 2819 | ("i" . ,todos-insertion-map) |
| 2820 | ("j" . todos-jump-to-category) | ||
| 2827 | ("k" . todos-delete-item) ;FIXME: not single letter? | 2821 | ("k" . todos-delete-item) ;FIXME: not single letter? |
| 2822 | ("l" . todos-lower-item-priority) | ||
| 2828 | ("m" . todos-move-item) | 2823 | ("m" . todos-move-item) |
| 2824 | ("n" . todos-next-item) | ||
| 2825 | ("p" . todos-previous-item) | ||
| 2826 | ("q" . todos-quit) | ||
| 2829 | ("r" . todos-raise-item-priority) | 2827 | ("r" . todos-raise-item-priority) |
| 2830 | ("l" . todos-lower-item-priority) | ||
| 2831 | ("#" . todos-set-item-priority) | ||
| 2832 | ("u" . todos-item-undo) | ||
| 2833 | ("Ad" . todos-archive-done-item) ;FIXME: ad | ||
| 2834 | ("AD" . todos-archive-category-done-items) ;FIXME: aD or C-u ad ? | ||
| 2835 | ("s" . todos-save) | 2828 | ("s" . todos-save) |
| 2836 | ("q" . todos-quit) | 2829 | ("t" . todos-show) |
| 2830 | ("u" . todos-item-undone) | ||
| 2831 | ("#" . todos-set-item-priority) | ||
| 2832 | ("*" . todos-toggle-mark-item) | ||
| 2837 | ([remap newline] . newline-and-indent) | 2833 | ([remap newline] . newline-and-indent) |
| 2838 | ) | 2834 | ) |
| 2839 | "Alist pairing keys defined in Todos modes and their bindings.") | 2835 | "Alist pairing keys defined in Todos modes and their bindings.") |
| @@ -2861,24 +2857,24 @@ which is the value of the user option | |||
| 2861 | ["Search Todos File" todos-search t] | 2857 | ["Search Todos File" todos-search t] |
| 2862 | ["Clear Highlighting on Search Matches" todos-category-done t]) | 2858 | ["Clear Highlighting on Search Matches" todos-category-done t]) |
| 2863 | ("Display" | 2859 | ("Display" |
| 2864 | ["List Current Categories" todos-display-categories t] | 2860 | ["List Current Categories" todos-show-categories-table t] |
| 2865 | ;; ["List Categories Alphabetically" todos-display-categories-alphabetically t] | 2861 | ;; ["List Categories Alphabetically" todos-display-categories-alphabetically t] |
| 2866 | ["Turn Item Highlighting on/off" todos-highlight-item t] | 2862 | ["Turn Item Highlighting on/off" todos-toggle-item-highlighting t] |
| 2867 | ["Turn Item Numbering on/off" todos-hide-show-item-numbering t] | 2863 | ["Turn Item Numbering on/off" todos-toggle-prefix-numbers t] |
| 2868 | ["Turn Item Time Stamp on/off" todos-hide-show-date-time t] | 2864 | ["Turn Item Time Stamp on/off" todos-toggle-item-header t] |
| 2869 | ["View/Hide Done Items" todos-hide-show-done-items t] | 2865 | ["View/Hide Done Items" todos-toggle-view-done-items t] |
| 2870 | "---" | 2866 | "---" |
| 2871 | ["View Diary Items" todos-diary-items t] | 2867 | ["View Diary Items" todos-filter-diary-items t] |
| 2872 | ["View Top Priority Items" todos-top-priorities t] | 2868 | ["View Top Priority Items" todos-filter-top-priorities t] |
| 2873 | ["View Multifile Top Priority Items" todos-top-priorities-multifile t] | 2869 | ["View Multifile Top Priority Items" todos-filter-top-priorities-multifile t] |
| 2874 | "---" | 2870 | "---" |
| 2875 | ["Print Category" todos-print t]) | 2871 | ["Print Category" todos-print-buffer t]) |
| 2876 | ("Editing" | 2872 | ("Editing" |
| 2877 | ["Insert New Item" todos-insert-item t] | 2873 | ["Insert New Item" todos-insert-item t] |
| 2878 | ["Insert Item Here" todos-insert-item-here t] | 2874 | ["Insert Item Here" todos-insert-item-here t] |
| 2879 | ("More Insertion Commands") | 2875 | ("More Insertion Commands") |
| 2880 | ["Edit Item" todos-edit-item t] | 2876 | ["Edit Item" todos-edit-item t] |
| 2881 | ["Edit Multiline Item" todos-edit-multiline t] | 2877 | ["Edit Multiline Item" todos-edit-multiline-item t] |
| 2882 | ["Edit Item Header" todos-edit-item-header t] | 2878 | ["Edit Item Header" todos-edit-item-header t] |
| 2883 | ["Edit Item Date" todos-edit-item-date t] | 2879 | ["Edit Item Date" todos-edit-item-date t] |
| 2884 | ["Edit Item Time" todos-edit-item-time t] | 2880 | ["Edit Item Time" todos-edit-item-time t] |
| @@ -2888,7 +2884,7 @@ which is the value of the user option | |||
| 2888 | ["Set Item Priority" todos-set-item-priority t] | 2884 | ["Set Item Priority" todos-set-item-priority t] |
| 2889 | ["Move (Recategorize) Item" todos-move-item t] | 2885 | ["Move (Recategorize) Item" todos-move-item t] |
| 2890 | ["Delete Item" todos-delete-item t] | 2886 | ["Delete Item" todos-delete-item t] |
| 2891 | ["Undo Done Item" todos-item-undo t] | 2887 | ["Undo Done Item" todos-item-undone t] |
| 2892 | ["Mark/Unmark Item for Diary" todos-toggle-item-diary-inclusion t] | 2888 | ["Mark/Unmark Item for Diary" todos-toggle-item-diary-inclusion t] |
| 2893 | ["Mark/Unmark Items for Diary" todos-edit-item-diary-inclusion t] | 2889 | ["Mark/Unmark Items for Diary" todos-edit-item-diary-inclusion t] |
| 2894 | ["Mark & Hide Done Item" todos-item-done t] | 2890 | ["Mark & Hide Done Item" todos-item-done t] |
| @@ -2908,26 +2904,28 @@ which is the value of the user option | |||
| 2908 | (defvar todos-archive-mode-map | 2904 | (defvar todos-archive-mode-map |
| 2909 | (let ((map (make-sparse-keymap))) | 2905 | (let ((map (make-sparse-keymap))) |
| 2910 | (suppress-keymap map t) | 2906 | (suppress-keymap map t) |
| 2911 | ;; navigation commands | ||
| 2912 | (define-key map "f" 'todos-forward-category) | ||
| 2913 | (define-key map "b" 'todos-backward-category) | ||
| 2914 | (define-key map "j" 'todos-jump-to-category) | ||
| 2915 | (define-key map "n" 'todos-forward-item) | ||
| 2916 | (define-key map "p" 'todos-backward-item) | ||
| 2917 | ;; display commands | ||
| 2918 | (define-key map "Cd" 'todos-display-categories) | ||
| 2919 | (define-key map "H" 'todos-highlight-item) | ||
| 2920 | (define-key map "N" 'todos-hide-show-item-numbering) | ||
| 2921 | (define-key map "*" 'todos-mark-unmark-item) | ||
| 2922 | (define-key map "C*" 'todos-mark-category) | 2907 | (define-key map "C*" 'todos-mark-category) |
| 2923 | (define-key map "Cu" 'todos-unmark-category) | 2908 | (define-key map "Cu" 'todos-unmark-category) |
| 2924 | ;; (define-key map "" 'todos-hide-show-date-time) | 2909 | (define-key map "Fc" 'todos-show-categories-table) |
| 2925 | (define-key map "P" 'todos-print) | 2910 | (define-key map "FH" 'todos-toggle-item-highlighting) |
| 2911 | (define-key map "H" 'todos-toggle-item-highlighting) | ||
| 2912 | (define-key map "FN" 'todos-toggle-prefix-numbers) | ||
| 2913 | (define-key map "N" 'todos-toggle-prefix-numbers) | ||
| 2914 | ;; (define-key map "" 'todos-toggle-item-header) | ||
| 2915 | (define-key map "PB" 'todos-print-buffer) | ||
| 2916 | (define-key map "PF" 'todos-print-buffer-to-file) | ||
| 2917 | (define-key map "S" 'todos-search) | ||
| 2918 | (define-key map "X" 'todos-clear-matches) | ||
| 2919 | (define-key map "b" 'todos-backward-category) | ||
| 2920 | (define-key map "f" 'todos-forward-category) | ||
| 2921 | (define-key map "j" 'todos-jump-to-category) | ||
| 2922 | (define-key map "n" 'todos-next-item) | ||
| 2923 | (define-key map "p" 'todos-previous-item) | ||
| 2926 | (define-key map "q" 'todos-quit) | 2924 | (define-key map "q" 'todos-quit) |
| 2927 | (define-key map "s" 'todos-save) | 2925 | (define-key map "s" 'todos-save) |
| 2928 | (define-key map "S" 'todos-search) | ||
| 2929 | (define-key map "t" 'todos-show) | 2926 | (define-key map "t" 'todos-show) |
| 2930 | (define-key map "u" 'todos-unarchive-items) | 2927 | (define-key map "u" 'todos-unarchive-items) |
| 2928 | (define-key map "*" 'todos-toggle-mark-item) | ||
| 2931 | map) | 2929 | map) |
| 2932 | "Todos Archive mode keymap.") | 2930 | "Todos Archive mode keymap.") |
| 2933 | 2931 | ||
| @@ -2941,21 +2939,18 @@ which is the value of the user option | |||
| 2941 | (defvar todos-categories-mode-map | 2939 | (defvar todos-categories-mode-map |
| 2942 | (let ((map (make-sparse-keymap))) | 2940 | (let ((map (make-sparse-keymap))) |
| 2943 | (suppress-keymap map t) | 2941 | (suppress-keymap map t) |
| 2944 | ;; (define-key map "c" 'todos-display-categories-numberically-or-alphabetically) | 2942 | (define-key map "c" 'todos-sort-categories-alphabetically-or-by-priority) |
| 2945 | (define-key map "c" 'todos-display-categories-alphabetically-or-by-priority) | 2943 | (define-key map "t" 'todos-sort-categories-by-todo) |
| 2946 | (define-key map "t" 'todos-display-categories-sorted-by-todo) | 2944 | (define-key map "y" 'todos-sort-categories-by-diary) |
| 2947 | (define-key map "y" 'todos-display-categories-sorted-by-diary) | 2945 | (define-key map "d" 'todos-sort-categories-by-done) |
| 2948 | (define-key map "d" 'todos-display-categories-sorted-by-done) | 2946 | (define-key map "a" 'todos-sort-categories-by-archived) |
| 2949 | (define-key map "a" 'todos-display-categories-sorted-by-archived) | ||
| 2950 | (define-key map "#" 'todos-set-category-priority) | 2947 | (define-key map "#" 'todos-set-category-priority) |
| 2951 | (define-key map "l" 'todos-lower-category-priority) | 2948 | (define-key map "l" 'todos-lower-category-priority) |
| 2952 | (define-key map "+" 'todos-lower-category-priority) | ||
| 2953 | (define-key map "r" 'todos-raise-category-priority) | 2949 | (define-key map "r" 'todos-raise-category-priority) |
| 2954 | (define-key map "-" 'todos-raise-category-priority) | 2950 | (define-key map "n" 'todos-next-button) |
| 2955 | (define-key map "n" 'todos-forward-button) ; todos-next-button | 2951 | (define-key map "p" 'todos-previous-button) |
| 2956 | (define-key map "p" 'todos-backward-button) ; todos-previous-button | 2952 | (define-key map [tab] 'todos-next-button) |
| 2957 | (define-key map [tab] 'todos-forward-button) | 2953 | (define-key map [backtab] 'todos-previous-button) |
| 2958 | (define-key map [backtab] 'todos-backward-button) | ||
| 2959 | (define-key map "q" 'todos-quit) | 2954 | (define-key map "q" 'todos-quit) |
| 2960 | ;; (define-key map "A" 'todos-add-category) | 2955 | ;; (define-key map "A" 'todos-add-category) |
| 2961 | ;; (define-key map "D" 'todos-delete-category) | 2956 | ;; (define-key map "D" 'todos-delete-category) |
| @@ -2966,21 +2961,23 @@ which is the value of the user option | |||
| 2966 | (defvar todos-filtered-items-mode-map | 2961 | (defvar todos-filtered-items-mode-map |
| 2967 | (let ((map (make-keymap))) | 2962 | (let ((map (make-keymap))) |
| 2968 | (suppress-keymap map t) | 2963 | (suppress-keymap map t) |
| 2969 | ;; navigation commands | 2964 | (define-key map "FH" 'todos-toggle-item-highlighting) |
| 2970 | (define-key map "j" 'todos-jump-to-item) | 2965 | (define-key map "H" 'todos-toggle-item-highlighting) |
| 2971 | (define-key map [remap newline] 'todos-jump-to-item) | 2966 | (define-key map "FN" 'todos-toggle-prefix-numbers) |
| 2972 | (define-key map "n" 'todos-forward-item) | 2967 | (define-key map "N" 'todos-toggle-prefix-numbers) |
| 2973 | (define-key map "p" 'todos-backward-item) | 2968 | (define-key map "Fh" 'todos-toggle-item-header) |
| 2974 | (define-key map "H" 'todos-highlight-item) | 2969 | (define-key map "h" 'todos-toggle-item-header) |
| 2975 | (define-key map "N" 'todos-hide-show-item-numbering) | 2970 | (define-key map "PB" 'todos-print-buffer) |
| 2976 | (define-key map "D" 'todos-hide-show-date-time) | 2971 | (define-key map "PF" 'todos-print-buffer-to-file) |
| 2977 | (define-key map "P" 'todos-print) | 2972 | (define-key map "j" 'todos-go-to-source-item) |
| 2978 | (define-key map "q" 'todos-quit) | ||
| 2979 | (define-key map "s" 'todos-save) | ||
| 2980 | ;; editing commands | ||
| 2981 | (define-key map "l" 'todos-lower-item-priority) | 2973 | (define-key map "l" 'todos-lower-item-priority) |
| 2974 | (define-key map "n" 'todos-next-item) | ||
| 2975 | (define-key map "p" 'todos-previous-item) | ||
| 2976 | (define-key map "q" 'todos-quit) | ||
| 2982 | (define-key map "r" 'todos-raise-item-priority) | 2977 | (define-key map "r" 'todos-raise-item-priority) |
| 2978 | (define-key map "s" 'todos-save) | ||
| 2983 | (define-key map "#" 'todos-set-item-priority) | 2979 | (define-key map "#" 'todos-set-item-priority) |
| 2980 | (define-key map [remap newline] 'todos-go-to-source-item) | ||
| 2984 | map) | 2981 | map) |
| 2985 | "Todos Top Priorities mode keymap.") | 2982 | "Todos Top Priorities mode keymap.") |
| 2986 | 2983 | ||
| @@ -3053,7 +3050,7 @@ which is the value of the user option | |||
| 3053 | todos-global-current-todos-file) | 3050 | todos-global-current-todos-file) |
| 3054 | (let ((cats (with-current-buffer | 3051 | (let ((cats (with-current-buffer |
| 3055 | ;; Can't use find-buffer-visiting when | 3052 | ;; Can't use find-buffer-visiting when |
| 3056 | ;; `todos-display-categories' is called on first | 3053 | ;; `todos-show-categories-table' is called on first |
| 3057 | ;; invocation of `todos-show', since there is then | 3054 | ;; invocation of `todos-show', since there is then |
| 3058 | ;; no buffer visiting the current file. | 3055 | ;; no buffer visiting the current file. |
| 3059 | (find-file-noselect todos-current-todos-file 'nowarn) | 3056 | (find-file-noselect todos-current-todos-file 'nowarn) |
| @@ -3127,7 +3124,7 @@ current (i.e., last displayed) category. | |||
| 3127 | 3124 | ||
| 3128 | In Todos mode just the category's unfinished todo items are shown | 3125 | In Todos mode just the category's unfinished todo items are shown |
| 3129 | by default. The done items are hidden, but typing | 3126 | by default. The done items are hidden, but typing |
| 3130 | `\\[todos-hide-show-done-items]' displays them below the todo | 3127 | `\\[todos-toggle-view-done-items]' displays them below the todo |
| 3131 | items. With non-nil user option `todos-show-with-done' both todo | 3128 | items. With non-nil user option `todos-show-with-done' both todo |
| 3132 | and done items are always shown on visiting a category. | 3129 | and done items are always shown on visiting a category. |
| 3133 | 3130 | ||
| @@ -3157,16 +3154,16 @@ corresponding Todos file, displaying the corresponding category." | |||
| 3157 | (todos-add-file)))))) | 3154 | (todos-add-file)))))) |
| 3158 | (unless (member file todos-visited) | 3155 | (unless (member file todos-visited) |
| 3159 | ;; Can't setq t-c-t-f here, otherwise wrong file shown when | 3156 | ;; Can't setq t-c-t-f here, otherwise wrong file shown when |
| 3160 | ;; todos-show is called from todos-display-categories. | 3157 | ;; todos-show is called from todos-show-categories-table. |
| 3161 | (let ((todos-current-todos-file file)) | 3158 | (let ((todos-current-todos-file file)) |
| 3162 | (cond ((eq todos-show-first 'table) | 3159 | (cond ((eq todos-show-first 'table) |
| 3163 | (todos-display-categories)) | 3160 | (todos-show-categories-table)) |
| 3164 | ((memq todos-show-first '(top diary regexp)) | 3161 | ((memq todos-show-first '(top diary regexp)) |
| 3165 | (let* ((shortf (todos-short-file-name file)) | 3162 | (let* ((shortf (todos-short-file-name file)) |
| 3166 | (fi-file (todos-absolute-file-name | 3163 | (fi-file (todos-absolute-file-name |
| 3167 | shortf todos-show-first))) | 3164 | shortf todos-show-first))) |
| 3168 | (when (eq todos-show-first 'regexp) | 3165 | (when (eq todos-show-first 'regexp) |
| 3169 | (let ((rxfiles (directory-files todos-files-directory t | 3166 | (let ((rxfiles (directory-files todos-directory t |
| 3170 | ".*\\.todr$" t))) | 3167 | ".*\\.todr$" t))) |
| 3171 | (when (and rxfiles (> (length rxfiles) 1)) | 3168 | (when (and rxfiles (> (length rxfiles) 1)) |
| 3172 | (let ((rxf (mapcar 'todos-short-file-name rxfiles))) | 3169 | (let ((rxf (mapcar 'todos-short-file-name rxfiles))) |
| @@ -3203,7 +3200,7 @@ corresponding Todos file, displaying the corresponding category." | |||
| 3203 | (setq todos-show-first show-first) | 3200 | (setq todos-show-first show-first) |
| 3204 | (add-to-list 'todos-visited file))) | 3201 | (add-to-list 'todos-visited file))) |
| 3205 | 3202 | ||
| 3206 | (defun todos-display-categories () | 3203 | (defun todos-show-categories-table () |
| 3207 | "Display a table of the current file's categories and item counts. | 3204 | "Display a table of the current file's categories and item counts. |
| 3208 | 3205 | ||
| 3209 | In the initial display the categories are numbered, indicating | 3206 | In the initial display the categories are numbered, indicating |
| @@ -3233,7 +3230,7 @@ are shown in `todos-archived-only' face." | |||
| 3233 | (let (sortkey) | 3230 | (let (sortkey) |
| 3234 | (todos-update-categories-display sortkey))) | 3231 | (todos-update-categories-display sortkey))) |
| 3235 | 3232 | ||
| 3236 | (defun todos-display-categories-alphabetically-or-by-priority () | 3233 | (defun todos-sort-categories-alphabetically-or-by-priority () |
| 3237 | "" | 3234 | "" |
| 3238 | (interactive) | 3235 | (interactive) |
| 3239 | (save-excursion | 3236 | (save-excursion |
| @@ -3246,7 +3243,7 @@ are shown in `todos-archived-only' face." | |||
| 3246 | (delete 'alpha todos-descending-counts))) | 3243 | (delete 'alpha todos-descending-counts))) |
| 3247 | (todos-update-categories-display 'alpha)))) | 3244 | (todos-update-categories-display 'alpha)))) |
| 3248 | 3245 | ||
| 3249 | (defun todos-display-categories-sorted-by-todo () | 3246 | (defun todos-sort-categories-by-todo () |
| 3250 | "" | 3247 | "" |
| 3251 | (interactive) | 3248 | (interactive) |
| 3252 | (save-excursion | 3249 | (save-excursion |
| @@ -3254,7 +3251,7 @@ are shown in `todos-archived-only' face." | |||
| 3254 | (forward-line 2) | 3251 | (forward-line 2) |
| 3255 | (todos-update-categories-display 'todo))) | 3252 | (todos-update-categories-display 'todo))) |
| 3256 | 3253 | ||
| 3257 | (defun todos-display-categories-sorted-by-diary () | 3254 | (defun todos-sort-categories-by-diary () |
| 3258 | "" | 3255 | "" |
| 3259 | (interactive) | 3256 | (interactive) |
| 3260 | (save-excursion | 3257 | (save-excursion |
| @@ -3262,7 +3259,7 @@ are shown in `todos-archived-only' face." | |||
| 3262 | (forward-line 2) | 3259 | (forward-line 2) |
| 3263 | (todos-update-categories-display 'diary))) | 3260 | (todos-update-categories-display 'diary))) |
| 3264 | 3261 | ||
| 3265 | (defun todos-display-categories-sorted-by-done () | 3262 | (defun todos-sort-categories-by-done () |
| 3266 | "" | 3263 | "" |
| 3267 | (interactive) | 3264 | (interactive) |
| 3268 | (save-excursion | 3265 | (save-excursion |
| @@ -3270,7 +3267,7 @@ are shown in `todos-archived-only' face." | |||
| 3270 | (forward-line 2) | 3267 | (forward-line 2) |
| 3271 | (todos-update-categories-display 'done))) | 3268 | (todos-update-categories-display 'done))) |
| 3272 | 3269 | ||
| 3273 | (defun todos-display-categories-sorted-by-archived () | 3270 | (defun todos-sort-categories-by-archived () |
| 3274 | "" | 3271 | "" |
| 3275 | (interactive) | 3272 | (interactive) |
| 3276 | (save-excursion | 3273 | (save-excursion |
| @@ -3338,7 +3335,7 @@ buries it and restores state as needed." | |||
| 3338 | ;; prevent killing todos-mode buffer. | 3335 | ;; prevent killing todos-mode buffer. |
| 3339 | (let ((buf (current-buffer))) | 3336 | (let ((buf (current-buffer))) |
| 3340 | (setq todos-descending-counts nil) | 3337 | (setq todos-descending-counts nil) |
| 3341 | ;; Ensure todos-show calls todos-display-categories only on | 3338 | ;; Ensure todos-show calls todos-show-categories-table only on |
| 3342 | ;; first invocation per file. | 3339 | ;; first invocation per file. |
| 3343 | (when (eq todos-show-first 'table) | 3340 | (when (eq todos-show-first 'table) |
| 3344 | (add-to-list 'todos-visited todos-current-todos-file)) | 3341 | (add-to-list 'todos-visited todos-current-todos-file)) |
| @@ -3353,10 +3350,10 @@ buries it and restores state as needed." | |||
| 3353 | (todos-save) | 3350 | (todos-save) |
| 3354 | (bury-buffer)))) | 3351 | (bury-buffer)))) |
| 3355 | 3352 | ||
| 3356 | (defun todos-print (&optional to-file) | 3353 | (defun todos-print-buffer (&optional to-file) |
| 3357 | "Produce a printable version of the current Todos buffer. | 3354 | "Produce a printable version of the current Todos buffer. |
| 3358 | This converts overlays and soft line wrapping and, depending on | 3355 | This converts overlays and soft line wrapping and, depending on |
| 3359 | the value of `todos-print-function', includes faces. With | 3356 | the value of `todos-print-buffer-function', includes faces. With |
| 3360 | non-nil argument TO-FILE write the printable version to a file; | 3357 | non-nil argument TO-FILE write the printable version to a file; |
| 3361 | otherwise, send it to the default printer." | 3358 | otherwise, send it to the default printer." |
| 3362 | (interactive) | 3359 | (interactive) |
| @@ -3380,7 +3377,7 @@ otherwise, send it to the default printer." | |||
| 3380 | (while (not (eobp)) | 3377 | (while (not (eobp)) |
| 3381 | (let ((beg (point)) | 3378 | (let ((beg (point)) |
| 3382 | (end (save-excursion (todos-item-end)))) | 3379 | (end (save-excursion (todos-item-end)))) |
| 3383 | (when todos-number-priorities | 3380 | (when todos-number-prefix |
| 3384 | (setq num (1+ num)) | 3381 | (setq num (1+ num)) |
| 3385 | (setq prefix (propertize (concat (number-to-string num) " ") | 3382 | (setq prefix (propertize (concat (number-to-string num) " ") |
| 3386 | 'face 'todos-prefix-string))) | 3383 | 'face 'todos-prefix-string))) |
| @@ -3399,20 +3396,20 @@ otherwise, send it to the default printer." | |||
| 3399 | (newline 2) | 3396 | (newline 2) |
| 3400 | (if to-file | 3397 | (if to-file |
| 3401 | (let ((file (read-file-name "Print to file: "))) | 3398 | (let ((file (read-file-name "Print to file: "))) |
| 3402 | (funcall todos-print-function file)) | 3399 | (funcall todos-print-buffer-function file)) |
| 3403 | (funcall todos-print-function))) | 3400 | (funcall todos-print-buffer-function))) |
| 3404 | (kill-buffer buf))) | 3401 | (kill-buffer buf))) |
| 3405 | 3402 | ||
| 3406 | (defun todos-print-to-file () | 3403 | (defun todos-print-buffer-to-file () |
| 3407 | "Save printable version of this Todos buffer to a file." | 3404 | "Save printable version of this Todos buffer to a file." |
| 3408 | (interactive) | 3405 | (interactive) |
| 3409 | (todos-print t)) | 3406 | (todos-print-buffer t)) |
| 3410 | 3407 | ||
| 3411 | (defun todos-convert-legacy-files () | 3408 | (defun todos-convert-legacy-files () |
| 3412 | "Convert legacy Todo files to the current Todos format. | 3409 | "Convert legacy Todo files to the current Todos format. |
| 3413 | The files `todo-file-do' and `todo-file-done' are converted and | 3410 | The files `todo-file-do' and `todo-file-done' are converted and |
| 3414 | saved (the latter as a Todos Archive file) with a new name in | 3411 | saved (the latter as a Todos Archive file) with a new name in |
| 3415 | `todos-files-directory'. See also the documentation string of | 3412 | `todos-directory'. See also the documentation string of |
| 3416 | `todos-todo-mode-date-time-regexp' for further details." | 3413 | `todos-todo-mode-date-time-regexp' for further details." |
| 3417 | (interactive) | 3414 | (interactive) |
| 3418 | (if (fboundp 'todo-mode) | 3415 | (if (fboundp 'todo-mode) |
| @@ -3444,7 +3441,7 @@ saved (the latter as a Todos Archive file) with a new name in | |||
| 3444 | (regexp-quote todo-initials) ":")) | 3441 | (regexp-quote todo-initials) ":")) |
| 3445 | (todos-convert-legacy-date-time))) | 3442 | (todos-convert-legacy-date-time))) |
| 3446 | (forward-line)) | 3443 | (forward-line)) |
| 3447 | (setq file (concat todos-files-directory | 3444 | (setq file (concat todos-directory |
| 3448 | (read-string | 3445 | (read-string |
| 3449 | (format "Save file as (default \"%s\"): " default) | 3446 | (format "Save file as (default \"%s\"): " default) |
| 3450 | nil nil default) | 3447 | nil nil default) |
| @@ -3631,8 +3628,8 @@ CAT; this is used in Todos Categories mode." | |||
| 3631 | (todos-category-select) | 3628 | (todos-category-select) |
| 3632 | (goto-char (point-min)))))) | 3629 | (goto-char (point-min)))))) |
| 3633 | 3630 | ||
| 3634 | (defun todos-jump-to-item () | 3631 | (defun todos-go-to-source-item () |
| 3635 | "Jump to the file and category of the filtered item at point." | 3632 | "Display the file and category of the filtered item at point." |
| 3636 | (interactive) | 3633 | (interactive) |
| 3637 | (let* ((str (todos-item-string)) | 3634 | (let* ((str (todos-item-string)) |
| 3638 | (buf (current-buffer)) | 3635 | (buf (current-buffer)) |
| @@ -3655,7 +3652,35 @@ CAT; this is used in Todos Categories mode." | |||
| 3655 | (goto-char (car found))))) | 3652 | (goto-char (car found))))) |
| 3656 | 3653 | ||
| 3657 | (defun todos-forward-item (&optional count) | 3654 | (defun todos-forward-item (&optional count) |
| 3658 | "Move point down to start of item with next lower priority. | 3655 | "Move point COUNT items down (by default, move down by one item)." |
| 3656 | (let* ((not-done (not (or (todos-done-item-p) (looking-at "^$")))) | ||
| 3657 | (start (line-end-position))) | ||
| 3658 | (goto-char start) | ||
| 3659 | (if (re-search-forward todos-item-start nil t (or count 1)) | ||
| 3660 | (goto-char (match-beginning 0)) | ||
| 3661 | (goto-char (point-max))) | ||
| 3662 | ;; If points advances by one from a todo to a done item, go back to the | ||
| 3663 | ;; space above todos-done-separator, since that is a legitimate place to | ||
| 3664 | ;; insert an item. But skip this space if count > 1, since that should | ||
| 3665 | ;; only stop on an item. | ||
| 3666 | (when (and not-done (todos-done-item-p) (not count)) | ||
| 3667 | ;; (if (or (not count) (= count 1)) | ||
| 3668 | (re-search-backward "^$" start t))));) | ||
| 3669 | ;; FIXME: The preceding sexp is insufficient when buffer is not narrowed, | ||
| 3670 | ;; since there could be no done items in this category, so the search puts | ||
| 3671 | ;; us on first todo item of next category. Does this ever happen? If so: | ||
| 3672 | ;; (let ((opoint) (point)) | ||
| 3673 | ;; (forward-line -1) | ||
| 3674 | ;; (when (or (not count) (= count 1)) | ||
| 3675 | ;; (cond ((looking-at (concat "^" (regexp-quote todos-category-beg))) | ||
| 3676 | ;; (forward-line -2)) | ||
| 3677 | ;; ((looking-at (concat "^" (regexp-quote todos-category-done))) | ||
| 3678 | ;; (forward-line -1)) | ||
| 3679 | ;; (t | ||
| 3680 | ;; (goto-char opoint))))))) | ||
| 3681 | |||
| 3682 | (defun todos-next-item (&optional count) | ||
| 3683 | "Move point down to the beginning of the next item. | ||
| 3659 | With positive numerical prefix COUNT, move point COUNT items | 3684 | With positive numerical prefix COUNT, move point COUNT items |
| 3660 | downward. | 3685 | downward. |
| 3661 | 3686 | ||
| @@ -3668,36 +3693,15 @@ e.g., with point on the last todo item and called with prefix 1, | |||
| 3668 | it moves point to the first done item; but if called with point | 3693 | it moves point to the first done item; but if called with point |
| 3669 | on the last todo item without a prefix argument, it moves point | 3694 | on the last todo item without a prefix argument, it moves point |
| 3670 | the the empty line above the done items separator." | 3695 | the the empty line above the done items separator." |
| 3671 | (interactive "P") | 3696 | (interactive "p") |
| 3672 | ;; It's not worth the trouble to allow prefix arg value < 1, since we have | 3697 | ;; It's not worth the trouble to allow prefix arg value < 1, since we have |
| 3673 | ;; the corresponding command. | 3698 | ;; the corresponding command. |
| 3674 | (if (and count (> 1 count)) | 3699 | (cond ((and current-prefix-arg (< count 1)) |
| 3675 | (error "This command only accepts a positive numerical prefix argument") | 3700 | (user-error "The prefix argument must be a positive number")) |
| 3676 | (let* ((not-done (not (or (todos-done-item-p) (looking-at "^$")))) | 3701 | (current-prefix-arg |
| 3677 | (start (line-end-position))) | 3702 | (todos-forward-item count)) |
| 3678 | (goto-char start) | 3703 | (t |
| 3679 | (if (re-search-forward todos-item-start nil t (or count 1)) | 3704 | (todos-forward-item)))) |
| 3680 | (goto-char (match-beginning 0)) | ||
| 3681 | (goto-char (point-max))) | ||
| 3682 | ;; If points advances by one from a todo to a done item, go back to the | ||
| 3683 | ;; space above todos-done-separator, since that is a legitimate place to | ||
| 3684 | ;; insert an item. But skip this space if count > 1, since that should | ||
| 3685 | ;; only stop on an item. | ||
| 3686 | (when (and not-done (todos-done-item-p) (not count)) | ||
| 3687 | ;; (if (or (not count) (= count 1)) | ||
| 3688 | (re-search-backward "^$" start t)))));) | ||
| 3689 | ;; FIXME: The preceding sexp is insufficient when buffer is not narrowed, | ||
| 3690 | ;; since there could be no done items in this category, so the search puts | ||
| 3691 | ;; us on first todo item of next category. Does this ever happen? If so: | ||
| 3692 | ;; (let ((opoint) (point)) | ||
| 3693 | ;; (forward-line -1) | ||
| 3694 | ;; (when (or (not count) (= count 1)) | ||
| 3695 | ;; (cond ((looking-at (concat "^" (regexp-quote todos-category-beg))) | ||
| 3696 | ;; (forward-line -2)) | ||
| 3697 | ;; ((looking-at (concat "^" (regexp-quote todos-category-done))) | ||
| 3698 | ;; (forward-line -1)) | ||
| 3699 | ;; (t | ||
| 3700 | ;; (goto-char opoint))))))) | ||
| 3701 | 3705 | ||
| 3702 | (defun todos-backward-item (&optional count) | 3706 | (defun todos-backward-item (&optional count) |
| 3703 | "Move point up to start of item with next higher priority. | 3707 | "Move point up to start of item with next higher priority. |
| @@ -3710,31 +3714,47 @@ with point on the first done item and called with prefix 1, it | |||
| 3710 | moves to the last todo item; but if called with point on the | 3714 | moves to the last todo item; but if called with point on the |
| 3711 | first done item without a prefix argument, it moves point the the | 3715 | first done item without a prefix argument, it moves point the the |
| 3712 | empty line above the done items separator." | 3716 | empty line above the done items separator." |
| 3713 | (interactive "P") | 3717 | (let* ((done (todos-done-item-p))) |
| 3718 | (todos-item-start) | ||
| 3719 | (unless (bobp) | ||
| 3720 | (re-search-backward todos-item-start nil t (or count 1))) | ||
| 3721 | ;; Unless this is a regexp filtered items buffer (which can contain | ||
| 3722 | ;; intermixed todo and done items), if points advances by one from a | ||
| 3723 | ;; done to a todo item, go back to the space above | ||
| 3724 | ;; todos-done-separator, since that is a legitimate place to insert an | ||
| 3725 | ;; item. But skip this space if count > 1, since that should only | ||
| 3726 | ;; stop on an item. | ||
| 3727 | (when (and done (not (todos-done-item-p)) (not count) | ||
| 3728 | ;(or (not count) (= count 1)) | ||
| 3729 | (not (equal (buffer-name) todos-regexp-items-buffer))) | ||
| 3730 | (re-search-forward (concat "^" (regexp-quote todos-category-done)) | ||
| 3731 | nil t) | ||
| 3732 | (forward-line -1)))) | ||
| 3733 | |||
| 3734 | (defun todos-previous-item (&optional count) | ||
| 3735 | "Move point up to start of item with next higher priority. | ||
| 3736 | With positive numerical prefix COUNT, move point COUNT items | ||
| 3737 | upward. | ||
| 3738 | |||
| 3739 | If the category's done items are visible, this command called | ||
| 3740 | with a prefix argument only moves point to a higher item, e.g., | ||
| 3741 | with point on the first done item and called with prefix 1, it | ||
| 3742 | moves to the last todo item; but if called with point on the | ||
| 3743 | first done item without a prefix argument, it moves point the the | ||
| 3744 | empty line above the done items separator." | ||
| 3745 | (interactive "p") | ||
| 3714 | ;; Avoid moving to bob if on the first item but not at bob. | 3746 | ;; Avoid moving to bob if on the first item but not at bob. |
| 3715 | (when (> (line-number-at-pos) 1) | 3747 | (when (> (line-number-at-pos) 1) |
| 3716 | ;; It's not worth the trouble to allow prefix arg value < 1, since we have | 3748 | ;; It's not worth the trouble to allow prefix arg value < 1, since we have |
| 3717 | ;; the corresponding command. | 3749 | ;; the corresponding command. |
| 3718 | (if (and count (> 1 count)) | 3750 | (cond ((and current-prefix-arg (< count 1)) |
| 3719 | (error "This command only accepts a positive numerical prefix argument") | 3751 | (user-error "The prefix argument must be a positive number")) |
| 3720 | (let* ((done (todos-done-item-p))) | 3752 | (current-prefix-arg |
| 3721 | (todos-item-start) | 3753 | (todos-backward-item count)) |
| 3722 | (unless (bobp) | 3754 | (t |
| 3723 | (re-search-backward todos-item-start nil t (or count 1))) | 3755 | (todos-backward-item))))) |
| 3724 | ;; Unless this is a regexp filtered items buffer (which can contain | ||
| 3725 | ;; intermixed todo and done items), if points advances by one from a | ||
| 3726 | ;; done to a todo item, go back to the space above | ||
| 3727 | ;; todos-done-separator, since that is a legitimate place to insert an | ||
| 3728 | ;; item. But skip this space if count > 1, since that should only | ||
| 3729 | ;; stop on an item. | ||
| 3730 | (when (and done (not (todos-done-item-p)) (not count) | ||
| 3731 | ;(or (not count) (= count 1)) | ||
| 3732 | (not (equal (buffer-name) todos-regexp-items-buffer))) | ||
| 3733 | (re-search-forward (concat "^" (regexp-quote todos-category-done)) | ||
| 3734 | nil t) | ||
| 3735 | (forward-line -1)))))) | ||
| 3736 | 3756 | ||
| 3737 | (defun todos-forward-button (n &optional wrap display-message) | 3757 | (defun todos-next-button (n &optional wrap display-message) |
| 3738 | "" | 3758 | "" |
| 3739 | (interactive "p\nd\nd") | 3759 | (interactive "p\nd\nd") |
| 3740 | (forward-button n wrap display-message) | 3760 | (forward-button n wrap display-message) |
| @@ -3742,7 +3762,7 @@ empty line above the done items separator." | |||
| 3742 | ;; Align with beginning of category label. | 3762 | ;; Align with beginning of category label. |
| 3743 | (forward-char (+ 4 (length todos-categories-number-separator))))) | 3763 | (forward-char (+ 4 (length todos-categories-number-separator))))) |
| 3744 | 3764 | ||
| 3745 | (defun todos-backward-button (n &optional wrap display-message) | 3765 | (defun todos-previous-button (n &optional wrap display-message) |
| 3746 | "" | 3766 | "" |
| 3747 | (interactive "p\nd\nd") | 3767 | (interactive "p\nd\nd") |
| 3748 | (backward-button n wrap display-message) | 3768 | (backward-button n wrap display-message) |
| @@ -3784,7 +3804,7 @@ face." | |||
| 3784 | (todos-category-number cat) | 3804 | (todos-category-number cat) |
| 3785 | (todos-category-select) | 3805 | (todos-category-select) |
| 3786 | (if in-done | 3806 | (if in-done |
| 3787 | (unless todos-show-with-done (todos-hide-show-done-items))) | 3807 | (unless todos-show-with-done (todos-toggle-view-done-items))) |
| 3788 | (goto-char match) | 3808 | (goto-char match) |
| 3789 | (setq ov (make-overlay (- (point) (length regex)) (point))) | 3809 | (setq ov (make-overlay (- (point) (length regex)) (point))) |
| 3790 | (overlay-put ov 'face 'todos-search) | 3810 | (overlay-put ov 'face 'todos-search) |
| @@ -3819,12 +3839,12 @@ face." | |||
| 3819 | ;; --------------------------------------------------------------------------- | 3839 | ;; --------------------------------------------------------------------------- |
| 3820 | ;;; Display Commands | 3840 | ;;; Display Commands |
| 3821 | 3841 | ||
| 3822 | (defun todos-hide-show-item-numbering () | 3842 | (defun todos-toggle-prefix-numbers () |
| 3823 | "" | 3843 | "" |
| 3824 | (interactive) | 3844 | (interactive) |
| 3825 | (todos-reset-prefix 'todos-number-priorities (not todos-number-priorities))) | 3845 | (todos-reset-prefix 'todos-number-prefix (not todos-number-prefix))) |
| 3826 | 3846 | ||
| 3827 | (defun todos-hide-show-done-items () | 3847 | (defun todos-toggle-view-done-items () |
| 3828 | "Show hidden or hide visible done items in current category." | 3848 | "Show hidden or hide visible done items in current category." |
| 3829 | (interactive) | 3849 | (interactive) |
| 3830 | (if (zerop (todos-get-count 'done (todos-current-category))) | 3850 | (if (zerop (todos-get-count 'done (todos-current-category))) |
| @@ -3845,13 +3865,13 @@ face." | |||
| 3845 | (recenter) | 3865 | (recenter) |
| 3846 | (goto-char opoint))))))) | 3866 | (goto-char opoint))))))) |
| 3847 | 3867 | ||
| 3848 | (defun todos-show-done-only () | 3868 | (defun todos-toggle-view-done-only () |
| 3849 | "Switch between displaying only done or only todo items." | 3869 | "Switch between displaying only done or only todo items." |
| 3850 | (interactive) | 3870 | (interactive) |
| 3851 | (setq todos-show-done-only (not todos-show-done-only)) | 3871 | (setq todos-show-done-only (not todos-show-done-only)) |
| 3852 | (todos-category-select)) | 3872 | (todos-category-select)) |
| 3853 | 3873 | ||
| 3854 | (defun todos-highlight-item () | 3874 | (defun todos-toggle-item-highlighting () |
| 3855 | "Highlight or unhighlight the todo item the cursor is on." | 3875 | "Highlight or unhighlight the todo item the cursor is on." |
| 3856 | (interactive) | 3876 | (interactive) |
| 3857 | (require 'hl-line) | 3877 | (require 'hl-line) |
| @@ -3859,7 +3879,7 @@ face." | |||
| 3859 | (hl-line-mode -1) | 3879 | (hl-line-mode -1) |
| 3860 | (hl-line-mode 1))) | 3880 | (hl-line-mode 1))) |
| 3861 | 3881 | ||
| 3862 | (defun todos-hide-show-date-time () | 3882 | (defun todos-toggle-item-header () |
| 3863 | "Hide or show date-time header of todo items in the current file." | 3883 | "Hide or show date-time header of todo items in the current file." |
| 3864 | (interactive) | 3884 | (interactive) |
| 3865 | (save-excursion | 3885 | (save-excursion |
| @@ -3881,7 +3901,7 @@ face." | |||
| 3881 | (overlay-put ov 'display ""))) | 3901 | (overlay-put ov 'display ""))) |
| 3882 | (todos-forward-item)))))) | 3902 | (todos-forward-item)))))) |
| 3883 | 3903 | ||
| 3884 | (defun todos-mark-unmark-item (&optional n) | 3904 | (defun todos-toggle-mark-item (&optional n) |
| 3885 | "Mark item with `todos-item-mark' if unmarked, otherwise unmark it. | 3905 | "Mark item with `todos-item-mark' if unmarked, otherwise unmark it. |
| 3886 | With a positive numerical prefix argument N, change the | 3906 | With a positive numerical prefix argument N, change the |
| 3887 | marking of the next N items." | 3907 | marking of the next N items." |
| @@ -3953,15 +3973,15 @@ See `todos-set-top-priorities' for more details." | |||
| 3953 | (interactive) | 3973 | (interactive) |
| 3954 | (todos-set-top-priorities t)) | 3974 | (todos-set-top-priorities t)) |
| 3955 | 3975 | ||
| 3956 | (defun todos-top-priorities (&optional arg) | 3976 | (defun todos-filter-top-priorities (&optional arg) |
| 3957 | "Display a list of top priority items from different categories. | 3977 | "Display a list of top priority items from different categories. |
| 3958 | The categories can be any of those in the current Todos file. | 3978 | The categories can be any of those in the current Todos file. |
| 3959 | 3979 | ||
| 3960 | With numerical prefix ARG show at most ARG top priority items | 3980 | With numerical prefix ARG show at most ARG top priority items |
| 3961 | from each category. With `C-u' as prefix argument show the | 3981 | from each category. With `C-u' as prefix argument show the |
| 3962 | numbers of top priority items specified by category in | 3982 | numbers of top priority items specified by category in |
| 3963 | `todos-priorities-rules', if this has an entry for the file(s); | 3983 | `todos-top-priorities-overrides', if this has an entry for the file(s); |
| 3964 | otherwise show `todos-show-priorities' items per category in the | 3984 | otherwise show `todos-top-priorities' items per category in the |
| 3965 | file(s). With no prefix argument, if a top priorities file for | 3985 | file(s). With no prefix argument, if a top priorities file for |
| 3966 | the current Todos file has previously been saved (see | 3986 | the current Todos file has previously been saved (see |
| 3967 | `todos-save-filtered-items-buffer'), visit this file; if there is | 3987 | `todos-save-filtered-items-buffer'), visit this file; if there is |
| @@ -3972,7 +3992,7 @@ each category to show, as described above." | |||
| 3972 | (interactive "P") | 3992 | (interactive "P") |
| 3973 | (todos-filter-items 'top arg)) | 3993 | (todos-filter-items 'top arg)) |
| 3974 | 3994 | ||
| 3975 | (defun todos-top-priorities-multifile (&optional arg) | 3995 | (defun todos-filter-top-priorities-multifile (&optional arg) |
| 3976 | "Display a list of top priority items from different categories. | 3996 | "Display a list of top priority items from different categories. |
| 3977 | The categories are a subset of the categories in the files listed | 3997 | The categories are a subset of the categories in the files listed |
| 3978 | in `todos-filter-files', or if this nil, in the files chosen from | 3998 | in `todos-filter-files', or if this nil, in the files chosen from |
| @@ -3981,8 +4001,8 @@ a file selection dialog that pops up in this case. | |||
| 3981 | With numerical prefix ARG show at most ARG top priority items | 4001 | With numerical prefix ARG show at most ARG top priority items |
| 3982 | from each category in each file. With `C-u' as prefix argument | 4002 | from each category in each file. With `C-u' as prefix argument |
| 3983 | show the numbers of top priority items specified in | 4003 | show the numbers of top priority items specified in |
| 3984 | `todos-priorities-rules', if this is non-nil; otherwise show | 4004 | `todos-top-priorities-overrides', if this is non-nil; otherwise show |
| 3985 | `todos-show-priorities' items per category. With no prefix | 4005 | `todos-top-priorities' items per category. With no prefix |
| 3986 | argument, if a top priorities file for the chosen Todos files | 4006 | argument, if a top priorities file for the chosen Todos files |
| 3987 | exists (see `todos-save-filtered-items-buffer'), visit this file; | 4007 | exists (see `todos-save-filtered-items-buffer'), visit this file; |
| 3988 | if there is no such file, do the same as with prefix argument | 4008 | if there is no such file, do the same as with prefix argument |
| @@ -3990,7 +4010,7 @@ if there is no such file, do the same as with prefix argument | |||
| 3990 | (interactive "P") | 4010 | (interactive "P") |
| 3991 | (todos-filter-items 'top arg t)) | 4011 | (todos-filter-items 'top arg t)) |
| 3992 | 4012 | ||
| 3993 | (defun todos-diary-items (&optional arg) | 4013 | (defun todos-filter-diary-items (&optional arg) |
| 3994 | "Display a list of todo diary items from different categories. | 4014 | "Display a list of todo diary items from different categories. |
| 3995 | The categories can be any of those in the current Todos file. | 4015 | The categories can be any of those in the current Todos file. |
| 3996 | 4016 | ||
| @@ -4003,7 +4023,7 @@ diary items." | |||
| 4003 | (interactive "P") | 4023 | (interactive "P") |
| 4004 | (todos-filter-items 'diary arg)) | 4024 | (todos-filter-items 'diary arg)) |
| 4005 | 4025 | ||
| 4006 | (defun todos-diary-items-multifile (&optional arg) | 4026 | (defun todos-filter-diary-items-multifile (&optional arg) |
| 4007 | "Display a list of todo diary items from different categories. | 4027 | "Display a list of todo diary items from different categories. |
| 4008 | The categories are a subset of the categories in the files listed | 4028 | The categories are a subset of the categories in the files listed |
| 4009 | in `todos-filter-files', or if this nil, in the files chosen from | 4029 | in `todos-filter-files', or if this nil, in the files chosen from |
| @@ -4018,7 +4038,7 @@ diary items." | |||
| 4018 | (interactive "P") | 4038 | (interactive "P") |
| 4019 | (todos-filter-items 'diary arg t)) | 4039 | (todos-filter-items 'diary arg t)) |
| 4020 | 4040 | ||
| 4021 | (defun todos-regexp-items (&optional arg) | 4041 | (defun todos-filter-regexp-items (&optional arg) |
| 4022 | "Prompt for a regular expression and display items that match it. | 4042 | "Prompt for a regular expression and display items that match it. |
| 4023 | The matches can be from any categories in the current Todos file | 4043 | The matches can be from any categories in the current Todos file |
| 4024 | and with non-nil option `todos-filter-done-items', can include | 4044 | and with non-nil option `todos-filter-done-items', can include |
| @@ -4034,7 +4054,7 @@ regexp items." | |||
| 4034 | (interactive "P") | 4054 | (interactive "P") |
| 4035 | (todos-filter-items 'regexp arg)) | 4055 | (todos-filter-items 'regexp arg)) |
| 4036 | 4056 | ||
| 4037 | (defun todos-regexp-items-multifile (&optional arg) | 4057 | (defun todos-filter-regexp-items-multifile (&optional arg) |
| 4038 | "Prompt for a regular expression and display items that match it. | 4058 | "Prompt for a regular expression and display items that match it. |
| 4039 | The matches can be from any categories in the files listed in | 4059 | The matches can be from any categories in the files listed in |
| 4040 | `todos-filter-files', or if this nil, in the files chosen from a | 4060 | `todos-filter-files', or if this nil, in the files chosen from a |
| @@ -4510,7 +4530,7 @@ raise or lower the category's priority by one." | |||
| 4510 | (with-current-buffer (find-buffer-visiting todos-current-todos-file) | 4530 | (with-current-buffer (find-buffer-visiting todos-current-todos-file) |
| 4511 | (setq todos-categories newcats) | 4531 | (setq todos-categories newcats) |
| 4512 | (todos-update-categories-sexp)) | 4532 | (todos-update-categories-sexp)) |
| 4513 | (todos-display-categories) | 4533 | (todos-show-categories-table) |
| 4514 | (forward-line (1+ priority)) | 4534 | (forward-line (1+ priority)) |
| 4515 | (forward-char col)))))) | 4535 | (forward-char col)))))) |
| 4516 | 4536 | ||
| @@ -4528,7 +4548,7 @@ raise or lower the category's priority by one." | |||
| 4528 | ;;; Item editing commands | 4548 | ;;; Item editing commands |
| 4529 | 4549 | ||
| 4530 | ;;;###autoload | 4550 | ;;;###autoload |
| 4531 | (defun todos-insert-item (&optional arg diary nonmarking date-type time | 4551 | (defun todos-insert-item-1 (&optional arg diary nonmarking date-type time |
| 4532 | region-or-here) | 4552 | region-or-here) |
| 4533 | "Add a new Todo item to a category. | 4553 | "Add a new Todo item to a category. |
| 4534 | \(See the note at the end of this document string about key | 4554 | \(See the note at the end of this document string about key |
| @@ -4625,7 +4645,7 @@ the priority is not given by HERE but by prompting." | |||
| 4625 | ;; An alternative interface for customizing key | 4645 | ;; An alternative interface for customizing key |
| 4626 | ;; binding is also provided with the function | 4646 | ;; binding is also provided with the function |
| 4627 | ;; `todos-insertion-bindings'." ;FIXME | 4647 | ;; `todos-insertion-bindings'." ;FIXME |
| 4628 | (interactive "P") | 4648 | ;; (interactive "P") |
| 4629 | ;; If invoked outside of Todos mode and there is not yet any Todos | 4649 | ;; If invoked outside of Todos mode and there is not yet any Todos |
| 4630 | ;; file, initialize one. | 4650 | ;; file, initialize one. |
| 4631 | (if (null todos-files) | 4651 | (if (null todos-files) |
| @@ -4730,7 +4750,7 @@ the priority is not given by HERE but by prompting." | |||
| 4730 | (goto-char (point-min)) | 4750 | (goto-char (point-min)) |
| 4731 | (looking-at todos-done-string-start)) | 4751 | (looking-at todos-done-string-start)) |
| 4732 | (setq done-only t) | 4752 | (setq done-only t) |
| 4733 | (todos-show-done-only)) | 4753 | (todos-toggle-view-done-only)) |
| 4734 | (if here | 4754 | (if here |
| 4735 | (progn | 4755 | (progn |
| 4736 | ;; If command was invoked with point in done | 4756 | ;; If command was invoked with point in done |
| @@ -4752,7 +4772,7 @@ the priority is not given by HERE but by prompting." | |||
| 4752 | (unless (equal cat ocat) | 4772 | (unless (equal cat ocat) |
| 4753 | (todos-category-number ocat) | 4773 | (todos-category-number ocat) |
| 4754 | (todos-category-select)) | 4774 | (todos-category-select)) |
| 4755 | (and done-only (todos-show-done-only))) | 4775 | (and done-only (todos-toggle-view-done-only))) |
| 4756 | (set-window-buffer (selected-window) (set-buffer obuf))) | 4776 | (set-window-buffer (selected-window) (set-buffer obuf))) |
| 4757 | (goto-char opoint)) | 4777 | (goto-char opoint)) |
| 4758 | ;; If the todo items section is not visible when the | 4778 | ;; If the todo items section is not visible when the |
| @@ -4919,7 +4939,7 @@ the format of Diary entries." | |||
| 4919 | (concat "Type \\[todos-edit-quit] " | 4939 | (concat "Type \\[todos-edit-quit] " |
| 4920 | "to return to Todos mode.\n")))))) | 4940 | "to return to Todos mode.\n")))))) |
| 4921 | 4941 | ||
| 4922 | (defun todos-edit-multiline (&optional item) ;FIXME: not item editing command | 4942 | (defun todos-edit-file (&optional item) ;FIXME: not item editing command |
| 4923 | "" ;FIXME | 4943 | "" ;FIXME |
| 4924 | (interactive) | 4944 | (interactive) |
| 4925 | (widen) | 4945 | (widen) |
| @@ -5445,7 +5465,7 @@ meaning to raise or lower the item's priority by one." | |||
| 5445 | (when priority | 5465 | (when priority |
| 5446 | (unless (= priority 1) | 5466 | (unless (= priority 1) |
| 5447 | (todos-forward-item (1- priority)) | 5467 | (todos-forward-item (1- priority)) |
| 5448 | ;; When called from todos-item-undo and the highest priority | 5468 | ;; When called from todos-item-undone and the highest priority |
| 5449 | ;; is chosen, this advances point to the first done item, so | 5469 | ;; is chosen, this advances point to the first done item, so |
| 5450 | ;; move it up to the empty line above the done items | 5470 | ;; move it up to the empty line above the done items |
| 5451 | ;; separator. | 5471 | ;; separator. |
| @@ -5724,7 +5744,7 @@ With prefix ARG delete an existing comment." | |||
| 5724 | (todos-item-end) | 5744 | (todos-item-end) |
| 5725 | (insert " [" todos-comment-string ": " comment "]")))))) | 5745 | (insert " [" todos-comment-string ": " comment "]")))))) |
| 5726 | 5746 | ||
| 5727 | (defun todos-item-undo () | 5747 | (defun todos-item-undone () |
| 5728 | "Restore at least one done item to this category's todo section. | 5748 | "Restore at least one done item to this category's todo section. |
| 5729 | Prompt for the new priority. If there are marked items, undo all | 5749 | Prompt for the new priority. If there are marked items, undo all |
| 5730 | of these, giving the first undone item the new priority and the | 5750 | of these, giving the first undone item the new priority and the |
| @@ -5823,14 +5843,14 @@ comments without asking." | |||
| 5823 | (defun todos-archive-done-item (&optional all) | 5843 | (defun todos-archive-done-item (&optional all) |
| 5824 | "Archive at least one done item in this category. | 5844 | "Archive at least one done item in this category. |
| 5825 | 5845 | ||
| 5826 | If there are marked done items (and no marked todo items), | 5846 | With a prefix argument, prompt whether to archive all done items |
| 5827 | archive all of these; otherwise, with non-nil argument ALL, | 5847 | in this category and on confirmation archive them. Otherwise, if |
| 5828 | archive all done items in this category; otherwise, archive the | 5848 | there are marked done items (and no marked todo items), archive |
| 5829 | done item at point. | 5849 | all of these; otherwise, archive the done item at point. |
| 5830 | 5850 | ||
| 5831 | If the archive of this file does not exist, it is created. If | 5851 | If the archive of this file does not exist, it is created. If |
| 5832 | this category does not exist in the archive, it is created." | 5852 | this category does not exist in the archive, it is created." |
| 5833 | (interactive) | 5853 | (interactive "P") |
| 5834 | (when (eq major-mode 'todos-mode) | 5854 | (when (eq major-mode 'todos-mode) |
| 5835 | (if (and all (zerop (todos-get-count 'done))) | 5855 | (if (and all (zerop (todos-get-count 'done))) |
| 5836 | (message "No done items in this category") | 5856 | (message "No done items in this category") |
| @@ -5849,17 +5869,6 @@ this category does not exist in the archive, it is created." | |||
| 5849 | marked-items beg end all-done | 5869 | marked-items beg end all-done |
| 5850 | buffer-read-only) | 5870 | buffer-read-only) |
| 5851 | (cond | 5871 | (cond |
| 5852 | (marked | ||
| 5853 | (save-excursion | ||
| 5854 | (goto-char (point-min)) | ||
| 5855 | (while (not (eobp)) | ||
| 5856 | (when (todos-marked-item-p) | ||
| 5857 | (if (not (todos-done-item-p)) | ||
| 5858 | (throw 'end (message "Only done items can be archived")) | ||
| 5859 | (setq marked-items | ||
| 5860 | (concat marked-items (todos-item-string) "\n")) | ||
| 5861 | (setq count (1+ count)))) | ||
| 5862 | (todos-forward-item)))) | ||
| 5863 | (all | 5872 | (all |
| 5864 | (if (y-or-n-p "Archive all done items in this category? ") | 5873 | (if (y-or-n-p "Archive all done items in this category? ") |
| 5865 | (save-excursion | 5874 | (save-excursion |
| @@ -5879,7 +5888,18 @@ this category does not exist in the archive, it is created." | |||
| 5879 | ;; Restore starting point, unless it was on a done | 5888 | ;; Restore starting point, unless it was on a done |
| 5880 | ;; item, since they will all be deleted. | 5889 | ;; item, since they will all be deleted. |
| 5881 | (when opoint (goto-char opoint)))) | 5890 | (when opoint (goto-char opoint)))) |
| 5882 | (throw 'end nil)))) | 5891 | (throw 'end nil))) |
| 5892 | (marked | ||
| 5893 | (save-excursion | ||
| 5894 | (goto-char (point-min)) | ||
| 5895 | (while (not (eobp)) | ||
| 5896 | (when (todos-marked-item-p) | ||
| 5897 | (if (not (todos-done-item-p)) | ||
| 5898 | (throw 'end (message "Only done items can be archived")) | ||
| 5899 | (setq marked-items | ||
| 5900 | (concat marked-items (todos-item-string) "\n")) | ||
| 5901 | (setq count (1+ count)))) | ||
| 5902 | (todos-forward-item))))) | ||
| 5883 | (if (not (or marked all item)) | 5903 | (if (not (or marked all item)) |
| 5884 | (throw 'end (message "Only done items can be archived")) | 5904 | (throw 'end (message "Only done items can be archived")) |
| 5885 | (with-current-buffer archive | 5905 | (with-current-buffer archive |
| @@ -5910,34 +5930,35 @@ this category does not exist in the archive, it is created." | |||
| 5910 | (write-region nil nil afile) | 5930 | (write-region nil nil afile) |
| 5911 | (kill-buffer)))) | 5931 | (kill-buffer)))) |
| 5912 | (with-current-buffer tbuf | 5932 | (with-current-buffer tbuf |
| 5913 | (cond ((or marked | 5933 | (cond |
| 5914 | ;; If we're archiving all done items, can't | 5934 | (all |
| 5915 | ;; first archive item point was on, since | 5935 | (save-excursion |
| 5916 | ;; that will short-circuit the rest. | 5936 | (save-restriction |
| 5917 | (and item (not all))) | 5937 | ;; Make sure done items are accessible. |
| 5918 | (and marked (goto-char (point-min))) | 5938 | (widen) |
| 5919 | (catch 'done | 5939 | (remove-overlays beg end) |
| 5920 | (while (not (eobp)) | 5940 | (delete-region beg end) |
| 5921 | (if (or (and marked (todos-marked-item-p)) item) | 5941 | (todos-update-count 'done (- count)) |
| 5922 | (progn | 5942 | (todos-update-count 'archived count)))) |
| 5923 | (todos-remove-item) | 5943 | ((or marked |
| 5924 | (todos-update-count 'done -1) | 5944 | ;; If we're archiving all done items, can't |
| 5925 | (todos-update-count 'archived 1) | 5945 | ;; first archive item point was on, since |
| 5926 | ;; Don't leave point below last item. | 5946 | ;; that will short-circuit the rest. |
| 5927 | (and item (bolp) (eolp) (< (point-min) (point-max)) | 5947 | (and item (not all))) |
| 5928 | (todos-backward-item)) | 5948 | (and marked (goto-char (point-min))) |
| 5929 | (when item | 5949 | (catch 'done |
| 5930 | (throw 'done (setq item nil)))) | 5950 | (while (not (eobp)) |
| 5931 | (todos-forward-item))))) | 5951 | (if (or (and marked (todos-marked-item-p)) item) |
| 5932 | (all | 5952 | (progn |
| 5933 | (save-excursion | 5953 | (todos-remove-item) |
| 5934 | (save-restriction | 5954 | (todos-update-count 'done -1) |
| 5935 | ;; Make sure done items are accessible. | 5955 | (todos-update-count 'archived 1) |
| 5936 | (widen) | 5956 | ;; Don't leave point below last item. |
| 5937 | (remove-overlays beg end) | 5957 | (and item (bolp) (eolp) (< (point-min) (point-max)) |
| 5938 | (delete-region beg end) | 5958 | (todos-backward-item)) |
| 5939 | (todos-update-count 'done (- count)) | 5959 | (when item |
| 5940 | (todos-update-count 'archived count))))) | 5960 | (throw 'done (setq item nil)))) |
| 5961 | (todos-forward-item)))))) | ||
| 5941 | (when marked | 5962 | (when marked |
| 5942 | (setq todos-categories-with-marks | 5963 | (setq todos-categories-with-marks |
| 5943 | (assq-delete-all cat todos-categories-with-marks))) | 5964 | (assq-delete-all cat todos-categories-with-marks))) |
| @@ -5954,11 +5975,6 @@ this category does not exist in the archive, it is created." | |||
| 5954 | ;; were initially visible). | 5975 | ;; were initially visible). |
| 5955 | (let (todos-show-with-done) (todos-category-select))))))) | 5976 | (let (todos-show-with-done) (todos-category-select))))))) |
| 5956 | 5977 | ||
| 5957 | (defun todos-archive-category-done-items () | ||
| 5958 | "Move all done items in this category to its archive." | ||
| 5959 | (interactive) | ||
| 5960 | (todos-archive-done-item t)) | ||
| 5961 | |||
| 5962 | (defun todos-unarchive-items () | 5978 | (defun todos-unarchive-items () |
| 5963 | "Unarchive at least one item in this archive category. | 5979 | "Unarchive at least one item in this archive category. |
| 5964 | If there are marked items, unarchive all of these; otherwise, | 5980 | If there are marked items, unarchive all of these; otherwise, |