zsh-users
 help / color / mirror / code / Atom feed
* mkdir completion not offering ignored patterns
@ 2015-04-11  5:44 Aleksandrina Nikolova
  2015-04-11 20:44 ` Bart Schaefer
  0 siblings, 1 reply; 5+ messages in thread
From: Aleksandrina Nikolova @ 2015-04-11  5:44 UTC (permalink / raw)
  To: zsh-users

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

Greetings, I am trying to make mkdir behave like similar commands (in 
particular, cd) but I can't seem to figure it out. I have set the 
completion system to ignore hidden files and only show them when there 
are no other options (no other files in the listed directory or I 
explicitly type . at the beginning). It works perfectly with all 
commands but mkdir, which simply refuses to offer hidden files, ever. 
I'm attaching the relevant part of my .zshrc, but here are the two lines 
I think control the behaviour:

     zstyle ':completion:*' completer _expand _complete _prefix _ignored 
_complete:-separators _match _approximate
     zstyle ':completion:*:((*-|)files|(*-|)directories)' 
ignored-patterns '(*/|).[^/]##'

Commenting the second one disables hiding of hidden files for all 
commands and I get those offered by mkdir along with non-hidden ones. I 
also have the following:

     zstyle ':completion:*:cd:*' tag-order local-directories 
"path-directories named-directories directory-stack users"

I tried including mkdir as well, but that didn't help. How can I make 
mkdir offer the ignored matches at a later time?

Thanks!

[-- Attachment #2: zshrc --]
[-- Type: text/plain, Size: 3579 bytes --]

######## COMPLETION, EXPANSION & MATCHING #########

autoload -Uz compinit
compinit

zstyle :compinstall filename '/home/aleksandrina/.zshrc'
zstyle ':completion:*' completer _expand _complete _prefix _ignored _complete:-separators _match _approximate
zstyle ':completion:*:expand:*' add-space true
zstyle ':completion:*:prefix:*' add-space false
zstyle ':completion:*' accept-exact false
zstyle ':completion:*' accept-exact-dirs false
zstyle ':completion:*:paths' ambiguous true
zstyle ':completion:*' insert-tab false
zstyle ':completion:*' insert-unambiguous true
zstyle ':completion:*' last-prompt true
zstyle ':completion:*' list-dirs-first true
zstyle ':completion:*' list-grouped true
zstyle ':completion:*' list-packed true
zstyle ':completion:*' list-suffixes true
zstyle ':completion:*' list-separator '#'
zstyle ':completion:*' original true
zstyle ':completion:*' path-completion true
zstyle ':completion:*' rehash true
zstyle ':completion:*' remove-all-dups true
zstyle ':completion:*' prefix-hidden false
zstyle ':completion:*' squeeze-slashes false
zstyle ':completion:*' expand suffix
zstyle ':completion:*' fake-parameters 'DISPLAY:scalar'
zstyle ':completion:*' group-name ''
zstyle ':completion:*' list-colors ${(s.:.)~~LS_COLORS}
zstyle ':completion:*' list-prompt %Smatch %M, line %L: Hit '<TAB>' for more, or the character to insert%s
zstyle ':completion:*' select-prompt %SScrolling active: current selection at %p%s
zstyle ':completion:*' menu select=2
zstyle ':completion:*' auto-description true
zstyle ':completion:*' verbose true
zstyle ':completion:*' word false
zstyle ':completion:*:auto-describe' format 'specify: %d'
zstyle ':completion:*:descriptions' format '
%F{cyan}%B%d:%b%f'
zstyle ':completion:*:-command-:*' completer _expand _complete _prefix _match _approximate _history _ignored
zstyle ':completion:*:-command-:*' group-order aliases functions builtins commands
zstyle ':completion:*:-command-:*' tag-order "aliases suffix-aliases reserved-words functions:-non-ignored builtins commands" parameters functions
zstyle ':completion:*:functions-non-ignored' ignored-patterns '_*'
zstyle ':completion:*:complete-separators:*' matcher-list '' 'r:|[._-]=** r:[^[:upper:]0-9]||[[:upper:]0-9]=** r:|=** l:|=**' '+m:{[:lower:][:upper:]}={[:upper:][:lower:]}'
zstyle ':completion:*:approximate:*' max-errors 1 numeric
zstyle ':completion:*:correct:*' max-errors 3 numeric
zstyle ':completion:*:expand:*' glob true
zstyle ':completion:*:expand:*' substitute true
zstyle ':completion:*:expand:*' suffix true
zstyle ':completion:*:expand:*' tag-order expansions
zstyle ':completion:*:match:*' match-original true
zstyle ':completion:*:ignore:*' single-ignored menu
zstyle ':completion:*:cd:*' tag-order local-directories "path-directories named-directories directory-stack users"
zstyle ':completion:*:((*-|)files|(*-|)directories)' ignored-patterns '(*/|).[^/]##'
zstyle ':completion:*:jobs' prefix-needed false
zstyle ':completion:*:jobs' numbers true
zstyle ':completion:*:processes' list-colors '=(#b) #([0-9]#)*=0=01'
zstyle ':completion:*:processes' insert-ids single
(( $UID )) && zstyle ':completion:*:processes' command "ps -u $USER" \
		     || zstyle ':completion:*:processes' command 'ps -e'
zstyle ':completion:*:sudo::' environ PATH="/sbin:/usr/sbin:$PATH" HOME="/root"
zstyle ':completion:*' complete true		# _expand_alias
zstyle ':completion:*' complete-options false	# cd, pushd
zstyle ':completion:*' stop true		# _history_complete_word
zstyle ':completion:*' recent-dirs-insert fallback
zstyle ':chpwd:*' recent-dirs-default true

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

* Re: mkdir completion not offering ignored patterns
  2015-04-11  5:44 mkdir completion not offering ignored patterns Aleksandrina Nikolova
@ 2015-04-11 20:44 ` Bart Schaefer
  2015-04-11 22:52   ` Aleksandrina Nikolova
  0 siblings, 1 reply; 5+ messages in thread
From: Bart Schaefer @ 2015-04-11 20:44 UTC (permalink / raw)
  To: zsh-users

On Apr 11,  3:44pm, Aleksandrina Nikolova wrote:
}
} Greetings, I am trying to make mkdir behave like similar commands (in 
} particular, cd) but I can't seem to figure it out. I have set the 
} completion system to ignore hidden files and only show them when there 
} are no other options (no other files in the listed directory or I 
} explicitly type . at the beginning). It works perfectly with all 
} commands but mkdir, which simply refuses to offer hidden files, ever. 

As far as I can tell, this is happening because _mkdir calls _wanted,
and _wanted forces completion to be limited to the first set of matches
for the desired tag ("directories" in this case).

If I do (after compinit)

autoload +X _mkdir
functions[_mkdir]="${functions[_mkdir]:s/_wanted/_tags directories;_requested}"

then things seem to work as you are expecting, though I'm not sure I've
tried all nuances.

I'd like feedback from other zsh-workers on whether this is the right
change to make permanent.


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

* Re: mkdir completion not offering ignored patterns
  2015-04-11 20:44 ` Bart Schaefer
