zsh-users
 help / Atom feed
* change in zstyle file-patterns handling between 5.5.1 & 5.6(.2)?
@ 2018-09-16 11:50 ml.zsh-workers.454
  2018-09-17  2:27 ` Takeshi Banse
  0 siblings, 1 reply; 6+ messages in thread
From: ml.zsh-workers.454 @ 2018-09-16 11:50 UTC (permalink / raw)
  To: zsh-users

[-- Attachment #1: Type: text/plain, Size: 1268 bytes --]

Hi

While I was trying out how to separate folders and files when completing 
`./<tab>` (based on [1]), I noticed a difference in behaviour between 
5.5.1 and 5.6.2.

- **minimal_zshrc.sh**:

	```
autoload -Uz compinit && compinit
zstyle ':completion:*:*:*:*:*' group-name ''
zstyle ':completion:*:descriptions' format '%B%F{red}%d%f%b'
zstyle ':completion:*:*:-command-:*:*' file-patterns 
'*(#q-*):executables:Executables *(-/):directories:Directories'
	```

- 5.5.1:

	```
> /usr/local/Cellar/zsh/5.5.1/bin/zsh -f
% source minimal_zshrc.sh
% ./<tab>
Executables
some_script*
Directories
directory/  folder/
	```

- 5.6.2:

	```
> /usr/local/Cellar/zsh/5.6.2/bin/zsh -f
% source minimal_zshrc.sh
% ./<tab>
executable file
directory/   some_script*  folder/
	```
   Same issue for 5.6 & 5.6.1

Seems like zsh is using a different group in 5.6 ... but a quick look 
through the **NEWS** file in the zsh repo did not give me any idea why 
the versions differ in their behaviour here.
Is this an intentional change?
How can I get the separation back in 5.6 (ideally in a way that also 
works in 5.5)?


[1]: 
https://superuser.com/questions/1326184/why-does-a-value-hyphen-in-tag-order-style-prevent-matching-of-the-exec

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

* Re: change in zstyle file-patterns handling between 5.5.1 & 5.6(.2)?
  2018-09-16 11:50 change in zstyle file-patterns handling between 5.5.1 & 5.6(.2)? ml.zsh-workers.454
@ 2018-09-17  2:27 ` Takeshi Banse
  2018-09-17  5:58   ` dana
  2018-09-25  0:13   ` dana
  0 siblings, 2 replies; 6+ messages in thread
From: Takeshi Banse @ 2018-09-17  2:27 UTC (permalink / raw)
  To: zsh-users

Hi,

I've also found a near related problem in zstyle list-dirs-first; that is,
zsh ignores list-dirs-first style.

Step to reproduce:
~/.zshrc-minimal:
----
autoload -Uz compinit && compinit
zstyle ':completion:*:*:*:*:*' group-name ''
zstyle ':completion:*' list-dirs-first yes
zstyle ':completion:*:descriptions' format '%B%F{black}%d%f%b'
----

Here is a shell session:
----
% zsh -f
host% . ~/.zsh-minimal
host% mkdir -p /tmp/test-dir/9dir{1,2}
host% touch /tmp/test-dir/0file
host% cat /tmp/test-dir/<TAB>
files
0file   9dir1/  9dir2/
----

I would expect the following:
----
host% cat /tmp/test-dir/<TAB>
directory
9dir1/  9dir2/
files
0file
----

* ml.zsh-workers.454@bitraven.io <ml.zsh-workers.454@bitraven.io> [2018-09-16 20:50]:
> Is this an intentional change?
> How can I get the separation back in 5.6 (ideally in a way that also works
> in 5.5)?

If I revert the commit 6b4e78dce6a505d8dab5554d9925e38e13bb40ea like
a workaround diff hunk at the end of this mail, it works here for these
2 particular issues.

The diff at the end of this mail breaks the patch:
"[PATCH] Completion: Small fixes for _files, _object_files"
http://www.zsh.org/mla/workers/2018/msg00788.html

So, my workaround diff is not good shape... I'm wondering if someone
could help.


Here is my trial diff:

diff --git a/Completion/Unix/Type/_files b/Completion/Unix/Type/_files
index 5df22ea46..2b0c5580a 100644
--- a/Completion/Unix/Type/_files
+++ b/Completion/Unix/Type/_files
@@ -121,7 +121,7 @@ for def in "$pats[@]"; do
 	    done
 	  fi
         else
-          _path_files -g "$pat" "$opts[@]" "$expl[@]" && ret=0
+          _path_files "$expl[@]" -g "$pat" "$opts[@]" && ret=0
         fi
       done
       (( ret )) || break

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

* Re: change in zstyle file-patterns handling between 5.5.1 & 5.6(.2)?
  2018-09-17  2:27 ` Takeshi Banse
@ 2018-09-17  5:58   ` dana
  2018-09-17 13:01     ` Daniel Shahaf
  2018-09-25  0:13   ` dana
  1 sibling, 1 reply; 6+ messages in thread
From: dana @ 2018-09-17  5:58 UTC (permalink / raw)
  To: Takeshi Banse; +Cc: zsh-users

