emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] externals/relint 125b869 02/44: Try harder recovering from read e


From: Mattias Engdegård
Subject: [elpa] externals/relint 125b869 02/44: Try harder recovering from read errors
Date: Tue, 26 Mar 2019 12:57:24 -0400 (EDT)

branch: externals/relint
commit 125b8693d6c986be888b01c7757c675d5ebbd064
Author: Mattias Engdegård <address@hidden>
Commit: Mattias Engdegård <address@hidden>

    Try harder recovering from read errors
    
    In particular, don't abandon the whole file because of a circular sexp.
---
 trawl.el | 28 ++++++++++++++++++++++------
 1 file changed, 22 insertions(+), 6 deletions(-)

diff --git a/trawl.el b/trawl.el
index 2882df8..ce26dfb 100644
--- a/trawl.el
+++ b/trawl.el
@@ -333,16 +333,32 @@
       (insert-file-contents file)
       (goto-char (point-min))
       (let ((pos nil)
+            (keep-going t)
             (read-circle nil)
             (trawl--variables nil)
             (trawl--checked-variables nil))
-        (condition-case err
-            (while t
+            (while keep-going
               (setq pos (point))
-              (let ((form (read (current-buffer))))
-                (trawl--check-toplevel-form form file pos)))
-          (end-of-file nil)
-          (error (trawl--report file pos nil (prin1-to-string err))))))
+              (let ((form nil))
+                (condition-case err
+                    (setq form (read (current-buffer)))
+                  (end-of-file
+                   (setq keep-going nil))
+                  (invalid-read-syntax
+                   (cond
+                    ((equal (cadr err) "#")
+                     (goto-char pos)
+                     (forward-sexp 1))
+                    (t
+                     (trawl--report file (point) nil
+                                    (prin1-to-string err))
+                     (setq keep-going nil))))
+                  (error
+                   (trawl--report file (point) nil
+                                  (prin1-to-string err))
+                   (setq keep-going nil)))
+                (when form
+                  (trawl--check-toplevel-form form file pos))))))
     (when (> trawl--error-count errors-before)
       (trawl--show-errors))))
         



reply via email to

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