+Calculator and code looks
[lineal.git] / src / webui / reload.lisp
blob6cd823db7bbb752d73a70d058eae96b0fd18c172
2 (in-package :lineal.webui)
4 (defmacro bind-reset ((&body args) . body)
5 (let (tmp-lets s-sets)
6 (loop :for a :in args
7 :and b = (gentemp)
8 :collect (list b a) :into l
9 :collect a :into s
10 :collect b :into s
11 :finally
12 (setq tmp-lets l
13 s-sets (cons 'setq s)))
14 `(let ,tmp-lets
15 (unwind-protect
16 ,(cons 'progn body)
17 ,s-sets))))
19 (defun fresheval ()
20 (bind-reset
21 (*saved-numbers* *saved-tuples* *saved-matrices*)
22 ;V Do file loading.V
23 (compile-lineal :load-all nil)
24 ;V Compile the javascript files.V
25 (recompile-ps)))
27 ;V Reload this file via the web.V
28 (defun reload (&aux (worked nil))
29 (compile-if-new
30 "reload" '(:relative "src" "webui")
31 :fasl-dir '(:relative "fasl" "webui")
32 :load-all nil)
33 (unwind-protect
34 (progn (fresheval)
35 ;V say it worked V
36 (setq worked t))
37 ;V explicit return, needed if error thrown V
38 (return-from
39 reload
40 (with-html-output-to-string
41 (s nil :prologue t)
42 (:html (:head (:title "Site reloaded."))
43 (:body (:center
44 (princ (if worked "Everything worked"
45 "eval errorz")
46 s))))))))