From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gatech.edu (gatech.edu [130.207.244.244]) by werple.mira.net.au (8.6.12/8.6.9) with SMTP id BAA09911 for ; Thu, 10 Aug 1995 01:25:38 +1000 Received: from math (math.skiles.gatech.edu) by gatech.edu with SMTP id AA00354 (5.65c/Gatech-10.0-IDA for ); Wed, 9 Aug 1995 11:27:28 -0400 Received: by math (5.x/SMI-SVR4) id AA18548; Wed, 9 Aug 1995 11:22:38 -0400 Resent-Date: Wed, 9 Aug 1995 17:21:01 +0200 (MET DST) Old-Return-Path: From: Zoltan Hidvegi Message-Id: <199508091521.RAA02428@bolyai.cs.elte.hu> Subject: Re: Revised dohistexpand() To: zsh-workers@math.gatech.edu (zsh-workers) Date: Wed, 9 Aug 1995 17:21:01 +0200 (MET DST) In-Reply-To: <22497.9508091344@pyro.swan.ac.uk> from "P.Stephenson@swansea.ac.uk" at Aug 9, 95 02:44:36 pm X-Mailer: ELM [version 2.4 PL24] Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Resent-Message-Id: <"50ft3.0.kX4.yADAm"@math> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/299 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu Peter Stephenson wrote: > One of the bits I like least about the history code (and that's a bold > statement) is the zle history expansion. The problem is that it > relies on calling the lexer, and via that the history code, and those > together build up a new editing line directly. This is one more > reason why the history code is hard to maintain, and is also very > wasteful: neither the resulting tokens nor the resulting history line > are used. I think that these few additional line for building the expanded line do not make the history code much more difficult to maintain. I agree that it is a bit tricky, but once you understand it it is quite obvious. And after your history rearrangement it become a bit simpler that it used to be. Also I wrote long comments about this staff in hist.c to make understanding easier. If something is still unclear ask me and hopefully I can explain it. > This revised version eliminates the lexer and uses hgetc() to get > history expansion directly. As most of the work is now done specially > in doexpandhist(), it was possible to rewrite it so that only history > expansions in the current word are expanded, which is now in keeping > with other forms of expansion and completion. This alone should make > it all worthwhile. For example, > % cmd !!:1 z > will now do completion on the second argument, as you would expect; > formerly it would expand the previous history reference first. This doesn't really a problem if you use magic-space. !!:1 is already expanded when you try to expand z. > There are a couple of drawbacks: single quotes don't hide this form of > expansion (though again that's just like glob expansion: try typing > '*' and then tab), and complex substitutions like !:s/a b/c d/ will > sometimes be mishandled (though usually you get what you deserve, > particularly if you've just finished typing the whole expression). I > don't think either of these is at all significant. I have also made > sure that magic-space still works. That's my main problem. Magic space is unusable if it expands single quoted history references. E.g. you couldn't type 'Hello!' (followed by a space). And without the lexer there is no way to get it right as there are so many cases: '!$', "'!$'", "`'!$'`" etc. The other thing you mention that '*' is turned to * after TAB is an other bug and it does not justify the bogous behaviour of single-quoted bangs. Also before beta5 (or beta6) doexpandhist() did not call the lexer. But before beta4 (as I remember) single quotes did not quote history references either. doexpandhist() was changed by Sven exactly because single quotes disabled history expansion. > There is still some small collusion with the history code: when > expanding, the history line is not modified and the pair \! is left as > it is instead of being turned into !. These are algorithmically That is the way it should work. \! should remain unchanged. Otherwise if you type \!$ it would turn to !$ and after RETURN it would change to the last word of the previous line. > simple and self-contained, however. It may also be possible to > simplify the qbang logic in hist.c (it's now not needed at all when > expanding), but I don't know enough about that (yet). This qbang is not too important in the stock beta10 as I remember, but it is important for my releases to fix a bug when >\!foo expanded history (or something like that). To summarize my opinion, I do not like this patch very much. It doesn't fixes any bugs but it introduces one. I normally bind magic-space to space so each time I hit space the whole line I typed so far goes through the lexer but the time spet there is unnoticable even on a slow 386/DX40 system (which I still use at home). Zoltan