zsh-workers
 help / color / mirror / code / Atom feed
From: Oliver Kiddle <okiddle@yahoo.co.uk>
To: zsh-workers@sunsite.dk
Subject: Re: Completion in pwd before subdirecories
Date: Thu, 18 Dec 2003 10:47:29 +0100	[thread overview]
Message-ID: <7919.1071740849@gmcs3.local> (raw)
In-Reply-To: <1031217183837.ZM16074@candle.brasslantern.com>

Bart wrote:
> 
> Hrm.  I thought I'd found it the other day but now I can't any more.  I
> believe it _used_ to be there (or in _path_files) because Sven grumbled
> at least once about how difficult it was to write.  But maybe something
> changed so that it was possible for it to be taken out again.

Doing a bit of a search in the archives, the nearest I can find is
11635. That deals with _path_files and glob qualifiers on the
command-line when doing pattern based matching. Is that perhaps what
you were thinking of?

> In fact, that may have been what led to the introduction of (#q) in the
> first place.

It was a comment by me in 16447 that led to (#q). I was suggesting
using things like -g '*.png(.)' back then so must have been thinking
clearer than earlier this week. I managed to forget why I had wanted to
add qualifiers in series but it might have been for the file-patterns
style.

> } So either we need to add #q when using glob qualifiers or _files should
> } attempt to merge trailing glob qualifiers. I favour the latter.
> 
> Good luck, then.
> 

The documentation is fairly clear that a glob qualifier is a trailing
set of parentheses containing no `|', `(' (or `~' if it is special).
Not sure I understand what the "if it is special" means - anyone? The
_path_files stuff from 11635 believes the documentation, using the 
pattern \([^\|\~]##\)
So the patch below (to _files) uses that pattern to find a glob
qualifier in the argument to the -g option and sticks a #q in.

Unfortunately, the documentation doesn't give the whole story:
  *(e:'[[ -d ~/$REPLY || -d ../$REPLY ]]':) and
  *(e:'(( 1 ))':)
both work. Seems to me that anything is valid just so long as it is
quoted. *(e'|'true'|') works while *(e|true|) doesn't.

So how do I match a quoted string with a glob? Does anyone have something
already? Is it even possible given nested quoting?

The only thing I can think of would be to dig into the C and add a
globbing flag which matches quoted characters, unquoting them before
matching so I could do something like:
 \(([^\|\~]|(#U)*(#u))##\)

I'm inclined to apply this patch as it is for now. I can't see any
existing uses of qualifiers with quotes and we could always add `#q'
manually for the odd case and exclude quotes along with |, ( and ~ in
_files.

My tip for the day for taking advantage of this change is this style:

zstyle ':completion:*:approximate*:*' file-patterns \
    '%p(D):globbed-files *(D-/):directories' '*(D):all-files'

With that, _approximate can correct `,zshrc' to `.zshrc'.

Now for the dull job of adding lots of (-.) qualifiers.

Oliver

PS. Hope you get well soon Bart.

Index: Completion/Unix/Type/_files
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Type/_files,v
retrieving revision 1.8
diff -u -r1.8 _files
--- Completion/Unix/Type/_files	4 Jul 2003 18:19:20 -0000	1.8
+++ Completion/Unix/Type/_files	18 Dec 2003 09:24:24 -0000
@@ -11,6 +11,10 @@
   glob="${${${${(@M)tmp:#-g*}#-g}##[[:blank:]]#}%%[[:blank:]]#}"
   [[ "$glob" = *[^\\][[:blank:]]* ]] &&
       glob="{${glob//(#b)([^\\])[[:blank:]]##/${match[1]},}}"
+
+  # add `#q' to the beginning of any glob qualifier if not there already
+  [[ "$glob" = (#b)(*\()([^\|\~]##\)) && $match[2] != \#q* ]] &&
+      glob="${match[1]}#q${match[2]}"
 fi
 tmp=$opts[(I)-F]
 if (( tmp )); then


      reply	other threads:[~2003-12-18  9:43 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20031213154651.GR18859@strindberg.dsv.su.se>
     [not found] ` <1031213191918.ZM5325@candle.brasslantern.com>
     [not found]   ` <20031213233905.GW18859@strindberg.dsv.su.se>
     [not found]     ` <3213.1071488991@gmcs3.local>
2003-12-15 17:02       ` Bart Schaefer
2003-12-15 17:09         ` Peter Stephenson
2003-12-15 19:13           ` Bart Schaefer
2003-12-15 18:56         ` Oliver Kiddle
2003-12-15 19:37           ` Bart Schaefer
2003-12-15 20:07             ` Oliver Kiddle
2003-12-15 21:41               ` Bart Schaefer
2003-12-16 11:23                 ` Oliver Kiddle
2003-12-17 15:57         ` Oliver Kiddle
2003-12-17 18:38           ` Bart Schaefer
2003-12-18  9:47             ` Oliver Kiddle [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7919.1071740849@gmcs3.local \
    --to=okiddle@yahoo.co.uk \
    --cc=zsh-workers@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).