zsh-workers
 help / color / mirror / code / Atom feed
* Re: PATCH: re-expand the prompt automatically
       [not found] <20040701164446.GA22234@blorf.net>
@ 2004-07-02 15:23 ` Peter Stephenson
  2004-07-02 21:06   ` Bart Schaefer
  0 siblings, 1 reply; 5+ messages in thread
From: Peter Stephenson @ 2004-07-02 15:23 UTC (permalink / raw)
  To: Zsh hackers list

Here's the tweak I just proposed to Wayne's patch: the only difference
is the `if (trashedzle)', plus the patch to the documentation.  If the
test succeeds we know the command line will be completely reprinted, so
this should do nicely what we want.

Index: Src/Zle/zle_main.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_main.c,v
retrieving revision 1.46
diff -u -r1.46 zle_main.c
--- Src/Zle/zle_main.c	1 Jul 2004 14:55:58 -0000	1.46
+++ Src/Zle/zle_main.c	2 Jul 2004 15:22:34 -0000
@@ -1311,14 +1311,20 @@
 }
 
 /**/
-int
-resetprompt(UNUSED(char **args))
+void
+reexpandprompt(void)
 {
     free(lpromptbuf);
     lpromptbuf = promptexpand(raw_lp, 1, NULL, NULL);
     free(rpromptbuf);
     rpromptbuf = promptexpand(raw_rp, 1, NULL, NULL);
+}
 
+/**/
+int
+resetprompt(UNUSED(char **args))
+{
+    reexpandprompt();
     return redisplay(NULL);
 }
 
Index: Src/Zle/zle_refresh.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_refresh.c,v
retrieving revision 1.12
diff -u -r1.12 zle_refresh.c
--- Src/Zle/zle_refresh.c	2 Jun 2004 22:15:02 -0000	1.12
+++ Src/Zle/zle_refresh.c	2 Jul 2004 15:22:35 -0000
@@ -291,7 +291,9 @@
     unsigned char *tmpline;	/* line with added pre/post text */
     int tmpcs, tmpll;		/* ditto cursor position and line length */
     int tmpalloced;		/* flag to free tmpline when finished */
-	
+
+    if (trashedzle)
+	reexpandprompt();
 
     /* If this is called from listmatches() (indirectly via trashzle()), and *
      * that was called from the end of zrefresh(), then we don't need to do  *


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


**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.

www.mimesweeper.com
**********************************************************************


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

* Re: PATCH: re-expand the prompt automatically
  2004-07-02 15:23 ` PATCH: re-expand the prompt automatically Peter Stephenson
@ 2004-07-02 21:06   ` Bart Schaefer
  2004-07-04 17:17     ` Peter Stephenson
  0 siblings, 1 reply; 5+ messages in thread
From: Bart Schaefer @ 2004-07-02 21:06 UTC (permalink / raw)
  To: Zsh hackers list

On Fri, 2 Jul 2004, Peter Stephenson wrote:

> Here's the tweak I just proposed to Wayne's patch

So does this mean "zle reset-prompt" goes away again?  Or does it serve
a different purpose?

(It would seem that, with this patch, "zle -I" can be used instead of 
reset-prompt.  Further, it seems odd to make reset-prompt a built-in 
widget rather than a zle option.)


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

* Re: PATCH: re-expand the prompt automatically
  2004-07-02 21:06   ` Bart Schaefer
@ 2004-07-04 17:17     ` Peter Stephenson
  2004-07-04 21:38       ` Bart Schaefer
  0 siblings, 1 reply; 5+ messages in thread
From: Peter Stephenson @ 2004-07-04 17:17 UTC (permalink / raw)
  To: Zsh hackers list

Bart Schaefer wrote:
> On Fri, 2 Jul 2004, Peter Stephenson wrote:
> 
> > Here's the tweak I just proposed to Wayne's patch
> 
> So does this mean "zle reset-prompt" goes away again?  Or does it serve
> a different purpose?

Neither, really, because you still need some way of reexpanding the
prompt when you don't get an asynchronous event.  So it serves the
purpose it always did.

> (It would seem that, with this patch, "zle -I" can be used instead of 
> reset-prompt.

That's not quite true.  zle -I invalidates the display, redrawing the
prompt below.  So at the minimum you get a new line, whether or not the
prompt changed.  zle reset-prompt reexpands the prompt on the current
line.  This is much less intrusive.

> Further, it seems odd to make reset-prompt a built-in 
> widget rather than a zle option.)

I don't understand that.  How would the option know when to reexpand the
prompt?  Are you suggesting it be tied to zle -R or zle redisplay or
both?  (Probably the latter since the former is supposed just to make
the changes requested by widgets explicit rather than refresh the
display.)  Why is that more natural?

-- 
Peter Stephenson <pws@pwstephenson.fsnet.co.uk>
Work: pws@csr.com
Web: http://www.pwstephenson.fsnet.co.uk


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

* Re: PATCH: re-expand the prompt automatically
  2004-07-04 17:17     ` Peter Stephenson
