zsh-workers
 help / color / mirror / code / Atom feed
* _files' default descriptions of globbed-files and all-files are identical
@ 2022-01-26 15:30 Daniel Shahaf
  2022-01-26 22:06 ` Eric Cook
  2022-01-27 10:09 ` Peter Stephenson
  0 siblings, 2 replies; 4+ messages in thread
From: Daniel Shahaf @ 2022-01-26 15:30 UTC (permalink / raw)
  To: zsh-workers; +Cc: Eric Cook

     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


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

* Re: _files' default descriptions of globbed-files and all-files are identical
  2022-01-26 15:30 _files' default descriptions of globbed-files and all-files are identical Daniel Shahaf
@ 2022-01-26 22:06 ` Eric Cook
  2022-01-26 22:15   ` Eric Cook
  2022-01-27 10:09 ` Peter Stephenson
  1 sibling, 1 reply; 4+ messages in thread
From: Eric Cook @ 2022-01-26 22:06 UTC (permalink / raw)
  To: Daniel Shahaf, zsh-workers

On 1/26/22 10:30, Daniel Shahaf wrote:

>
> 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

I'll try to be more clear:
My mention of _path_files over the use of _files was me mistakenly thinking
that you had a completer that you /only/ wanted to show files that
_files -g glob matches and when nothing does match, show nothing. which is the
behavior _path_files have; not looping over a preset of patterns as _files does.

Since the question is knowing which group of tags is being presented at the moment
in the minibuffer (though not really explained, i think are called `tab labels'
in man page), i don't think the use of _path_files appropriate since it wouldn't
solve what you want.

 > +  pats=( "${${glob:-*}//:/\\:}:globbed-files:globbed\\ files *(-/):directories:directories" "*:all-files:other\\ files" )
When -g /isn't/ used ${glob:-*} expands to * for that tag label, changing the default
description from `file' to `globbed files'. which is something i don't think that you mean.
unless you invoke _next_tags, you ignore globbed-files and directories in tag-order
or use -g nonmatchingpattern you won't see the all-files tag.

completers have a style:

show-completer
        Tested whenever a new completer is tried.  If it is `true', the completion system  out‐
        puts a progress message in the listing area showing what completer is being tried.  The
        message will be overwritten by any output when completions are found and is removed af‐
        ter completion is finished.


that i think could be a way of showing which tag label is being tried, if the user
desired to know (show-taglabel or whatever). which is more generic than just
changing _files behavior.






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

* Re: _files' default descriptions of globbed-files and all-files are identical
  2022-01-26 22:06 ` Eric Cook
@ 2022-01-26 22:15   ` Eric Cook
  0 siblings, 0 replies; 4+ messages in thread
From: Eric Cook @ 2022-01-26 22:15 UTC (permalink / raw)
  To: zsh-workers

On 1/26/22 17:06, Eric Cook wrote:
>  > +  pats=( "${${glob:-*}//:/\\:}:globbed-files:globbed\\ files *(-/):directories:directories" "*:all-files:other\\ files" )
> When -g /isn't/ used ${glob:-*} expands to * for that tag label, changing the default
> description from `file' to `globbed files'. which is something i don't think that you mean.
> unless you invoke _next_tags, you ignore globbed-files and directories in tag-order
> or use -g nonmatchingpattern you won't see the all-files tag.
something like:
" *(-/):directories:directory ${${glob:-*}//:/\\:}(#q^-/):globbed-files${glob:+:globbed\\ file\\ (${${glob}//:/\\:})}" '*:all-files'
would get what you intended


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

* Re: _files' default descriptions of globbed-files and all-files are identical
  2022-01-26 15:30 _files' default descriptions of globbed-files and all-files are identical Daniel Shahaf
  2022-01-26 22:06 ` Eric Cook
@ 2022-01-27 10:09 ` Peter Stephenson
  1 sibling, 0 replies; 4+ messages in thread
From: Peter Stephenson @ 2022-01-27 10:09 UTC (permalink / raw)
  To: zsh-workers

> On 26 January 2022 at 15:30 Daniel Shahaf <d.s@daniel.shahaf.name> wrote:
> 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:

Something along these lines would be a useful enhancement.  Personally, I'm
not picky about the details; anything that reflects what's actually going on
better is good.

pws


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

end of thread, other threads:[~2022-01-27 10:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-26 15:30 _files' default descriptions of globbed-files and all-files are identical Daniel Shahaf
2022-01-26 22:06 ` Eric Cook
2022-01-26 22:15   ` Eric Cook
2022-01-27 10:09 ` Peter Stephenson

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).