branch: externals/relint commit 125b8693d6c986be888b01c7757c675d5ebbd064 Author: Mattias Engdegård <matti...@acm.org> Commit: Mattias Engdegård <matti...@acm.org>
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))))