X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Ftoplevel.lisp;h=9d6594b464d08e442ca04a3e02980a9e105edb88;hb=e8992591d4100811ac125bf97c5b153ddecb0250;hp=42864e61e0a685af0ec1fdd63f4613b278a8c765;hpb=f92bc46ea965b290b67119e0dd076bd8ad0d1b46;p=jscl.git diff --git a/src/toplevel.lisp b/src/toplevel.lisp index 42864e6..9d6594b 100644 --- a/src/toplevel.lisp +++ b/src/toplevel.lisp @@ -264,23 +264,31 @@ (#j:jqconsole:Write prompt "jqconsole-prompt")) (flet ((process-input (input) (let* ((form (read-from-string input)) - (result (multiple-value-list (eval-interactive form)))) - (dolist (x result) - (#j:jqconsole:Write (format nil "~S~%" x) "jqconsole-return")) + (successp nil) + result) + ;; Capture errors. We evaluate the form and set successp + ;; to T. However, if a non-local exist happens, we cancel + ;; it, so it is not propagated more. + (block nil + (unwind-protect + (progn + (setq result (multiple-value-list (eval-interactive form))) + (setq successp t)) + (return))) + + (if successp + (dolist (x result) + (#j:jqconsole:Write (format nil "~S~%" x) "jqconsole-return")) + (#j:jqconsole:Write (format nil "Error occurred~%") "jqconsole-error")) + (save-history)) (toplevel))) (#j:jqconsole:Prompt t #'process-input))) -;;; KLUDGE: I tried -;;; -;;; (#j:document.addEventListener "load" #'topevel nil) -;;; -;;; but it is not working. So I am using this temporarily to wait -;;; until the DOM is ready before starting the REPL. +(defun init (&rest args) + (#j:jqconsole:RegisterMatching "(" ")" "parents") + (load-history) + (toplevel)) -(#j:setTimeout (lambda () - (#j:jqconsole:RegisterMatching "(" ")" "parents") - (load-history) - (toplevel)) - 0) +(#j:window:addEventListener "load" #'init)