Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

PATCH: Don't store ZLE_LINE_ABORTED in vared context



The description of the parameter itself says

ZLE_LINE_ABORTED
       This  parameter  is  set  by the line editor when an error occurs.  It
       contains the line that was being edited at the  point  of  the  error.
       `print  -zr  --  $ZLE_LINE_ABORTED'  can  be used to recover the line.
       Only the most recent line of this kind is remembered.

and the description of send-break says

send-break (^G ESC-^G) (unbound) (unbound)
       Abort  the current editor function, e.g. execute-named-command, or the
       editor itself, e.g. if you are in vared. Otherwise abort  the  parsing
       of the current line; in this case the aborted line is available in the
       shell variable ZLE_LINE_ABORTED.

However, pressing ctrl-c inside vared stores whatever was being edited
in ZLE_LINE_ABORTED, which the above seems to imply should not happen.
The following adjusts the code accordingly. It was actually a bit
annoying if you set up a widget to do the up-line-or-aborted, because
it will grab the vared text as a command then.

diff --git a/Src/Zle/zle_main.c b/Src/Zle/zle_main.c
index f344ecc..5b1d5f9 100644
--- a/Src/Zle/zle_main.c
+++ b/Src/Zle/zle_main.c
@@ -1252,7 +1252,7 @@ zleread(char **lp,

     zlecore();

-    if (errflag)
+    if (errflag && zlecontext != ZLCON_VARED)
        setsparam("ZLE_LINE_ABORTED", zlegetline(NULL, NULL));

     if (done && !exit_pending && !errflag)



-- 
Mikael Magnusson



Messages sorted by: Reverse Date, Date, Thread, Author