Hi, my problem I tried to summarize in the subject line is: Since the recent OS upgrade to Ubuntu 18.04 my zsh (5.4.2) behaves strangely when typing keys together with Meta + Shift. The first time I type e.g. Meta+Shift+f nothing happens. The second time (and all following times) the bound function is executed and everything seems normal. I've bound finer-forward-word to Meta+Shift+f and finer-backward-word to Meta+Shift+b They are defined as follows: -------- finer-forward-word() { local WORDCHARS=$WORDCHARS_FINER zle forward-word } finer-backward-word() { local WORDCHARS=$WORDCHARS_FINER zle backward-word } -------- export WORDCHARS='*?_-.[]~=/&;!%^(){}<>+:@' export WORDCHARS_FINER='?~&!%' zle -N finer-forward-word zle -N finer-backward-word bindkey "^[F" finer-forward-word bindkey "^[B" finer-backward-word -------- All my other keybindings work normally. Just these two are crazy. BTW if I bind the functions to a different key the same thing happens. Uhm, as if the function would have to be loaded/initialized on the first try? I know I should let you know about the rest of my zsh config but it has grown pretty large over the last decades. :-) But nothing except some aliases has changed during the last months so the problem must have to do with the upgrade. Any ideas how I can debug this? Thanks, Andy -- Experience is something you don't get until just after you need it. (Olivier)
> Any ideas how I can debug this? Unfortunately I still don't know a good way to debug problems like that. This time, I found the solution by reading zsh man pages over and over. :-) > BTW if I bind the functions to a different key the same thing happens. > Uhm, as if the function would have to be loaded/initialized on the first try? Turned out to be exactly that. On the first call the function file is loaded and the function initialized but NOT executed. So, I added the line "zle finer-forward-word" at the end of the function file - after the function definition. And now it works as expected again. zsh's default behavior of this must have changed recently, right? -------- finer-forward-word() { local WORDCHARS=$WORDCHARS_FINER zle forward-word } zle finer-forward-word -------- But is that the "correct" way to do it or just a dumb workaround? Thanks, Andy -- The typewriting machine, when played with expression, is no more annoying than the piano when played by a sister or near relation. (Oscar Wilde)
Hi Andy,
2018-09-19 20:27 GMT+02:00 Andy Spiegl <zsh.Andy@spiegl.de>:
> finer-forward-word() {
> local WORDCHARS=$WORDCHARS_FINER
> zle forward-word
> }
> zle finer-forward-word
>
> is that the "correct" way to do it or just a dumb workaround?
I'm not sure what the “correct” way is, but I've always done as follow:
my-widget() {
// …
}
zle -N my-widget
Best regards,
PS: thanks a lot for the “finer WORDCHARS” idea; I'm going to use this too!
--
Jérémie
Hello Jérémie, > I'm not sure what the “correct” way is, but I've always done as follow: ... > zle -N my-widget I had tried that, too, but it only works without "-N". According to "man zshzle" you are right but it has no effect. :-( > PS: thanks a lot for the “finer WORDCHARS” idea; I'm going to use this too! You are welcome. I've been using it for 15 years now. :-) The implementation is from Oliver Kiddle. --> http://www.zsh.org/mla/users/2003/msg00824.html Thanks, Andy -- That's the funny thing about havin' a kid. They come with their own set of problems; make everything else you were worried about seem kinda silly. (Greg Garcia)
On Wed, Sep 19, 2018 at 8:27 PM, Andy Spiegl <zsh.Andy@spiegl.de> wrote:
>> Any ideas how I can debug this?
> Unfortunately I still don't know a good way to debug problems like that.
> This time, I found the solution by reading zsh man pages over and over. :-)
>
>> BTW if I bind the functions to a different key the same thing happens.
>> Uhm, as if the function would have to be loaded/initialized on the first try?
>
> Turned out to be exactly that. On the first call the function file is
> loaded and the function initialized but NOT executed. So, I added the line
> "zle finer-forward-word" at the end of the function file - after the
> function definition. And now it works as expected again. zsh's default
> behavior of this must have changed recently, right?
>
> --------
> finer-forward-word() {
> local WORDCHARS=$WORDCHARS_FINER
> zle forward-word
> }
> zle finer-forward-word
> --------
>
> But is that the "correct" way to do it or just a dumb workaround?
Your mails are somewhat unclear, but if you have these functions
defined in autoloadable files then they should look as following
% cat finer-forward-word
local WORDCHARS=$WORDCHARS_FINER
zle forward-word
Ie, do not include the "finer-forward-word() {" and "}" lines in the
file. Your original versions probably work if you use autoload -k, but
you don't show your autoload lines at all in the example.
--
Mikael Magnusson
> Ie, do not include the "finer-forward-word() {" and "}" lines in the > file. Oh, I see! Great, that really works. > Your original versions probably work if you use autoload -k, but > you don't show your autoload lines at all in the example. Sorry. All files in ~/.zsh/functions are autoloaded like this: ########## fpath=( ~/{local/lib/zsh,.zsh}/{functions,scripts}(N) $fpath ) typeset -gU fpath autoload -U $^fpath/*(-.N.x:t) ########## Andy -- The only time people dislike gossip is when you gossip about them. (Will Rogers)