From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh workers <zsh-workers@zsh.org>
Subject: Re: prexec never gets empty string?
Date: Tue, 17 Feb 2015 09:09:51 -0800 [thread overview]
Message-ID: <150217090952.ZM7198@torch.brasslantern.com> (raw)
In-Reply-To: <CANOe-=7Oa8pT4SSVwnpKsNrKbCFiX_x=abS1HVBcqzmt9cg3hw@mail.gmail.com>
On Feb 16, 9:11am, Derek Gleim wrote:
}
} As an aside, I'd still like to be able to get the prompt expansion `%!` to
} always show the number to be assigned to the next command...
}
} % PROMPT='%! >' zsh --no-rcs --histignorespace
} 1 > true ignore me
} 2 >this command will really be event 1
} 2 >
Hrm. The history number isn't ajusted until the hend() call of the input
command following the one to be ignored. That's because the previous
line actually CAN be referenced as (in the example above) !1 while you
are at the prompt that says "2 > ".
So there's an inherent conflict here; for a short while, there effectively
are two history events both numbered the same. You're either going to be
misled about what the last command was numbered, or about what the current
command will be numbered. This actually works well for HIST_IGNORE_DUPS
because the two identical commands are collapsed onto the same number, but
in other cases cases you end up with !N references where N finds something
that doesn't match your terminal scrollback.
Possible approaches:
(0) Do nothing.
(1) Make the numbering match the "what it will be" case.
(a) Introduce a second history counter used only in prompt expansion
that skips incrementing at hbegin() time [rather than hend()].
(b) Do a significant rework of hist.c so the "curhist" variable can
serve that role correctly.
(2) Rework history to leave holes in the number sequence when an event
is skipped. I believe this is already done for HIST_IGNORE_ALL_DUPS
and HIST_EXPIRE_DUPS_FIRST when the older duplicate is dropped. The
history is stored in a hash table, so event numbers are just keys in
the hash and holes are (I think) not an issue.
I'm not going to jump in on implementing any of the above any time soon,
but perhaps we can reach consensus on which is the best thing and then
somebody else can tackle it.
prev parent reply other threads:[~2015-02-17 17:10 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-13 17:19 Derek Gleim
2015-02-13 17:35 ` Peter Stephenson
2015-02-13 19:27 ` Derek Gleim
2015-02-13 20:19 ` Peter Stephenson
2015-02-13 22:16 ` Mikael Magnusson
2015-02-13 22:41 ` Derek Gleim
2015-02-13 23:04 ` Mikael Magnusson
2015-02-13 23:14 ` Mikael Magnusson
2015-02-14 21:37 ` Peter Stephenson
2015-02-16 15:11 ` Derek Gleim
2015-02-16 15:16 ` Derek Gleim
2015-02-16 15:59 ` Peter Stephenson
2015-02-17 17:09 ` Bart Schaefer [this message]
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=150217090952.ZM7198@torch.brasslantern.com \
--to=schaefer@brasslantern.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).