@ 2004-07-04 21:38       ` Bart Schaefer
  2004-07-05  9:26         ` Peter Stephenson
  0 siblings, 1 reply; 5+ messages in thread
From: Bart Schaefer @ 2004-07-04 21:38 UTC (permalink / raw)
  To: Zsh hackers list

On Sun, 4 Jul 2004, Peter Stephenson wrote:

> Bart Schaefer wrote:
> > (It would seem that, with this patch, "zle -I" can be used instead of 
> > reset-prompt.
> 
> That's not quite true.  zle -I invalidates the display, redrawing the 
> prompt below.  [...] zle reset-prompt reexpands the prompt on the 
> current line.

Aha.  I hadn't caught that distinction.

> > Further, it seems odd to make reset-prompt a built-in 
> > widget rather than a zle option.)
> 
> I don't understand that.  How would the option know when to reexpand the
> prompt?

In part this suggestion came from my misinterpretation of reset-prompt (by
the way, the ChangeLog calls it "prompt-reset".)  However:

> Are you suggesting it be tied to zle -R or zle redisplay or both?

Neither ...  Put to it, I don't think "redisplay" should have been a 
built-in widget either, except that for historic reasons it had to be.  
I'm suggesting that built-in widgets should always act on the editor 
buffer (on either the contents or the position of the mark or the cursor) 
whereas zle options -- or special commands like compadd -- should act on 
the editing engine itself (widgets, keymaps, prompts and displays).

My criteria would best be described by the question, "Would it ever make 
sense to use any of the zle -A, -C, -D, or -N options to supercede or 
remove this action?"  If the answer is yes, it should be a widget; if no, 
then either a zle option or a separate command.

I recognize that the line is pretty fuzzy, and now I see that reset-prompt 
is a lot deeper in the fuzz than I originally thought.


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

* Re: PATCH: re-expand the prompt automatically
  2004-07-04 21:38       ` Bart Schaefer
@ 2004-07-05  9:26         ` Peter Stephenson
  0 siblings, 0 replies; 5+ messages in thread
From: Peter Stephenson @ 2004-07-05  9:26 UTC (permalink / raw)
  To: Zsh hackers list

Bart Schaefer wrote:
> > Are you suggesting it be tied to zle -R or zle redisplay or both?
> 
> Neither ...  Put to it, I don't think "redisplay" should have been a 
> built-in widget either, except that for historic reasons it had to be.  
> I'm suggesting that built-in widgets should always act on the editor 
> buffer (on either the contents or the position of the mark or the cursor) 
> whereas zle options -- or special commands like compadd -- should act on 
> the editing engine itself (widgets, keymaps, prompts and displays).
> 
> My criteria would best be described by the question, "Would it ever make 
> sense to use any of the zle -A, -C, -D, or -N options to supercede or 
> remove this action?"  If the answer is yes, it should be a widget; if no, 
> then either a zle option or a separate command.

I think I misinterpreted your use of `option'... I presumed you meant
something like `setopt always_redraw_prompt', whereas you presumably
meant something link `zle -P'.  I can certainly see an argument for that
but, as you say, it's all a bit murky.

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


**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.

www.mimesweeper.com
**********************************************************************


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

end of thread, other threads:[~2004-07-05  9:27 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20040701164446.GA22234@blorf.net>
2004-07-02 15:23 ` PATCH: re-expand the prompt automatically Peter Stephenson
2004-07-02 21:06   ` Bart Schaefer
2004-07-04 17:17     ` Peter Stephenson
2004-07-04 21:38       ` Bart Schaefer
2004-07-05  9:26         ` 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).