[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[STUMP] [PATCH] Fix `eval-line' for the case when the user aborts
From: |
Diogo F. S. Ramos |
Subject: |
[STUMP] [PATCH] Fix `eval-line' for the case when the user aborts |
Date: |
Wed, 5 Nov 2014 01:28:36 -0200 |
When the user aborts, pressing C-g for example, `cmd' is NIL, so
`read-from-string' will trow a TYPE-ERROR.
`colon', the command which reads further commands from the user, use
the form (unless cmd (throw 'error :abort)) for the case of a user
aborting. Although this makes for a nice "Abort." message to the
user, it breaks evaling (colon) from the REPL and pressing C-g,
because the tag `'error' doesn't exist.
---
I think there is a deep fix here.
`colon' works nicely when called by a keybind because StumpWM has in
the call stack `eval-command', which checks for a result of `:abort'
and then prints "Abort.".
Using `call-interactively' protects the caller from the nonexistent
tag because it wraps command using the tag `'error'.
There might be a way to integrate this calling conventions, so
whichever the user aborts inside a input box, "Abort." is print and
there is no error thrown.
user.lisp | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/user.lisp b/user.lisp
index 63b65ae..f630292 100644
--- a/user.lisp
+++ b/user.lisp
@@ -175,9 +175,10 @@ such a case, kill the shell command to resume StumpWM."
(defcommand eval-line (cmd) ((:rest "Eval: "))
"Evaluate the s-expression and display the result(s)."
(handler-case
- (message "^20~{~a~^~%~}"
- (mapcar 'prin1-to-string
- (multiple-value-list (eval (read-from-string cmd)))))
+ (when cmd
+ (message "^20~{~a~^~%~}"
+ (mapcar 'prin1-to-string
+ (multiple-value-list (eval (read-from-string cmd))))))
(error (c)
(err "^B^1*~A" c))))
--
1.7.10.4
- [STUMP] [PATCH] Fix `eval-line' for the case when the user aborts,
Diogo F. S. Ramos <=