zsh-workers
 help / color / mirror / code / Atom feed
* Fwd: Re: %N in prompt shows "_zsh_highlight_call_widget" on Ctrl-L instead of e.g. "/usr/bin/zsh" or "-zsh" since recently (#414)
@ 2017-02-07  7:48 Axel Beckert
  2017-02-10 17:59 ` Bart Schaefer
  0 siblings, 1 reply; 6+ messages in thread
From: Axel Beckert @ 2017-02-07  7:48 UTC (permalink / raw)
  To: zsh-workers

Hi,

I'm not sure since when this happens, but that part of my prompt
hasn't changed for quite a while and this happens for a few weeks now,
maybe since the zsh-syntax-highlighting (z-sy-h) 0.5.0 release or
since the zsh 5.3 release, but at least with the combination of z-sy-h
0.5.0 and zsh 5.3.1:

Everytime I press Ctrl-L in my xterm, %N inside my prompt shows
_zsh_highlight_call_widget instead of e.g. /usr/bin/zsh or -zsh:

Normal prompt:

!5334 Z5 ?0 L1 user@host:~ (pts/39 -zsh 5.3.1 stretch) 21:35:56 
~ → 

After Ctrl-L:

!5334 Z2 ?0 L1 user@host:~ (pts/39 _zsh_highlight_call_widget 5.3.1
stretch) 21:36:18 
~ → 

Due to z-sy-h's widget name appearing in the prompt, I first reported
this as issue against z-sy-h:
https://github.com/zsh-users/zsh-syntax-highlighting/issues/414

But according to Daniel Shahaf, this difference is reproducible
without z-sy-h. How to reproduce:

----- Forwarded message from Daniel Shahaf <notifications@github.com> -----
Date: Mon, 06 Feb 2017 20:00:08 -0800
From: Daniel Shahaf <notifications@github.com>
To: zsh-users/zsh-syntax-highlighting <zsh-syntax-highlighting@noreply.github.com>
Reply-To: zsh-users/zsh-syntax-highlighting
	<reply+0003adc668ce77949b9ad8968432beed62e5c54cae8f86bf92cf0000000114b1084892a169ce0c42c2fb@reply.github.com>

Hello Axel!

> ~ → zsh -f
> host% . /usr/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh 
> host% PS1='%N %% '
> zsh % ^L
> _zsh_highlight_call_widget % 

I can reproduce this without z-sy-h:

```zsh
$ zsh -f
% clear-screen() { zle .$WIDGET -- "$@" }
% zle -N clear-screen 
% PS1='%1N %# '
zsh % <^L>
clear-screen % 
```

That's with zsh master; with zsh 5.0.7 from debian stable, the last
prompt says "zsh", …

> should just use `$0` instead of `%N`.

… so this is an upstream change.  I am not sure whether it's a regression
or a bugfix.

Is a change on z-sy-h's side needed?

(I quickly grepped upstream's git, but haven't found anything yet)
----- End forwarded message -----

		Regards, Axel
-- 
/~\  Plain Text Ribbon Campaign                   | Axel Beckert, PGP: 612616B5
\ /  Say No to HTML in E-Mail and News            | abe@deuxchevaux.org  (Mail)
 X   See http://arc.pasp.de/                      | abe@noone.org (Mail+Jabber)
/ \  I love long mails: http://email.is-not-s.ms/ | http://abe.noone.org/ (Web)


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

* Re: Fwd: Re: %N in prompt shows "_zsh_highlight_call_widget" on Ctrl-L instead of e.g. "/usr/bin/zsh" or "-zsh" since recently (#414)
  2017-02-07  7:48 Fwd: Re: %N in prompt shows "_zsh_highlight_call_widget" on Ctrl-L instead of e.g. "/usr/bin/zsh" or "-zsh" since recently (#414) Axel Beckert
@ 2017-02-10 17:59 ` Bart Schaefer
  2017-02-14 15:32   ` Axel Beckert
  0 siblings, 1 reply; 6+ messages in thread
From: Bart Schaefer @ 2017-02-10 17:59 UTC (permalink / raw)
  To: zsh-workers

On Feb 7,  8:48am, Axel Beckert wrote:
}
} Everytime I press Ctrl-L in my xterm, %N inside my prompt shows
} _zsh_highlight_call_widget instead of e.g. /usr/bin/zsh or -zsh

I'm not sure at which point this might have shown up -- possibly
after workers/38991 (commit f026a4dc) -- but I think it has to be
considered a bugfix, because _zsh_highlight_call_widget (or in the
other example the "clear-screen" widget) is what is being executed
at the time the prompt is recalculated.

Of course in this case you'd really like to know what's happening at
the time the prompt is displayed; %N is really intended for use in PS4
where the recalculation and the display occur together.  For PS1 that
only happens when the editor starts up for each new command input.

In what circumstances would you expect to need %N in PS1?  That is,
the reason to use any %-expando is to display information that will
change after the prompt is assigned.  If there is no case in which
you would expect %N to return something different, then you should
not need to use it.  Instead for example:

    PS1="$ZSH_ARGZERO:t %# "


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

* Re: Fwd: Re: %N in prompt shows "_zsh_highlight_call_widget" on Ctrl-L instead of e.g. "/usr/bin/zsh" or "-zsh" since recently (#414)
  2017-02-10 17:59 ` Bart Schaefer
@ 2017-02-14 15:32   ` Axel Beckert
  2017-02-14 16:18     ` Axel Beckert
  0 siblings, 1 reply; 6+ messages in thread
From: Axel Beckert @ 2017-02-14 15:32 UTC (permalink / raw)
  To: zsh-workers

Hi Bart,

On Fri, Feb 10, 2017 at 09:59:49AM -0800, Bart Schaefer wrote:
> On Feb 7,  8:48am, Axel Beckert wrote:
> } Everytime I press Ctrl-L in my xterm, %N inside my prompt shows
> } _zsh_highlight_call_widget instead of e.g. /usr/bin/zsh or -zsh
[…]
> In what circumstances would you expect to need %N in PS1?  That is,
> the reason to use any %-expando is to display information that will
> change after the prompt is assigned.  If there is no case in which
> you would expect %N to return something different, then you should
> not need to use it.

