Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

PATCH: Re: Standard setopts for completion system, again



Bart Schaefer wrote:

> ...
> 
> Grepping through the completion functions for `setopt', I find that I have
> some questions ....
> 
> Builtins/_cd:14:setopt localoptions nonomatch
> Builtins/_popd:8:setopt extendedglob nonomatch
>   Given these functions explicitly setopt nonomatch, does that mean that
>   they intend patterns that don't match to remain unchanged?  If that's
>   the case, then they should also unsetopt nullglob.

We use nonomatch not because of globbing, but because of ~... and
=... expansion. So I only changed that extendedglob to localoptions.

A good question might be if we should just move the nonomatch into
_main_complete `and be done with it'. Instead of error messages we
always want strings we can handle, or don't we?

> Commands/_read_comp:26:setopt localoptions extendedglob nobadpattern # xtrace promptsubst
>   It looks like this function could use a few more of the standard setopts
>   than it has, especially ksharrays, but I wanted to double-check.

I'll leave that one to Peter.

> Core/_expand:10:setopt localoptions nullglob nonomatch
>   Hmm, is it necessary to set both nullglob and nonomatch?  Nullglob will
>   make the patterns vanish before nomatch has a chance to complain.  And
>   this function ought either to get the rest of the standard setopts if it
>   is meant to be called independent of _main_complete, or else it doesn't
>   need any setopts at all.

See above and: I don't think completers should (or need to) be
designed to be callable stand-alone. The calling function has to make
sure that the function is called in the right environment -- we expect 
that in some hundred completion functions anyway...

> Core/_path_files:13:setopt localoptions nullglob rcexpandparam
> Core/_path_files:14:unsetopt markdirs globsubst shwordsplit nounset
> User/_mailboxes:70:  setopt localoptions nullglob
> User/_man:3:setopt localoptions rcexpandparam
> User/_perl_modules:49:        setopt localoptions extendedglob
>   Other cases where either all or none of the standard options seems to be
>   the right thing.  Am I missing something?

That _path_files surprised me a bit, but, yes, you are right. And it
even looks as if those (un|)setopts we copied from there to
_main_complete or the other way round. Maybe I once was to lazy to
remove them?

> ...
> 
> I changed Sven's `no*' forms back into an unsetopt in _main_complete; I
> don't think it's significantly faster to use one command instead of two,
> and it's much easier to read without all those repeated `no's.

I don't care either way very much...


And the patch also removes the N's from glob qualifier lists where
possible (and if I found all places...).


Still no decision on how to move that init code into a function or
alias. I think I'd prefer an alias since it makes it easier for
function writers. We should thet put a note in the docs that the
completion functions can't be compiled correctly if compinit hasn't
been executed in that shell, though (and that may be a good reason to
use a function, of course; sigh).

Bye
 Sven

