zsh-users
 help / color / mirror / code / Atom feed
* Expansions with glob_complete ignore no_case_glob
@ 2005-01-08 22:41 Christian Taylor
  2005-01-10 10:44 ` Peter Stephenson
  0 siblings, 1 reply; 5+ messages in thread
From: Christian Taylor @ 2005-01-08 22:41 UTC (permalink / raw)
  To: zsh-users

Hi! I'm running zsh 4.2.1 under Linux, and I've observed the following 
unexpected behaviour:

With glob_complete set, the menu-completion of a glob pattern should contain 
the same matches that would be inserted if glob_complete was not set (except 
that a '*' is added at the end of the pattern). However, the menu-completion 
always globs case-sensitive, even if no_case_glob is set. Only including (#i) 
in the pattern causes the menu-completion to ignore case.
The description of glob_complete mentions that "this actually uses pattern 
matching, not globbing, so it works not only for files but for any 
completion, such as options, user names, etc.", but other globbing options 
(like glob_dots, extended_glob etc.) have normal effect on menu-completed 
glob patterns.

Is this behaviour intentional?

Christian Taylor


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Expansions with glob_complete ignore no_case_glob
  2005-01-08 22:41 Expansions with glob_complete ignore no_case_glob Christian Taylor
@ 2005-01-10 10:44 ` Peter Stephenson
  2005-01-12  0:53   ` Christian Taylor
  0 siblings, 1 reply; 5+ messages in thread
From: Peter Stephenson @ 2005-01-10 10:44 UTC (permalink / raw)
  To: zsh-users

Christian Taylor wrote:
> Hi! I'm running zsh 4.2.1 under Linux, and I've observed the following 
> unexpected behaviour:
> 
> With glob_complete set, the menu-completion of a glob pattern should contain 
> the same matches that would be inserted if glob_complete was not set (except 
> that a '*' is added at the end of the pattern). However, the menu-completion 
> always globs case-sensitive, even if no_case_glob is set. Only including (#i)
>  
> in the pattern causes the menu-completion to ignore case.

Yes, this is deliberate for patterns.  As you've spotted, glob_complete
doesn't do filename generation.  This means NO_CASE_GLOB doesn't apply:

CASE_GLOB <D>
       Make globbing (filename generation)  sensitive  to  case.   Note
       that  other  uses  of patterns are always sensitive to case.  If
       the option is unset, the presence of any character which is spe-
       cial  to  filename generation will cause case-insensitive match-
       ing.  For example, cvs(/) can match the directory CVS  owing  to
       the   presence   of   the   globbing  flag  (unless  the  option
       BARE_GLOB_QUAL is unset).

To control case-sensitivity in completion you need to use the more
sophisticated "match control" feature:

zstyle ':completion:*' matcher-list '' 'm:{a-zA-Z}={A-Za-z}'

This version tries completion without case conversion, then with, and
replaces the value on the command line with the value generated by
completion.  This is normally correct, but you can choose instead to
have the version on the command line left alone by using "M:" at the
start instead.

See the description of the matcher-list style in the zshcompsys manual
and the Matching Control section in the zshcompwid manual.

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.

www.mimesweeper.com
**********************************************************************


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Expansions with glob_complete ignore no_case_glob
  2005-01-10 10:44 ` Peter Stephenson
@ 2005-01-12  0:53   ` Christian Taylor
  2005-01-12 13:06     ` Peter Stephenson
  0 siblings, 1 reply; 5+ messages in thread
From: Christian Taylor @ 2005-01-12  0:53 UTC (permalink / raw)
  To: zsh-users

Peter Stephenson wrote:
> Christian Taylor wrote:
> > With glob_complete set, the menu-completion of a glob pattern should
> > contain the same matches that would be inserted if glob_complete was not
> > set (except that a '*' is added at the end of the pattern). However, the
> > menu-completion always globs case-sensitive, even if no_case_glob is set.
>
> Yes, this is deliberate for patterns.  As you've spotted, glob_complete
> doesn't do filename generation.  This means NO_CASE_GLOB doesn't apply:
> [...]
> To control case-sensitivity in completion you need to use the more
> sophisticated "match control" feature:
>
> zstyle ':completion:*' matcher-list '' 'm:{a-zA-Z}={A-Za-z}'

I'm sorry, I forgot to mention that a similar line is already included in 
my .zshrc:
zstyle ':completion:*' matcher-list 'm:{a-zA-ZäöüÄÖÜ}={A-Za-zÄÖÜäöü}'
This works fine for all normal completions.

