Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: PATCH 3/5: _imagemagick: complete all files if image files didn't match
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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author