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

Re: zstyle ':completion:*' menu select=4 interactive



Thomas Lauer wrote on Sat, 14 Nov 2020 10:36 +0000:
> Here's another long-standing problem I am having with zsh. I have
> googgled for hours but found nothing (Google search these days is like
> a cat: it brings home loads of things it thinks will please you but
> which are not really what you were looking for. Google just knows
> better than we do what we're searching for... But I digress.).
> 
> I have the subject line in my .zshrc (BTW this is 5.7.1). The tab is
> bound to expand-or-complete-prefix. The trouble starts when the
> interactive part of this kicks in, ie there are four or more items (if
> there are fewer, all works fine) and if the cursor is somewhere in the
> middle of a line I am editing.
> 
> So I do get the menu and I start navigating, with my current choice
> being copied into the line that's edited. The problem is that this
> choice overwrites part of the line I am editing. Consider this:
> 
> $ bla D<tab> somestuff # cursor behind the D when I press tab)
> 
> I get a few choices (say "D1/ Documents/ Dz2/ Dz3/ ..."), but nothing is
> as yet inserted into the line. Now I press <right> and "Documents/" gets
> inserted, overwriting the first few characters of somestuff. The line
> now looks like this:
> 
> $ bla Documents/estuff # cursor behind the /)
> 

What happens if you press ^L (clear-screen) at this point?

Can you reproduce this from 'zsh -f'?

> Not what I want. So I have done an ugly hack to sort of solve this:
> 
> ugly() {
> 	[[ ! -z $RBUFFER ]] && RBUFFER="          $RBUFFER"
> 	zle expand-or-complete-prefix
> }  
> ...
> zle -N ugly
> 
> with ugly() bound to the tab key. This (sort of) works but it's
> pretty 'orrible.
> 

Well, for starters:

ugly() {
  local save_RBUFFER=$RBUFFER
  RBUFFER=
  { zle expand-or-complete-prefix -- "$@" } always { RBUFFER=$save_RBUFFER }
}

Not tested.

> I'm sure the zsh gurus have an idea what's going on here and can
> point out the problem :-) 
> 





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