On 16 Sep 2018, at 21:27, Takeshi Banse <thb@laafc.net> wrote:
>If I revert the commit 6b4e78dce6a505d8dab5554d9925e38e13bb40ea like
>a workaround diff hunk at the end of this mail, it works here for these
>2 particular issues.

I guess this one is mine, sorry. :/

Going back over it, i'm having trouble remembering exactly why i changed _files;
as far as i know, it's not necessary to fix the _object_files problem i found.
Maybe during troubleshooting i noticed that the one _path_files call was
different from the other two in that function, and i decided it was a mistake?
Sounds like the kind of dumb thing i'd do.

Unless someone else can figure out what past-me was going for, i'm in favour of
reverting that half of the change per your patch.

dana


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

* Re: change in zstyle file-patterns handling between 5.5.1 & 5.6(.2)?
  2018-09-17  5:58   ` dana
@ 2018-09-17 13:01     ` Daniel Shahaf
  2018-09-17 21:09       ` dana
  0 siblings, 1 reply; 6+ messages in thread
From: Daniel Shahaf @ 2018-09-17 13:01 UTC (permalink / raw)
  To: dana, Takeshi Banse; +Cc: zsh-users

dana wrote on Mon, 17 Sep 2018 00:58 -0500:
> On 16 Sep 2018, at 21:27, Takeshi Banse <thb@laafc.net> wrote:
> >If I revert the commit 6b4e78dce6a505d8dab5554d9925e38e13bb40ea like
> >a workaround diff hunk at the end of this mail, it works here for these
> >2 particular issues.
> 
> I guess this one is mine, sorry. :/
> 
> Going back over it, i'm having trouble remembering exactly why i changed _files;
> as far as i know, it's not necessary to fix the _object_files problem i found.
> Maybe during troubleshooting i noticed that the one _path_files call was
> different from the other two in that function, and i decided it was a mistake?
> Sounds like the kind of dumb thing i'd do.
> 
> Unless someone else can figure out what past-me was going for, i'm in favour of
> reverting that half of the change per your patch.

Should the order of "$@" and "${(@)expl}" in the _object_files part of
that patch be reversed?

In general, the parameters should be ordered so a function's caller has
an opportunity to override defaults set by the function; so options in
"$@" should be placed so as to override those in "$expl[@]".

I'm not sure, however, what that means in practice.  I *thought* that in
compadd, when an option flag is repeated its last occurrence wins, but
'compadd -ld foo -d bar' uses $foo, not $bar...

Cheers,

Daniel

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

* Re: change in zstyle file-patterns handling between 5.5.1 & 5.6(.2)?
  2018-09-17 13:01     ` Daniel Shahaf
@ 2018-09-17 21:09       ` dana
  0 siblings, 0 replies; 6+ messages in thread
From: dana @ 2018-09-17 21:09 UTC (permalink / raw)
  To: Daniel Shahaf; +Cc: Takeshi Banse, zsh-users

On 17 Sep 2018, at 08:01, Daniel Shahaf <d.s@daniel.shahaf.name> wrote:
>I'm not sure, however, what that means in practice.  I *thought* that in
>compadd, when an option flag is repeated its last occurrence wins, but
>'compadd -ld foo -d bar' uses $foo, not $bar...

Yeah, it's been my experience that, with compadd options, it's usually the
*first* one wins. That's why the list-dirs-first thing is broken; the
_path_files call when that's enabled has gone from this...

  _path_files \
    -J directories -X 'completing directory:' \
    -g '*(-/)' \
    -J argument-rest -X 'completing files:'

... to this...

  _path_files \
    -g '*(-/)' \
    -J argument-rest -X 'completing files:' \
    -J directories -X 'completing directory:'

... and so it never adds that directories group.

dana


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

* Re: change in zstyle file-patterns handling between 5.5.1 & 5.6(.2)?
  2018-09-17  2:27 ` Takeshi Banse
  2018-09-17  5:58   ` dana
@ 2018-09-25  0:13   ` dana
  1 sibling, 0 replies; 6+ messages in thread
From: dana @ 2018-09-25  0:13 UTC (permalink / raw)
  To: Takeshi Banse; +Cc: zsh-users

On 16 Sep 2018, at 21:27, Takeshi Banse <thb@laafc.net> wrote:
>Here is my trial diff:

I think the only conclusion we can draw is that my change to _files is just
bogus, so i've applied this patch. Sorry again.

I've not had time to test it thoroughly, but i *believe* the _object_files bit
is still good, so i've left that alone. Will revisit later if i find problems,
obv.

dana


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

end of thread, back to index

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-16 11:50 change in zstyle file-patterns handling between 5.5.1 & 5.6(.2)? ml.zsh-workers.454
2018-09-17  2:27 ` Takeshi Banse
2018-09-17  5:58   ` dana
2018-09-17 13:01     ` Daniel Shahaf
2018-09-17 21:09       ` dana
2018-09-25  0:13   ` dana

zsh-users

Archives are clonable: git clone --mirror http://inbox.vuxu.org/zsh-users

Newsgroup available over NNTP:
	nntp://inbox.vuxu.org/vuxu.archive.zsh.users


AGPL code for this site: git clone https://public-inbox.org/ public-inbox