@ 2015-04-11 22:52   ` Aleksandrina Nikolova
  2015-04-12 17:18     ` Bart Schaefer
  0 siblings, 1 reply; 5+ messages in thread
From: Aleksandrina Nikolova @ 2015-04-11 22:52 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: zsh-users

Hi and thank you for replying! Your suggested solution changes nothing 
for me though, not sure why it works for you. If it's of any importance, 
my zsh version is 5.0.7

On 12/04/15 06:44, Bart Schaefer wrote:
> On Apr 11,  3:44pm, Aleksandrina Nikolova wrote:
> }
> } Greetings, I am trying to make mkdir behave like similar commands (in
> } particular, cd) but I can't seem to figure it out. I have set the
> } completion system to ignore hidden files and only show them when there
> } are no other options (no other files in the listed directory or I
> } explicitly type . at the beginning). It works perfectly with all
> } commands but mkdir, which simply refuses to offer hidden files, ever.
>
> As far as I can tell, this is happening because _mkdir calls _wanted,
> and _wanted forces completion to be limited to the first set of matches
> for the desired tag ("directories" in this case).
>
> If I do (after compinit)
>
> autoload +X _mkdir
> functions[_mkdir]="${functions[_mkdir]:s/_wanted/_tags directories;_requested}"
>
> then things seem to work as you are expecting, though I'm not sure I've
> tried all nuances.
>
> I'd like feedback from other zsh-workers on whether this is the right
> change to make permanent.


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

