zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: 4.0.2: rprompt2 variable
@ 2002-01-25 12:48 Derek Peschel
  2002-01-29 18:21 ` Oliver Kiddle
  0 siblings, 1 reply; 5+ messages in thread
From: Derek Peschel @ 2002-01-25 12:48 UTC (permalink / raw)
  To: zsh-workers

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).

-- Derek




--- Src/params.c.orig	Thu Jan 24 15:23:36 2002
+++ Src/params.c	Thu Jan 24 18:33:52 2002
@@ -65,6 +65,7 @@
      *prompt4,		/* $PROMPT4     */
      *readnullcmd,	/* $READNULLCMD */
      *rprompt,		/* $RPROMPT     */
+     *rprompt2,		/* $RPROMPT2    */
      *sprompt,		/* $SPROMPT     */
      *wordchars,	/* $WORDCHARS   */
      *zsh_name;		/* $ZSH_NAME    */
@@ -193,12 +194,14 @@
 IPDEF7("NULLCMD", &nullcmd),
 IPDEF7("POSTEDIT", &postedit),
 IPDEF7("READNULLCMD", &readnullcmd),
-IPDEF7("RPROMPT", &rprompt),
 IPDEF7("PS1", &prompt),
+IPDEF7("RPS1", &rprompt),
+IPDEF7("RPROMPT", &rprompt),
 IPDEF7("PS2", &prompt2),
+IPDEF7("RPS2", &rprompt2),
+IPDEF7("RPROMPT2", &rprompt2),
 IPDEF7("PS3", &prompt3),
 IPDEF7("PS4", &prompt4),
-IPDEF7("RPS1", &rprompt),
 IPDEF7("SPROMPT", &sprompt),
 IPDEF7("0", &argzero),
 
--- Src/input.c.orig	Thu Jan 24 15:38:18 2002
+++ Src/input.c	Thu Jan 24 18:33:53 2002
@@ -222,8 +222,11 @@
 
     /* If reading code interactively, work out the prompts. */
     if (interact && isset(SHINSTDIN)) {
-	if (!isfirstln)
+	if (!isfirstln) {
 	    ingetcpmptl = prompt2;
+	    if (rprompt2)
+		ingetcpmptr = rprompt2;
+	}
 	else {
 	    ingetcpmptl = prompt;
 	    if (rprompt)
--- Doc/Zsh/params.yo.orig	Thu Jan 24 19:33:03 2002
+++ Doc/Zsh/params.yo	Thu Jan 24 19:34:34 2002
@@ -955,6 +955,15 @@
 This does not work if the tt(SINGLELINEZLE) option is set.
 It is expanded in the same way as tt(PS1).
 )
+vindex(RPROMPT2)
+xitem(tt(RPROMPT2) <S>)
+vindex(RPS2)
+item(tt(RPS2) <S>)(
+This prompt is displayed on the right-hand side of the screen
+when the secondary prompt is being displayed on the left.
+This does not work if the tt(SINGLELINEZLE) option is set.
+It is expanded in the same way as tt(PS2).
+)
 vindex(SAVEHIST)
 item(tt(SAVEHIST))(
 The maximum number of history events to save in the history file.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: PATCH: 4.0.2: rprompt2 variable
  2002-01-25 12:48 PATCH: 4.0.2: rprompt2 variable Derek Peschel
@ 2002-01-29 18:21 ` Oliver Kiddle
  2002-01-31  5:01   ` Derek Peschel
  2002-01-31 12:06   ` Peter Stephenson
  0 siblings, 2 replies; 5+ messages in thread
From: Oliver Kiddle @ 2002-01-29 18:21 UTC (permalink / raw)
  To: Derek Peschel; +Cc: zsh-workers

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.

> %_ 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.

Note that these patches do apply to the latest code from cvs. Has
anyone else tried them?

Oliver

________________________________________________________________________
This email has been scanned for all viruses by the MessageLabs SkyScan
service. For more information on a proactive anti-virus service working
around the clock, around the globe, visit http://www.messagelabs.com
________________________________________________________________________


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: PATCH: 4.0.2: rprompt2 variable
  2002-01-29 18:21 ` Oliver Kiddle
@ 2002-01-31  5:01   ` Derek Peschel
  2002-01-31 14:12     ` Oliver Kiddle
  2002-01-31 12:06   ` Peter Stephenson
  1 sibling, 1 reply; 5+ messages in thread
From: Derek Peschel @ 2002-01-31  5:01 UTC (permalink / raw)
  To: Oliver Kiddle; +Cc: zsh-workers

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"
feature.

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
to
	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


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: PATCH: 4.0.2: rprompt2 variable
  2002-01-29 18:21 ` Oliver Kiddle
  2002-01-31  5:01   ` Derek Peschel
@ 2002-01-31 12:06   ` Peter Stephenson
  1 sibling, 0 replies; 5+ messages in thread
From: Peter Stephenson @ 2002-01-31 12:06 UTC (permalink / raw)
  To: Zsh hackers list

Oliver Kiddle wrote:
> Derek Peschel wrote:
> > 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.

You might as well commit it.  I don't think anyone's going to mind.

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK                          Tel: +44 (0)1223 392070


**********************************************************************
The information transmitted is intended only for the person or
entity to which it is addressed and may contain confidential 
and/or privileged material. 
Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by 
persons or entities other than the intended recipient is 
prohibited.  
If you received this in error, please contact the sender and 
delete the material from any computer.
**********************************************************************


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: PATCH: 4.0.2: rprompt2 variable
  2002-01-31  5:01   ` Derek Peschel
@ 2002-01-31 14:12     ` Oliver Kiddle
  0 siblings, 0 replies; 5+ messages in thread
From: Oliver Kiddle @ 2002-01-31 14:12 UTC (permalink / raw)
  To: Derek Peschel; +Cc: zsh-workers

Derek Peschel wrote:

> 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).

I'm happy with that argument. And thinking about it, I agree that there
might be uses - RPS2='<%6(_,%2^ ... %-2^,%^)' might be used to avoid
the state list getting too long.

> 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.

It seems that precmd is only run before each PS1 prompt so the answer
to the question is no. Of course, we could change that or add a precmd2
but I'm not sure there would be much point. My vote is for sticking
with %^ because it is likely to be commonly used in RPS2.

Peter wrote:

> You might as well commit it.  I don't think anyone's going to mind.

Okay, I will.

Derek wrote:

> The behavior affects the released 4.0.2, as well as today's daily 4.1
> snapshot.  I haven't tested 4.0.4 (it seems not to compile on my system)
> but undoubtedly it works the same way.

What is the compiler error or whatever with 4.0.4? What type of system
is it?

Oliver

________________________________________________________________________
This email has been scanned for all viruses by the MessageLabs SkyScan
service. For more information on a proactive anti-virus service working
around the clock, around the globe, visit http://www.messagelabs.com
________________________________________________________________________


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2002-01-31 14:12 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-01-25 12:48 PATCH: 4.0.2: rprompt2 variable Derek Peschel
2002-01-29 18:21 ` Oliver Kiddle
2002-01-31  5:01   ` Derek Peschel
2002-01-31 14:12     ` Oliver Kiddle
2002-01-31 12:06   ` Peter Stephenson

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).