diff options
| author | Stephen Berman | 2013-01-31 00:34:31 +0100 |
|---|---|---|
| committer | Stephen Berman | 2013-01-31 00:34:31 +0100 |
| commit | 0d6eb16262072a01b3ee7d4bbe7916ca4b52da6d (patch) | |
| tree | ef0966db89e7660f4e25f178cb87b05913acef2b | |
| parent | 1fcf038b833284393c3bdc3b3e6358385c682e3d (diff) | |
| download | emacs-0d6eb16262072a01b3ee7d4bbe7916ca4b52da6d.tar.gz emacs-0d6eb16262072a01b3ee7d4bbe7916ca4b52da6d.zip | |
* calendar/todos.el: Fix done separator overlay bug. Remove most
FIXME comments.
(todos-reset-and-enable-done-separator): Remove commented out
workaround for done separator overlay bug; fix doc string.
(todos-reset-done-separator): Delete old overlay after adding new
overlay to fix done separator overlay bug; improve implementation.
(todos-prefix-overlays): Improve first line of doc string.
| -rw-r--r-- | lisp/ChangeLog | 10 | ||||
| -rw-r--r-- | lisp/calendar/todos.el | 122 |
2 files changed, 29 insertions, 103 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index c9ca1b6865a..f2d5d2e22c4 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,13 @@ | |||
| 1 | 2013-01-30 Stephen Berman <stephen.berman@gmx.net> | ||
| 2 | |||
| 3 | * calendar/todos.el: Fix done separator overlay bug. Remove most | ||
| 4 | FIXME comments. | ||
| 5 | (todos-reset-and-enable-done-separator): Remove commented out | ||
| 6 | workaround for done separator overlay bug; fix doc string. | ||
| 7 | (todos-reset-done-separator): Delete old overlay after adding new | ||
| 8 | overlay to fix done separator overlay bug; improve implementation. | ||
| 9 | (todos-prefix-overlays): Improve first line of doc string. | ||
| 10 | |||
| 1 | 2013-01-29 Stephen Berman <stephen.berman@gmx.net> | 11 | 2013-01-29 Stephen Berman <stephen.berman@gmx.net> |
| 2 | 12 | ||
| 3 | * calendar/todos.el: Improve item marking and handling of marked items. | 13 | * calendar/todos.el: Improve item marking and handling of marked items. |
diff --git a/lisp/calendar/todos.el b/lisp/calendar/todos.el index d396fe69357..7511c7cc2b6 100644 --- a/lisp/calendar/todos.el +++ b/lisp/calendar/todos.el | |||
| @@ -40,7 +40,6 @@ | |||
| 40 | :version "24.2" | 40 | :version "24.2" |
| 41 | :group 'calendar) | 41 | :group 'calendar) |
| 42 | 42 | ||
| 43 | ;; FIXME: use file-truename (but in a defcustom) ? | ||
| 44 | (defcustom todos-files-directory (locate-user-emacs-file "todos/") | 43 | (defcustom todos-files-directory (locate-user-emacs-file "todos/") |
| 45 | "Directory where user's Todos files are saved." | 44 | "Directory where user's Todos files are saved." |
| 46 | :type 'directory | 45 | :type 'directory |
| @@ -80,7 +79,6 @@ This lacks the extension and directory components." | |||
| 80 | (funcall todos-files-function)))) | 79 | (funcall todos-files-function)))) |
| 81 | :group 'todos) | 80 | :group 'todos) |
| 82 | 81 | ||
| 83 | ;; FIXME: is there a better alternative to this? | ||
| 84 | (defun todos-reevaluate-default-file-defcustom () | 82 | (defun todos-reevaluate-default-file-defcustom () |
| 85 | "Reevaluate defcustom of `todos-default-todos-file'. | 83 | "Reevaluate defcustom of `todos-default-todos-file'. |
| 86 | Called after adding or deleting a Todos file." | 84 | Called after adding or deleting a Todos file." |
| @@ -113,7 +111,6 @@ Otherwise, `todos-show' always visits `todos-default-todos-file'." | |||
| 113 | (funcall todos-files-function)))) | 111 | (funcall todos-files-function)))) |
| 114 | :group 'todos) | 112 | :group 'todos) |
| 115 | 113 | ||
| 116 | ;; FIXME: is there a better alternative to this? | ||
| 117 | (defun todos-reevaluate-category-completions-files-defcustom () | 114 | (defun todos-reevaluate-category-completions-files-defcustom () |
| 118 | "Reevaluate defcustom of `todos-category-completions-files'. | 115 | "Reevaluate defcustom of `todos-category-completions-files'. |
| 119 | Called after adding or deleting a Todos file." | 116 | Called after adding or deleting a Todos file." |
| @@ -403,8 +400,6 @@ The amount of indentation is given by user option | |||
| 403 | (unless (member '(continuation) fringe-indicator-alist) | 400 | (unless (member '(continuation) fringe-indicator-alist) |
| 404 | (push '(continuation) fringe-indicator-alist))) | 401 | (push '(continuation) fringe-indicator-alist))) |
| 405 | 402 | ||
| 406 | ;; FIXME: :set function to refill items with hard newlines and to immediately | ||
| 407 | ;; update wrapped prefix display | ||
| 408 | (defcustom todos-indent-to-here 6 | 403 | (defcustom todos-indent-to-here 6 |
| 409 | "Number of spaces `todos-line-wrapping-function' indents to." | 404 | "Number of spaces `todos-line-wrapping-function' indents to." |
| 410 | :type '(integer :validate | 405 | :type '(integer :validate |
| @@ -544,11 +539,6 @@ items in that category, which overrides NUM." | |||
| 544 | :type 'integer | 539 | :type 'integer |
| 545 | :group 'todos-filtered) | 540 | :group 'todos-filtered) |
| 546 | 541 | ||
| 547 | ;; (defcustom todos-save-top-priorities nil ;FIXME: use or delete this | ||
| 548 | ;; "Non-nil to" | ||
| 549 | ;; :type 'boolean | ||
| 550 | ;; :group 'todos-filtered) | ||
| 551 | |||
| 552 | (defcustom todos-filter-files nil | 542 | (defcustom todos-filter-files nil |
| 553 | "List of default files for multifile item filtering." | 543 | "List of default files for multifile item filtering." |
| 554 | :type `(set ,@(mapcar (lambda (f) (list 'const f)) | 544 | :type `(set ,@(mapcar (lambda (f) (list 'const f)) |
| @@ -556,7 +546,6 @@ items in that category, which overrides NUM." | |||
| 556 | (funcall todos-files-function)))) | 546 | (funcall todos-files-function)))) |
| 557 | :group 'todos-filtered) | 547 | :group 'todos-filtered) |
| 558 | 548 | ||
| 559 | ;; FIXME: is there a better alternative to this? | ||
| 560 | (defun todos-reevaluate-filter-files-defcustom () | 549 | (defun todos-reevaluate-filter-files-defcustom () |
| 561 | "Reevaluate defcustom of `todos-filter-files'. | 550 | "Reevaluate defcustom of `todos-filter-files'. |
| 562 | Called after adding or deleting a Todos file." | 551 | Called after adding or deleting a Todos file." |
| @@ -1030,24 +1019,12 @@ Set by the command `todos-show-done-only' and used by | |||
| 1030 | `todos-category-select'.") | 1019 | `todos-category-select'.") |
| 1031 | 1020 | ||
| 1032 | (defun todos-reset-and-enable-done-separator () | 1021 | (defun todos-reset-and-enable-done-separator () |
| 1033 | "Show resized catagory separator overlay after window size change. | 1022 | "Show resized done items separator overlay after window change. |
| 1034 | Added to `window-configuration-change-hook' in `todos-mode'." | 1023 | Added to `window-configuration-change-hook' in `todos-mode'." |
| 1035 | (when (= 1 (length todos-done-separator-string)) | 1024 | (when (= 1 (length todos-done-separator-string)) |
| 1036 | (let ((sep todos-done-separator)) | 1025 | (let ((sep todos-done-separator)) |
| 1037 | (setq todos-done-separator (todos-done-separator)) | 1026 | (setq todos-done-separator (todos-done-separator)) |
| 1038 | (save-match-data (todos-reset-done-separator sep))) | 1027 | (save-match-data (todos-reset-done-separator sep))))) |
| 1039 | ;; FIXME: If this is called while the separator overlay is shown, the | ||
| 1040 | ;; separator with deleted overlay becomes visible when waiting for user | ||
| 1041 | ;; input and remains so. The following workaround prevents this, but it | ||
| 1042 | ;; also prevents widening category when edebugging todos.el. | ||
| 1043 | ;; (save-excursion | ||
| 1044 | ;; (goto-char (point-min)) | ||
| 1045 | ;; (when (re-search-forward todos-done-string-start nil t) | ||
| 1046 | ;; (let ((todos-show-with-done nil)) | ||
| 1047 | ;; (todos-category-select)) | ||
| 1048 | ;; (let ((todos-show-with-done t)) | ||
| 1049 | ;; (todos-category-select)))) | ||
| 1050 | )) | ||
| 1051 | 1028 | ||
| 1052 | ;; --------------------------------------------------------------------------- | 1029 | ;; --------------------------------------------------------------------------- |
| 1053 | ;;; Global variables and helper functions for files and buffers | 1030 | ;;; Global variables and helper functions for files and buffers |
| @@ -1159,7 +1136,7 @@ number as its value." | |||
| 1159 | (1+ (- (length categories) | 1136 | (1+ (- (length categories) |
| 1160 | (length (member cat categories))))))) | 1137 | (length (member cat categories))))))) |
| 1161 | 1138 | ||
| 1162 | (defun todos-current-category () ;FIXME: arg FILE ? | 1139 | (defun todos-current-category () |
| 1163 | "Return the name of the current category." | 1140 | "Return the name of the current category." |
| 1164 | (car (nth (1- todos-category-number) todos-categories))) | 1141 | (car (nth (1- todos-category-number) todos-categories))) |
| 1165 | 1142 | ||
| @@ -1194,14 +1171,13 @@ done items are shown. Its value is determined by user option | |||
| 1194 | (let* ((beg (match-beginning 1)) | 1171 | (let* ((beg (match-beginning 1)) |
| 1195 | (end (match-end 0)) | 1172 | (end (match-end 0)) |
| 1196 | (ovs (overlays-at beg)) | 1173 | (ovs (overlays-at beg)) |
| 1197 | old-sep new-sep) | 1174 | (ov (when ovs (car ovs))) |
| 1198 | (and ovs | 1175 | (old-sep (when ov (overlay-get ov 'display))) |
| 1199 | (setq old-sep (overlay-get (car ovs) 'display)) | 1176 | new-ov) |
| 1200 | (string= old-sep sep) | 1177 | (when (string= old-sep sep) |
| 1201 | (delete-overlay (car ovs)) | 1178 | (setq new-ov (make-overlay beg end)) |
| 1202 | (setq new-sep (make-overlay beg end)) | 1179 | (overlay-put new-ov 'display todos-done-separator) |
| 1203 | (overlay-put new-sep 'display | 1180 | (delete-overlay ov))))))) |
| 1204 | todos-done-separator))))))) | ||
| 1205 | 1181 | ||
| 1206 | (defun todos-category-completions () | 1182 | (defun todos-category-completions () |
| 1207 | "Return a list of completions for `todos-read-category'. | 1183 | "Return a list of completions for `todos-read-category'. |
| @@ -1252,11 +1228,6 @@ Todos files named in `todos-category-completions-files'." | |||
| 1252 | (point-max))) | 1228 | (point-max))) |
| 1253 | (setq mode-line-buffer-identification | 1229 | (setq mode-line-buffer-identification |
| 1254 | (funcall todos-mode-line-function name)) | 1230 | (funcall todos-mode-line-function name)) |
| 1255 | ;; FIXME: When, starting from `C-u i i' (and apparently only from | ||
| 1256 | ;; this, e.g. `m' does not trigger the problem), after the | ||
| 1257 | ;; following line is executed, the last line of the narrowed | ||
| 1258 | ;; region (sometimes, always?) is at (window-start)... (continued | ||
| 1259 | ;; below) | ||
| 1260 | (narrow-to-region cat-begin cat-end) | 1231 | (narrow-to-region cat-begin cat-end) |
| 1261 | (todos-prefix-overlays) | 1232 | (todos-prefix-overlays) |
| 1262 | (goto-char (point-min)) | 1233 | (goto-char (point-min)) |
| @@ -1283,14 +1254,6 @@ Todos files named in `todos-category-completions-files'." | |||
| 1283 | (unless (and ovs (string= (overlay-get (car ovs) 'display) done-sep)) | 1254 | (unless (and ovs (string= (overlay-get (car ovs) 'display) done-sep)) |
| 1284 | (setq ov-sep (make-overlay done-sep-start done-end)) | 1255 | (setq ov-sep (make-overlay done-sep-start done-end)) |
| 1285 | (overlay-put ov-sep 'display done-sep)))) | 1256 | (overlay-put ov-sep 'display done-sep)))) |
| 1286 | ;; FIXME: (continued) ...and after the following line, now the | ||
| 1287 | ;; new last line of the narrowed region is (sometimes?) at | ||
| 1288 | ;; (window-start), and after inserting the new item at the | ||
| 1289 | ;; bottom of the list, the latter remains at (window-start). | ||
| 1290 | ;; But `M-<' corrects the display, and since the narrowed region | ||
| 1291 | ;; is shorter than (window-height), there is no way to | ||
| 1292 | ;; interactively make Emacs show the last line at | ||
| 1293 | ;; (window-start). | ||
| 1294 | (narrow-to-region (point-min) done-start) | 1257 | (narrow-to-region (point-min) done-start) |
| 1295 | ;; Loading this from todos-mode, or adding it to the mode hook, causes | 1258 | ;; Loading this from todos-mode, or adding it to the mode hook, causes |
| 1296 | ;; Emacs to hang in todos-item-start, at (looking-at todos-item-start). | 1259 | ;; Emacs to hang in todos-item-start, at (looking-at todos-item-start). |
| @@ -1349,7 +1312,6 @@ With nil or omitted CATEGORY, default to the current category." | |||
| 1349 | ;; to this file, so have to initialize Todos file and | 1312 | ;; to this file, so have to initialize Todos file and |
| 1350 | ;; categories variables in order e.g. to enable categories | 1313 | ;; categories variables in order e.g. to enable categories |
| 1351 | ;; display. | 1314 | ;; display. |
| 1352 | ;; FIXME: is this right? | ||
| 1353 | (setq todos-default-todos-file (buffer-file-name)) | 1315 | (setq todos-default-todos-file (buffer-file-name)) |
| 1354 | (setq todos-categories (todos-make-categories-list t))) | 1316 | (setq todos-categories (todos-make-categories-list t))) |
| 1355 | ;; With empty buffer (e.g. with new archive in | 1317 | ;; With empty buffer (e.g. with new archive in |
| @@ -1452,12 +1414,6 @@ The final element is \"*\", indicating an unspecified month.") | |||
| 1452 | (let ((dayname (diary-name-pattern calendar-day-name-array nil t))) | 1414 | (let ((dayname (diary-name-pattern calendar-day-name-array nil t))) |
| 1453 | (concat "\\(?5:" dayname "\\|" | 1415 | (concat "\\(?5:" dayname "\\|" |
| 1454 | (let ((dayname) | 1416 | (let ((dayname) |
| 1455 | ;; FIXME: how to choose between abbreviated and unabbreviated | ||
| 1456 | ;; month name? | ||
| 1457 | ;; (monthname (format "\\(?6:%s\\|\\*\\)" | ||
| 1458 | ;; (diary-name-pattern | ||
| 1459 | ;; calendar-month-name-array | ||
| 1460 | ;; calendar-month-abbrev-array))) | ||
| 1461 | (monthname (format "\\(?6:%s\\)" (diary-name-pattern | 1417 | (monthname (format "\\(?6:%s\\)" (diary-name-pattern |
| 1462 | todos-month-name-array | 1418 | todos-month-name-array |
| 1463 | todos-month-abbrev-array))) | 1419 | todos-month-abbrev-array))) |
| @@ -1599,8 +1555,8 @@ The final element is \"*\", indicating an unspecified month.") | |||
| 1599 | (todos-backward-item) | 1555 | (todos-backward-item) |
| 1600 | (todos-prefix-overlays)) | 1556 | (todos-prefix-overlays)) |
| 1601 | 1557 | ||
| 1602 | (defun todos-prefix-overlays () ;FIXME: this is a category function | 1558 | (defun todos-prefix-overlays () |
| 1603 | "Put before-string overlay in front of this category's items. | 1559 | "Update the prefix overlays of the current category's items. |
| 1604 | The overlay's value is the string `todos-prefix' or with non-nil | 1560 | The overlay's value is the string `todos-prefix' or with non-nil |
| 1605 | `todos-number-priorities' an integer in the sequence from 1 to | 1561 | `todos-number-priorities' an integer in the sequence from 1 to |
| 1606 | the number of todo or done items in the category indicating the | 1562 | the number of todo or done items in the category indicating the |
| @@ -1820,7 +1776,6 @@ When ARG is `day', non-nil arguments MO and YR determine the | |||
| 1820 | number of the last the day of the month." | 1776 | number of the last the day of the month." |
| 1821 | (let (year monthname month day | 1777 | (let (year monthname month day |
| 1822 | dayname) ; Needed by calendar-date-display-form. | 1778 | dayname) ; Needed by calendar-date-display-form. |
| 1823 | ;; FIXME: year can be omitted from Diary | ||
| 1824 | (when (or (not arg) (eq arg 'year)) | 1779 | (when (or (not arg) (eq arg 'year)) |
| 1825 | (while (if (natnump year) (< year 1) (not (eq year '*))) | 1780 | (while (if (natnump year) (< year 1) (not (eq year '*))) |
| 1826 | (setq year (read-from-minibuffer | 1781 | (setq year (read-from-minibuffer |
| @@ -1846,9 +1801,6 @@ number of the last the day of the month." | |||
| 1846 | month (1+ (- (length mlist) | 1801 | month (1+ (- (length mlist) |
| 1847 | (length (or (member monthname mlist) | 1802 | (length (or (member monthname mlist) |
| 1848 | (member monthname mablist)))))) | 1803 | (member monthname mablist)))))) |
| 1849 | ;; FIXME: We follow diary-insert-entry in using abbreviated | ||
| 1850 | ;; month name (and no day name) in date string. Should this | ||
| 1851 | ;; be customizable? | ||
| 1852 | (setq monthname (aref mabarray (1- month))))) | 1804 | (setq monthname (aref mabarray (1- month))))) |
| 1853 | (when (or (not arg) (eq arg 'day)) | 1805 | (when (or (not arg) (eq arg 'day)) |
| 1854 | (let ((last (let ((mm (or month mo)) | 1806 | (let ((last (let ((mm (or month mo)) |
| @@ -2272,7 +2224,7 @@ priority has changed or its text was truncated or augmented, and | |||
| 2272 | ;; "\nType <return> on item for details." | 2224 | ;; "\nType <return> on item for details." |
| 2273 | ))))) | 2225 | ))))) |
| 2274 | 2226 | ||
| 2275 | (defun todos-top-priorities-filename () ;FIXME: make part of t-s-t-p-b ? | 2227 | (defun todos-top-priorities-filename () |
| 2276 | "" | 2228 | "" |
| 2277 | (let ((bufname (buffer-name))) | 2229 | (let ((bufname (buffer-name))) |
| 2278 | (string-match "\"\\([^\"]+\\)\"" bufname) | 2230 | (string-match "\"\\([^\"]+\\)\"" bufname) |
| @@ -2488,7 +2440,6 @@ which is the value of the user option | |||
| 2488 | (let ((archive (member todos-current-todos-file todos-archives)) | 2440 | (let ((archive (member todos-current-todos-file todos-archives)) |
| 2489 | buffer-read-only) | 2441 | buffer-read-only) |
| 2490 | (erase-buffer) | 2442 | (erase-buffer) |
| 2491 | ;; FIXME: add usage tips? | ||
| 2492 | (insert (format (concat "Category counts for Todos " | 2443 | (insert (format (concat "Category counts for Todos " |
| 2493 | (if archive "archive" "file") | 2444 | (if archive "archive" "file") |
| 2494 | " \"%s\".") | 2445 | " \"%s\".") |
| @@ -2648,7 +2599,6 @@ which is the value of the user option | |||
| 2648 | "-\\_>" "" | 2599 | "-\\_>" "" |
| 2649 | (replace-regexp-in-string | 2600 | (replace-regexp-in-string |
| 2650 | "-+" "-" | 2601 | "-+" "-" |
| 2651 | ;; FIXME: "todos-insert-item-" | ||
| 2652 | (concat "todos-item-insert-" | 2602 | (concat "todos-item-insert-" |
| 2653 | (mapconcat (lambda (e) (if e (symbol-name e))) arglist "-"))))) | 2603 | (mapconcat (lambda (e) (if e (symbol-name e))) arglist "-"))))) |
| 2654 | 2604 | ||
| @@ -2658,7 +2608,6 @@ which is the value of the user option | |||
| 2658 | todos-insertion-commands-args) | 2608 | todos-insertion-commands-args) |
| 2659 | "List of names of Todos insertion commands.") | 2609 | "List of names of Todos insertion commands.") |
| 2660 | 2610 | ||
| 2661 | ;; FIXME: prefix argument ARG is nil | ||
| 2662 | (defmacro todos-define-insertion-command (&rest args) | 2611 | (defmacro todos-define-insertion-command (&rest args) |
| 2663 | (let ((name (intern (todos-insertion-command-name args))) | 2612 | (let ((name (intern (todos-insertion-command-name args))) |
| 2664 | (arg0 (nth 0 args)) | 2613 | (arg0 (nth 0 args)) |
| @@ -2671,9 +2620,6 @@ which is the value of the user option | |||
| 2671 | (interactive (list current-prefix-arg)) | 2620 | (interactive (list current-prefix-arg)) |
| 2672 | (todos-insert-item arg ',arg0 ',arg1 ',arg2 ',arg3 ',arg4)))) | 2621 | (todos-insert-item arg ',arg0 ',arg1 ',arg2 ',arg3 ',arg4)))) |
| 2673 | 2622 | ||
| 2674 | ;; FIXME: exclude todos-insert-item (or rather from | ||
| 2675 | ;; todos-insertion-key-bindings?), otherwise its doc string won't be | ||
| 2676 | ;; found with C-h k (but it will with M-x todos-insert-item) | ||
| 2677 | (defvar todos-insertion-commands | 2623 | (defvar todos-insertion-commands |
| 2678 | (mapcar (lambda (c) | 2624 | (mapcar (lambda (c) |
| 2679 | (eval `(todos-define-insertion-command ,@c))) | 2625 | (eval `(todos-define-insertion-command ,@c))) |
| @@ -2803,7 +2749,6 @@ which is the value of the user option | |||
| 2803 | map) | 2749 | map) |
| 2804 | "Todos mode keymap.") | 2750 | "Todos mode keymap.") |
| 2805 | 2751 | ||
| 2806 | ;; FIXME | ||
| 2807 | (easy-menu-define | 2752 | (easy-menu-define |
| 2808 | todos-menu todos-mode-map "Todos Menu" | 2753 | todos-menu todos-mode-map "Todos Menu" |
| 2809 | '("Todos" | 2754 | '("Todos" |
| @@ -3109,7 +3054,6 @@ corresponding Todos file, displaying the corresponding category." | |||
| 3109 | ;; called again from todos-display-categories. | 3054 | ;; called again from todos-display-categories. |
| 3110 | (let ((todos-current-todos-file file)) | 3055 | (let ((todos-current-todos-file file)) |
| 3111 | (cond ((eq todos-show-first 'table) | 3056 | (cond ((eq todos-show-first 'table) |
| 3112 | ;; FIXME: what if there are no categories yet? | ||
| 3113 | (todos-display-categories)) | 3057 | (todos-display-categories)) |
| 3114 | ((eq todos-show-first 'top) | 3058 | ((eq todos-show-first 'top) |
| 3115 | (let* ((shortf (todos-short-file-name file)) | 3059 | (let* ((shortf (todos-short-file-name file)) |
| @@ -3665,9 +3609,6 @@ upward." | |||
| 3665 | ;; Align with beginning of category label. | 3609 | ;; Align with beginning of category label. |
| 3666 | (forward-char (+ 4 (length todos-categories-number-separator))))) | 3610 | (forward-char (+ 4 (length todos-categories-number-separator))))) |
| 3667 | 3611 | ||
| 3668 | ;; FIXME: (i) Extend search to other Todos files. (ii) Allow navigating among | ||
| 3669 | ;; hits. (But these features are effectively available with | ||
| 3670 | ;; todos-regexp-items-multifile, so maybe it's not worth the trouble here.) | ||
| 3671 | (defun todos-search () | 3612 | (defun todos-search () |
| 3672 | "Search for a regular expression in this Todos file. | 3613 | "Search for a regular expression in this Todos file. |
| 3673 | The search runs through the whole file and encompasses all and | 3614 | The search runs through the whole file and encompasses all and |
| @@ -4051,7 +3992,7 @@ return the new category number." | |||
| 4051 | file0 (if (called-interactively-p 'any) | 3992 | file0 (if (called-interactively-p 'any) |
| 4052 | (cdr catfil) | 3993 | (cdr catfil) |
| 4053 | file))) | 3994 | file))) |
| 4054 | (find-file file0) ;FIXME:? find-file-noselect, set-buffer etc. | 3995 | (find-file file0) |
| 4055 | (let ((counts (make-vector 4 0)) ; [todo diary done archived] | 3996 | (let ((counts (make-vector 4 0)) ; [todo diary done archived] |
| 4056 | (num (1+ (length todos-categories))) | 3997 | (num (1+ (length todos-categories))) |
| 4057 | (buffer-read-only nil)) | 3998 | (buffer-read-only nil)) |
| @@ -4236,10 +4177,9 @@ archive of the file moved to, creating it if it does not exist." | |||
| 4236 | (setq todos-categories | 4177 | (setq todos-categories |
| 4237 | (append todos-categories (list (cons new counts)))) | 4178 | (append todos-categories (list (cons new counts)))) |
| 4238 | (todos-update-categories-sexp) | 4179 | (todos-update-categories-sexp) |
| 4239 | ;; If archive was just created, save it to avoid "File <xyz> no | 4180 | ;; If archive was just created, save it to avoid "File |
| 4240 | ;; longer exists!" message on invoking | 4181 | ;; <xyz> no longer exists!" message on invoking |
| 4241 | ;; `todos-view-archived-items'. FIXME: maybe better to save | 4182 | ;; `todos-view-archived-items'. |
| 4242 | ;; unconditionally? | ||
| 4243 | (unless (file-exists-p (buffer-file-name)) | 4183 | (unless (file-exists-p (buffer-file-name)) |
| 4244 | (save-buffer)) | 4184 | (save-buffer)) |
| 4245 | (todos-category-number (or new cat)) | 4185 | (todos-category-number (or new cat)) |
| @@ -4475,7 +4415,6 @@ raise or lower the category's priority by one." | |||
| 4475 | ;; --------------------------------------------------------------------------- | 4415 | ;; --------------------------------------------------------------------------- |
| 4476 | ;;; Item editing commands | 4416 | ;;; Item editing commands |
| 4477 | 4417 | ||
| 4478 | ;; FIXME: make insertion options customizable per category? | ||
| 4479 | ;;;###autoload | 4418 | ;;;###autoload |
| 4480 | (defun todos-insert-item (&optional arg diary nonmarking date-type time | 4419 | (defun todos-insert-item (&optional arg diary nonmarking date-type time |
| 4481 | region-or-here) | 4420 | region-or-here) |
| @@ -4615,10 +4554,6 @@ the priority is not given by HERE but by prompting." | |||
| 4615 | (setq todos-date-from-calendar date-type) | 4554 | (setq todos-date-from-calendar date-type) |
| 4616 | (todos-set-date-from-calendar)) | 4555 | (todos-set-date-from-calendar)) |
| 4617 | (t | 4556 | (t |
| 4618 | ;; FIXME: We follow diary-insert-entry in | ||
| 4619 | ;; hardcoding abbreviated month name and no | ||
| 4620 | ;; day name in date string. Should this be | ||
| 4621 | ;; customizable? | ||
| 4622 | (calendar-date-string (calendar-current-date) t t)))) | 4557 | (calendar-date-string (calendar-current-date) t t)))) |
| 4623 | (time-string (or (and time (todos-read-time)) | 4558 | (time-string (or (and time (todos-read-time)) |
| 4624 | (and todos-always-add-time-string | 4559 | (and todos-always-add-time-string |
| @@ -4655,8 +4590,6 @@ the priority is not given by HERE but by prompting." | |||
| 4655 | "\\(\n\\)[^[:blank:]]" | 4590 | "\\(\n\\)[^[:blank:]]" |
| 4656 | (concat "\n" (make-string todos-indent-to-here 32)) | 4591 | (concat "\n" (make-string todos-indent-to-here 32)) |
| 4657 | new-item nil nil 1)) | 4592 | new-item nil nil 1)) |
| 4658 | ;; FIXME: after jumping to another category due to `C-u i h', | ||
| 4659 | ;; item is inserted as first item -- ok? | ||
| 4660 | (if here | 4593 | (if here |
| 4661 | (cond ((not (eq major-mode 'todos-mode)) | 4594 | (cond ((not (eq major-mode 'todos-mode)) |
| 4662 | (error "Cannot insert a todo item here outside of Todos mode")) | 4595 | (error "Cannot insert a todo item here outside of Todos mode")) |
| @@ -4708,7 +4641,6 @@ the priority is not given by HERE but by prompting." | |||
| 4708 | (calendar-exit) | 4641 | (calendar-exit) |
| 4709 | (exit-recursive-edit)))) | 4642 | (exit-recursive-edit)))) |
| 4710 | (message "Put cursor on a date and type <return> to set it.") | 4643 | (message "Put cursor on a date and type <return> to set it.") |
| 4711 | ;; FIXME: is there a better way than recursive-edit? | ||
| 4712 | (recursive-edit) | 4644 | (recursive-edit) |
| 4713 | (unwind-protect | 4645 | (unwind-protect |
| 4714 | (when (equal (buffer-name) calendar-buffer) | 4646 | (when (equal (buffer-name) calendar-buffer) |
| @@ -4733,7 +4665,6 @@ the item at point." | |||
| 4733 | (let* ((cat (todos-current-category)) | 4665 | (let* ((cat (todos-current-category)) |
| 4734 | (marked (assoc cat todos-categories-with-marks)) | 4666 | (marked (assoc cat todos-categories-with-marks)) |
| 4735 | (item (unless marked (todos-item-string))) | 4667 | (item (unless marked (todos-item-string))) |
| 4736 | ;; FIXME: make confirmation an option? | ||
| 4737 | (answer (if marked | 4668 | (answer (if marked |
| 4738 | (y-or-n-p "Permanently delete all marked items? ") | 4669 | (y-or-n-p "Permanently delete all marked items? ") |
| 4739 | (when item | 4670 | (when item |
| @@ -4849,8 +4780,6 @@ whether the file is still a valid Todos file and if so, also | |||
| 4849 | recalculate the Todos categories sexp, in case changes were made | 4780 | recalculate the Todos categories sexp, in case changes were made |
| 4850 | in the number or names of categories." | 4781 | in the number or names of categories." |
| 4851 | (interactive) | 4782 | (interactive) |
| 4852 | ;; FIXME: Should do todos-check-format only if file was actually changed -- | ||
| 4853 | ;; but how to tell? | ||
| 4854 | (when (eq (buffer-size) (- (point-max) (point-min))) | 4783 | (when (eq (buffer-size) (- (point-max) (point-min))) |
| 4855 | (when (todos-check-format) (todos-repair-categories-sexp))) | 4784 | (when (todos-check-format) (todos-repair-categories-sexp))) |
| 4856 | (kill-buffer) | 4785 | (kill-buffer) |
| @@ -4858,7 +4787,7 @@ in the number or names of categories." | |||
| 4858 | (todos-show)) | 4787 | (todos-show)) |
| 4859 | 4788 | ||
| 4860 | (defun todos-edit-item-header-1 (what &optional inc) | 4789 | (defun todos-edit-item-header-1 (what &optional inc) |
| 4861 | "Underlying function to edit items' date/time headers. | 4790 | "Function underlying commands to edit item date/time header. |
| 4862 | 4791 | ||
| 4863 | The argument WHAT (passed by invoking commands) specifies what | 4792 | The argument WHAT (passed by invoking commands) specifies what |
| 4864 | part of the header to edit; possible values are these symbols: | 4793 | part of the header to edit; possible values are these symbols: |
| @@ -4949,7 +4878,7 @@ otherwise, edit just the item at point." | |||
| 4949 | (todos-read-date 'year)) | 4878 | (todos-read-date 'year)) |
| 4950 | ((string= oyear "*") | 4879 | ((string= oyear "*") |
| 4951 | (error "Cannot increment *")) | 4880 | (error "Cannot increment *")) |
| 4952 | (t ; FIXME: handle negative years | 4881 | (t |
| 4953 | (number-to-string (+ yy inc)))))) | 4882 | (number-to-string (+ yy inc)))))) |
| 4954 | ((eq what 'month) | 4883 | ((eq what 'month) |
| 4955 | (setf day oday | 4884 | (setf day oday |
| @@ -5218,8 +5147,6 @@ items in this category." | |||
| 5218 | (insert diary-nonmarking-symbol)))) | 5147 | (insert diary-nonmarking-symbol)))) |
| 5219 | (todos-forward-item))))))) | 5148 | (todos-forward-item))))))) |
| 5220 | 5149 | ||
| 5221 | ;; FIXME: Make NOP if point isn't on a todo item (cf. todos-copy-item, | ||
| 5222 | ;; todos-move-item | ||
| 5223 | (defun todos-set-item-priority (&optional item cat new arg) | 5150 | (defun todos-set-item-priority (&optional item cat new arg) |
| 5224 | "Set todo ITEM's priority in CATegory and move item accordingly. | 5151 | "Set todo ITEM's priority in CATegory and move item accordingly. |
| 5225 | 5152 | ||
| @@ -5491,17 +5418,6 @@ section in the category moved to." | |||
| 5491 | (todos-category-select) | 5418 | (todos-category-select) |
| 5492 | (goto-char omark)))))))) | 5419 | (goto-char omark)))))))) |
| 5493 | 5420 | ||
| 5494 | ;; (defun todos-move-item-to-diary () | ||
| 5495 | ;; "Move one or more items in current category to the diary file. | ||
| 5496 | ;; | ||
| 5497 | ;; If there are marked items, move all of these; otherwise, move | ||
| 5498 | ;; the item at point." | ||
| 5499 | ;; (interactive) | ||
| 5500 | ;; ;; FIXME | ||
| 5501 | ;; ) | ||
| 5502 | |||
| 5503 | ;; FIXME: make adding date customizable, and make this and time customization | ||
| 5504 | ;; overridable via double prefix arg ?? | ||
| 5505 | (defun todos-item-done (&optional arg) | 5421 | (defun todos-item-done (&optional arg) |
| 5506 | "Tag at least one item in this category as done and hide it. | 5422 | "Tag at least one item in this category as done and hide it. |
| 5507 | 5423 | ||