zsh-workers
 help / color / mirror / code / Atom feed
* Disable all-files completions in a directory
@ 2013-03-03 18:26 joe M
  2013-03-03 19:36 ` Bart Schaefer
  0 siblings, 1 reply; 4+ messages in thread
From: joe M @ 2013-03-03 18:26 UTC (permalink / raw)
  To: zsh-workers

Hello,

Is it possible to disable completions on all-files in some directories?

There is a directory that has a lot of files and I do not want the
all-files pattern to work in that directory or when completing files
in that directory.

Any thoughts, please?

Thanks
Joe


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

* Re: Disable all-files completions in a directory
  2013-03-03 18:26 Disable all-files completions in a directory joe M
@ 2013-03-03 19:36 ` Bart Schaefer
  2013-03-03 22:47   ` joe M
  0 siblings, 1 reply; 4+ messages in thread
From: Bart Schaefer @ 2013-03-03 19:36 UTC (permalink / raw)
  To: zsh-workers

On Mar 3,  1:26pm, joe M wrote:
}
} Is it possible to disable completions on all-files in some directories?

Depends on what you mean by "in".  (William J. Clinton, 1998)

If you mean "Is it possible to disable completions on all-files when
the value of $PWD matches certain directories?" then yes, you can use
zstyle -e to include/omit all-files from tag-order as necessary.

If you mean "... any time completion reaches certain directories, even
if I'm completing a path that begins somewhere above that directory in
the directory tree?" then the answer is probably no.  However ...

You might experiment with using the file-patterns style to break up the
files into groups regardless of what directory you are in.  For example:

zstyle ':completion:*' file-patterns \
   '*([1,10]):first-ten-files' \
   '*([11,30]):second-twenty-files' \
   '*([31,-1]):all-remaining-files'

Now when you press TAB you'll be offered at most the first-ten-files.
You can advance to the next twenty with the _next_tags widget (bound
by default to control-x n), and then to all the rest of the files with
one more tap of ^Xn.  If you combine this with, for example,

zstyle ':completion:*' file-sort modification

then you'll always be offered the ten most recent files, etc.


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

* Re: Disable all-files completions in a directory
  2013-03-03 19:36 ` Bart Schaefer
@ 2013-03-03 22:47   ` joe M
  2013-03-04  2:30     ` Bart Schaefer
  0 siblings, 1 reply; 4+ messages in thread
From: joe M @ 2013-03-03 22:47 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: zsh-workers

Hello Bart,

> You might experiment with using the file-patterns style to break up the
> files into groups regardless of what directory you are in.  For example:
>
> zstyle ':completion:*' file-patterns \
>    '*([1,10]):first-ten-files' \
>    '*([11,30]):second-twenty-files' \
>    '*([31,-1]):all-remaining-files'
>
> Now when you press TAB you'll be offered at most the first-ten-files.
> You can advance to the next twenty with the _next_tags widget (bound
> by default to control-x n), and then to all the rest of the files with
> one more tap of ^Xn.  If you combine this with, for example,
>
> zstyle ':completion:*' file-sort modification
>
> then you'll always be offered the ten most recent files, etc.

I tried the above with:

zstyle ':completion:*' file-patterns \
  '%p([1,10]):first-ten-globbed-files' \
  '%p([11,30]):second-twenty-globbed-files' \
  '%p([31,-1]):remaining-globbed-files' \
  '*(-/):directories'\
  '*([1,10]):first-ten-files' \
  '*([11,30]):second-twenty-files' \
  '*([31,-1]):remaining-files' \


and this is what I get with _complete_help:

ls \#crux
tags in context :completion::complete:ls::
    argument-rest options  (_arguments _ls (eval))
tags in context :completion::complete:ls:argument-rest:
    first-ten-globbed-files      (_files _arguments _ls (eval))
    second-twenty-globbed-files  (_files _arguments _ls (eval))
    remaining-globbed-files      (_files _arguments _ls (eval))
    directories                  (_files _arguments _ls (eval))

with ^D:

ls \#crux
 -- files --
