Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
_files' default descriptions of globbed-files and all-files are identical
- X-seq: zsh-workers 49716
- From: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Cc: Eric Cook <llua@xxxxxxx>
- Subject: _files' default descriptions of globbed-files and all-files are identical
- Date: Wed, 26 Jan 2022 15:30:05 +0000
- Archived-at: <https://zsh.org/workers/49716>
- List-id: <zsh-workers.zsh.org>
1 $ cd "$(mktemp -d)"
2 $ touch foo bar
3 $ zsh -f
4 % autoload compinit && compinit
5 % zstyle '*' format '::: %d'
6 % zstyle '*' group-name ''
7 % _f() { _files -g '*(+true)' }
8 % _g() { _files -g '*(+false)' }
9 % compdef _f f
10 % compdef _g g
11 % f <TAB>
12 ::: file
13 bar foo
14 % g <TAB>
15 ::: file
16 bar foo
17 % zstyle ':completion:*' file-patterns '%p:globbed-files:globbed\ files *(-/):directories' '*:all-files:other\ files'
18 % f <TAB>
19 ::: globbed files
20 bar foo
21 % g <TAB>
22 ::: file
23 bar foo
The invocations on lines 11 and 14 generate the same output.
Consequently, if a completion function uses «_files -g "*(+foo)"» for
some non-trivial value of foo, a user can't immediately tell whether the
files they're seeing are those that match the criterion, or the
«*:all-files» group.
One way to approach this is to set the file-patterns style, as on
line 17. That makes the two cases generate different output.
Should this setting be the default?
I'm not proposing to literally set a zstyle by default, but to change
_files so it assumes this value if no style is set; for instance:
diff --git a/Completion/Unix/Type/_files b/Completion/Unix/Type/_files
index f03b4a148..14cfe4e4e 100644
--- a/Completion/Unix/Type/_files
+++ b/Completion/Unix/Type/_files
@@ -71,11 +71,11 @@ if zstyle -a ":completion:${curcontext}:" file-patterns tmp; then
fi
done
elif zstyle -t ":completion:${curcontext}:" list-dirs-first; then
- pats=( " *(-/):directories:directory ${${glob:-*}//:/\\:}(#q^-/):globbed-files" '*:all-files' )
+ pats=( " *(-/):directories:directory ${${glob:-*}//:/\\:}(#q^-/):globbed-files:globbed\\ files" "*:all-files:other\\ files" )
else
# People prefer to have directories shown on first try as default.
# Even if the calling function didn't use -/.
- pats=( "${${glob:-*}//:/\\:}:globbed-files *(-/):directories" '*:all-files ' )
+ pats=( "${${glob:-*}//:/\\:}:globbed-files:globbed\\ files *(-/):directories:directories" "*:all-files:other\\ files" )
fi
tried=()
Thoughts?
---
I've discussed this on IRC and Eric did not support the change. If I
understand correctly (and I'm not sure I do), Eric'd prefer that the
completion function would use _path_files instead or that the user would
set the file-patterns style on a specific context. Eric, please
add/correct this as needed.
Cheers,
Daniel
Messages sorted by:
Reverse Date,
Date,
Thread,
Author