zsh-users
 help / color / mirror / code / Atom feed
From: Peter Stephenson <pws@csr.com>
To: zsh-users@sunsite.dk (Zsh users list)
Subject: Re: Jumping to the line above
Date: Thu, 01 Jul 2004 13:14:42 +0100	[thread overview]
Message-ID: <200407011214.i61CEhUe012898@news01.csr.com> (raw)
In-Reply-To: "Peter Stephenson"'s message of "Thu, 01 Jul 2004 12:32:08 BST." <200407011132.i61BW9Ss012116@news01.csr.com>

Peter Stephenson wrote:
> > 	[Some previous output]
> > 	~/bin/foo/bar $ 
> > 
> > After typing (for example) ^U twice:
> > 
> > 	[Some previous output]
> > 	~/bin $ 
>
> I think what you *really* want is a way of re-expanding the current
> prompt.

This may be oversimple (in particular, I have no idea what to do about
pmpt_attr and rpmpt_attr) ...  Further followups on that should go
to zsh-workers.

After the patch, you can do stuff like

PS1="%~%# "
zle-pushd() {
  emulate -L zsh
  setopt pushdsilent

  # Use the numeric argument to get a new directory.
  # Make sure we get an argument in the +/- from expected by pushd.
  local numeric=${NUMERIC:-+1}
  [[ $numeric = [-+]* ]] || numeric="+$numeric"
  pushd $numeric

  zle reset-prompt
}
zle -N zle-pushd
bindkey '^x^p' zle-pushd


Index: Doc/Zsh/zle.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/zle.yo,v
retrieving revision 1.35
diff -u -r1.35 zle.yo
--- Doc/Zsh/zle.yo	22 Jun 2004 07:02:50 -0000	1.35
+++ Doc/Zsh/zle.yo	1 Jul 2004 12:03:19 -0000
@@ -1737,6 +1737,15 @@
 item(tt(redisplay) (unbound) (^R) (^R))(
 Redisplays the edit buffer.
 )
+tindex(reset-prompt)
+item(tt(reset-prompt) (unbound) (unbound) (unbound))(
+Force the prompts on both the left and right of the screen to be
+re-expanded, then redisplay the edit buffer.  Note that this
+does not reflect changes to the prompt variables themselves, only changes
+in the expansion of the values (for example, changes in time or
+directory, or changes to the value of variables referred to by the
+prompt).
+)
 tindex(send-break)
 item(tt(send-break) (^G ESC-^G) (unbound) (unbound))(
 Abort the current editor function, e.g. tt(execute-named-command), or the
Index: Src/Zle/iwidgets.list
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/iwidgets.list,v
retrieving revision 1.5
diff -u -r1.5 iwidgets.list
--- Src/Zle/iwidgets.list	20 Feb 2004 15:27:53 -0000	1.5
+++ Src/Zle/iwidgets.list	1 Jul 2004 12:03:19 -0000
@@ -88,6 +88,7 @@
 "recursive-edit", recursiveedit, ZLE_MENUCMP | ZLE_KEEPSUFFIX | ZLE_LASTCOL
 "redisplay", redisplay, ZLE_MENUCMP | ZLE_KEEPSUFFIX | ZLE_LASTCOL
 "redo", redo, ZLE_KEEPSUFFIX
+"reset-prompt", resetprompt, ZLE_MENUCMP | ZLE_KEEPSUFFIX | ZLE_LASTCOL
 "reverse-menu-complete", reversemenucomplete, ZLE_MENUCMP | ZLE_KEEPSUFFIX | ZLE_ISCOMP
 "run-help", processcmd, ZLE_MENUCMP | ZLE_KEEPSUFFIX | ZLE_LASTCOL
 "self-insert", selfinsert, ZLE_MENUCMP | ZLE_KEEPSUFFIX
Index: Src/Zle/zle_main.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_main.c,v
retrieving revision 1.45
diff -u -r1.45 zle_main.c
--- Src/Zle/zle_main.c	2 Jun 2004 22:15:01 -0000	1.45
+++ Src/Zle/zle_main.c	1 Jul 2004 12:03:20 -0000
@@ -150,6 +150,8 @@
 /**/
 mod_export char *zlenoargs[1] = { NULL };
 
+static char *raw_lp, *raw_rp;
+
 #ifdef FIONREAD
 static int delayzsetterm;
 #endif
@@ -785,8 +787,10 @@
     insmode = unset(OVERSTRIKE);
     eofsent = 0;
     resetneeded = 0;
+    raw_lp = lp;
     lpromptbuf = promptexpand(lp, 1, NULL, NULL);
     pmpt_attr = txtchange;
+    raw_rp = rp;
     rpromptbuf = promptexpand(rp, 1, NULL, NULL);
     rpmpt_attr = txtchange;
     free_prepostdisplay();
@@ -1307,6 +1311,18 @@
 }
 
 /**/
+int
+resetprompt(UNUSED(char **args))
+{
+    free(lpromptbuf);
+    lpromptbuf = promptexpand(raw_lp, 1, NULL, NULL);
+    free(rpromptbuf);
+    rpromptbuf = promptexpand(raw_rp, 1, NULL, NULL);
+
+    return redisplay(NULL);
+}
+
+/**/
 mod_export void
 trashzle(void)
 {

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


  reply	other threads:[~2004-07-01 12:16 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-07-01 11:23 Fabiano Sidler
2004-07-01 11:32 ` Peter Stephenson
2004-07-01 12:14   ` Peter Stephenson [this message]
2004-07-01 12:30     ` Oliver Kiddle
2004-07-01 16:44       ` PATCH: re-expand the prompt automatically Wayne Davison
2004-07-01 19:55     ` Jumping to the line above Fabiano Sidler
2004-07-01 23:45       ` Bart Schaefer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200407011214.i61CEhUe012898@news01.csr.com \
    --to=pws@csr.com \
    --cc=zsh-users@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).