emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

emacs-29 6ae83322d4c: Prevent truncation of todo-mode categories sexp


From: Stephen Berman
Subject: emacs-29 6ae83322d4c: Prevent truncation of todo-mode categories sexp
Date: Tue, 27 Jun 2023 11:38:29 -0400 (EDT)

branch: emacs-29
commit 6ae83322d4c2792265f39ef84fefd5ca8be94b8d
Author: Stephen Berman <stephen.berman@gmx.net>
Commit: Stephen Berman <stephen.berman@gmx.net>

    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.
---
 lisp/calendar/todo-mode.el | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/lisp/calendar/todo-mode.el b/lisp/calendar/todo-mode.el
index 564ead1376b..ce04a15b2b0 100644
--- a/lisp/calendar/todo-mode.el
+++ b/lisp/calendar/todo-mode.el
@@ -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)))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]