zsh-workers
 help / color / mirror / code / Atom feed
From: Mikael Magnusson <mikachu@gmail.com>
To: zsh-workers@zsh.org
Subject: Re: PATCH: $ZLE_LINE_ABORTED
Date: Sun, 12 Sep 2010 21:49:25 +0200	[thread overview]
Message-ID: <AANLkTi=uW9_Ur1uQf6Ku5WS-1YGD4UzX9xg5DOYLyHv9@mail.gmail.com> (raw)
In-Reply-To: <m3eid5sj32.fsf@klanderman.net>

On 7 September 2010 16:51, Greg Klanderman <gak@klanderman.net> wrote:
>
> Wow that was fast!  Seems to be working here, will continue to play
> with it..

I played with it a bit now, and came up with this

#the intent here is to insert syntax errors back on the command line, since
#those aren't saved in history, for example entering "do;"
function _zle_line_init() {
  if [[ -n $ZLE_LINE_SAVED && $ZLE_LINE_SAVED[1] != " " &&
$ZLE_LINE_SAVED != $history[$((HISTCMD-1))] ]]; then
    LBUFFER=$ZLE_LINE_SAVED
    zle -R
  fi
  unset ZLE_LINE_SAVED
}

#like pws said, if we accept a line, we don't need the aborted one anymore
function _zle_line_finish() {
  ZLE_LINE_SAVED=$BUFFER
  unset ZLE_LINE_ABORTED
}


#this puts back the aborted line when you try to go up history, can be
bound to other
#things too but haven't got around to that yet (ie up-line-or-search).
should probably
#also check the current line is empty first too.
function _recover_line_or_else() {
  if [[ -n $ZLE_LINE_SAVED ]]; then
    LBUFFER+=$ZLE_LINE_SAVED
    unset ZLE_LINE_SAVED
  elif [[ -n $ZLE_LINE_ABORTED ]]; then
    LBUFFER+=$ZLE_LINE_ABORTED
    unset ZLE_LINE_ABORTED
  else
    zle .$WIDGET
  fi
}
zle -N up-history _recover_line_or_else

-- 
Mikael Magnusson


  reply	other threads:[~2010-09-12 19:49 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-07 10:44 Peter Stephenson
2010-09-07 11:46 ` Nikolai Weibull
2010-09-07 12:02   ` Peter Stephenson
2010-09-07 14:31     ` Greg Klanderman
2010-09-07 14:44       ` Peter Stephenson
2010-09-07 14:51         ` Greg Klanderman
2010-09-12 19:49           ` Mikael Magnusson [this message]
2010-09-12 19:51             ` 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='AANLkTi=uW9_Ur1uQf6Ku5WS-1YGD4UzX9xg5DOYLyHv9@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).