Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: PATCH: 4.0.2: rprompt2 variable

On Tue, Jan 29, 2002 at 06:21:32PM +0000, Oliver Kiddle wrote:
> Derek Peschel wrote:
> > 
> > Even if a feature (right-hand prompts) is frivolous, it might as well be
> > available in general.
> > 
> > Now you can see the parser state (or whatever else you might want to put
> > in PROMPT2) and still have a consistent left margin when entering a multi-
> > line command.  See my companion "reverse parser state" patch if you want
> > the parser state to expand leftward on your screen.
> > 
> > Comments welcome (I just started using zsh and I have no idea if anyone
> > else will find these patches useful).
> I'd just like to say that I like this. I've never actually used
> rprompts but this with the transient_rprompt option (new since 4.0.2)
> is useful. For one thing, it makes life easier if I decide to cut 'n'
> paste the lines into an editor or other terminal because I don't then
> have a prompt to get rid of. I fear that other people may want a
> separate transient_rprompt2 option with this.

Because you mentioned it, I decided to see how easy it is to add.
(I'm not sure why people would want one prompt transient and not the
other, but I also don't like it when programs make assumptions that
prevent me from doing something.)

> > %_ no longer treats negative integers like zero, but instead extracts
> > leading (outermost) words.  Maybe someone somewhere cares more about
> > the outer state than the inner state.
> > 
> > %^ works like %_ (including the behavior described above) but after
> > the words are selected they are printed in reverse order.  Try using %^
> > in RPS2.
> > 
> > I picked ^ because it comes before _ in ASCII.
> I'm not sure whether the negative integers part might ever be useful
> though I have no objections because it is logical. I'd be tempted to
> use negative numbers for reversing the order but -0 not being a
> distinct number from +0 makes that less clean as a solution.

It's very important for programs (especially large and complicated ones)
to act consistently IMO.  Some of the other prompt escapes (like the one
for the current directory) already use the sign to choose between first
and last components.  I don't think any other escapes have a "reverse order"

I'm not sure whether the negative integer feature might be useful either.
Though someone might not like the way the line changes from

	for for for if then
	for for if then if

and reason that if the line is going to get too long, it should just
stop growing.  So leaving the feature out on principle seems a bit
presumptuous to me (especially since it was easy to add and didn't use
very much code).

Would it be possible to do the reversal using the precmd feature?  (Can
you "print" the prompt to a string?)  If so, then the %^ escape can go.
And that makes more sense as the code to take out, since none of the
other escapes has a "reverse order" feature.

-- Derek

Messages sorted by: Reverse Date, Date, Thread, Author