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

Re: _expand completer and hashed dirs



Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>:
> On Sep 21,  3:47pm, Frank Terbeck wrote:
> } While this works fine:
> } 
> }     % ls ~vi<tab>
> }     % ls ~vim/
> } 
> } This doesn't:
> } 
> }     % ls ~vim<tab>
> }     - all expansions -
> }     /home/hawk/.vim
> }     - original -
> }     ~vim
> } 
> } I would much rather like to get 'ls ~vim/' out of it.
> 
> To the extent that there's an intention involved here, it's that the
> presumption is that completion is supposed to save keystrokes; so if
> you hit TAB at a position where exactly one other keystroke (in this
> case a slash) would remove the ambiguity, you get offered the longer
> possibility ... because if you meant the shorter one you would have
> just typed that other key in the first place.

Yes, that's true.
However on a keyboard with german layout, typing a slash requires you
to hit shift-7, which I find *very* awkward to type. I commonly use
tab to generate slashes for me; that's also the reason why I do:
  zstyle ':completion:*' special-dirs ..

That's just so that I don't have to hit shift-7 when I want to get to
'../' from '..'.

> That said ...
> 
> } I've been playing with a number of styles, but they don't seem to
> } have any impact on the situation.
> 
>     zstyle ':completion:*:expand:*' accept-exact true
> 
> would seem to be *supposed* to produce the effect you want, but the
> definition of "words beginning with a tilde or parameter expansion"
> is implemented so as to exclude words that have no suffix beyond the 
> parameter or nameddir -- that is, as I noted above, it's making the
> presumption that you wouldn't have used TAB at that position if your
> intent was not to expand the word.
> 
> Here's a patch that implements accept-exact strict, which applies
> in the way that you want.  I'll not commit this, for the following
> reasons:
> 
> (1) "setopt rec_exact" behaves like strict rather than like true
> 
> (2) a better word than "strict" might be found
> 
> (3) a better (but changed from historical) behavior might be to
>     extend yes/true/on/1 to behave as this makes strict, and have
>     a different value ("prefix"?) to mean the current behavior
> 
> (4) I haven't had a chance to document it
> 
> Patch is bigger than would seem necessary because the "tmp" local
> is clobbered after it's initially used to test accept-exact.

I applied the patch locally, and changed my test zshrc to this:

[snip]
bindkey -e
hash -d vim=${HOME}/.vim
autoload -Uz compinit
compinit
bindkey '^i' complete-word
zstyle ':completion:*:descriptions' format "- %d -"
zstyle ':completion:*' group-name ''
zstyle ':completion:*' completer _expand _complete _ignored _approximate
zstyle ':completion:*:expand:*' accept-exact strict
[snap]

While that does fix this:
    % ls ~vim<tab>

This now doesn't:
    % print $HISTSIZE<tab>

_expand used to offer me to expand to the value of the variable. Now
it just adds a space.

Am I missing something?

Regards, Frank



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