* Re: mkdir completion not offering ignored patterns
  2015-04-11 22:52   ` Aleksandrina Nikolova
@ 2015-04-12 17:18     ` Bart Schaefer
  2015-04-12 22:09       ` Aleksandrina Nikolova
  0 siblings, 1 reply; 5+ messages in thread
From: Bart Schaefer @ 2015-04-12 17:18 UTC (permalink / raw)
  To: zsh-users

So, disregard my previous message (see below).

On Apr 12,  8:52am, Aleksandrina Nikolova wrote:
} Subject: Re: mkdir completion not offering ignored patterns
}
} On 12/04/15 06:44, Bart Schaefer wrote:
} > autoload +X _mkdir
} > functions[_mkdir]="${functions[_mkdir]:s/_wanted/_tags directories;_requested}"
} 
} Hi and thank you for replying! Your suggested solution changes nothing 
} for me though, not sure why it works for you. If it's of any importance, 
} my zsh version is 5.0.7

Hm.  I must have tweaked something else in the course of trying things
that led to that, because *just* that's not sufficient for me either.

I went back through and discovered that I had not fully cleared some test
styles and still had an ignored-patterns with a different context.

Re-reading your original description more closely:

> I have set the 
> completion system to ignore hidden files and only show them when there 
> are no other options (no other files in the listed directory or I 
> explicitly type . at the beginning).

This actually should be the default behavior with no ignored-patterns set
at all.  So that made me confused about this:

>      zstyle ':completion:*:((*-|)files|(*-|)directories)' ignored-patterns '(*/|).[^/]##'
> 
> Commenting the second one disables hiding of hidden files for all 
> commands and I get those offered by mkdir along with non-hidden ones.

The only thing I can figure out is that you must use the GLOB_DOTS option,
which causes _path_files to generate matches for hidden files.  Perhaps
that is an option for which completion should have a style override.

Once I got that straight I was able to find the real reason for:

> It works perfectly with all 
> commands but mkdir, which simply refuses to offer hidden files, ever.

Which turns out to be that _mkdir calls _message which breaks out of the
loop over _completers in _main_complete, so the _ignored completer in your
style is never reached.

This would not happen if you did not have a "format" style for the context
with tag "descriptions" (which is used as a fallback for tag "messages").

_message really ought to be called only when there is no possibility of
other completions being generated, not merely to suggest what ought to
be typed at that point.  Either that or it needs some option (the inverse
of "_message -e"?) that tells _main_complete to continue even though a
message is pending.

There is at least a workaround:

   zstyle ':completion::*:mkdir::messages' format ''


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

* Re: mkdir completion not offering ignored patterns
  2015-04-12 17:18     ` Bart Schaefer
