diff options
| author | Stefan Monnier | 2023-09-27 18:52:00 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2023-09-27 18:52:00 -0400 |
| commit | dc2199de3e663cf3cdcf3cd523d273e230aa3ac0 (patch) | |
| tree | 9e3eb7557d043309d76426e71aa6196ceea6b4ee | |
| parent | d813f71ffe62844f5d4cc97cb54f3877dcf55a06 (diff) | |
| download | emacs-dc2199de3e663cf3cdcf3cd523d273e230aa3ac0.tar.gz emacs-dc2199de3e663cf3cdcf3cd523d273e230aa3ac0.zip | |
* lisp/calendar/todo-mode.el: Let-bind `inhibit-read-only`
rather than `buffer-read-only`. Applied throughout the file.
(todo-date-pattern, todo-edit-item--header, todo-convert-legacy-date-time)
(todo-read-date): Remove redundant "" arg to `mapconcat`.
| -rw-r--r-- | lisp/calendar/todo-mode.el | 60 |
1 files changed, 29 insertions, 31 deletions
diff --git a/lisp/calendar/todo-mode.el b/lisp/calendar/todo-mode.el index ffb7b7168dd..093ea0e22b6 100644 --- a/lisp/calendar/todo-mode.el +++ b/lisp/calendar/todo-mode.el | |||
| @@ -200,7 +200,7 @@ The final element is \"*\", indicating an unspecified month.") | |||
| 200 | (month "\\(?7:[0-9]+\\|\\*\\)") | 200 | (month "\\(?7:[0-9]+\\|\\*\\)") |
| 201 | (day "\\(?8:[0-9]+\\|\\*\\)") | 201 | (day "\\(?8:[0-9]+\\|\\*\\)") |
| 202 | (year "-?\\(?9:[0-9]+\\|\\*\\)")) | 202 | (year "-?\\(?9:[0-9]+\\|\\*\\)")) |
| 203 | (mapconcat #'eval calendar-date-display-form "")) | 203 | (mapconcat #'eval calendar-date-display-form)) |
| 204 | "\\)")) | 204 | "\\)")) |
| 205 | "Regular expression matching a todo item date header.") | 205 | "Regular expression matching a todo item date header.") |
| 206 | 206 | ||
| @@ -1206,7 +1206,7 @@ visiting the deleted files." | |||
| 1206 | (let ((sexp (read (buffer-substring-no-properties | 1206 | (let ((sexp (read (buffer-substring-no-properties |
| 1207 | (line-beginning-position) | 1207 | (line-beginning-position) |
| 1208 | (line-end-position)))) | 1208 | (line-end-position)))) |
| 1209 | (buffer-read-only nil) | 1209 | (inhibit-read-only t) |
| 1210 | (print-length nil) | 1210 | (print-length nil) |
| 1211 | (print-level nil)) | 1211 | (print-level nil)) |
| 1212 | (mapc (lambda (x) (aset (cdr x) 3 0)) sexp) | 1212 | (mapc (lambda (x) (aset (cdr x) 3 0)) sexp) |
| @@ -1304,7 +1304,7 @@ return the new category number." | |||
| 1304 | (widen) | 1304 | (widen) |
| 1305 | (goto-char (point-max)) | 1305 | (goto-char (point-max)) |
| 1306 | (save-excursion ; Save point for todo-category-select. | 1306 | (save-excursion ; Save point for todo-category-select. |
| 1307 | (let ((buffer-read-only nil)) | 1307 | (let ((inhibit-read-only t)) |
| 1308 | (insert todo-category-beg cat "\n\n" todo-category-done "\n"))) | 1308 | (insert todo-category-beg cat "\n\n" todo-category-done "\n"))) |
| 1309 | (todo-update-categories-sexp) | 1309 | (todo-update-categories-sexp) |
| 1310 | ;; If invoked by user, display the newly added category, if | 1310 | ;; If invoked by user, display the newly added category, if |
| @@ -1486,7 +1486,7 @@ the archive of the file moved to, creating it if it does not exist." | |||
| 1486 | nfile-short) | 1486 | nfile-short) |
| 1487 | (format "the category \"%s\";\n" cat) | 1487 | (format "the category \"%s\";\n" cat) |
| 1488 | "enter a new category name: ")) | 1488 | "enter a new category name: ")) |
| 1489 | (buffer-read-only nil) | 1489 | (inhibit-read-only t) |
| 1490 | (print-length nil) | 1490 | (print-length nil) |
| 1491 | (print-level nil)) | 1491 | (print-level nil)) |
| 1492 | (widen) | 1492 | (widen) |
| @@ -1528,7 +1528,7 @@ the archive of the file moved to, creating it if it does not exist." | |||
| 1528 | ;; Delete the category from the old file, and if that was the | 1528 | ;; Delete the category from the old file, and if that was the |
| 1529 | ;; last category, delete the file. Also handle archive file | 1529 | ;; last category, delete the file. Also handle archive file |
| 1530 | ;; if necessary. | 1530 | ;; if necessary. |
| 1531 | (let ((buffer-read-only nil)) | 1531 | (let ((inhibit-read-only t)) |
| 1532 | (widen) | 1532 | (widen) |
| 1533 | (remove-overlays beg end) | 1533 | (remove-overlays beg end) |
| 1534 | (delete-region beg end) | 1534 | (delete-region beg end) |
| @@ -1581,7 +1581,7 @@ archive file and the source category is deleted." | |||
| 1581 | here) | 1581 | here) |
| 1582 | (with-current-buffer (get-buffer (find-file-noselect tfile)) | 1582 | (with-current-buffer (get-buffer (find-file-noselect tfile)) |
| 1583 | (widen) | 1583 | (widen) |
| 1584 | (let* ((buffer-read-only nil) | 1584 | (let* ((inhibit-read-only t) |
| 1585 | (cbeg (progn | 1585 | (cbeg (progn |
| 1586 | (re-search-backward | 1586 | (re-search-backward |
| 1587 | (concat "^" (regexp-quote todo-category-beg)) nil t) | 1587 | (concat "^" (regexp-quote todo-category-beg)) nil t) |
| @@ -1609,7 +1609,7 @@ archive file and the source category is deleted." | |||
| 1609 | (unless (derived-mode-p 'todo-mode) (todo-mode)) | 1609 | (unless (derived-mode-p 'todo-mode) (todo-mode)) |
| 1610 | (widen) | 1610 | (widen) |
| 1611 | (goto-char (point-min)) | 1611 | (goto-char (point-min)) |
| 1612 | (let ((buffer-read-only nil)) | 1612 | (let ((inhibit-read-only t)) |
| 1613 | ;; Merge any todo items. | 1613 | ;; Merge any todo items. |
| 1614 | (unless (zerop (length todo)) | 1614 | (unless (zerop (length todo)) |
| 1615 | (re-search-forward | 1615 | (re-search-forward |
| @@ -1647,7 +1647,7 @@ archive file and the source category is deleted." | |||
| 1647 | (with-current-buffer (get-buffer (find-file-noselect tarchive)) | 1647 | (with-current-buffer (get-buffer (find-file-noselect tarchive)) |
| 1648 | (widen) | 1648 | (widen) |
| 1649 | (goto-char (point-min)) | 1649 | (goto-char (point-min)) |
| 1650 | (let* ((buffer-read-only nil) | 1650 | (let* ((inhibit-read-only t) |
| 1651 | (cbeg (progn | 1651 | (cbeg (progn |
| 1652 | (when (re-search-forward | 1652 | (when (re-search-forward |
| 1653 | (concat "^" (regexp-quote | 1653 | (concat "^" (regexp-quote |
| @@ -1967,7 +1967,7 @@ their associated keys and their effects." | |||
| 1967 | (setq todo-current-todo-file file) | 1967 | (setq todo-current-todo-file file) |
| 1968 | (unless todo-global-current-todo-file | 1968 | (unless todo-global-current-todo-file |
| 1969 | (setq todo-global-current-todo-file todo-current-todo-file)) | 1969 | (setq todo-global-current-todo-file todo-current-todo-file)) |
| 1970 | (let ((buffer-read-only nil) | 1970 | (let ((inhibit-read-only t) |
| 1971 | done-only item-added) | 1971 | done-only item-added) |
| 1972 | (unless copy | 1972 | (unless copy |
| 1973 | (setq new-item | 1973 | (setq new-item |
| @@ -2197,9 +2197,9 @@ the item at point." | |||
| 2197 | end t) | 2197 | end t) |
| 2198 | (if comment-delete | 2198 | (if comment-delete |
| 2199 | (when (todo-y-or-n-p "Delete comment? ") | 2199 | (when (todo-y-or-n-p "Delete comment? ") |
| 2200 | (let ((buffer-read-only nil)) | 2200 | (let ((inhibit-read-only t)) |
| 2201 | (delete-region (match-beginning 0) (match-end 0)))) | 2201 | (delete-region (match-beginning 0) (match-end 0)))) |
| 2202 | (let ((buffer-read-only nil)) | 2202 | (let ((inhibit-read-only t)) |
| 2203 | (replace-match (save-match-data | 2203 | (replace-match (save-match-data |
| 2204 | (prog1 (let ((buffer-read-only t)) | 2204 | (prog1 (let ((buffer-read-only t)) |
| 2205 | (read-string | 2205 | (read-string |
| @@ -2216,7 +2216,7 @@ the item at point." | |||
| 2216 | nil nil nil 1))) | 2216 | nil nil nil 1))) |
| 2217 | (if comment-delete | 2217 | (if comment-delete |
| 2218 | (user-error "There is no comment to delete") | 2218 | (user-error "There is no comment to delete") |
| 2219 | (let ((buffer-read-only nil)) | 2219 | (let ((inhibit-read-only t)) |
| 2220 | (insert " [" todo-comment-string ": " | 2220 | (insert " [" todo-comment-string ": " |
| 2221 | (prog1 (let ((buffer-read-only t)) | 2221 | (prog1 (let ((buffer-read-only t)) |
| 2222 | (read-string prompt)) | 2222 | (read-string prompt)) |
| @@ -2261,7 +2261,7 @@ the item at point." | |||
| 2261 | (todo-category-number ocat) | 2261 | (todo-category-number ocat) |
| 2262 | (todo-category-select) | 2262 | (todo-category-select) |
| 2263 | (goto-char opoint)) | 2263 | (goto-char opoint)) |
| 2264 | (let ((buffer-read-only nil)) | 2264 | (let ((inhibit-read-only t)) |
| 2265 | (todo-remove-item) | 2265 | (todo-remove-item) |
| 2266 | (todo-insert-with-overlays new)) | 2266 | (todo-insert-with-overlays new)) |
| 2267 | (move-to-column item-beg))))))))) | 2267 | (move-to-column item-beg))))))))) |
| @@ -2493,8 +2493,8 @@ made in the number or names of categories." | |||
| 2493 | (month month) | 2493 | (month month) |
| 2494 | (day day) | 2494 | (day day) |
| 2495 | (dayname nil)) ;; dayname | 2495 | (dayname nil)) ;; dayname |
| 2496 | (mapconcat #'eval calendar-date-display-form ""))))) | 2496 | (mapconcat #'eval calendar-date-display-form))))) |
| 2497 | (let ((buffer-read-only nil)) | 2497 | (let ((inhibit-read-only t)) |
| 2498 | (when ndate (replace-match ndate nil nil nil 1)) | 2498 | (when ndate (replace-match ndate nil nil nil 1)) |
| 2499 | ;; Add new time string to the header, if it was supplied. | 2499 | ;; Add new time string to the header, if it was supplied. |
| 2500 | (when ntime | 2500 | (when ntime |
| @@ -2754,7 +2754,7 @@ meaning to raise or lower the item's priority by one." | |||
| 2754 | (when match | 2754 | (when match |
| 2755 | (user-error (concat "Cannot reprioritize items from the same " | 2755 | (user-error (concat "Cannot reprioritize items from the same " |
| 2756 | "category in this mode, only in Todo mode"))))) | 2756 | "category in this mode, only in Todo mode"))))) |
| 2757 | (let ((buffer-read-only nil)) | 2757 | (let ((inhibit-read-only t)) |
| 2758 | ;; Interactively or with non-nil ARG, relocate the item within its | 2758 | ;; Interactively or with non-nil ARG, relocate the item within its |
| 2759 | ;; category. | 2759 | ;; category. |
| 2760 | (when (or arg (called-interactively-p 'any)) | 2760 | (when (or arg (called-interactively-p 'any)) |
| @@ -2877,7 +2877,7 @@ section in the category moved to." | |||
| 2877 | (setq here (point)) | 2877 | (setq here (point)) |
| 2878 | (while todo-items | 2878 | (while todo-items |
| 2879 | (todo-forward-item) | 2879 | (todo-forward-item) |
| 2880 | (let ((buffer-read-only nil)) | 2880 | (let ((inhibit-read-only t)) |
| 2881 | (todo-insert-with-overlays (pop todo-items))))) | 2881 | (todo-insert-with-overlays (pop todo-items))))) |
| 2882 | ;; Move done items en bloc to top of done items section. | 2882 | ;; Move done items en bloc to top of done items section. |
| 2883 | (when done-items | 2883 | (when done-items |
| @@ -2892,7 +2892,7 @@ section in the category moved to." | |||
| 2892 | (forward-line) | 2892 | (forward-line) |
| 2893 | (unless here (setq here (point))) | 2893 | (unless here (setq here (point))) |
| 2894 | (while done-items | 2894 | (while done-items |
| 2895 | (let ((buffer-read-only nil)) | 2895 | (let ((inhibit-read-only t)) |
| 2896 | (todo-insert-with-overlays (pop done-items))) | 2896 | (todo-insert-with-overlays (pop done-items))) |
| 2897 | (todo-item-end) | 2897 | (todo-item-end) |
| 2898 | (forward-line))) | 2898 | (forward-line))) |
| @@ -2933,13 +2933,13 @@ section in the category moved to." | |||
| 2933 | (goto-char beg) | 2933 | (goto-char beg) |
| 2934 | (while (< (point) end) | 2934 | (while (< (point) end) |
| 2935 | (if (todo-marked-item-p) | 2935 | (if (todo-marked-item-p) |
| 2936 | (let ((buffer-read-only nil)) | 2936 | (let ((inhibit-read-only t)) |
| 2937 | (todo-remove-item)) | 2937 | (todo-remove-item)) |
| 2938 | (todo-forward-item))) | 2938 | (todo-forward-item))) |
| 2939 | (setq todo-categories-with-marks | 2939 | (setq todo-categories-with-marks |
| 2940 | (assq-delete-all cat1 todo-categories-with-marks))) | 2940 | (assq-delete-all cat1 todo-categories-with-marks))) |
| 2941 | (if ov (delete-overlay ov)) | 2941 | (if ov (delete-overlay ov)) |
| 2942 | (let ((buffer-read-only nil)) | 2942 | (let ((inhibit-read-only t)) |
| 2943 | (todo-remove-item))))) | 2943 | (todo-remove-item))))) |
| 2944 | (when todo (todo-update-count 'todo (- todo) cat1)) | 2944 | (when todo (todo-update-count 'todo (- todo) cat1)) |
| 2945 | (when diary (todo-update-count 'diary (- diary) cat1)) | 2945 | (when diary (todo-update-count 'diary (- diary) cat1)) |
| @@ -2999,7 +2999,7 @@ visible." | |||
| 2999 | (show-done (save-excursion | 2999 | (show-done (save-excursion |
| 3000 | (goto-char (point-min)) | 3000 | (goto-char (point-min)) |
| 3001 | (re-search-forward todo-done-string-start nil t))) | 3001 | (re-search-forward todo-done-string-start nil t))) |
| 3002 | (buffer-read-only nil) | 3002 | (inhibit-read-only t) |
| 3003 | header item done-items | 3003 | header item done-items |
| 3004 | (opoint (point))) | 3004 | (opoint (point))) |
| 3005 | ;; Don't add empty comment to done item. | 3005 | ;; Don't add empty comment to done item. |
| @@ -3131,7 +3131,7 @@ comments without asking." | |||
| 3131 | (when ov (delete-overlay ov)) | 3131 | (when ov (delete-overlay ov)) |
| 3132 | (if (not undone) | 3132 | (if (not undone) |
| 3133 | (goto-char opoint) | 3133 | (goto-char opoint) |
| 3134 | (let ((buffer-read-only nil)) | 3134 | (let ((inhibit-read-only t)) |
| 3135 | (if marked | 3135 | (if marked |
| 3136 | (progn | 3136 | (progn |
| 3137 | (setq item nil) | 3137 | (setq item nil) |
| @@ -3299,7 +3299,7 @@ this category does not exist in the archive, it is created." | |||
| 3299 | (todo-archive-mode)) | 3299 | (todo-archive-mode)) |
| 3300 | (if headers-hidden (todo-toggle-item-header)))) | 3300 | (if headers-hidden (todo-toggle-item-header)))) |
| 3301 | (with-current-buffer tbuf | 3301 | (with-current-buffer tbuf |
| 3302 | (let ((buffer-read-only nil)) | 3302 | (let ((inhibit-read-only t)) |
| 3303 | (cond | 3303 | (cond |
| 3304 | (all | 3304 | (all |
| 3305 | (save-excursion | 3305 | (save-excursion |
| @@ -3602,7 +3602,7 @@ decreasing or increasing its number." | |||
| 3602 | ;; Category's name and items counts list. | 3602 | ;; Category's name and items counts list. |
| 3603 | (catcons (nth (1- curnum) todo-categories)) | 3603 | (catcons (nth (1- curnum) todo-categories)) |
| 3604 | (todo-categories (nconc head (list catcons) tail)) | 3604 | (todo-categories (nconc head (list catcons) tail)) |
| 3605 | (buffer-read-only nil) | 3605 | (inhibit-read-only t) |
| 3606 | newcats) | 3606 | newcats) |
| 3607 | (when lower (setq todo-categories (nreverse todo-categories))) | 3607 | (when lower (setq todo-categories (nreverse todo-categories))) |
| 3608 | (setq todo-categories (delete-dups todo-categories)) | 3608 | (setq todo-categories (delete-dups todo-categories)) |
| @@ -3823,8 +3823,7 @@ which is the value of the user option | |||
| 3823 | (cons todo-categories-diary-label 'diary) | 3823 | (cons todo-categories-diary-label 'diary) |
| 3824 | (cons todo-categories-done-label 'done) | 3824 | (cons todo-categories-done-label 'done) |
| 3825 | (cons todo-categories-archived-label | 3825 | (cons todo-categories-archived-label |
| 3826 | 'archived))) | 3826 | 'archived)))) |
| 3827 | "") | ||
| 3828 | " ") ; Make highlighting on last column look better. | 3827 | " ") ; Make highlighting on last column look better. |
| 3829 | 'face (if (and todo-skip-archived-categories | 3828 | 'face (if (and todo-skip-archived-categories |
| 3830 | (zerop (todo-get-count 'todo cat)) | 3829 | (zerop (todo-get-count 'todo cat)) |
| @@ -3932,8 +3931,7 @@ which is the value of the user option | |||
| 3932 | (list (cons todo-categories-todo-label 0) | 3931 | (list (cons todo-categories-todo-label 0) |
| 3933 | (cons todo-categories-diary-label 1) | 3932 | (cons todo-categories-diary-label 1) |
| 3934 | (cons todo-categories-done-label 2) | 3933 | (cons todo-categories-done-label 2) |
| 3935 | (cons todo-categories-archived-label 3))) | 3934 | (cons todo-categories-archived-label 3))))) |
| 3936 | "")) | ||
| 3937 | ;; Put cursor on Category button initially. | 3935 | ;; Put cursor on Category button initially. |
| 3938 | (if pt (goto-char pt)) | 3936 | (if pt (goto-char pt)) |
| 3939 | (setq buffer-read-only t))) | 3937 | (setq buffer-read-only t))) |
| @@ -4758,7 +4756,7 @@ Helper function for `todo-convert-legacy-files'." | |||
| 4758 | (time (match-string 4)) | 4756 | (time (match-string 4)) |
| 4759 | dayname) | 4757 | dayname) |
| 4760 | (replace-match "") | 4758 | (replace-match "") |
| 4761 | (insert (mapconcat #'eval calendar-date-display-form "") | 4759 | (insert (mapconcat #'eval calendar-date-display-form) |
| 4762 | (when time (concat " " time))))) | 4760 | (when time (concat " " time))))) |
| 4763 | 4761 | ||
| 4764 | (defun todo-convert-legacy-files () | 4762 | (defun todo-convert-legacy-files () |
| @@ -5112,7 +5110,7 @@ With nil or omitted CATEGORY, default to the current category." | |||
| 5112 | 5110 | ||
| 5113 | (defun todo-update-categories-sexp () | 5111 | (defun todo-update-categories-sexp () |
| 5114 | "Update the `todo-categories' sexp at the top of the file." | 5112 | "Update the `todo-categories' sexp at the top of the file." |
| 5115 | (let ((buffer-read-only nil) | 5113 | (let ((inhibit-read-only t) |
| 5116 | (print-length nil) | 5114 | (print-length nil) |
| 5117 | (print-level nil)) | 5115 | (print-level nil)) |
| 5118 | (save-excursion | 5116 | (save-excursion |
| @@ -6180,7 +6178,7 @@ number of the last the day of the month." | |||
| 6180 | (if (memq 'month calendar-date-display-form) | 6178 | (if (memq 'month calendar-date-display-form) |
| 6181 | month | 6179 | month |
| 6182 | monthname))) | 6180 | monthname))) |
| 6183 | (mapconcat #'eval calendar-date-display-form "")))) | 6181 | (mapconcat #'eval calendar-date-display-form)))) |
| 6184 | 6182 | ||
| 6185 | (defun todo-read-dayname () | 6183 | (defun todo-read-dayname () |
| 6186 | "Choose name of a day of the week with completion and return it." | 6184 | "Choose name of a day of the week with completion and return it." |