]> git.eshelyaron.com Git - emacs.git/commitdiff
Prevent truncation of todo-mode categories sexp
authorStephen Berman <stephen.berman@gmx.net>
Tue, 27 Jun 2023 15:38:20 +0000 (17:38 +0200)
committerStephen Berman <stephen.berman@gmx.net>
Tue, 27 Jun 2023 15:38:20 +0000 (17:38 +0200)
* 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.

lisp/calendar/todo-mode.el

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