zsh-workers
 help / color / mirror / code / Atom feed
From: Mikael Magnusson <mikachu@gmail.com>
To: zsh workers <zsh-workers@zsh.org>
Subject: PATCH: Don't store ZLE_LINE_ABORTED in vared context
Date: Wed, 4 Mar 2015 19:40:03 +0100	[thread overview]
Message-ID: <CAHYJk3TOafzzcfxE5A72MSumEZFasi95+5-AbRkpHPXKDhCt+w@mail.gmail.com> (raw)

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


             reply	other threads:[~2015-03-04 18:40 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-04 18:40 Mikael Magnusson [this message]
2015-03-05  1:57 ` Bart Schaefer
2015-03-05  2:41   ` Mikael Magnusson
2015-03-05  4:46     ` Bart Schaefer
2015-03-05  9:59 ` Peter Stephenson
2015-03-05 13:58   ` Peter Stephenson
2015-03-06  9:52     ` Peter Stephenson
2015-03-06 16:05       ` Mikael Magnusson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAHYJk3TOafzzcfxE5A72MSumEZFasi95+5-AbRkpHPXKDhCt+w@mail.gmail.com \
    --to=mikachu@gmail.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).