Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Weird reset-prompt behavior
- X-seq: zsh-users 13158
- From: "Mikael Magnusson" <mikachu@xxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: Weird reset-prompt behavior
- Date: Mon, 25 Aug 2008 00:22:49 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=7cXWNFLSXY/wPfT2A6FzNj89H7WyXyGwlXeoQH4OM3g=; b=ZU61dpqeunzXNvKvrKk8OcW1Ra54DuS1iae5j5pWZ8eMCt8UlIBbl0cL7QwWVEXEpT 4KM37t0M26E/ZpqeZKTX1KNmxnnuw1zkrMXRJ7qtXTFcUd0xYVjoDQCX4s3GE3uuoUbl ctzNmEE1mG2m8lW6rqEP263QKr8fCSS26XE5c=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=Dl5pUfmyUK2ocNaflj1VGS/23VGB4an1KwEy9OlEP2Z56yVGgqWTELaTVIiaJLMW23 iTfify7Dq0Si1Pby6CM7F0DJ3PefOOiez3WVScrgKqsSLiq8ga0a9nryZYsOW21a4Z0o 2+wM4SW0z/EYZO3L9F3CKPnaRiV33cTim07U0=
- In-reply-to: <080824145849.ZM26037@xxxxxxxxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <200808232249.13582.raichoo@xxxxxxxxxxxxxx> <080824145849.ZM26037@xxxxxxxxxxxxxxxxxxxxxx>
2008/8/24 Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>:
> On Aug 23, 10:49pm, Björn wrote:
> } Subject: Weird reset-prompt behavior
> }
> } I'm pretty new to zsh so i don't know if this is already known, but i
> } discovered a pretty weird behavior when resetting the prompt and rprompt
>
> To address your specific problem, you shouldn't need zle-line-init at
> all for this. The editor always starts in the same state with the
> viins keymap, so just set up PROMPT and RPROMPT in your precmd and let
> zle-keymap-select do all the rest of the work.
>
> However, your example does point out a bit of odd behavior. Ignoring
> zle-keymap-select for the moment, try the following in a new shell.
>
> torch% n=0
> torch% zle-line-init() { RPS1=$[n++]; zle reset-prompt }
> torch% zle -N zle-line-init
> torch%
>
> Hmm. Why didn't the right prompt appear when the new left prompt was
> printed after creating the widget? It gets stranger, though; enter
> a command, such as "print $n" (using a 40-column terminal below so as
> to avoid line-wrapping) ...
>
> torch% print $n
> 1
> torch% 0
>
> Well, OK, n=1 and RPS1=0, which is sort of as expected. But now it gets
> really strange. Begin typing anything (I started to type "print" again
> in the cut-and-paste below):
>
> torch% p 1
>
> RPS1 just belatedly updated itself! I'm pretty sure zle-line-init was
> not called again here, so there's some kind of delayed reaction (the
> $[n++] did happen when the widget was created, but the display was
> never updated). Further demonstration, again starting fresh:
>
> torch% zle-line-init() {
> function> zle -R $SECONDS
> function> PS1="$SECONDS %# "
> function> zle reset-prompt
> function> }
> torch% zle -N zle-line-init
> torch%
> 42
>
> Now start to type anything, and the screen suddenly looks like this:
>
> torch% zle-line-init() {
> function> zle -R $SECONDS
> function> PS1="$SECONDS %# "
> function> zle reset-prompt
> function> }
> torch% zle -N zle-line-init
> 42 % p
>
> Note the "torch%" prompt has been updated and the "zle -R" output has
> been erased. (Things are even stranger if I used "zle -M" instead,
> but leave that aside for now.) Proceeding ...
>
> function> }
> torch% zle -N zle-line-init
> 42 % print $SECONDS
> 156
> 42 %
> 156
>
> This proves that zle-line-init ran when the editor started, but that
> Again start to type ...
>
> 42 % print $SECONDS
> 156
> 156 % p
>
> I almost suspect this is just a matter of a fflush() that hasn't yet
> happened, except for that $[n++] oddity in the very first example.
This may or may not be related, but I have the time in my PS1, and I've
noticed that sometimes the time changes just as I start typing. I have
never been able to discern a pattern though... It was especially annoying
before I switched to 0-padded hours since then it messed up the input line
too somehow I think. I'm not sure if I've noticed it "lately" though, might
have been months.
--
Mikael Magnusson
Messages sorted by:
Reverse Date,
Date,
Thread,
Author