stumpwm-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [STUMP] [PATCH] Fix `eval-line' for the case when the user aborts


From: David Bjergaard
Subject: Re: [STUMP] [PATCH] Fix `eval-line' for the case when the user aborts
Date: Thu, 06 Nov 2014 14:10:47 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux)

Hi Diogo, 

Thanks for the patch! I've tweaked it a bit to get the behavior you
suggest:
> 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.
This will be integrated in the master branch soon.

Cheers,

    Dave

"Diogo F. S. Ramos" <address@hidden> writes:

> 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))))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]