zsh-users
 help / color / mirror / code / Atom feed
From: "Nadav Har'El" <nyh@math.technion.ac.il>
To: Bart Schaefer <schaefer@brasslantern.com>
Cc: zsh-users@zsh.org
Subject: Re: Append cancelled commands to history
Date: Fri, 26 Mar 2010 23:23:49 +0300	[thread overview]
Message-ID: <20100326202349.GA17385@fermat.math.technion.ac.il> (raw)
In-Reply-To: <100324091951.ZM25340@torch.brasslantern.com>

On Wed, Mar 24, 2010, Bart Schaefer wrote about "Re: Append cancelled commands to history":
> } So apparently, that interrupted multiline editing is *not* in the
> } history, and never was. So where is it? Why do I see it when I go "up"
> } for the first time? How do I prevent this?
> 
> Oh, of course.  Zsh *always* makes the immediately preceding accepted
> input available for scrollback in the line editor, even if it was not
> put into the history (because of HIST_IGNORE_ALL_DUPS, HIST_NO_STORE,
> or HIST_IGNORE_SPACE, etc.).
> 
> There is no way to prevent this.

Thanks. I think I understand better now what is happening. What I still find
a bit odd is the fact that this behavior (of saving the partially entered
command in a special place outside the history) is only applied to whole
lines of multiline commands, and not to interrupted single line commands,
or to the last partially-written line of a multiline command. I have two
reservations about this behavior:

1. Why this should apply only to multi-line commands

2. Why is that special (out of history) memory location for one last command
   is needed, or even desired. If it was added, I assume people wanted to
   scroll back to it. Now, what happens if you accidentally run some other
   command and only then wish to scroll back to that interrupted command?
   You can't. So what's wrong with just using the normal history to store it?

> You could, however, stop using the interrupt signal and its trap, and
> instead re-bind ctrl-C (or whatever your interrupt key is) to a zle
> function that, whenever $PREBUFER is non-empty, does a no-op equivalent
> of accept-line followed by a send-break.

Thanks! Maybe I'll indeed try that. I'm a bit reluctant, though, to go
through all this complexity just to avoid that extra partial history
(or not really history :-)) entry. Because, like I said, the simple 4-line

TRAPINT() {
        zle && [[ $HISTNO -eq $HISTCMD ]] && print -sr -- "$PREBUFFER$BUFFER"
        return $1
}

already saves the partial command (single or multi-line) correctly.

Thanks again for your explanations, and I'll try your trick later.

Nadav.


-- 
Nadav Har'El                        |       Friday, Mar 26 2010, 12 Nisan 5770
nyh@math.technion.ac.il             |-----------------------------------------
Phone +972-523-790466, ICQ 13349191 |Strike not only while the iron is hot,
http://nadav.harel.org.il           |make the iron hot by striking it.


  reply	other threads:[~2010-03-26 20:24 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-18 21:50 thomasg
2008-09-19 16:20 ` Simon Ruderich
2009-07-06 15:16   ` Re[2]: " Vadim Zeitlin
2009-07-06 15:43     ` Nadav Har'El
2009-07-06 15:53       ` Nadav Har'El
2010-03-15 16:42         ` Nadav Har'El
2010-03-20 17:50           ` Bart Schaefer
2010-03-22  8:42             ` Nadav Har'El
2010-03-22 15:07               ` Bart Schaefer
2010-03-24 10:27                 ` Nadav Har'El
2010-03-24 16:19                   ` Bart Schaefer
2010-03-26 20:23                     ` Nadav Har'El [this message]
2010-03-27  4:23                       ` Bart Schaefer
2010-04-05 19:36       ` Simon Ruderich
2009-07-07 19:49     ` Simon Ruderich

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=20100326202349.GA17385@fermat.math.technion.ac.il \
    --to=nyh@math.technion.ac.il \
    --cc=schaefer@brasslantern.com \
    --cc=zsh-users@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).