zsh-workers
 help / color / mirror / code / Atom feed
From: Oliver Kiddle <opk@u.genie.co.uk>
To: zsh-workers@sunsite.auc.dk
Subject: PATCH: use _arguments in _which and _unhash
Date: Sun, 28 May 2000 18:35:09 +0100	[thread overview]
Message-ID: <393158CD.C9142475@u.genie.co.uk> (raw)

Bart Schaefer wrote:

> I can reproduce this, but
> 
> } % zpty -w l <tab>
> } _arguments:shift:297: shift count must be <= $#
> 
> I can't reproduce that.

Are you sure? I can reproduce it on different platforms and when
starting with zsh -f. Maybe one of your options avoids it.

Totally unrelated to this, I've changed a couple more of the
completion functions to use _arguments (which and unhash).

Oliver


--- Completion/Builtins/_unhash	Thu Dec 30 18:28:37 1999
+++ Completion/Builtins/_unhash	Sun May 28 16:45:29 2000
@@ -1,14 +1,14 @@
 #compdef unhash
 
-local fl="$words[2]" args
+local expl state line curcontext="$curcontext"
 
-args=()
-[[ "$fl" = -*d* ]] &&
-    args=( 'named-directories:named directory:compadd - ${(@k)nameddirs}' )
-[[ "$fl" = -*a* ]] &&
-    args=( "$args[@]"
-           'aliases:alias:compadd - ${(@k)aliases} ${(@k)galiases} ${(@k)dis-aliases} ${(@k)dis-galiases}' )
-[[ "$fl" != -* ]] &&
-    args=( 'commands:: _command_names -e' )
+_arguments -C -s \
+  '(-a -f *)-d[remove named directories]:*:named directory:->nameddir' \
+  '(-d -f *)-a[remove aliases]:*:aliases:_aliases' \
+  '(-d -a *)-f[remove functions]:*:functions:_functions' \
+  '-m[treat arguments as patterns]' \
+  '*:commands:_command_names -e'  && return 0
 
-_alternative "$args[@]"
+if [[ "$state" = nameddir ]]; then
+  _wanted nameddir expl 'named directory' compadd - ${(@k)nameddirs}
+fi
--- Completion/Builtins/_which.bak	Mon Nov 15 12:01:47 1999
+++ Completion/Builtins/_which	Sun May 28 15:50:57 2000
@@ -1,6 +1,29 @@
 #compdef which whence where type
 
-local args
+local farg aarg cargs args state line curcontext="$curcontext"
+
+cargs=( \
+  '(-v -c)-w[print command type]' \
+  '-p[always do a path search]' \
+  '-m[treat the arguments as patterns]' \
+  '-s[print symlink free path as well]' \
+  '*:commands:->command' )
+farg='-f[output contents of functions]'
+aarg='-a[print all occurences in path]'
+
+case ${words[1]} in
+  whence)
+    _arguments -C -s \
+      '(-c -w)-v[verbose output]' \
+      '(-v -w)-c[csh-like output]' \
+      "${cargs[@]}" "$farg" "$aarg" && return 0
+  ;;
+  where) _arguments -C -s "${cargs[@]}" && return 0;;
+  which) _arguments -C -s "${cargs[@]}" "$aarg" && return 0;;
+  type) _arguments -C -s "${cargs[@]}" "$aarg" "$farg" && return 0;;
+esac
+
+if [[ "$state" = command ]]; then
 
 args=( "$@" )
 
@@ -10,3 +33,5 @@
   'functions:shell function:compadd - ${(k@)functions}' \
   'aliases:alias:compadd - ${(k@)aliases}' \
   'reserved-words:reserved word:compadd - ${(k@)reswords}'
+
+fi



             reply	other threads:[~2000-05-28 19:34 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-05-28 17:35 Oliver Kiddle [this message]
2000-05-28 20:52 ` PATCH: _arguments (Re: PATCH: use _arguments in _which and _unhash) Bart Schaefer

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=393158CD.C9142475@u.genie.co.uk \
    --to=opk@u.genie.co.uk \
    --cc=zsh-workers@sunsite.auc.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).