lisp-critic: criticize AND eval

for #7
This commit is contained in:
vindarel 2020-11-10 00:09:31 +01:00
parent 28ce34a9e4
commit 1d8ea0404e
2 changed files with 29 additions and 7 deletions

View file

@ -149,6 +149,17 @@ USE-EQL: Unless something special is going on, use EQL, not EQUAL.
X-PLUS-1: Don't use (+ N 1), use (1+ N) for its value or (INCF N) to
change N, whichever is appropriate here.
----------------------------------------------------------------------
; in: DEFUN COUNT-A
; (SETQ CIEL-USER::N 0)
;
; caught WARNING:
; undefined variable: N
;
; compilation unit finished
; Undefined variable:
; N
; caught 1 WARNING condition
=> COUNT-A
```

View file

@ -240,15 +240,26 @@
(defun handle-lisp (before text)
(let* ((new-txt (format nil "~a ~a" before text))
(txt (if (and *lisp-critic*
(lisp-critic-applicalbe new-txt))
(format nil "(LISP-CRITIC:CRITIQUE ~a)" new-txt)
new-txt))
(parsed (handler-case (read-from-string txt)
(end-of-file () (sbcli txt *prompt2*))
(to-critic (when (and *lisp-critic*
(lisp-critic-applicalbe new-txt))
(format nil "(LISP-CRITIC:CRITIQUE ~a)" new-txt)))
(parsed (handler-case (read-from-string new-txt)
(end-of-file () (sbcli new-txt *prompt2*))
(error (condition)
(format *error-output* "Parser error: ~a~%" condition)))))
(format *error-output* "Parser error: ~a~%" condition))))
(to-critic-parsed (when (and to-critic
parsed)
(handler-case (read-from-string to-critic)
(end-of-file () (sbcli to-critic *prompt2*))
(error (condition)
(format *error-output* "Critic parser error: ~a~%" condition))))))
(when to-critic-parsed
;; The call to lisp-critic doesn't evaluate the lisp code,
;; it only scans it and prints feedback.
(evaluate-lisp text to-critic-parsed))
;; But even if the lisp-critic is enabled,
;; we want the code we type to be eval'ed.
(when parsed
(evaluate-lisp text parsed))))