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

Re: PATCH: zstyle to control completion of functions/parameters beginning with underscore



On Tue, 01 Mar 2011 15:39:55 -0500
Greg Klanderman <gak@xxxxxxxxxxxxxx> wrote:
> >>>>> On May 28, 2009 Richard Hartmann <richih.mailinglist@xxxxxxxxx> wrote:
> > On Wed, May 27, 2009 at 21:12, Greg Klanderman <gak@xxxxxxxxxxxxxx> wrote:
> >> But in the same vein, what I really want is a way to configure the
> >> behavior for functions, variables, etc. beginning with "_" to be like
> >> filenames beginning with ".": completion should work if I have
> >> explicitly typed the leading "_", but even substring matching should
> >> not *generate* a leading "_".
> 
> > I think this is a good explanation of what, imo, the final goal should be.
> 
> What do you guys think of the patch below?  I'm open to better names
> for the zstyle.. I've tested it a fair amount locally.

Looks good to me.

I think you missed the following case...

Index: Completion/Zsh/Type/_functions
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Zsh/Type/_functions,v
retrieving revision 1.3
diff -p -u -r1.3 _functions
--- Completion/Zsh/Type/_functions	8 Jun 2005 12:45:36 -0000	1.3
+++ Completion/Zsh/Type/_functions	1 Mar 2011 21:10:13 -0000
@@ -1,5 +1,15 @@
 #compdef unfunction
 
-local expl
+local expl hide ffilt
 
-_wanted functions expl 'shell function' compadd -k "$@" - functions
+zstyle -s ":completion:${curcontext}:functions" hide-internal hide
+case "${hide:-never}" in
+  no|false|never)
+    ffilt='';;
+  yes|true|always)
+    ffilt='[(I)[^_.]*]';;
+  auto|dtrt)
+    [[ $PREFIX = [_.]* ]] && ffilt='' || ffilt='[(I)[^_.]*]';;
+esac
+
+_wanted functions expl 'shell function' compadd -k "$@" - "functions$ffilt"

-- 
Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/



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