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

PATCH: re-expand the prompt automatically



On Thu, Jul 01, 2004 at 02:30:20PM +0200, Oliver Kiddle wrote:
> Is there any chance this could be automatically called before the
> prompt is reprinted when a background job finishes? That would allow %j
> prompt expansions to be right.

I had this same thought.  Here's a patch that makes the re-expanding
part of the new function get called from zrefresh().  If that turns out
to be too pervasive, we could mod_export the new reexpandprompt()
function and call it from various other places in the code, such as
from jobs.c.

..wayne..
--- Src/Zle/zle_main.c	1 Jul 2004 14:55:58 -0000	1.46
+++ Src/Zle/zle_main.c	1 Jul 2004 16:42:30 -0000
@@ -1311,14 +1311,20 @@ recursiveedit(UNUSED(char **args))
 }
 
 /**/
-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);
 }
 
--- Src/Zle/zle_refresh.c	2 Jun 2004 22:15:02 -0000	1.12
+++ Src/Zle/zle_refresh.c	1 Jul 2004 16:42:30 -0000
@@ -291,7 +291,8 @@ zrefresh(void)
     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 */
-	
+
+    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  *


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