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

Re: Case-insensitive completion



On Sep 14, 12:30pm, Jesper Holmberg wrote:
}
} As I interpret the manual, the following lines:
} 
} zstyle ':completion:*' completer _expand _complete _complete:jhcase _ignored
} zstyle ':completion:*:jhcase:*' matcher-list 'm:{a-z}={A-Z}'
} 
} would achieve what I want. However, now typing "cd ni<tab>" gives me only
} "nik", and apparently "Nic" no longer matches.
} 
} What am I missing?

Completers are called in order until one of them succeeds.  Because the
_complete call found "nik", _complete:jhcase was never called.

To get both kinds of patterns, you instead need to use a combination of
several styles that can be rather bewildering:

file-patterns and/or tag-order, to divide the matches into tagged groups;
group-order and possibly group-name, for display ordering of the groups;
matcher (not matcher-list), to control which matches are in which group.

This is a start at it:

-------
zstyle ':completion:*:ci-globbed-files' matcher 'm:{a-z}={A-Z}'
zstyle ':completion:*' file-patterns \
  '(#I)%p:globbed-files %p:ci-globbed-files' '*:all-files'
zstyle ':completion:*' group-order globbed-files ci-globbed-files all-files
zstyle ':completion:*' group-name ''
-------

The difficulties are:

- It may work differently when completing in default context than when
  completing after a command such as "ls" that has its own completion
  function defined.  E.g., "ls" somehow ignores the globbed-files group
  and goes directly to ci-globbed-files, I don't know why.

- It's quite difficult to express the concept "only files that match
  case-insensitively, not those that match case-sensitively."  Thus the
  ci-globbed-files group is a superset of globbed-files and you get a
  redundant listing.

- file-patterns are not tried after the first one that has the pattern
  '*:...' which is why the (#I) is thrown in on globbed-files, to force
  attempting both globbed-files and ci-globbed-files even if the match
  pattern substituted by %p is '*'.

Also note that there was at least one dev release where %p was not
handled properly.  I don't recall whether 4.0.7 has that bug.  I tried
the above only with the current CVS incarnation of 4.1.1-dev-1.



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