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

Re: zle oddity or some option running wild?



From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
Date: Thu, 27 Jun 2024 21:35:45 -0700

> On Thu, Jun 27, 2024 at 9:08?AM Thomas Lauer <thomas.lauer@xxxxxxxxxx> wrote:
> >
> > From: Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
> > Date: Thu, 27 Jun 2024 16:41:50 +0100 (BST)
> >
> > > This is likely to be something to do with the "zle -f" stuff documented
> > > in the zshzle manual page
> >
> > Whatever the cause, select-word-style seems to change something globally
> > in a way that isn't helpful (to my use case).
> 
> I think it's this:
> 
> backward-kill-word-match-    if [[ -n $done || $LASTWIDGET = *kill* ]]; then
> backward-kill-word-match:      CUTBUFFER="$word$CUTBUFFER"
> backward-kill-word-match-    else
> 
> kill-word-match-    if [[ -n $done || $LASTWIDGET = *kill* ]]; then
> kill-word-match:      CUTBUFFER="$CUTBUFFER$word"
> kill-word-match-    else
> 
> The kill widget replacements try to reproduce the builtin behavior of
> building up the cutbuffer as they are called repeatedly.  If you use
> widget names containing "kill" that are not supposed to have that
> behavior, and then call through to those replacements, unexpected
> things are going to happen.
> 
> You should also probably be selectively using one or both of -w and -f as in
>   zle widgetname -w -f nolast
> to change and/or restore LASTWIDGET when calling one widget from
> inside another, so that actions that differ on the second and
> successive repeated calls behave properly.

If I am trying to use some third-party stuff whose inner workings I
don't really fully understand and it doesn't work OOTB then I tend to
move on. All the more since the solution I outlined earlier is, though
by no means perfect*, "good enough" for my use case.

* vi-backward-blank-word simply stops after the first blank, so an
argument with blanks (ie a pathname) will not work with my quick fix. I
avoid blanks in file/pathnames like the plague so it's not much of a
problem for me but it's clearly not a general solution. And I do think
that a set of functions that works well with what the shell sees as a
single argument:

$>touch Test\ Directory
$>touch "Test Directory"

even if it contains funny characters would be nice to have. So maybe
I'll look into select-word-style, time permitting.

Thomas




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