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

Re: PATCH: suffix aliases

Peter wrote:
> Patterns would need to be array-based rather than hash-based.  That way
> you don't get a hit if you don't have any pattern aliases.  It's not
> at all technically difficult to add.  I think we need suffix aliases for
> efficiency anyway.

Okay. There's other things like correction that also work better with
suffix aliases being separate so I agree that's best.

I've just been trying them out. All looks good. A couple of the whence
outputs are not quite right by the way:
% alias -s c=nedit
% whence -v t.c
c is a suffix alias fornedit  (missing space)
% whence -c t.c
c: suffix  aliased to nedit   (two spaces after `suffix')

I'm not particularly bothered but any thoughts on the suggestion of
suffix aliases checking for files in a special path and not needing the
suffix to be typed? This is closer to what 4DOS did; I'd be slightly
inclined towards not having the current directory in that path and it
could be useful for things like wine and java.

> > > I dutifully added completion to _alias, but it seems that doesn't
> > > understand the difference between aliases with different options, so I
> > 
> > There isn't much point: completing existing aliases when defining new
> > ones isn't that useful anyway.
> It would be useful when trying to output existing messages.  I'm a bit
> bemused why _aliases goes to all that trouble of sorting aliases into
> type but _alias doesn't use it.

You mean trying to output existing aliases right.

Was probably just laziness when _alias was written. Easy enough though.


Index: Completion/Zsh/Command/_alias
RCS file: /cvsroot/zsh/zsh/Completion/Zsh/Command/_alias,v
retrieving revision 1.3
diff -u -r1.3 _alias
--- Completion/Zsh/Command/_alias	3 Sep 2003 10:15:35 -0000	1.3
+++ Completion/Zsh/Command/_alias	3 Sep 2003 12:19:15 -0000
@@ -1,11 +1,12 @@
 #compdef alias
-local curcontext="$curcontext" state line suf
+local curcontext="$curcontext" state line type suf
+typeset -A opt_args
 _arguments -C -s -A "-*" -S \
-  '-+g[list or define global aliases]' \
-  '-+r[list or define regular aliases]' \
-  '-+s[list or define suffix aliases]' \
+  '(-r +r -s +s)-+g[list or define global aliases]' \
+  '(-g +g -s +s)-+r[list or define regular aliases]' \
+  '(-r +r -g +g)-+s[list or define suffix aliases]' \
   '-+m[print aliases matching specified pattern]' \
   '-L[print each alias in the form of calls to alias]' \
   '*::alias definition:->defn'
@@ -16,6 +17,8 @@
     compset -S '=*' || suf='='
-    _wanted alias expl 'alias definition' _aliases -S "$suf"
+    type=( ${opt_args[(i)[-+][grs]]#?} )
+    (( $#type )) && type=( -s $type )
+    _wanted -x alias expl 'alias definition' _aliases -S "$suf" "$type[@]"
Index: Completion/Zsh/Command/_unhash
RCS file: /cvsroot/zsh/zsh/Completion/Zsh/Command/_unhash,v
retrieving revision 1.1
diff -u -r1.1 _unhash
--- Completion/Zsh/Command/_unhash	2 Apr 2001 11:31:42 -0000	1.1
+++ Completion/Zsh/Command/_unhash	3 Sep 2003 12:19:15 -0000
@@ -3,11 +3,12 @@
 local expl state line curcontext="$curcontext"
 _arguments -C -s -S \
-  '(-a -f *)-d[remove named directories]:*:named directory:->nameddir' \
-  '(-d -f *)-a[remove aliases]:*:aliases:_aliases' \
-  '(-d -a *)-f[remove functions]:*:functions:_functions' \
+  '(-a -f -s *)-d[remove named directories]:*:named directory:->nameddir' \
+  '(-d -f -s *)-a[remove aliases]:*:alias:_aliases' \
+  '(-a -d -f *)-s[remove suffix aliases]:*:suffix alias:_aliases -s s' \
+  '(-d -a -s *)-f[remove functions]:*:function:_functions' \
   '-m[treat arguments as patterns]' \
-  '(-a -d -f -m)*:commands: _command_names -e' && return 0
+  '(-a -d -f -m)*:command: _command_names -e' && return 0
 [[ "$state" = nameddir ]] &&
   _wanted named-directories expl 'named directory' compadd -k nameddirs

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