Index: Completion/Bsd/_bsd_pkg
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Bsd/_bsd_pkg,v
retrieving revision 1.4
diff -u -r1.4 _bsd_pkg
--- Completion/Bsd/_bsd_pkg	2000/09/07 08:39:22	1.4
+++ Completion/Bsd/_bsd_pkg	2000/10/06 12:45:06
@@ -7,7 +7,7 @@
   paths=( "${(@)${(@s.:.)PKG_PATH}:#}" )
   _files "$@" -g \*.tgz && ret=0
   (( $#path )) && _files "$@" -W paths -g \*.tgz && ret=0
-  compadd "$@" - /usr/ports/packages/All/*.tgz(N) && ret=0
+  compadd "$@" - /usr/ports/packages/All/*.tgz && ret=0
 
   return ret
 }
@@ -37,7 +37,7 @@
 	'-d[remove empty directories]' \
 	'-f[force deinstallation]' \
         '-p:prefix directory:_files -/' \
-        '*:package to deinstall:compadd - /var/db/pkg/*(N\:t)'
+        '*:package to deinstall:compadd - /var/db/pkg/*(\:t)'
     ;;
 
   pkg_info)
@@ -57,10 +57,10 @@
 	'-R[show list list of installed requiring packages]' \
 	'-m[show mtree files]' \
 	'-L[show full pathnames of files]' \
-        '-e[test if package is installed]:package name:compadd - /var/db/pkg/*(N\:t)' \
+        '-e[test if package is installed]:package name:compadd - /var/db/pkg/*(\:t)' \
         '-l:prefix directory:_files -/' \
         '-t:mktemp template:_files -/' \
-        '(-a)*:package name:compadd - /var/db/pkg/*(N\:t)'
+        '(-a)*:package name:compadd - /var/db/pkg/*(\:t)'
     ;;
   esac
 }
Index: Completion/Bsd/_kld
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Bsd/_kld,v
retrieving revision 1.4
diff -u -r1.4 _kld
--- Completion/Bsd/_kld	2000/09/07 08:39:22	1.4
+++ Completion/Bsd/_kld	2000/10/06 12:45:06
@@ -4,7 +4,7 @@
 _kld_module() {
   local ret=1
 
-  compadd "$@" - /boot/kernel/*.ko(N:t) /modules/*.ko(N:t) && ret=0
+  compadd "$@" - /boot/kernel/*.ko(:t) /modules/*.ko(:t) && ret=0
   _files "$@" -g \*.ko && ret=0
 
   return ret
Index: Completion/Builtins/_autoload
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Builtins/_autoload,v
retrieving revision 1.2
diff -u -r1.2 _autoload
--- Completion/Builtins/_autoload	2000/04/01 20:43:43	1.2
+++ Completion/Builtins/_autoload	2000/10/06 12:45:06
@@ -6,5 +6,5 @@
   _description files expl 'zwc file'
   _files "$expl[@]" -g '*.zwc'
 else
-  _wanted functions expl 'shell function' compadd - ${^fpath}/*(N:t)
+  _wanted functions expl 'shell function' compadd - ${^fpath}/*(:t)
 fi
Index: Completion/Builtins/_cd
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Builtins/_cd,v
retrieving revision 1.4
diff -u -r1.4 _cd
--- Completion/Builtins/_cd	2000/09/07 09:14:24	1.4
+++ Completion/Builtins/_cd	2000/10/06 12:45:06
@@ -19,7 +19,7 @@
   # cd old new: look for old in $PWD and see what can replace it
   local rep
   # Get possible completions using word in position 2
-  rep=(${~PWD/$words[2]/*}~$PWD(-/N))
+  rep=(${~PWD/$words[2]/*}~$PWD(-/))
   # Now remove all the common parts of $PWD and the completions from this
   rep=(${${rep#${PWD%%$words[2]*}}%${PWD#*$words[2]}})
   (( $#rep )) && _wanted -C replacement strings expl replacement compadd -a rep
Index: Completion/Builtins/_compdef
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Builtins/_compdef,v
retrieving revision 1.7
diff -u -r1.7 _compdef
--- Completion/Builtins/_compdef	2000/05/31 09:38:26	1.7
+++ Completion/Builtins/_compdef	2000/10/06 12:45:06
@@ -33,7 +33,7 @@
     _wanted commands expl 'completed command' compadd -k _comps
   ;;
   cfun)
-    list=( ${^fpath:/.}/_(|*[^~])(N:t) )
+    list=( ${^fpath:/.}/_(|*[^~])(:t) )
     if zstyle -T ":completion:${curcontext}:functions" prefix-hidden; then
       disp=( ${list[@]#_} )
       _wanted functions expl 'completion function' \
Index: Completion/Builtins/_popd
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Builtins/_popd,v
retrieving revision 1.4
diff -u -r1.4 _popd
--- Completion/Builtins/_popd	2000/05/31 09:38:26	1.4
+++ Completion/Builtins/_popd	2000/10/06 12:45:06
@@ -5,7 +5,7 @@
 # way round if pushdminus is set). Note that this function is also called
 # from _cd for cd and pushd.
 
-setopt extendedglob nonomatch
+setopt localoptions nonomatch
 
 local expl list lines revlines disp
 
Index: Completion/Core/_expand
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Core/_expand,v
retrieving revision 1.29
diff -u -r1.29 _expand
--- Completion/Core/_expand	2000/09/21 05:16:22	1.29
+++ Completion/Core/_expand	2000/10/06 12:45:06
@@ -7,7 +7,7 @@
 # the expansions done produce no result or do not change the original
 # word from the line.
 
-setopt localoptions nullglob nonomatch
+setopt localoptions nonomatch
 
 [[ _matcher_num -gt 1 ]] && return 1
 
Index: Completion/Core/_path_files
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Core/_path_files,v
retrieving revision 1.31
diff -u -r1.31 _path_files
--- Completion/Core/_path_files	2000/10/05 07:31:00	1.31
+++ Completion/Core/_path_files	2000/10/06 12:45:06
@@ -10,9 +10,6 @@
 
 typeset -U prepaths exppaths
 
-setopt localoptions nullglob rcexpandparam
-unsetopt markdirs globsubst shwordsplit nounset
-
 exppaths=()
 
 # Get the options.
@@ -317,7 +314,7 @@
 
     # Force auto-mounting. There might be a better way...
 
-    : ${^tmp1}/${PREFIX}${SUFFIX}/.(N/)
+    : ${^tmp1}/${PREFIX}${SUFFIX}/.(/)
 
     # Get the matching files by globbing.
 
Index: Completion/Linux/_rpm
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Linux/_rpm,v
retrieving revision 1.17
diff -u -r1.17 _rpm
--- Completion/Linux/_rpm	2000/08/08 12:11:42	1.17
+++ Completion/Linux/_rpm	2000/10/06 12:45:06
@@ -269,7 +269,7 @@
 
 _rpms_caching_policy () {
   # rebuild if cache is more than a week old
-  oldp=( "$1"(Nmw+1) )
+  oldp=( "$1"(mw+1) )
   (( $#oldp )) && return 0
 
   [[ /var/lib/rpm/packages.rpm -nt "$1" ]]
Index: Completion/User/_gcc
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/User/_gcc,v
retrieving revision 1.2
diff -u -r1.2 _gcc
--- Completion/User/_gcc	2000/09/07 08:39:22	1.2
+++ Completion/User/_gcc	2000/10/06 12:45:06
@@ -274,7 +274,7 @@
   ;;
 library)
   _wanted libraries expl library \
-      compadd - ${^=LD_LIBRARY_PATH:-/usr/lib /usr/local/lib}/lib*.(a|so*)(N:t:fr:s/lib//) && ret=0
+      compadd - ${^=LD_LIBRARY_PATH:-/usr/lib /usr/local/lib}/lib*.(a|so*)(:t:fr:s/lib//) && ret=0
   ;;
 esac
 
Index: Completion/User/_gdb
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/User/_gdb,v
retrieving revision 1.5
diff -u -r1.5 _gdb
--- Completion/User/_gdb	2000/09/07 08:39:22	1.5
+++ Completion/User/_gdb	2000/10/06 12:45:06
@@ -5,12 +5,12 @@
 [[ "$PREFIX" = --* ]] &&
     _arguments -- '*=(CORE|SYM)FILE:core file:_files' \
 		  '*=EXECFILE:executable:_files -g \*\(-\*\)' \
-		  '*=TTY:terminal device:compadd /dev/tty\*\(N\)' && return 0
+		  '*=TTY:terminal device:compadd /dev/tty\*' && return 0
 
 if compset -P '-(cd|directory)='; then
   _files -/
 elif compset -P '-tty='; then
-  _wanted devices expl 'terminal device' compadd - /dev/tty*(N)
+  _wanted devices expl 'terminal device' compadd - /dev/tty*
 elif compset -P '-(exec|se)='; then
   _description files expl executable
   _files "$expl[@]" -g '*(-*)'
Index: Completion/User/_mailboxes
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/User/_mailboxes,v
retrieving revision 1.6
diff -u -r1.6 _mailboxes
--- Completion/User/_mailboxes	2000/09/07 08:39:22	1.6
+++ Completion/User/_mailboxes	2000/10/06 12:45:08
@@ -67,17 +67,15 @@
   typeset -aU -g _mailbox_cache
   typeset -aU -g _maildir_cache _mbox_cache _mh_cache _mutt_cache _pine_cache
 
-  setopt localoptions nullglob
 
-
   [[ -f ${~muttrc:-.} ]] &&
     _mutt_cache=( ${=${(M)${(f)"$(<${~muttrc})"}:#mailboxes *}#mailboxes *} )
 
 
-  _mbox_cache=( ${~maildirectory}/*(N^/) )
-  _pine_cache=( ${~pinedirectory}/**/*(N.) )
+  _mbox_cache=( ${~maildirectory}/*(^/) )
+  _pine_cache=( ${~pinedirectory}/**/*(.) )
 
-  dirboxes=( ${~maildirectory}/*(N/) )
+  dirboxes=( ${~maildirectory}/*(/) )
 
   while (( $#dirboxes )); do
     i=${dirboxes[1]}
@@ -87,7 +85,7 @@
     elif j=( "$i"/<1-> ) && [[ -n "$j" ]]; then
       _mh_cache=( "${_mh_cache[@]}" "$i" )
     else
-      _mbox_cache=( "${_mbox_cache[@]}" "$i"/*(N.) )
+      _mbox_cache=( "${_mbox_cache[@]}" "$i"/*(.) )
       dirboxes=( $dirboxes "$i"/*(/) )
     fi
   done
Index: Completion/User/_man
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/User/_man,v
retrieving revision 1.6
diff -u -r1.6 _man
--- Completion/User/_man	2000/09/03 21:45:37	1.6
+++ Completion/User/_man	2000/10/06 12:45:08
@@ -1,7 +1,5 @@
 #compdef man apropos whatis
 
-setopt localoptions rcexpandparam
-
 local rep expl star approx mrd
 
 if [[ $words[1] == man ]] && (( $words[(I)-l] + $words[(I)--local-file] )); then
@@ -26,7 +24,7 @@
 fi
 
 (( $#manpath )) || manpath=( ${(s.:.)$(manpath 2>/dev/null)} ) ||
-    manpath=( /usr/man(-/N) /(opt|usr)/(dt|share|X11R6|local)/(cat|)man(-/N) )
+    manpath=( /usr/man(-/) /(opt|usr)/(dt|share|X11R6|local)/(cat|)man(-/) )
 
 # `sman' is the SGML manual directory for Solaris 7.
 # 1M is system administrator commands on SVR4
@@ -34,10 +32,10 @@
 mrd=(${^manpath/\%L/${LANG:-En_US.ASCII}}/mandb(N))
 if [[ $words[2] = (<->*|1M|l|n) ]]; then
   rep=(
-  $manpath/(sman|man|cat)${words[2]}/${~approx}$PREFIX${~star}$SUFFIX.*(N:t) )
+  $manpath/(sman|man|cat)${words[2]}/${~approx}$PREFIX${~star}$SUFFIX.*(:t) )
   (($#mrd)) && rep[$#rep+1]=($(awk "\$2 == \"$words[2]\" {print \$1}" $mrd))
 else
-  rep=( $manpath/(sman|man|cat)*/${~approx}$PREFIX${~star}$SUFFIX.*(N:t) )
+  rep=( $manpath/(sman|man|cat)*/${~approx}$PREFIX${~star}$SUFFIX.*(:t) )
   (($#mrd)) && rep[$#rep+1]=($(awk '{print $1}' $mrd))
 fi
 
Index: Completion/User/_perl_modules
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/User/_perl_modules,v
retrieving revision 1.7
diff -u -r1.7 _perl_modules
--- Completion/User/_perl_modules	2000/08/02 13:45:52	1.7
+++ Completion/User/_perl_modules	2000/10/06 12:45:08
@@ -46,7 +46,6 @@
         # complete Perl modules.  Maybe her $path is wrong?
         _message "Didn't find perl on \$PATH; guessing @INC ..."
   
-        setopt localoptions extendedglob
         inc=( /usr/lib/perl5{,/{site_perl/,}<5->.([0-9]##)}(N) 
               ${(s.:.)PERL5LIB} )
       fi
@@ -61,7 +60,7 @@
         # Find all modules
         if [[ -d $libdir && -x $libdir ]]; then
         cd $libdir
-        new_pms=( {[A-Z]*/***/,}*.pm~*blib*(N) )
+        new_pms=( {[A-Z]*/***/,}*.pm~*blib* )
         cd $OLDPWD
         fi
   
@@ -84,10 +83,10 @@
   local _perllocals
 
   # rebuild if cache is more than a week old
-  oldp=( "$1"(Nmw+1) )
+  oldp=( "$1"(mw+1) )
   (( $#oldp )) && return 0
 
-  _perllocals=( /usr/lib/perl5/**/perllocal.pod(N) )
+  _perllocals=( /usr/lib/perl5/**/perllocal.pod )
 
   if (( $#_perllocals )); then
     for pod in $_perllocals; do
Index: Completion/User/_printers
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/User/_printers,v
retrieving revision 1.2
diff -u -r1.2 _printers
--- Completion/User/_printers	2000/07/06 12:40:01	1.2
+++ Completion/User/_printers	2000/10/06 12:45:08
@@ -11,7 +11,7 @@
 if (( ! $+_lp_cache )); then
   local file entry names i
 
-  file=( /etc/(printcap|printers.conf)(N) )
+  file=( /etc/(printcap|printers.conf) )
 
   _lp_cache=()
   _lp_alias_cache=()
Index: Completion/User/_zdump
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/User/_zdump,v
retrieving revision 1.2
diff -u -r1.2 _zdump
--- Completion/User/_zdump	2000/09/07 08:39:22	1.2
+++ Completion/User/_zdump	2000/10/06 12:45:08
@@ -1,7 +1,7 @@
 #compdef zdump
 
 if (( ! $+_zoneinfo_dirs )); then
-  _zoneinfo_dirs=( /usr/{share,lib,share/lib}/zoneinfo*(N/) )
+  _zoneinfo_dirs=( /usr/{share,lib,share/lib}/zoneinfo*(/) )
 fi
 
 _arguments '-v[lowest possible]' \

--
Sven Wischnowsky                         wischnow@xxxxxxxxxxxxxxxxxxxxxxx



Messages sorted by: Reverse Date, Date, Thread, Author