zsh-workers
 help / color / mirror / code / Atom feed
From: Oliver Kiddle <okiddle@yahoo.co.uk>
To: zsh-workers@sunsite.dk (Zsh hackers list)
Subject: Re: PATCH: suffix aliases
Date: Wed, 03 Sep 2003 14:33:12 +0200	[thread overview]
Message-ID: <12877.1062592392@gmcs3.local> (raw)
In-Reply-To: <18526.1062585527@csr.com>

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.

Oliver

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 @@
     _normal
   else
     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[@]"
   fi
 fi
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


  reply	other threads:[~2003-09-03 12:31 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-09-02 21:11 Peter Stephenson
2003-09-02 23:37 ` DervishD
2003-09-03  7:55 ` Oliver Kiddle
2003-09-03 10:38   ` Peter Stephenson
2003-09-03 12:33     ` Oliver Kiddle [this message]
2003-09-03 12:59       ` Peter Stephenson

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=12877.1062592392@gmcs3.local \
    --to=okiddle@yahoo.co.uk \
    --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).