You're right. The main issue is probably that I wrote that part years
ago and was surprised that its behaviour changed. But I can't remember
anymore why I've chosen %N over $0. Will replace it with $0 and see if
that works out as expected.

		Kind regards, Axel
-- 
/~\  Plain Text Ribbon Campaign                   | Axel Beckert
\ /  Say No to HTML in E-Mail and News            | abe@deuxchevaux.org  (Mail)
 X   See http://www.nonhtmlmail.org/campaign.html | abe@noone.org (Mail+Jabber)
/ \  I love long mails: http://email.is-not-s.ms/ | http://abe.noone.org/ (Web)


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

* Re: Fwd: Re: %N in prompt shows "_zsh_highlight_call_widget" on Ctrl-L instead of e.g. "/usr/bin/zsh" or "-zsh" since recently (#414)
  2017-02-14 15:32   ` Axel Beckert
@ 2017-02-14 16:18     ` Axel Beckert
  2017-02-14 16:40       ` Bart Schaefer
  0 siblings, 1 reply; 6+ messages in thread
From: Axel Beckert @ 2017-02-14 16:18 UTC (permalink / raw)
  To: zsh-workers

Hi again,

On Tue, Feb 14, 2017 at 04:32:30PM +0100, Axel Beckert wrote:
> On Fri, Feb 10, 2017 at 09:59:49AM -0800, Bart Schaefer wrote:
> > On Feb 7,  8:48am, Axel Beckert wrote:
> > } Everytime I press Ctrl-L in my xterm, %N inside my prompt shows
> > } _zsh_highlight_call_widget instead of e.g. /usr/bin/zsh or -zsh
> […]
> > In what circumstances would you expect to need %N in PS1?  That is,
> > the reason to use any %-expando is to display information that will
> > change after the prompt is assigned.  If there is no case in which
> > you would expect %N to return something different, then you should
> > not need to use it.
> 
> You're right. The main issue is probably that I wrote that part years
> ago and was surprised that its behaviour changed. But I can't remember
> anymore why I've chosen %N over $0.

I now know again…

> Will replace it with $0 and see if that works out as expected.

That's worse: Now the prompt _always_ shows
"/home/abe/.zsh/zsh.d/15-prompt" (which is the sourced file where the
PS1 assigning happens) instead of e.g. "/usr/bin/zsh". So that needs
some more fine-tuning.

$ZSH_NAME seems close, except that it doesn't show "su" if the shell
was spawned by using "su" (neglectable) and that it doesn't show the
leading dash if it's a login shell.

What I was looking for seems to be $ZSH_ARGZERO. So far that works
fine. I hope, it's backwards compatible to at least 4.3.9 from Debian
7 Wheezy. :-)

		Kind regards, Axel
-- 
/~\  Plain Text Ribbon Campaign                   | Axel Beckert
\ /  Say No to HTML in E-Mail and News            | abe@deuxchevaux.org  (Mail)
 X   See http://www.nonhtmlmail.org/campaign.html | abe@noone.org (Mail+Jabber)
/ \  I love long mails: http://email.is-not-s.ms/ | http://abe.noone.org/ (Web)


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

* Re: Fwd: Re: %N in prompt shows "_zsh_highlight_call_widget" on Ctrl-L instead of e.g. "/usr/bin/zsh" or "-zsh" since recently (#414)
  2017-02-14 16:18     ` Axel Beckert
@ 2017-02-14 16:40       ` Bart Schaefer
  2017-02-15 16:52         ` Axel Beckert
  0 siblings, 1 reply; 6+ messages in thread
From: Bart Schaefer @ 2017-02-14 16:40 UTC (permalink / raw)
  To: Axel Beckert, zsh-workers; +Cc: zsh-workers

On Feb 14,  5:18pm, Axel Beckert wrote:
}
} What I was looking for seems to be $ZSH_ARGZERO. So far that works
} fine. I hope, it's backwards compatible to at least 4.3.9 from Debian
} 7 Wheezy. :-)

