Prevent truncation of todo-mode categories sexp

* lisp/calendar/todo-mode.el (todo-delete-file)
(todo-move-category, todo-convert-legacy-files)
(todo-update-categories-sexp, todo-check-format):
Bind print-length and print-level to nil before using prin1
and related functions, to avoid truncating the todo categories
sexp and possibly corrupting the file format.
This commit is contained in:
Stephen Berman 2023-06-27 17:38:20 +02:00
parent ee41f07be5
commit 6ae83322d4

View file

@ -1205,7 +1205,9 @@ visiting the deleted files."
(let ((sexp (read (buffer-substring-no-properties (let ((sexp (read (buffer-substring-no-properties
(line-beginning-position) (line-beginning-position)
(line-end-position)))) (line-end-position))))
(buffer-read-only nil)) (buffer-read-only nil)
(print-length nil)
(print-level nil))
(mapc (lambda (x) (aset (cdr x) 3 0)) sexp) (mapc (lambda (x) (aset (cdr x) 3 0)) sexp)
(delete-region (line-beginning-position) (line-end-position)) (delete-region (line-beginning-position) (line-end-position))
(prin1 sexp (current-buffer))))) (prin1 sexp (current-buffer)))))
@ -1479,7 +1481,9 @@ the archive of the file moved to, creating it if it does not exist."
nfile-short) nfile-short)
(format "the category \"%s\";\n" cat) (format "the category \"%s\";\n" cat)
"enter a new category name: ")) "enter a new category name: "))
buffer-read-only) (buffer-read-only nil)
(print-length nil)
(print-level nil))
(widen) (widen)
(goto-char (point-max)) (goto-char (point-max))
(insert content) (insert content)
@ -4877,7 +4881,9 @@ name in `todo-directory'. See also the documentation string of
(insert-file-contents file) (insert-file-contents file)
(let ((sexp (read (buffer-substring-no-properties (let ((sexp (read (buffer-substring-no-properties
(line-beginning-position) (line-beginning-position)
(line-end-position))))) (line-end-position))))
(print-length nil)
(print-level nil))
(dolist (cat sexp) (dolist (cat sexp)
(let ((archive-cat (assoc (car cat) archive-sexp))) (let ((archive-cat (assoc (car cat) archive-sexp)))
(if archive-cat (if archive-cat
@ -5058,7 +5064,9 @@ With nil or omitted CATEGORY, default to the current category."
(defun todo-update-categories-sexp () (defun todo-update-categories-sexp ()
"Update the `todo-categories' sexp at the top of the file." "Update the `todo-categories' sexp at the top of the file."
(let (buffer-read-only) (let ((buffer-read-only nil)
(print-length nil)
(print-level nil))
(save-excursion (save-excursion
(save-restriction (save-restriction
(widen) (widen)
@ -5167,7 +5175,9 @@ but the categories sexp differs from the current value of
(save-restriction (save-restriction
(widen) (widen)
(goto-char (point-min)) (goto-char (point-min))
(let* ((cats (prin1-to-string todo-categories)) (let* ((print-length nil)
(print-level nil)
(cats (prin1-to-string todo-categories))
(ssexp (buffer-substring-no-properties (line-beginning-position) (ssexp (buffer-substring-no-properties (line-beginning-position)
(line-end-position))) (line-end-position)))
(sexp (read ssexp))) (sexp (read ssexp)))