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

Trouble using file-patterns to group filetypes in completion



Hi,

I wanted to make source files complete before other files when using
vim (for example), so I tried
zstyle ':completion:*' file-patterns '*(-/):directories
*.(c|cpp|cxx|C):source-files:source\ file
^*.(c|cpp|cxx|C):other-files:other\ file'
but it only seems to work with commands that don't specify a pattern
to _files, contrary to what the manpage says.

% edit <tab>
---- file
evmouse*       joylauncher*   joymouse*      joywheel*      usbkeypad*
evmouse.c      joylauncher.c  joymouse.c     joywheel.c     usbkeypad.c
% ls <tab>
---- source file
evmouse.c      joylauncher.c  joymouse.c     joywheel.c     usbkeypad.c
---- other file
evmouse*       joylauncher*   joymouse*      joywheel*      usbkeypad*

It would additionally be nice to not have to specify the pattern twice
to avoid this effect,
% ls <tab>
---- source file
evmouse.c         joylauncher.c     joymouse.c        joywheel.c
 usbkeypad.c
---- other file
evmouse*       joylauncher*   joymouse*      joywheel*      usbkeypad*
evmouse.c      joylauncher.c  joymouse.c     joywheel.c     usbkeypad.c

which you get with
zstyle ':completion:*' file-patterns '*(-/):directories
*.(c|cpp|cxx|C):source-files:source\ file *:other-file:other\ file'

Note that I don't want to use
zstyle ':completion:*' file-patterns '*(-/):directories
*.(c|cpp|cxx|C):source-files:source\ file' '*:other-file:other\ file'
as this results in
% ls <tab>
---- source file
evmouse.c      joylauncher.c  joymouse.c     joywheel.c     usbkeypad.c

with no other files listed at all. Weirdly, this seems to work for vim
too, it now only lists .c files, but under just a "--- file" header
rather than "--- source file". Does it somehow override the tags I set
in file-patterns resulting in them not being grouped separately?

If I change '(-t)*:file:_vim_files' to '(-t)*: :_vim_files' in _vim, I
get this...
---- source file
---- other file
evmouse*       joylauncher*   joymouse*      joywheel*      usbkeypad*
evmouse.c      joylauncher.c  joymouse.c     joywheel.c     usbkeypad.c

which looks like
zstyle ':completion:*' group-name ''
being ignored.

-- 
Mikael Magnusson



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