zsh-workers
 help / color / mirror / code / Atom feed
From: Oliver Kiddle <okiddle@yahoo.co.uk>
To: zsh workers <zsh-workers@zsh.org>
Subject: Re: PATCH 3/5: _imagemagick: complete all files if image files didn't match
Date: Thu, 13 Aug 2015 12:12:19 +0200	[thread overview]
Message-ID: <12099.1439460739@thecus.kiddle.eu> (raw)
In-Reply-To: <150812154611.ZM14299@torch.brasslantern.com>

Bart wrote:
> 
> I was implying that you probably CAN change both to other-files but the
> opinionated one here seems to be Oliver so let's give him a chance to
> chime in.

Had I been paying enough attention in 2008 to be opinionated then, I
would have questioned why we need a special style corresponding to a
specific user preference that ought to be covered by file-patterns.

That mail, briefly mentions that the reason for it was that
file-patterns was broken for zmodload completion. _zmodload does:
  _files -W module_path -/g '*.(dll|s[ol]|bundle)(:r)' && ret=0

The use of (:r) there makes this a borderline case where _path_files
should perhaps have been used but it is actually -/g that is causing
the problem.

-/g with compctl gives you directories mixed with globbed files which
was very useful at the time. It is still just about relevant to
_path_files but with _files, if it actually worked, it would just be
overriding user preferences which is missing the whole point of _files.
_files does:
  [[ "$type" = */* ]] && glob="$glob,*(-/)"

Either comma was at one time special to _path_files or this was never
tested. In the patch below, I just remove it.

The one other use of -/g that we have was in _command_names with
_path_files. In that case, I can't see a reason not to use _files
instead.

> Anybody else want to comment on the likelyhood of the tag changing from
> all-files to other-files causing a problem?

I would actually be inclined to suggest that other-files should be
globbed-files: _files is defining three defaults for file-patterns
corresponding to whether -g, -/ or neither was specified. So how do you
override just one of those file patterns? If we define _files without a
-g as being equivalent to _files -g '*(-.)' then a single file-patterns
default would suffice. It'd also mean all-files would only be used as a
fallback and globbed-files would be the tag for all the files when no
glob is specified. It might be better named in that case but it is the
tag we already have for specifically requested files and in that case,
all files are what have been selected. Furthermore, there are issues to
consider of when we actually want a specific set of directories to be
globbed for. The single default I have in mind would be something like:

'%p(-.):globbed-files %p(-/):globbed-dirs *(-/):directories' '*:all-files'

That would be more likely to cause problems for someone's setup than renaming
an all-files or other-files tag however. It would probably be a good
thing if we can avoid every little completion function needing to do
stuff like _files -g '*.png(-.)". -/ would mean we actually want to
select directories. Any opinions?

Patch below is just for the zmodload etc issues mentioned at the
beginning.

Oliver

diff --git a/Completion/Unix/Type/_files b/Completion/Unix/Type/_files
index a8ba9b3..b9ff12b 100644
--- a/Completion/Unix/Type/_files
+++ b/Completion/Unix/Type/_files
@@ -51,7 +51,6 @@ else
 fi
 
 if zstyle -a ":completion:${curcontext}:" file-patterns tmp; then
-  [[ "$type" = */* ]] && glob="$glob,*(-/)"
   pats=()
 
   for i in ${tmp//\%p/${${glob:-\*}//:/\\:}}; do
diff --git a/Completion/Zsh/Command/_zmodload b/Completion/Zsh/Command/_zmodload
index e144b98..57fb990 100644
--- a/Completion/Zsh/Command/_zmodload
+++ b/Completion/Zsh/Command/_zmodload
@@ -68,7 +68,7 @@ else
     _requested loadedmodules expl 'loaded modules' \
       compadd -k 'modules[(R)loaded]' && ret=0
     _requested files expl 'module file' \
-      _files -W module_path -/g '*.(dll|s[ol]|bundle)(:r)' && ret=0
+      _files -W module_path -g '*.(dll|s[ol]|bundle)(:r)' && ret=0
     _requested aliases expl 'module alias' \
       compadd "$suf[@]" -k 'modules[(R)alias*]' && ret=0
   done
diff --git a/Completion/Zsh/Type/_command_names b/Completion/Zsh/Type/_command_names
index d9fc62d..940f341 100644
--- a/Completion/Zsh/Type/_command_names
+++ b/Completion/Zsh/Type/_command_names
@@ -17,9 +17,7 @@ defs=(
 )
 
 [[ -n "$path[(r).]" || $PREFIX = */* ]] &&
-  defs=( "$defs[@]"
-         'executables:executable file or directory:_path_files -/g \*\(-\*\)'
-  )
+    defs+=( 'executables:executable file:_files -g \*\(-\*\)' )
 
 if [[ "$1" = -e ]]; then
   shift


  parent reply	other threads:[~2015-08-13 10:19 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-12  3:04 PATCH 1/5: _git: various fixes Mikael Magnusson
2015-08-12  3:05 ` PATCH 2/5: _wget: complete headers for --header and add --no-use-server-timestamps Mikael Magnusson
2015-08-12  3:05 ` PATCH 3/5: _imagemagick: complete all files if image files didn't match Mikael Magnusson
2015-08-12 17:20   ` Oliver Kiddle
2015-08-12 18:12     ` Mikael Magnusson
2015-08-12 18:59       ` Bart Schaefer
2015-08-12 19:35         ` Mikael Magnusson
2015-08-12 19:42           ` Bart Schaefer
2015-08-12 20:05         ` Mikael Magnusson
2015-08-12 20:57           ` Bart Schaefer
2015-08-12 21:15             ` Mikael Magnusson
2015-08-12 21:44               ` Bart Schaefer
2015-08-12 22:34                 ` Mikael Magnusson
2015-08-12 22:46                   ` Bart Schaefer
2015-08-12 23:37                     ` Mikael Magnusson
2015-08-13 10:12                     ` Oliver Kiddle [this message]
2015-08-13 20:27                       ` Bart Schaefer
2015-08-14  8:44                         ` Oliver Kiddle
2015-08-14 16:18                           ` Mikael Magnusson
2015-08-14 16:24                             ` Bart Schaefer
2015-08-14 22:31   ` Mikael Magnusson
2015-08-15  0:05     ` Bart Schaefer
2015-08-15  0:52       ` Mikael Magnusson
2015-08-12  3:05 ` PATCH 4/5: _sort: Fix syntax error Mikael Magnusson
2015-08-12  3:05 ` PATCH 5/5: _strftime: Add completion for zsh/datetime's strftime builtin Mikael Magnusson

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=12099.1439460739@thecus.kiddle.eu \
    --to=okiddle@yahoo.co.uk \
    --cc=zsh-workers@zsh.org \
    /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).