Reading my post again, I realize that I should have been more clear on what 
exactly I observed. The thing that suprised me originally is that for 
instance wildcards apparently cause the pattern to be completed by a 
mechanism that both ignores NO_CASE_GLOB and the matcher-list configuration. 
Here is an example in an empty directory:

% touch AbCd aBcD abcd
% ls abc(.)<TAB>
AbCd aBcD abcd [listed for completion]

As soon as there are wildcards or "^" in the pattern, it becomes case 
sensitive:

% ls a?c(.)<TAB>
aBcD abcd [listed for completion, instead of all files]
% ls a^k(.)<TAB>
(same)
% ls a*(.)<TAB>
(same)
% ls a*~*cd(.)<TAB>
[aBcD gets inserted, instead of no match]

If I understand the documentation I've read correctly, the matcher-list 
configuration does not apply here because it is not used if the command line 
contains a glob pattern and the GLOB_COMPLETE option is set. It is also not 
used by the _match function, which I suppose handles this completion. Is 
there an easy way to do case insensitive completion nonetheless?
I realize that I should just read through the whole documentation on the 
completion system to get an understanding for it, but I hope you can maybe 
direct me to a specific section again to accomplish this.
Thank you either way!

Christian Taylor


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Expansions with glob_complete ignore no_case_glob
  2005-01-12  0:53   ` Christian Taylor
@ 2005-01-12 13:06     ` Peter Stephenson
  2005-01-12 23:28       ` Christian Taylor
  0 siblings, 1 reply; 5+ messages in thread
From: Peter Stephenson @ 2005-01-12 13:06 UTC (permalink / raw)
  To: zsh-users

Christian Taylor wrote:
> The thing that suprised me originally is that for
> instance wildcards apparently cause the pattern to be completed by a
> mechanism that both ignores NO_CASE_GLOB and the matcher-list
> configuration
> [when glob_complete is set].

Yes, it looks like you're correct.  It seems that the completion code
decides if there are pattern characters present and if there aren't it
handles matching internally, so that it works.  Otherwise it passes the
whole thing to the pattern matcher.  (I haven't traced this through but
something like this must be happening.)

Hmm, I think this is quite tricky.  The pattern matcher doesn't know
about the matcher list and training it would be tricky.  Getting the
completion code to fix up fixed string parts of the completion is also
tricky.  So this probably needs documenting as a limitation for now.

Index: Doc/Zsh/options.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/options.yo,v
retrieving revision 1.35
diff -u -r1.35 options.yo
--- Doc/Zsh/options.yo	3 Sep 2004 09:47:48 -0000	1.35
+++ Doc/Zsh/options.yo	12 Jan 2005 13:05:41 -0000
@@ -215,6 +215,11 @@
 tt(COMPLETE_IN_WORD) is set.  This actually uses pattern matching, not
 globbing, so it works not only for files but for any completion, such as
 options, user names, etc.
+
+Note that when the pattern matcher is used, matching control (for example,
+case-insensitive or anchored matching) cannot be used.  This limitation
+only applies when the current word contains a pattern; simply turning
+on the tt(GLOB_COMPLETE) option does not have this effect.
 )
 pindex(HASH_LIST_ALL)
 item(tt(HASH_LIST_ALL) <D>)(

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.

www.mimesweeper.com
**********************************************************************


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Expansions with glob_complete ignore no_case_glob
  2005-01-12 13:06     ` Peter Stephenson
@ 2005-01-12 23:28       ` Christian Taylor
  0 siblings, 0 replies; 5+ messages in thread
From: Christian Taylor @ 2005-01-12 23:28 UTC (permalink / raw)
  To: zsh-users

Peter Stephenson wrote:
> Christian Taylor wrote:
> > The thing that suprised me originally is that for
> > instance wildcards apparently cause the pattern to be completed by a
> > mechanism that both ignores NO_CASE_GLOB and the matcher-list
> > configuration
> > [when glob_complete is set].
>
> Hmm, I think this is quite tricky.  The pattern matcher doesn't know
> about the matcher list and training it would be tricky.  Getting the
> completion code to fix up fixed string parts of the completion is also
> tricky.  So this probably needs documenting as a limitation for now.

I was afraid of that :)
I've now worked around the problem using an editor widget that basically does 
the completion with (#i) prepended, which is sufficient for my purpose.
Thanks for responding!

Christian Taylor


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2005-01-12 23:31 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-01-08 22:41 Expansions with glob_complete ignore no_case_glob Christian Taylor
2005-01-10 10:44 ` Peter Stephenson
2005-01-12  0:53   ` Christian Taylor
2005-01-12 13:06     ` Peter Stephenson
2005-01-12 23:28       ` Christian Taylor

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).