summary refs log tree commit diff
path: root/Completion
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2003-09-03 10:15:32 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2003-09-03 10:15:32 +0000
commit3ffb3ad2f2f733fbee58e21dc6aab23827ab8d49 (patch)
tree3ccb2278fd41a91aea8935e4454f91ec4ddd7df0 /Completion
parent716e9253122b962da887fde382c9fd00b40c8a42 (diff)
downloadzsh-3ffb3ad2f2f733fbee58e21dc6aab23827ab8d49.tar.gz
zsh-3ffb3ad2f2f733fbee58e21dc6aab23827ab8d49.tar.xz
zsh-3ffb3ad2f2f733fbee58e21dc6aab23827ab8d49.zip
19014: add alias -s suf=handler
Diffstat (limited to 'Completion')
-rw-r--r--Completion/Zsh/Command/_alias2
-rw-r--r--Completion/Zsh/Type/.distfiles1
-rw-r--r--Completion/Zsh/Type/_aliases4
-rw-r--r--Completion/Zsh/Type/_command_names1
-rw-r--r--Completion/Zsh/Type/_suffix_alias_files21
5 files changed, 27 insertions, 2 deletions
diff --git a/Completion/Zsh/Command/_alias b/Completion/Zsh/Command/_alias
index ecc298c73..8feb14a07 100644
--- a/Completion/Zsh/Command/_alias
+++ b/Completion/Zsh/Command/_alias
@@ -5,6 +5,7 @@ local curcontext="$curcontext" state line suf
 _arguments -C -s -A "-*" -S \
   '-+g[list or define global aliases]' \
   '-+r[list or define regular aliases]' \
+  '-+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'
@@ -18,4 +19,3 @@ if [[ -n "$state" ]]; then
     _wanted alias expl 'alias definition' _aliases -S "$suf"
   fi
 fi
-
diff --git a/Completion/Zsh/Type/.distfiles b/Completion/Zsh/Type/.distfiles
index 652148b61..f8f7cc905 100644
--- a/Completion/Zsh/Type/.distfiles
+++ b/Completion/Zsh/Type/.distfiles
@@ -4,4 +4,5 @@ _aliases           _file_descriptors  _jobs_fg           _options_unset
 _arrays            _functions         _limits            _parameters
 _command_names     _jobs              _options           _vars
 _directory_stack   _jobs_bg           _options_set
+_suffix_alias_files
 '
diff --git a/Completion/Zsh/Type/_aliases b/Completion/Zsh/Type/_aliases
index 30e091d98..6506ece13 100644
--- a/Completion/Zsh/Type/_aliases
+++ b/Completion/Zsh/Type/_aliases
@@ -4,14 +4,16 @@ local expl sel args opts
 
 zparseopts -E -D s:=sel
 
-[[ -z $sel ]] && sel=rg
+[[ -z $sel ]] && sel=rgs
 
 opts=( "$@" )
 
 args=()
 [[ $sel = *r* ]] && args=( $args 'aliases:regular alias:compadd -k aliases' )
 [[ $sel = *g* ]] && args=( $args 'global-aliases:global alias:compadd -k galiases' )
+[[ $sel = *s* ]] && args=( $args 'suffix-aliases:suffix alias:compadd -k saliases' )
 [[ $sel = *R* ]] && args=( $args 'disabled-aliases:disabled regular alias:compadd -k dis_aliases' )
 [[ $sel = *G* ]] && args=( $args 'disabled-global-aliases:disabled global alias:compadd -k dis_galiases' )
+[[ $sel = *S* ]] && args=( $args 'disabled-suffix-aliases:disabled suffix alias:compadd -k dis_saliases' )
 
 _alternative -O opts $args
diff --git a/Completion/Zsh/Type/_command_names b/Completion/Zsh/Type/_command_names
index 613f1fe59..a8bf7b481 100644
--- a/Completion/Zsh/Type/_command_names
+++ b/Completion/Zsh/Type/_command_names
@@ -24,6 +24,7 @@ else
     'builtins:builtin command:compadd -k builtins'
     'functions:shell function:compadd -k functions'
     'aliases:alias:compadd -k aliases'
+    'suffix-aliases:suffix alias:_suffix_alias_files'
     'reserved-words:reserved word:compadd -k reswords'
     'jobs:: _jobs -t'
     'parameters:: _parameters -g "^*readonly*" -qS= -r "\n\t\- =["'
diff --git a/Completion/Zsh/Type/_suffix_alias_files b/Completion/Zsh/Type/_suffix_alias_files
new file mode 100644
index 000000000..1c2c8ebb5
--- /dev/null
+++ b/Completion/Zsh/Type/_suffix_alias_files
@@ -0,0 +1,21 @@
+#autoload
+
+# Complete files for which a suffix alias exists.
+
+local expl pat
+
+(( ${#saliases} )) || return 1
+
+if (( ${#saliases} == 1 )); then
+    pat="*.${(kq)saliases}"
+else
+    local -a tmpa
+    # This is so we can quote the alias names against expansion
+    # without quoting the `|' which needs to be active in the pattern
+    # --- remember that an alias name can be pretty much anything.
+    tmpa=(${(kq)saliases})
+    pat="*.(${(kj.|.)tmpa})"
+fi
+
+# _wanted is called for us by _command_names
+_path_files "$@" -g $pat