diff options
| author | Stephen Berman | 2012-06-27 12:26:28 +0100 |
|---|---|---|
| committer | Stephen Berman | 2012-06-27 12:26:28 +0100 |
| commit | 36341a665a7cad79eafc77685503f7fa9e234c30 (patch) | |
| tree | 5bb69a9565ad2c86bfc363e55cc85cf17cf15502 | |
| parent | 3160f2eb373462baf6bb2c224c74e83a9b37c537 (diff) | |
| download | emacs-36341a665a7cad79eafc77685503f7fa9e234c30.tar.gz emacs-36341a665a7cad79eafc77685503f7fa9e234c30.zip | |
* calendar/todos.el: Further code rearrangement; further new and
revised comments.
(todos-reevaluate-filelist-defcustoms): Rename from
todos-reevaluate-defcustoms and adjust callers.
(todos-date-pattern, todos-nondiary-start, todos-nondiary-end)
(todos-date-string-start, todos-done-string-start)
(todos-item-start): Change from defvar to defconst.
(todos-set-top-priorities): Use read-number and simplify.
(todos-insert-item): Check whether date-type argument is a string.
(todos-set-date-from-calendar): Check whether
todos-date-from-calendar is a string; simplify cond clause.
(todos-archive-done-item, todos-unarchive-items):
Use buffer-substring-no-properties.
| -rw-r--r-- | lisp/ChangeLog | 16 | ||||
| -rw-r--r-- | lisp/calendar/todos.el | 216 |
2 files changed, 132 insertions, 100 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index e2a7037e1a6..eaab22994b0 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,19 @@ | |||
| 1 | 2012-09-24 Stephen Berman <stephen.berman@gmx.net> | ||
| 2 | |||
| 3 | * calendar/todos.el: Further code rearrangement; further new and | ||
| 4 | revised comments. | ||
| 5 | (todos-reevaluate-filelist-defcustoms): Rename from | ||
| 6 | todos-reevaluate-defcustoms and adjust callers. | ||
| 7 | (todos-date-pattern, todos-nondiary-start, todos-nondiary-end) | ||
| 8 | (todos-date-string-start, todos-done-string-start) | ||
| 9 | (todos-item-start): Change from defvar to defconst. | ||
| 10 | (todos-set-top-priorities): Use read-number and simplify. | ||
| 11 | (todos-insert-item): Check whether date-type argument is a string. | ||
| 12 | (todos-set-date-from-calendar): Check whether | ||
| 13 | todos-date-from-calendar is a string; simplify cond clause. | ||
| 14 | (todos-archive-done-item, todos-unarchive-items): | ||
| 15 | Use buffer-substring-no-properties. | ||
| 16 | |||
| 1 | 2012-09-23 Stephen Berman <stephen.berman@gmx.net> | 17 | 2012-09-23 Stephen Berman <stephen.berman@gmx.net> |
| 2 | 18 | ||
| 3 | * calendar/todos.el (todos-item-undo): Fix restoration on | 19 | * calendar/todos.el (todos-item-undo): Fix restoration on |
diff --git a/lisp/calendar/todos.el b/lisp/calendar/todos.el index 2d0dfdb10a8..08fe35b9612 100644 --- a/lisp/calendar/todos.el +++ b/lisp/calendar/todos.el | |||
| @@ -152,6 +152,9 @@ todo-mode.el." | |||
| 152 | :type 'regexp | 152 | :type 'regexp |
| 153 | :group 'todos) | 153 | :group 'todos) |
| 154 | 154 | ||
| 155 | ;; --------------------------------------------------------------------------- | ||
| 156 | ;;; Todos mode display options | ||
| 157 | |||
| 155 | (defgroup todos-mode-display nil | 158 | (defgroup todos-mode-display nil |
| 156 | "User display options for Todos mode." | 159 | "User display options for Todos mode." |
| 157 | :version "24.2" | 160 | :version "24.2" |
| @@ -364,6 +367,9 @@ The amount of indentation is given by user option | |||
| 364 | "Indent from point to `todos-indent-to-here'." | 367 | "Indent from point to `todos-indent-to-here'." |
| 365 | (indent-to todos-indent-to-here todos-indent-to-here)) | 368 | (indent-to todos-indent-to-here todos-indent-to-here)) |
| 366 | 369 | ||
| 370 | ;; --------------------------------------------------------------------------- | ||
| 371 | ;;; Item insertion options | ||
| 372 | |||
| 367 | (defgroup todos-item-insertion nil | 373 | (defgroup todos-item-insertion nil |
| 368 | "User options for adding new todo items." | 374 | "User options for adding new todo items." |
| 369 | :version "24.2" | 375 | :version "24.2" |
| @@ -438,6 +444,9 @@ current time, if nil, they include it." | |||
| 438 | :type 'boolean | 444 | :type 'boolean |
| 439 | :group 'todos-item-insertion) | 445 | :group 'todos-item-insertion) |
| 440 | 446 | ||
| 447 | ;; --------------------------------------------------------------------------- | ||
| 448 | ;;; Todos Filter Items mode options | ||
| 449 | |||
| 441 | (defgroup todos-filtered nil | 450 | (defgroup todos-filtered nil |
| 442 | "User options for Todos Filter Items mode." | 451 | "User options for Todos Filter Items mode." |
| 443 | :version "24.2" | 452 | :version "24.2" |
| @@ -507,6 +516,9 @@ Done items from corresponding archive files are also included." | |||
| 507 | :type 'boolean | 516 | :type 'boolean |
| 508 | :group 'todos-filtered) | 517 | :group 'todos-filtered) |
| 509 | 518 | ||
| 519 | ;; --------------------------------------------------------------------------- | ||
| 520 | ;;; Todos Categories mode options | ||
| 521 | |||
| 510 | (defgroup todos-categories nil | 522 | (defgroup todos-categories nil |
| 511 | "User options for Todos Categories mode." | 523 | "User options for Todos Categories mode." |
| 512 | :version "24.2" | 524 | :version "24.2" |
| @@ -555,7 +567,7 @@ categories display according to priority." | |||
| 555 | :group 'todos-categories) | 567 | :group 'todos-categories) |
| 556 | 568 | ||
| 557 | ;; --------------------------------------------------------------------------- | 569 | ;; --------------------------------------------------------------------------- |
| 558 | ;;; Faces and font-locking | 570 | ;;; Faces and font-lock matcher functions |
| 559 | 571 | ||
| 560 | (defgroup todos-faces nil | 572 | (defgroup todos-faces nil |
| 561 | "Faces for the Todos modes." | 573 | "Faces for the Todos modes." |
| @@ -950,7 +962,7 @@ Added to `window-configuration-change-hook' in `todos-mode'." | |||
| 950 | ;; FIXME: If this is called while the separator overlay is shown, the | 962 | ;; FIXME: If this is called while the separator overlay is shown, the |
| 951 | ;; separator with deleted overlay becomes visible when waiting for user | 963 | ;; separator with deleted overlay becomes visible when waiting for user |
| 952 | ;; input and remains so. The following workaround prevents this, but it | 964 | ;; input and remains so. The following workaround prevents this, but it |
| 953 | ;; also prevents widening when edebugging todos.el. | 965 | ;; also prevents widening category when edebugging todos.el. |
| 954 | ;; (save-excursion | 966 | ;; (save-excursion |
| 955 | ;; (goto-char (point-min)) | 967 | ;; (goto-char (point-min)) |
| 956 | ;; (when (re-search-forward todos-done-string-start nil t) | 968 | ;; (when (re-search-forward todos-done-string-start nil t) |
| @@ -961,7 +973,7 @@ Added to `window-configuration-change-hook' in `todos-mode'." | |||
| 961 | )) | 973 | )) |
| 962 | 974 | ||
| 963 | ;; --------------------------------------------------------------------------- | 975 | ;; --------------------------------------------------------------------------- |
| 964 | ;;; Global variables and helper functions | 976 | ;;; Global variables and helper functions for files and buffers |
| 965 | 977 | ||
| 966 | (defvar todos-files (funcall todos-files-function) | 978 | (defvar todos-files (funcall todos-files-function) |
| 967 | "List of truenames of user's Todos files.") | 979 | "List of truenames of user's Todos files.") |
| @@ -978,7 +990,7 @@ Used by functions called from outside of Todos mode to visit the | |||
| 978 | current Todos file rather than the default Todos file (i.e. when | 990 | current Todos file rather than the default Todos file (i.e. when |
| 979 | users option `todos-show-current-file' is non-nil).") | 991 | users option `todos-show-current-file' is non-nil).") |
| 980 | 992 | ||
| 981 | (defun todos-reevaluate-defcustoms () | 993 | (defun todos-reevaluate-filelist-defcustoms () |
| 982 | "Reevaluate defcustoms that provide choice list of Todos files." | 994 | "Reevaluate defcustoms that provide choice list of Todos files." |
| 983 | (custom-set-default 'todos-default-todos-file | 995 | (custom-set-default 'todos-default-todos-file |
| 984 | (symbol-value 'todos-default-todos-file)) | 996 | (symbol-value 'todos-default-todos-file)) |
| @@ -995,40 +1007,49 @@ users option `todos-show-current-file' is non-nil).") | |||
| 995 | (defvar todos-print-buffer "*Todos Print*" | 1007 | (defvar todos-print-buffer "*Todos Print*" |
| 996 | "Name of buffer containing printable Todos text.") | 1008 | "Name of buffer containing printable Todos text.") |
| 997 | 1009 | ||
| 998 | (defvar todos-date-pattern | 1010 | (defun todos-check-format () |
| 999 | (let ((dayname (diary-name-pattern calendar-day-name-array nil t))) | 1011 | "Signal an error if the current Todos file is ill-formatted. |
| 1000 | (concat "\\(?:" dayname "\\|" | 1012 | Otherwise return t. The error message gives the line number |
| 1001 | (let ((dayname) | 1013 | where the invalid formatting was found." |
| 1002 | ;; FIXME: how to choose between abbreviated and unabbreviated | 1014 | (save-excursion |
| 1003 | ;; month name? | 1015 | (save-restriction |
| 1004 | (monthname (format "\\(?:%s\\|\\*\\)" | 1016 | (widen) |
| 1005 | (diary-name-pattern | 1017 | (goto-char (point-min)) |
| 1006 | calendar-month-name-array | 1018 | ;; Check for `todos-categories' sexp as the first line |
| 1007 | calendar-month-abbrev-array t))) | 1019 | (let ((cats (prin1-to-string todos-categories))) |
| 1008 | (month "\\(?:[0-9]+\\|\\*\\)") | 1020 | (unless (looking-at (regexp-quote cats)) |
| 1009 | (day "\\(?:[0-9]+\\|\\*\\)") | 1021 | (error "Invalid or missing todos-categories sexp"))) |
| 1010 | (year "-?\\(?:[0-9]+\\|\\*\\)")) | 1022 | (forward-line) |
| 1011 | (mapconcat 'eval calendar-date-display-form "")) | 1023 | (let ((legit (concat "\\(^" (regexp-quote todos-category-beg) "\\)" |
| 1012 | "\\)")) | 1024 | "\\|\\(" todos-date-string-start todos-date-pattern "\\)" |
| 1013 | "Regular expression matching a Todos date header.") | 1025 | "\\|\\(^[ \t]+[^ \t]*\\)" |
| 1014 | 1026 | "\\|^$" | |
| 1015 | (defvar todos-nondiary-start (nth 0 todos-nondiary-marker) | 1027 | "\\|\\(^" (regexp-quote todos-category-done) "\\)" |
| 1016 | "String inserted before item date to block diary inclusion.") | 1028 | "\\|\\(" todos-done-string-start "\\)"))) |
| 1017 | 1029 | (while (not (eobp)) | |
| 1018 | (defvar todos-nondiary-end (nth 1 todos-nondiary-marker) | 1030 | (unless (looking-at legit) |
| 1019 | "String inserted after item date matching `todos-nondiary-start'.") | 1031 | (error "Illegitimate Todos file format at line %d" |
| 1032 | (line-number-at-pos (point)))) | ||
| 1033 | (forward-line))))) | ||
| 1034 | ;; (message "This Todos file is well-formatted.") | ||
| 1035 | t) | ||
| 1020 | 1036 | ||
| 1021 | ;; By itself this matches anything, because of the `?'; however, it's only | 1037 | ;; --------------------------------------------------------------------------- |
| 1022 | ;; used in the context of `todos-date-pattern' (but Emacs Lisp lacks | 1038 | (defun todos-convert-legacy-date-time () |
| 1023 | ;; lookahead). | 1039 | "Return converted date-time string. |
| 1024 | (defvar todos-date-string-start | 1040 | Helper function for `todos-convert-legacy-files'." |
| 1025 | (concat "^\\(" (regexp-quote todos-nondiary-start) "\\|" | 1041 | (let* ((year (match-string 1)) |
| 1026 | (regexp-quote diary-nonmarking-symbol) "\\)?") | 1042 | (month (match-string 2)) |
| 1027 | "Regular expression matching part of item header before the date.") | 1043 | (monthname (calendar-month-name (string-to-number month) t)) |
| 1044 | (day (match-string 3)) | ||
| 1045 | (time (match-string 4)) | ||
| 1046 | dayname) | ||
| 1047 | (replace-match "") | ||
| 1048 | (insert (mapconcat 'eval calendar-date-display-form "") | ||
| 1049 | (when time (concat " " time))))) | ||
| 1028 | 1050 | ||
| 1029 | (defvar todos-done-string-start | 1051 | ;; --------------------------------------------------------------------------- |
| 1030 | (concat "^\\[" (regexp-quote todos-done-string)) | 1052 | ;;; Global variables and helper functions for categories |
| 1031 | "Regular expression matching start of done item.") | ||
| 1032 | 1053 | ||
| 1033 | (defun todos-category-number (cat) | 1054 | (defun todos-category-number (cat) |
| 1034 | "Return the number of category CAT in this Todos file. | 1055 | "Return the number of category CAT in this Todos file. |
| @@ -1065,7 +1086,7 @@ done items are shown. Its value is determined by user option | |||
| 1065 | `todos-done-separator-string'.") | 1086 | `todos-done-separator-string'.") |
| 1066 | 1087 | ||
| 1067 | (defun todos-reset-done-separator (sep) | 1088 | (defun todos-reset-done-separator (sep) |
| 1068 | "Replace any existing overlays of separator string SEP." | 1089 | "Replace existing overlays of done items separator string SEP." |
| 1069 | (save-excursion | 1090 | (save-excursion |
| 1070 | (save-restriction | 1091 | (save-restriction |
| 1071 | (widen) | 1092 | (widen) |
| @@ -1260,33 +1281,6 @@ the file." | |||
| 1260 | (forward-line))))) | 1281 | (forward-line))))) |
| 1261 | todos-categories) | 1282 | todos-categories) |
| 1262 | 1283 | ||
| 1263 | (defun todos-check-format () | ||
| 1264 | "Signal an error if the current Todos file is ill-formatted. | ||
| 1265 | Otherwise return t. The error message gives the line number | ||
| 1266 | where the invalid formatting was found." | ||
| 1267 | (save-excursion | ||
| 1268 | (save-restriction | ||
| 1269 | (widen) | ||
| 1270 | (goto-char (point-min)) | ||
| 1271 | ;; Check for `todos-categories' sexp as the first line | ||
| 1272 | (let ((cats (prin1-to-string todos-categories))) | ||
| 1273 | (unless (looking-at (regexp-quote cats)) | ||
| 1274 | (error "Invalid or missing todos-categories sexp"))) | ||
| 1275 | (forward-line) | ||
| 1276 | (let ((legit (concat "\\(^" (regexp-quote todos-category-beg) "\\)" | ||
| 1277 | "\\|\\(" todos-date-string-start todos-date-pattern "\\)" | ||
| 1278 | "\\|\\(^[ \t]+[^ \t]*\\)" | ||
| 1279 | "\\|^$" | ||
| 1280 | "\\|\\(^" (regexp-quote todos-category-done) "\\)" | ||
| 1281 | "\\|\\(" todos-done-string-start "\\)"))) | ||
| 1282 | (while (not (eobp)) | ||
| 1283 | (unless (looking-at legit) | ||
| 1284 | (error "Illegitimate Todos file format at line %d" | ||
| 1285 | (line-number-at-pos (point)))) | ||
| 1286 | (forward-line))))) | ||
| 1287 | ;; (message "This Todos file is well-formatted.") | ||
| 1288 | t) | ||
| 1289 | |||
| 1290 | (defun todos-repair-categories-sexp () | 1284 | (defun todos-repair-categories-sexp () |
| 1291 | "Repair corrupt Todos categories sexp. | 1285 | "Repair corrupt Todos categories sexp. |
| 1292 | This should only be needed as a consequence of careless manual | 1286 | This should only be needed as a consequence of careless manual |
| @@ -1295,20 +1289,44 @@ editing or a bug in todos.el." | |||
| 1295 | (let ((todos-categories (todos-make-categories-list t))) | 1289 | (let ((todos-categories (todos-make-categories-list t))) |
| 1296 | (todos-update-categories-sexp))) | 1290 | (todos-update-categories-sexp))) |
| 1297 | 1291 | ||
| 1298 | (defun todos-convert-legacy-date-time () | 1292 | ;;; Global variables and helper functions for items |
| 1299 | "Return converted date-time string. | 1293 | |
| 1300 | Helper function for `todos-convert-legacy-files'." | 1294 | (defconst todos-date-pattern |
| 1301 | (let* ((year (match-string 1)) | 1295 | (let ((dayname (diary-name-pattern calendar-day-name-array nil t))) |
| 1302 | (month (match-string 2)) | 1296 | (concat "\\(?:" dayname "\\|" |
| 1303 | (monthname (calendar-month-name (string-to-number month) t)) | 1297 | (let ((dayname) |
| 1304 | (day (match-string 3)) | 1298 | ;; FIXME: how to choose between abbreviated and unabbreviated |
| 1305 | (time (match-string 4)) | 1299 | ;; month name? |
| 1306 | dayname) | 1300 | (monthname (format "\\(?:%s\\|\\*\\)" |
| 1307 | (replace-match "") | 1301 | (diary-name-pattern |
| 1308 | (insert (mapconcat 'eval calendar-date-display-form "") | 1302 | calendar-month-name-array |
| 1309 | (when time (concat " " time))))) | 1303 | calendar-month-abbrev-array t))) |
| 1304 | (month "\\(?:[0-9]+\\|\\*\\)") | ||
| 1305 | (day "\\(?:[0-9]+\\|\\*\\)") | ||
| 1306 | (year "-?\\(?:[0-9]+\\|\\*\\)")) | ||
| 1307 | (mapconcat 'eval calendar-date-display-form "")) | ||
| 1308 | "\\)")) | ||
| 1309 | "Regular expression matching a Todos date header.") | ||
| 1310 | |||
| 1311 | (defconst todos-nondiary-start (nth 0 todos-nondiary-marker) | ||
| 1312 | "String inserted before item date to block diary inclusion.") | ||
| 1313 | |||
| 1314 | (defconst todos-nondiary-end (nth 1 todos-nondiary-marker) | ||
| 1315 | "String inserted after item date matching `todos-nondiary-start'.") | ||
| 1316 | |||
| 1317 | ;; By itself this matches anything, because of the `?'; however, it's only | ||
| 1318 | ;; used in the context of `todos-date-pattern' (but Emacs Lisp lacks | ||
| 1319 | ;; lookahead). | ||
| 1320 | (defconst todos-date-string-start | ||
| 1321 | (concat "^\\(" (regexp-quote todos-nondiary-start) "\\|" | ||
| 1322 | (regexp-quote diary-nonmarking-symbol) "\\)?") | ||
| 1323 | "Regular expression matching part of item header before the date.") | ||
| 1324 | |||
| 1325 | (defconst todos-done-string-start | ||
| 1326 | (concat "^\\[" (regexp-quote todos-done-string)) | ||
| 1327 | "Regular expression matching start of done item.") | ||
| 1310 | 1328 | ||
| 1311 | (defvar todos-item-start (concat "\\(" todos-date-string-start "\\|" | 1329 | (defconst todos-item-start (concat "\\(" todos-date-string-start "\\|" |
| 1312 | todos-done-string-start "\\)" | 1330 | todos-done-string-start "\\)" |
| 1313 | todos-date-pattern) | 1331 | todos-date-pattern) |
| 1314 | "String identifying start of a Todos item.") | 1332 | "String identifying start of a Todos item.") |
| @@ -1459,7 +1477,7 @@ of each other." | |||
| 1459 | (forward-line)))))) | 1477 | (forward-line)))))) |
| 1460 | 1478 | ||
| 1461 | ;; --------------------------------------------------------------------------- | 1479 | ;; --------------------------------------------------------------------------- |
| 1462 | ;;; Functions for user input with prompting and completion | 1480 | ;;; Helper functions for user input with prompting and completion |
| 1463 | 1481 | ||
| 1464 | (defun todos-read-file-name (prompt &optional archive mustmatch) | 1482 | (defun todos-read-file-name (prompt &optional archive mustmatch) |
| 1465 | "Choose and return the name of a Todos file, prompting with PROMPT. | 1483 | "Choose and return the name of a Todos file, prompting with PROMPT. |
| @@ -1642,7 +1660,7 @@ the empty string (i.e., no time string)." | |||
| 1642 | answer)) | 1660 | answer)) |
| 1643 | 1661 | ||
| 1644 | ;; --------------------------------------------------------------------------- | 1662 | ;; --------------------------------------------------------------------------- |
| 1645 | ;;; Item filtering | 1663 | ;;; Item filtering infrastructure |
| 1646 | 1664 | ||
| 1647 | (defvar todos-multiple-filter-files nil | 1665 | (defvar todos-multiple-filter-files nil |
| 1648 | "List of files selected from `todos-multiple-filter-files' widget.") | 1666 | "List of files selected from `todos-multiple-filter-files' widget.") |
| @@ -1884,14 +1902,11 @@ set the user customizable option `todos-priorities-rules'." | |||
| 1884 | "enter new number: ")) | 1902 | "enter new number: ")) |
| 1885 | (new "-1") | 1903 | (new "-1") |
| 1886 | nrule) | 1904 | nrule) |
| 1887 | ;; FIXME: use read-number | 1905 | (while (< (string-to-number new) 0) |
| 1888 | (while (or (not (string-match "[0-9]+" new)) ; Don't accept "" or "bla". | ||
| 1889 | (< (string-to-number new) 0)) | ||
| 1890 | (let ((cur0 cur)) | 1906 | (let ((cur0 cur)) |
| 1891 | (setq new (read-string (format prompt cur0) nil nil cur0) | 1907 | (setq new (read-number (format prompt cur0) cur0) |
| 1892 | prompt "Enter a non-negative number: " | 1908 | prompt "Enter a non-negative number: " |
| 1893 | cur0 nil))) | 1909 | cur0 nil))) |
| 1894 | (setq new (string-to-number new)) | ||
| 1895 | (setq nrule (if arg | 1910 | (setq nrule (if arg |
| 1896 | (append (nth 2 (delete crule frule)) (list (cons cat new))) | 1911 | (append (nth 2 (delete crule frule)) (list (cons cat new))) |
| 1897 | (append (list file new) (list (nth 2 frule))))) | 1912 | (append (list file new) (list (nth 2 frule))))) |
| @@ -2333,7 +2348,6 @@ which is the value of the user option | |||
| 2333 | `( | 2348 | `( |
| 2334 | ;; display | 2349 | ;; display |
| 2335 | ("Cd" . todos-display-categories) ;FIXME: Cs todos-show-categories? | 2350 | ("Cd" . todos-display-categories) ;FIXME: Cs todos-show-categories? |
| 2336 | ;("" . todos-display-categories-alphabetically) | ||
| 2337 | ("H" . todos-highlight-item) | 2351 | ("H" . todos-highlight-item) |
| 2338 | ("N" . todos-hide-show-item-numbering) | 2352 | ("N" . todos-hide-show-item-numbering) |
| 2339 | ("D" . todos-hide-show-date-time) | 2353 | ("D" . todos-hide-show-date-time) |
| @@ -3060,7 +3074,7 @@ saved (the latter as a Todos Archive file) with a new name in | |||
| 3060 | (delete-region (line-beginning-position) (line-end-position)) | 3074 | (delete-region (line-beginning-position) (line-end-position)) |
| 3061 | (prin1 sexp (current-buffer))) | 3075 | (prin1 sexp (current-buffer))) |
| 3062 | (write-region (point-min) (point-max) file nil 'nomessage))) | 3076 | (write-region (point-min) (point-max) file nil 'nomessage))) |
| 3063 | (todos-reevaluate-defcustoms) | 3077 | (todos-reevaluate-filelist-defcustoms) |
| 3064 | (message "Format conversion done.")) | 3078 | (message "Format conversion done.")) |
| 3065 | (error "No legacy Todo file exists"))) | 3079 | (error "No legacy Todo file exists"))) |
| 3066 | 3080 | ||
| @@ -3556,7 +3570,7 @@ Noninteractively, return the name of the new file." | |||
| 3556 | (erase-buffer) | 3570 | (erase-buffer) |
| 3557 | (write-region (point-min) (point-max) file nil 'nomessage nil t) | 3571 | (write-region (point-min) (point-max) file nil 'nomessage nil t) |
| 3558 | (kill-buffer file)) | 3572 | (kill-buffer file)) |
| 3559 | (todos-reevaluate-defcustoms) | 3573 | (todos-reevaluate-filelist-defcustoms) |
| 3560 | (if (called-interactively-p) | 3574 | (if (called-interactively-p) |
| 3561 | (progn | 3575 | (progn |
| 3562 | (set-window-buffer (selected-window) | 3576 | (set-window-buffer (selected-window) |
| @@ -3668,7 +3682,7 @@ i.e. including all existing todo and done items." | |||
| 3668 | (if (= (length todos-categories) 1) | 3682 | (if (= (length todos-categories) 1) |
| 3669 | ;; If deleted category was the only one, delete the file. | 3683 | ;; If deleted category was the only one, delete the file. |
| 3670 | (progn | 3684 | (progn |
| 3671 | (todos-reevaluate-defcustoms) | 3685 | (todos-reevaluate-filelist-defcustoms) |
| 3672 | ;; Skip confirming killing the archive buffer if it has been | 3686 | ;; Skip confirming killing the archive buffer if it has been |
| 3673 | ;; modified and not saved. | 3687 | ;; modified and not saved. |
| 3674 | (set-buffer-modified-p nil) | 3688 | (set-buffer-modified-p nil) |
| @@ -3780,7 +3794,7 @@ archive of the file moved to, creating it if it does not exist." | |||
| 3780 | (delete-file todos-current-todos-file) | 3794 | (delete-file todos-current-todos-file) |
| 3781 | (kill-buffer) | 3795 | (kill-buffer) |
| 3782 | (when (member todos-current-todos-file todos-files) | 3796 | (when (member todos-current-todos-file todos-files) |
| 3783 | (todos-reevaluate-defcustoms))) | 3797 | (todos-reevaluate-filelist-defcustoms))) |
| 3784 | (setq todos-categories (delete (assoc cat todos-categories) | 3798 | (setq todos-categories (delete (assoc cat todos-categories) |
| 3785 | todos-categories)) | 3799 | todos-categories)) |
| 3786 | (todos-update-categories-sexp) | 3800 | (todos-update-categories-sexp) |
| @@ -4092,7 +4106,6 @@ the priority is not given by HERE but by prompting." | |||
| 4092 | (error "There is no active region")))) | 4106 | (error "There is no active region")))) |
| 4093 | (let* ((buf (current-buffer)) | 4107 | (let* ((buf (current-buffer)) |
| 4094 | (new-item (if region | 4108 | (new-item (if region |
| 4095 | ;; FIXME: or keep properties? | ||
| 4096 | (buffer-substring-no-properties | 4109 | (buffer-substring-no-properties |
| 4097 | (region-beginning) (region-end)) | 4110 | (region-beginning) (region-end)) |
| 4098 | (read-from-minibuffer "Todo item: "))) | 4111 | (read-from-minibuffer "Todo item: "))) |
| @@ -4104,7 +4117,8 @@ the priority is not given by HERE but by prompting." | |||
| 4104 | ((eq date-type 'calendar) | 4117 | ((eq date-type 'calendar) |
| 4105 | (setq todos-date-from-calendar t) | 4118 | (setq todos-date-from-calendar t) |
| 4106 | (todos-set-date-from-calendar)) | 4119 | (todos-set-date-from-calendar)) |
| 4107 | ((string-match todos-date-pattern date-type) | 4120 | ((and (stringp date-type) |
| 4121 | (string-match todos-date-pattern date-type)) | ||
| 4108 | (setq todos-date-from-calendar date-type) | 4122 | (setq todos-date-from-calendar date-type) |
| 4109 | (todos-set-date-from-calendar)) | 4123 | (todos-set-date-from-calendar)) |
| 4110 | (t (calendar-date-string (calendar-current-date) t t)))) | 4124 | (t (calendar-date-string (calendar-current-date) t t)))) |
| @@ -4112,12 +4126,12 @@ the priority is not given by HERE but by prompting." | |||
| 4112 | (and todos-always-add-time-string | 4126 | (and todos-always-add-time-string |
| 4113 | (substring (current-time-string) 11 16))))) | 4127 | (substring (current-time-string) 11 16))))) |
| 4114 | (setq todos-date-from-calendar nil) | 4128 | (setq todos-date-from-calendar nil) |
| 4115 | (cond ((equal arg '(16)) ; FIXME: cf. set-mark-command | 4129 | (cond ((equal arg '(16)) |
| 4116 | (todos-jump-to-category nil t) | 4130 | (todos-jump-to-category nil t) |
| 4117 | (set-window-buffer | 4131 | (set-window-buffer |
| 4118 | (selected-window) | 4132 | (selected-window) |
| 4119 | (set-buffer (find-buffer-visiting todos-global-current-todos-file)))) | 4133 | (set-buffer (find-buffer-visiting todos-global-current-todos-file)))) |
| 4120 | ((equal arg '(4)) ; FIXME: just arg? | 4134 | ((equal arg '(4)) |
| 4121 | (todos-jump-to-category) | 4135 | (todos-jump-to-category) |
| 4122 | (set-window-buffer | 4136 | (set-window-buffer |
| 4123 | (selected-window) | 4137 | (selected-window) |
| @@ -4163,16 +4177,16 @@ the priority is not given by HERE but by prompting." | |||
| 4163 | 4177 | ||
| 4164 | (defun todos-set-date-from-calendar () | 4178 | (defun todos-set-date-from-calendar () |
| 4165 | "Return string of date chosen from Calendar." | 4179 | "Return string of date chosen from Calendar." |
| 4166 | (cond ((string-match todos-date-pattern todos-date-from-calendar) | 4180 | (cond ((and (stringp todos-date-from-calendar) |
| 4181 | (string-match todos-date-pattern todos-date-from-calendar)) | ||
| 4167 | todos-date-from-calendar) | 4182 | todos-date-from-calendar) |
| 4168 | ((todos-date-from-calendar t) | 4183 | (todos-date-from-calendar |
| 4169 | (let (calendar-view-diary-initially-flag) | 4184 | (let (calendar-view-diary-initially-flag) |
| 4170 | (calendar)) | 4185 | (calendar)) |
| 4171 | ;; *Calendar* is now current buffer. | 4186 | ;; *Calendar* is now current buffer. |
| 4172 | (local-set-key (kbd "RET") 'exit-recursive-edit) | 4187 | (local-set-key (kbd "RET") 'exit-recursive-edit) |
| 4173 | (message "Put cursor on a date and type <return> to set it.") | 4188 | (message "Put cursor on a date and type <return> to set it.") |
| 4174 | ;; FIXME: is there a better way than recursive-edit? Use unwind-protect? | 4189 | ;; FIXME: is there a better way than recursive-edit? |
| 4175 | ;; Check recursive-depth? | ||
| 4176 | (recursive-edit) | 4190 | (recursive-edit) |
| 4177 | (setq todos-date-from-calendar | 4191 | (setq todos-date-from-calendar |
| 4178 | (calendar-date-string (calendar-cursor-to-date t) t t)) | 4192 | (calendar-date-string (calendar-cursor-to-date t) t t)) |
| @@ -4299,7 +4313,8 @@ whether the file is still a valid Todos file and if so, also | |||
| 4299 | recalculate the Todos categories sexp, in case changes were made | 4313 | recalculate the Todos categories sexp, in case changes were made |
| 4300 | in the number or names of categories." | 4314 | in the number or names of categories." |
| 4301 | (interactive) | 4315 | (interactive) |
| 4302 | ;; FIXME: should do only if file was actually changed -- but how to tell? | 4316 | ;; FIXME: Should do todos-check-format only if file was actually changed -- |
| 4317 | ;; but how to tell? | ||
| 4303 | (when (eq (buffer-size) (- (point-max) (point-min))) | 4318 | (when (eq (buffer-size) (- (point-max) (point-min))) |
| 4304 | (when (todos-check-format) (todos-repair-categories-sexp))) | 4319 | (when (todos-check-format) (todos-repair-categories-sexp))) |
| 4305 | (kill-buffer) | 4320 | (kill-buffer) |
| @@ -4978,7 +4993,7 @@ this category does not exist in the archive, it is created." | |||
| 4978 | nil t) | 4993 | nil t) |
| 4979 | (match-beginning 0) | 4994 | (match-beginning 0) |
| 4980 | (point-max)) | 4995 | (point-max)) |
| 4981 | all-done (buffer-substring beg end) | 4996 | all-done (buffer-substring-no-properties beg end) |
| 4982 | count (todos-get-count 'done)))) | 4997 | count (todos-get-count 'done)))) |
| 4983 | (throw 'end nil)))) | 4998 | (throw 'end nil)))) |
| 4984 | (when (or marked all item) | 4999 | (when (or marked all item) |
| @@ -5070,7 +5085,8 @@ archive, the archive file is deleted." | |||
| 5070 | ".todo") t)) | 5085 | ".todo") t)) |
| 5071 | (marked (assoc cat todos-categories-with-marks)) | 5086 | (marked (assoc cat todos-categories-with-marks)) |
| 5072 | (item (concat (todos-item-string) "\n")) | 5087 | (item (concat (todos-item-string) "\n")) |
| 5073 | (all-items (when all (buffer-substring (point-min) (point-max)))) | 5088 | (all-items (when all (buffer-substring-no-properties |
| 5089 | (point-min) (point-max)))) | ||
| 5074 | (all-count (when all (todos-get-count 'done))) | 5090 | (all-count (when all (todos-get-count 'done))) |
| 5075 | marked-items marked-count | 5091 | marked-items marked-count |
| 5076 | buffer-read-only) | 5092 | buffer-read-only) |