@ 2015-04-12 22:09       ` Aleksandrina Nikolova
  0 siblings, 0 replies; 5+ messages in thread
From: Aleksandrina Nikolova @ 2015-04-12 22:09 UTC (permalink / raw)
  To: zsh-users

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


On 13/04/15 03:18, Bart Schaefer wrote:
>
>> I have set the
>> completion system to ignore hidden files and only show them when there
>> are no other options (no other files in the listed directory or I
>> explicitly type . at the beginning).
> This actually should be the default behavior with no ignored-patterns set
> at all.
Oh, sorry about this, I thought the options I have set don't affect the 
style in particular, but you're right. I attach a more complete .zshrc 
with the options I have set as well.
> Once I got that straight I was able to find the real reason for:
>
>> It works perfectly with all
>> commands but mkdir, which simply refuses to offer hidden files, ever.
> Which turns out to be that _mkdir calls _message which breaks out of the
> loop over _completers in _main_complete, so the _ignored completer in your
> style is never reached.
>
> This would not happen if you did not have a "format" style for the context
> with tag "descriptions" (which is used as a fallback for tag "messages").
>
> _message really ought to be called only when there is no possibility of
> other completions being generated, not merely to suggest what ought to
> be typed at that point.  Either that or it needs some option (the inverse
> of "_message -e"?) that tells _main_complete to continue even though a
> message is pending.
>
> There is at least a workaround:
>
>     zstyle ':completion::*:mkdir::messages' format ''
Great find! Although that workaround did not work for me, the one that 
did (a more ugly one, but...) was to simply remove the call to _messages:
functions[_mkdir]="${functions[_mkdir]:s/ || _message 'name of directory'/}"
And now it works great. Thank you!

[-- Attachment #2: zshrc --]
[-- Type: text/plain, Size: 4181 bytes --]

######## COMPLETION, EXPANSION & MATCHING #########

autoload -Uz compinit
compinit
autoload +X _mkdir
functions[_mkdir]="${functions[_mkdir]:s/ || _message 'name of directory'/}"
setopt extendedglob

zstyle :compinstall filename '/home/aleksandrina/.zshrc'
zstyle ':completion:*' completer _expand _complete _prefix _ignored _complete:-separators _match _approximate
zstyle ':completion:*:expand:*' add-space true
zstyle ':completion:*:prefix:*' add-space false
zstyle ':completion:*' accept-exact false
zstyle ':completion:*' accept-exact-dirs false
zstyle ':completion:*:paths' ambiguous true
zstyle ':completion:*' insert-tab false
zstyle ':completion:*' insert-unambiguous true
zstyle ':completion:*' last-prompt true
zstyle ':completion:*' list-dirs-first true
zstyle ':completion:*' list-grouped true
zstyle ':completion:*' list-packed true
zstyle ':completion:*' list-suffixes true
zstyle ':completion:*' list-separator '#'
zstyle ':completion:*' original true
zstyle ':completion:*' path-completion true
zstyle ':completion:*' rehash true
zstyle ':completion:*' remove-all-dups true
zstyle ':completion:*' prefix-hidden false
zstyle ':completion:*' squeeze-slashes false
zstyle ':completion:*' expand suffix
zstyle ':completion:*' fake-parameters 'DISPLAY:scalar'
zstyle ':completion:*' group-name ''
zstyle ':completion:*' list-colors ${(s.:.)~~LS_COLORS}
zstyle ':completion:*' list-prompt %Smatch %M, line %L: Hit '<TAB>' for more, or the character to insert%s
zstyle ':completion:*' select-prompt %SScrolling active: current selection at %p%s
zstyle ':completion:*' menu select=2
zstyle ':completion:*' auto-description true
zstyle ':completion:*' verbose true
zstyle ':completion:*' word false
zstyle ':completion:*:auto-describe' format 'specify: %d'
zstyle ':completion:*:descriptions' format '
%F{cyan}%B%d:%b%f'
zstyle ':completion:*:-command-:*' completer _expand _complete _prefix _match _approximate _history _ignored
zstyle ':completion:*:-command-:*' group-order aliases functions builtins commands
zstyle ':completion:*:-command-:*' tag-order "aliases suffix-aliases reserved-words functions:-non-ignored builtins commands" parameters functions
zstyle ':completion:*:functions-non-ignored' ignored-patterns '_*'
zstyle ':completion:*:complete-separators:*' matcher-list '' 'r:|[._-]=** r:[^[:upper:]0-9]||[[:upper:]0-9]=** r:|=** l:|=**' '+m:{[:lower:][:upper:]}={[:upper:][:lower:]}'
zstyle ':completion:*:approximate:*' max-errors 1 numeric
zstyle ':completion:*:correct:*' max-errors 3 numeric
zstyle ':completion:*:expand:*' glob true
zstyle ':completion:*:expand:*' substitute true
zstyle ':completion:*:expand:*' suffix true
zstyle ':completion:*:expand:*' tag-order expansions
zstyle ':completion:*:match:*' match-original true
zstyle ':completion:*:ignore:*' single-ignored menu
zstyle ':completion:*:cd:*' tag-order local-directories "path-directories named-directories directory-stack users"
zstyle ':completion:*:((*-|)files|(*-|)directories)' ignored-patterns '(*/|).[^/]##'
zstyle ':completion:*:jobs' prefix-needed false
zstyle ':completion:*:jobs' numbers true
zstyle ':completion:*:processes' list-colors '=(#b) #([0-9]#)*=0=01'
zstyle ':completion:*:processes' insert-ids single
(( $UID )) && zstyle ':completion:*:processes' command "ps -u $USER" \
		     || zstyle ':completion:*:processes' command 'ps -e'
zstyle ':completion:*:sudo::' environ PATH="/sbin:/usr/sbin:$PATH" HOME="/root"
zstyle ':completion:*' complete true		# _expand_alias
zstyle ':completion:*' complete-options false	# cd, pushd
zstyle ':completion:*' stop true		# _history_complete_word
zstyle ':completion:*' recent-dirs-insert fallback
zstyle ':chpwd:*' recent-dirs-default true

setopt autocd cdablevars chasedots chaselinks
unsetopt autoremoveslash listtypes

setopt braceccl cshnullglob extendedglob globassign globdots globsubst histsubstpattern numericglobsort rcexpandparam rematchpcre

setopt extendedhistory histexpiredupsfirst histignoredups histignorespace histreduceblanks incappendhistory sharehistory
unsetopt histbeep

setopt interactivecomments promptsubst rcquotes
unsetopt beep

unsetopt checkjobs hup

setopt autopushd pushdignoredups pushdsilent

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

end of thread, other threads:[~2015-04-12 22:09 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-11  5:44 mkdir completion not offering ignored patterns Aleksandrina Nikolova
2015-04-11 20:44 ` Bart Schaefer
2015-04-11 22:52   ` Aleksandrina Nikolova
2015-04-12 17:18     ` Bart Schaefer
2015-04-12 22:09       ` Aleksandrina Nikolova

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