\#crux.2011-10-03.log.bz2        \#crux.2011-10-04.log.bz2
\#crux.2011-10-05.log.bz2        \#crux.2011-10-06.log.bz2
\#crux.2011-10-07.log.bz2        \#crux.2011-10-08.log.bz2
\#crux.2011-10-09.log.bz2
\#crux.2011-10-10.log.bz2        \#crux.2011-10-11.log.bz2
\#crux.2011-10-12.log.bz2        \#crux.2011-10-13.log.bz2
\#crux.2011-10-14.log.bz2        \#crux.2011-10-15.log.bz2
\#crux.2011-10-16.log.bz2
\#crux.2011-10-17.log.bz2        \#crux.2011-10-18.log.bz2
\#crux.2011-10-19.log.bz2        \#crux.2011-10-20.log.bz2
\#crux.2011-10-21.log.bz2        \#crux.2011-10-22.log.bz2
\#crux.2011-10-23.log.bz2
\#crux.2011-10-24.log.bz2        \#crux.2011-10-25.log.bz2
\#crux.2011-10-26.log.bz2        \#crux.2011-10-27.log.bz2
\#crux.2011-10-28.log.bz2        \#crux.2011-10-29.log.bz2
\#crux.2011-10-30.log.bz2
\#crux.2011-10-31.log.bz2        \#crux.2011-11-01.log.bz2
\#crux.2011-11-02.log.bz2        \#crux.2011-11-03.log.bz2
\#crux.2011-11-04.log.bz2        \#crux.2011-11-05.log.bz2
\#crux.2011-11-06.log.bz2
\#crux.2011-11-07.log.bz2        \#crux.2011-11-08.log.bz2
\#crux.2011-11-09.log.bz2        \#crux.2011-11-10.log.bz2
\#crux.2011-11-11.log.bz2        \#crux.2011-11-12.log.bz2
\#crux.2011-11-13.log.bz2
\#crux.2011-11-14.log.bz2        \#crux.2011-11-15.log.bz2
\#crux.2011-11-16.log.bz2        \#crux.2011-11-17.log.bz2
\#crux.2011-11-18.log.bz2        \#crux.2011-11-20.log.bz2
\#crux.2011-11-21.log.bz2

bindkey
"^A"-"^C" self-insert
"^D" list-choices
"^E"-"^F" self-insert
"^G" list-expand
"^H" vi-backward-delete-char
"^I" complete-word
"^J" accept-line
"^K" self-insert
"^L" clear-screen
"^M" accept-line
"^N" most-accessed-file
"^O"-"^P" self-insert
"^Q" vi-quoted-insert
"^R" redisplay
"^S"-"^T" self-insert
"^U" vi-kill-line
"^V" vi-quoted-insert
"^W" vi-backward-kill-word
"^X" self-insert
"^X^A" all-matches
"^X^P" pids
"^X^R" _read_comp
"^X^X" hist-complete
"^X " no-magic-abbrev-expand
"^X?" _complete_debug
"^XC" _correct_filename
"^Xa" _expand_alias
"^Xc" _correct_word
"^Xd" _list_expansions
"^Xe" _expand_word
"^Xh" _complete_help
"^Xm" _most_recent_file
"^Xn" _next_tags
"^Xt" _complete_tag
"^X~" _bash_list-choices
"^Y"-"^Z" self-insert
"^[" vi-cmd-mode
"^[," _history-complete-newer
"^[/" _history-complete-older
"^[0A" history-substring-search-up
"^[0B" history-substring-search-down
"^[OA" history-substring-search-up
"^[OB" history-substring-search-down
"^[OC" vi-forward-char
"^[OD" vi-backward-char
"^[[A" history-substring-search-up
"^[[B" history-substring-search-down
"^[[C" vi-forward-char
"^[[D" vi-backward-char
"^[~" _bash_complete-word
"^\\\\"-"^_" self-insert
" " magic-abbrev-expand
"!"-"i" self-insert
"ih" vi-cmd-mode
"j"-"~" self-insert
"^?" vi-backward-delete-char
"\M-^@"-"\M-^?" self-insert
- (0:~/var/irclogs)  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
 -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
