zsh-workers
 help / color / mirror / code / Atom feed
From: Sven Wischnowsky <wischnow@berkom.de>
To: zsh-workers@sunsite.dk
Subject: compwhich
Date: Wed, 26 Jun 2002 12:19:52 +0200	[thread overview]
Message-ID: <15641.38216.138325.134649@wischnow.berkom.de> (raw)


Would something like this be worthwhile? A function `compwhich',
currently just defined in `compinit' that gets names of command and
special contexts and spits out the functio names (and services) that
define their completion.


Bye
  Sven

diff -ur -r ../oz/Completion/compinit ./Completion/compinit
--- ../oz/Completion/compinit	Fri Jun 21 20:57:36 2002
+++ ./Completion/compinit	Fri Jun 21 21:32:27 2002
@@ -399,6 +399,59 @@
   fi
 }
 
+# A small function that prints the handling function(s) for its
+# arguments (names of commands or special contexts).
+
+compwhich()
+{
+eval "$_comp_setup"
+
+local _comp_command1 _comp_command2 _comp_command
+local i def strs str words
+
+strs=()
+for str; do
+  if [[ "$str" = -* ]] then
+    strs+=( "$str" )
+  else
+    words=($str)
+    _comp_command1=
+    _comp_command2=
+    _set_command
+    [[ -n "$_comp_command1" ]] && strs+=( "$_comp_command1" )
+    [[ -n "$_comp_command2" ]] && strs+=( "$_comp_command2" )
+  fi
+done
+
+_set_command
+
+for str in "$strs[@]"; do
+  def=yes
+
+  for i in "${(@)_patcomps[(K)$str]}"; do
+    print -r - "$str matches pre-pattern in $i${_services[$str]:+ (service: ${_services[$str]})}"
+    def=
+  done
+
+  if [[ -n "$def" ]]; then
+    i="${_comps[$str]}"
+    if [[ -n "$i" ]]; then
+      print -r - "$str is handled by $i${_services[$str]:+ (service: ${_services[$str]})}"
+      def=
+    fi
+  fi
+
+  if [[ -n "$def" ]]; then
+    for i in "${(@)_postpatcomps[(K)$str]}"; do
+      print -r - "$str matches post-pattern in $i${_services[$str]:+ (service: ${_services[$str]})}"
+      def=
+    done
+  fi
+
+  [[ -n "$def" ]] && print -r - "$str is handled by _default${_services[$str]:+ (service: ${_services[$str]})}"
+done
+}
+
 # Now we automatically make the definition files autoloaded.
 
 typeset _i_wdirs _i_wfiles
diff -ur -r ../oz/Doc/Zsh/compsys.yo ./Doc/Zsh/compsys.yo
--- ../oz/Doc/Zsh/compsys.yo	Fri Jun 21 20:57:35 2002
+++ ./Doc/Zsh/compsys.yo	Fri Jun 21 21:38:08 2002
@@ -252,7 +252,7 @@
 
 subsect(Functions)
 
-The tt(compinit) file defines the following function, which may
+The tt(compinit) file defines the following functions, which may
 also be called directly by the user.
 
 findex(compdef)
@@ -321,6 +321,15 @@
 In each of the forms supporting it the tt(-a) option makes the
 var(function) autoloadable (exactly equivalent to
 tt(autoload -U )var(function)).
+)
+
+findex(compwhich)
+cindex(completion system, searching definitions)
+startitem()
+item(tt(compwhich) var(names...))(
+This interprets each of the var(names) as the name of a command or
+special context, looks up which function(s) handle completion for them
+and prints their names.
 )
 enditem()
 

-- 
Sven Wischnowsky                          wischnow@berkom.de


                 reply	other threads:[~2002-06-26 10:19 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=15641.38216.138325.134649@wischnow.berkom.de \
    --to=wischnow@berkom.de \
    --cc=zsh-workers@sunsite.dk \
    /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).