To help catch predictable errors, I've written my own linting tasks that read the code and report any inconsistencies it finds. One of the hackier pieces to this right now is the following function:
(defun lint-get-forms (filename)
"Read FILENAME and return a list of its Lisp forms."
(let ((pos 0) forms)
(with-temp-buffer
(insert-file-contents filename)
(condition-case _
(while t
(when-let ((cell (read-from-string (buffer-string) pos)))
(push (car cell) forms)
(goto-char (setq pos (cdr cell)))))
(error forms)))
forms))
Is there a better way to do this (preferably without condition-case
)?
Ideally these checks would be done at compile-time, but they're not stable enough yet to move to the other repository.
read
's optional argument.