setopt
alwaystoend
autocd
autonamedirs
autopushd
nobadpattern
nobgnice
braceccl
nocaseglob
cbases
cdablevars
noclobber
completeinword
correct
cprecedences
dvorak
noequals
extendedglob
extendedhistory
noflowcontrol
noglobalrcs
globdots
histallowclobber
histexpiredupsfirst
histfindnodups
histignorealldups
histignoredups
histignorespace
histreduceblanks
histsavenodups
incappendhistory
interactive
interactivecomments
listpacked
listrowsfirst
localoptions
longlistjobs
monitor
nonomatch
nullglob
numericglobsort
octalzeroes
pathdirs
nopromptcr
nopromptsp
promptsubst
pushdignoredups
pushdsilent
pushdtohome
rcexpandparam
rematchpcre
shinstdin
sunkeyboardhack
transientrprompt
vi
zle
- (0:~/var/irclogs)  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
 -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
zstyle -L
zstyle ':completion:*:*:unrarec:*' *(-/):directories
zstyle ':completion:*:*:cd:*' accept-exact-dirs true
zstyle ':completion:*:*:cd:*' ambiguous true
zstyle ':completion:*:options' auto-description %d
zstyle ':completion::complete:*' cache-path /home/j/var/zsh/zcompcache
zstyle ':completion:*:processes' command 'ps --forest -A -o pid,user,cmd'
zstyle ':completion:*:processes-names' command 'ps c -u ${USER} -o
command | uniq'
zstyle ':completion:hist-complete:*' completer _history
zstyle ':completion:*' completer _complete
zstyle ':completion:*:options' description yes
zstyle ':completion:*:*:chmod:*' extra-verbose true
zstyle ':completion:*:*:cd:*' extra-verbose false
zstyle ':completion:*:*:unrar:*' file-patterns '*.rar|*(-/):directories'
zstyle ':completion:*:*:mupdf:*' file-patterns '(#i)*.pdf'
zstyle ':completion:*:*:mplayer:*' file-patterns
'*.(rmvb|mkv|mpe|mpg|mpeg|wmv|avi|flv|mp3|mp4|flac|ogg|webm|iso|img|mov|ts|vob|mov|m2v|asf|ogv):video'
'*:all-files' '*(-/):directories'
zstyle ':completion:*:*:ffprobe:*' file-patterns
'*.(rmvb|mkv|mpe|mpg|mpeg|wmv|avi|flv|mp3|mp4|flac|ogg|webm|iso|img|mov|ts|vob|mov|m2v|asf|ogv):video'
'*:all-files' '*(-/):directories'
zstyle ':completion:*:*:seen:*' file-patterns
'*.(rmvb|mkv|mpe|mpg|mpeg|wmv|avi|flv|mp4|webm|iso|img|mov|ts|vob|m2v|ogv):video'
'*:all-files' '*(-/):directories'
zstyle ':completion:*:*:mplayer_6ch_headphones:*' file-patterns
'*.(dts|ac3|flac|mkv|mp4)(#i)' '*(-/):directories'
zstyle ':completion:*' file-patterns
'%p([1,10]):first-ten-globbed-files'
'%p([11,30]):second-twenty-globbed-files'
'%p([31,-1]):remaining-globbed-files' '*(-/):directories'
'*([1,10]):first-ten-files' '*([11,30]):second-twenty-files'
'*([31,-1]):remaining-files'
zstyle ':completion:*:*:cd:*' force-list
zstyle ':completion:*:corrections' format ' %F{green}-- %d (errors: %e) --%f'
zstyle ':completion:*:descriptions' format ' %F{yellow}-- %d --%f'
zstyle ':completion:*:messages' format ' %F{purple} -- %d --%f'
zstyle ':completion:*:warnings' format ' %F{red}-- no matches found --%f'
zstyle ':completion:*:*:cd:*' format ''
zstyle ':completion:*' format ' %F{yellow}-- %d --%f'
zstyle ':completion:*:matches' group yes
zstyle ':completion:*' group-name ''
zstyle ':completion::approximate-1:*' group-order original corrections
zstyle ':completion::match:*' group-order original matches
zstyle ':completion::expand:*' group-order original corrections
zstyle ':completion::*approximate*:*' group-order original corrections
zstyle ':completion::*match:*' group-order original matches
zstyle ':completion:*:*:cd:*' group-order paths path-directories
directories directory-stack bookmarks
zstyle ':completion:*:(rm|kill|mplayer|m|ms|f|feh):*' ignore-line yes
zstyle ':completion:*' ignore-parents parent pwd
zstyle ':completion:*:vim:*:directories' ignored-patterns '*'
zstyle ':completion:*:*:([vw]im|rview|vimdiff|xxd):*:*files'
ignored-patterns
'*~|*.(old|bak|zwc|viminfo|rxvt-*|zcompdump)|pm_to_blib|cover_db|blib'
file-sort modification
zstyle ':completion:*:*:cd:*' ignored-patterns '(*/)#lost+found'
zstyle ':completion:*:*:unrar:*' ignored-patterns 'Sample|Subs'
zstyle ':completion:*:*:mplayer:*' ignored-patterns '[Ss](ubs|ample|creens)[.]*'
zstyle ':completion:*:(functions|parameters|association-keys)'
ignored-patterns '_*'
zstyle ':completion:*:manuals.(^1*)' insert-sections true
zstyle ':completion:*:default' list-prompt '%S%M matches%s'
zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=*
r:|=*' 'l:|=* r:|=*'
zstyle ':completion:*:approximate-1:*' max-errors 1 numeric
zstyle -e ':completion:*:*approximate*:*' max-errors 'reply=( $((
($#PREFIX + $#SUFFIX) / 2 )) )'
zstyle ':completion:*:*:*:*:*' menu select
zstyle ':completion::approximate-1:*' original true
zstyle ':completion::match:*' original only
zstyle ':completion::*approximate*:*' original true
zstyle ':completion::*match:*' original only
zstyle ':completion:*:default' select-prompt 'Match %m,  Line %l, Pattern %p'
zstyle ':completion:*:manuals' separate-sections true
zstyle ':completion:*' show-completer true
zstyle ':completion::ignored:*' single-ignored show
zstyle ':completion:*:*:kill:*:processes' sort false
zstyle ':completion:*:*:mupdf:*' tag-order files
zstyle ':completion:*:*:mplayer:*' tag-order files
zstyle ':completion:*:*:([vw]im|rview|vimdiff|xxd):*' tag-order files
zstyle ':completion::complete:*' use-cache on
zstyle ':completion:*' use-compctl false
zstyle ':completion:*' verbose yes
- (0:~/var/irclogs)  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
 -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -

wondering if you see anything weird that might be messing with the
file-patterns.

Thanks
Joe


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

* Re: Disable all-files completions in a directory
  2013-03-03 22:47   ` joe M
@ 2013-03-04  2:30     ` Bart Schaefer
  0 siblings, 0 replies; 4+ messages in thread
From: Bart Schaefer @ 2013-03-04  2:30 UTC (permalink / raw)
  To: zsh-workers

On Mar 3,  5:47pm, joe M wrote:
} Subject: Re: Disable all-files completions in a directory
}
} > You might experiment with using the file-patterns style to break up the
} > files into groups regardless of what directory you are in.
}
} wondering if you see anything weird that might be messing with the
} file-patterns.

No, but I did just discover a bug with _next_tags.  I haven't figured out
how to reproduce it, but the effect is that it's possible to get the
compprefuncs variable set to

_next_tags_pre _next_tags_pre _next_tags_pre _next_tags_pre _next_tags_pre
_next_tags_pre _next_tags_pre _next_tags_pre _next_tags_pre _next_tags_pre
_next_tags_pre _next_tags_pre _next_tags_pre _next_tags_pre _next_tags_pre
_next_tags_pre _next_tags_pre _next_tags_pre _next_tags_pre

which pretty much goes nuts skipping over all your possible tags as soon
as you start the subsequent completion.  I think.

Anyway MOST of the time the zstyle you tried works for me.  It's only if
I've done something to trigger repetitive compprefuncs falue that things
go off the rails.  So I don't know if that's what happened to you, or if
there is some other obscure interaction with the rest of your styles.

-- 
Barton E. Schaefer


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

end of thread, other threads:[~2013-03-04  2:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-03 18:26 Disable all-files completions in a directory joe M
2013-03-03 19:36 ` Bart Schaefer
2013-03-03 22:47   ` joe M
2013-03-04  2:30     ` Bart Schaefer

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