zsh-workers
 help / color / mirror / code / Atom feed
From: Greg Klanderman <gak@klanderman.net>
To: zsh-workers@zsh.org
Subject: Re: PATCH: zstyle to control completion of functions/parameters beginning with underscore
Date: Thu, 03 Mar 2011 11:11:13 -0500	[thread overview]
Message-ID: <m3zkpctc9q.fsf@klanderman.net> (raw)
In-Reply-To: <m339n4uskj.fsf@klanderman.net> (Greg Klanderman's message of "Thu, 03 Mar 2011 10:33:48 -0500")


Here's a new patch for the easier option (without 'auto').
Let me know what you think..

cheers,
Greg



Index: Completion/Zsh/Type/_functions
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Zsh/Type/_functions,v
retrieving revision 1.3
diff -u -r1.3 _functions
--- Completion/Zsh/Type/_functions	8 Jun 2005 12:45:36 -0000	1.3
+++ Completion/Zsh/Type/_functions	3 Mar 2011 16:08:17 -0000
@@ -1,5 +1,9 @@
 #compdef unfunction
 
-local expl
+local expl ffilt
 
-_wanted functions expl 'shell function' compadd -k "$@" - functions
+zstyle -t ":completion:${curcontext}:functions" prefix-needed && \
+ [[ $PREFIX != [_.]* ]] && \
+ ffilt='[(I)[^_.]*]'
+
+_wanted functions expl 'shell function' compadd -k "$@" - "functions$ffilt"
Index: Completion/Zsh/Type/_command_names
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Zsh/Type/_command_names,v
retrieving revision 1.9
diff -u -r1.9 _command_names
--- Completion/Zsh/Type/_command_names	19 Aug 2007 23:31:31 -0000	1.9
+++ Completion/Zsh/Type/_command_names	3 Mar 2011 16:08:17 -0000
@@ -4,10 +4,14 @@
 # complete only external commands and executable files. This and a
 # `-' as the first argument is then removed from the arguments.
 
-local args defs
+local args defs ffilt
 
 zstyle -t ":completion:${curcontext}:commands" rehash && rehash
 
+zstyle -t ":completion:${curcontext}:functions" prefix-needed && \
+ [[ $PREFIX != [_.]* ]] && \
+ ffilt='[(I)[^_.]*]'
+
 defs=(
   'commands:external command:_path_commands'
 )
@@ -24,7 +28,7 @@
 
   defs=( "$defs[@]"
     'builtins:builtin command:compadd -k builtins'
-    'functions:shell function:compadd -k functions'
+    "functions:shell function:compadd -k functions$ffilt"
     'aliases:alias:compadd -k aliases'
     'suffix-aliases:suffix alias:_suffix_alias_files'
     'reserved-words:reserved word:compadd -k reswords'
Index: Completion/Zsh/Type/_parameters
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Zsh/Type/_parameters,v
retrieving revision 1.1
diff -u -r1.1 _parameters
--- Completion/Zsh/Type/_parameters	2 Apr 2001 11:20:15 -0000	1.1
+++ Completion/Zsh/Type/_parameters	3 Mar 2011 16:08:17 -0000
@@ -6,7 +6,7 @@
 # If you specify a -g option with a pattern, the pattern will be used to
 # restrict the type of parameters matched.
 
-local expl pattern fakes faked tmp
+local expl pattern fakes faked tmp pfilt
 
 pattern=(-g \*)
 zparseopts -D -K -E g:=pattern
@@ -23,8 +23,12 @@
   done
 fi
 
+zstyle -t ":completion:${curcontext}:parameters" prefix-needed && \
+ [[ $PREFIX != [_.]* ]] && \
+ pfilt='[^_.]'
+
 _wanted parameters expl parameter \
     compadd "$@" -Q - \
-        "${(@k)parameters[(R)${pattern[2]}~*local*]}" \
+        "${(@M)${(@k)parameters[(R)${pattern[2]}~*local*]}:#${~pfilt}*}" \
         "$fakes[@]" \
         "${(@)${(@M)faked:#${~pattern[2]}}%%:*}"
Index: Doc/Zsh/compsys.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/compsys.yo,v
retrieving revision 1.232
diff -u -r1.232 compsys.yo
--- Doc/Zsh/compsys.yo	17 Dec 2010 17:10:48 -0000	1.232
+++ Doc/Zsh/compsys.yo	3 Mar 2011 16:08:17 -0000
@@ -2298,13 +2298,29 @@
 )
 kindex(prefix-needed, completion style)
 item(tt(prefix-needed))(
-This, too, is used for matches with a common prefix.  If it is set to
-`true' this common prefix must be typed by the user to generate the
-matches.  In the case of command options, this means that the initial
-`tt(-)', `tt(+)', or `tt(-)tt(-)' must be typed explicitly before option
-names will be completed.
+This style is also relevant for matches with a common prefix.  If it is
+set to `true' this common prefix must be typed by the user to generate
+the matches.
 
-The default value for this style is `true'.
+The style is applicable to the tt(options), tt(signals), tt(jobs),
+tt(functions), and tt(parameters) completion tags.
+
+For command options, this means that the initial `tt(-)', `tt(+)', or
+`tt(-)tt(-)' must be typed explicitly before option names will be
+completed.
+
+For signals, an initial `tt(-)' is required before signal names will
+be completed.
+
+For jobs, an initial `tt(%)' is required before job names will be
+completed.
+
+For function and parameter names, an initial `tt(_)' or `tt(.)' is
+required before function or parameter names starting with those
+characters will be completed.
+
+The default value for this style is `false' for tt(function) and
+tt(parameter) completions, and  `true' otherwise.
 )
 kindex(preserve-prefix, completion style)
 item(tt(preserve-prefix))(


  reply	other threads:[~2011-03-03 16:11 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-05  0:07 PATCH: Add CORRECT_NOCOMPSYS option Frank Terbeck
2009-04-05  2:37 ` Bart Schaefer
2009-04-05 12:23   ` Frank Terbeck
2009-04-05 18:13   ` Peter Stephenson
2009-04-05 22:11     ` Bart Schaefer
2009-04-06  9:09       ` Peter Stephenson
2009-05-27 16:30         ` Richard Hartmann
2009-05-27 16:59           ` Peter Stephenson
2009-05-27 19:12             ` Greg Klanderman
2009-05-28  8:48               ` Richard Hartmann
2009-05-28  9:25                 ` Frank Terbeck
2009-05-28 18:44                   ` Greg Klanderman
2009-05-28 19:03                     ` Frank Terbeck
2009-05-28 19:35                     ` Peter Stephenson
2009-05-28 22:56                       ` Greg Klanderman
2009-05-29  8:32                         ` Peter Stephenson
2009-05-29 14:38                           ` Greg Klanderman
2009-05-29 14:49                             ` Peter Stephenson
2011-03-01 20:39                 ` PATCH: zstyle to control completion of functions/parameters beginning with underscore Greg Klanderman
2011-03-01 21:11                   ` Peter Stephenson
2011-03-01 22:07                     ` Greg Klanderman
2011-03-02  1:05                   ` Oliver Kiddle
2011-03-02 18:49                     ` Greg Klanderman
2011-03-02 23:30                       ` Bart Schaefer
2011-03-03 15:33                         ` Greg Klanderman
2011-03-03 16:11                           ` Greg Klanderman [this message]
2011-03-03 16:54                           ` Bart Schaefer
2011-03-06 20:07                             ` Greg Klanderman
2011-03-06 22:02                               ` Bart Schaefer
2011-03-08 15:13                                 ` Greg Klanderman
2011-03-09 18:41                                 ` Greg Klanderman
2011-03-10 15:54                                   ` Bart Schaefer
2011-03-10 16:44                                     ` Greg Klanderman
2011-03-10 17:10                                       ` Bart Schaefer
2011-03-10 18:01                                         ` Greg Klanderman
2011-03-11 17:01                                     ` Greg Klanderman
2011-03-03 16:58                           ` Oliver Kiddle
2011-03-02  1:13                   ` Richard Hartmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m3zkpctc9q.fsf@klanderman.net \
    --to=gak@klanderman.net \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).