From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10159 invoked by alias); 17 Feb 2015 17:10:22 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 34565 Received: (qmail 15816 invoked from network); 17 Feb 2015 17:10:20 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 X-CMAE-Score: 0 X-CMAE-Analysis: v=2.1 cv=Ko/6AtSI c=1 sm=1 tr=0 a=FT8er97JFeGWzr5TCOCO5w==:117 a=kj9zAlcOel0A:10 a=q2GGsy2AAAAA:8 a=oR5dmqMzAAAA:8 a=-9mUelKeXuEA:10 a=0HtSIViG9nkA:10 a=DB6ZE7A2DrTYhM3iC-wA:9 a=v-4Ne5QdtiDqc5Ug:21 a=bW0DExLnRocuknuJ:21 a=CjuIK1q_8ugA:10 From: Bart Schaefer Message-id: <150217090952.ZM7198@torch.brasslantern.com> Date: Tue, 17 Feb 2015 09:09:51 -0800 In-reply-to: Comments: In reply to Derek Gleim "Re: prexec never gets empty string?" (Feb 16, 9:11am) References: <20150214213757.010b0c82@ntlworld.com> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh workers Subject: Re: prexec never gets empty string? MIME-version: 1.0 Content-type: text/plain; charset=us-ascii 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.