Sadly, I think not.  ZSH_ARGZERO was only added in the past year.

It should work backwards-portably to do e.g.

PS1="${${ZSH_ARGZERO:-%N}:t} %# "

because %N will do what you want for versions where ZSH_ARGZERO is not
defined.


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

* Re: Fwd: Re: %N in prompt shows "_zsh_highlight_call_widget" on Ctrl-L instead of e.g. "/usr/bin/zsh" or "-zsh" since recently (#414)
  2017-02-14 16:40       ` Bart Schaefer
@ 2017-02-15 16:52         ` Axel Beckert
  0 siblings, 0 replies; 6+ messages in thread
From: Axel Beckert @ 2017-02-15 16:52 UTC (permalink / raw)
  To: zsh-workers

Hi Bart,

On Tue, Feb 14, 2017 at 08:40:38AM -0800, Bart Schaefer wrote:
> On Feb 14,  5:18pm, Axel Beckert wrote:
> } What I was looking for seems to be $ZSH_ARGZERO. So far that works
> } fine. I hope, it's backwards compatible to at least 4.3.9 from Debian
> } 7 Wheezy. :-)
> 
> Sadly, I think not.  ZSH_ARGZERO was only added in the past year.
> 
> It should work backwards-portably to do e.g.
> 
> PS1="${${ZSH_ARGZERO:-%N}:t} %# "
> 
> because %N will do what you want for versions where ZSH_ARGZERO is not
> defined.

Thanks for that idea!

		Kind regards, Axel
-- 
/~\  Plain Text Ribbon Campaign                   | Axel Beckert
\ /  Say No to HTML in E-Mail and News            | abe@deuxchevaux.org  (Mail)
 X   See http://www.nonhtmlmail.org/campaign.html | abe@noone.org (Mail+Jabber)
/ \  I love long mails: http://email.is-not-s.ms/ | http://abe.noone.org/ (Web)


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

end of thread, other threads:[~2017-02-15 16:52 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-07  7:48 Fwd: Re: %N in prompt shows "_zsh_highlight_call_widget" on Ctrl-L instead of e.g. "/usr/bin/zsh" or "-zsh" since recently (#414) Axel Beckert
2017-02-10 17:59 ` Bart Schaefer
2017-02-14 15:32   ` Axel Beckert
2017-02-14 16:18     ` Axel Beckert
2017-02-14 16:40       ` Bart Schaefer
2017-02-15 16:52         ` Axel Beckert

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