about summary refs log tree commit diff
path: root/Completion/Commands
diff options
context:
space:
mode:
authorTanaka Akira <akr@users.sourceforge.net>1999-11-15 12:01:46 +0000
committerTanaka Akira <akr@users.sourceforge.net>1999-11-15 12:01:46 +0000
commit35b2633ad941966f5fca07b625a594a5b68c0fdb (patch)
treeb54740d014e594ba5d81931cdcdb3387bcf9dfca /Completion/Commands
parentbb98460a01ce1f6c1e71f7e401f782c81b71486b (diff)
downloadzsh-35b2633ad941966f5fca07b625a594a5b68c0fdb.tar.gz
zsh-35b2633ad941966f5fca07b625a594a5b68c0fdb.tar.xz
zsh-35b2633ad941966f5fca07b625a594a5b68c0fdb.zip
manual/8639
Diffstat (limited to 'Completion/Commands')
-rw-r--r--Completion/Commands/_complete_help35
-rw-r--r--Completion/Commands/_correct_word15
-rw-r--r--Completion/Commands/_expand_word21
-rw-r--r--Completion/Commands/_history_complete_word36
-rw-r--r--Completion/Commands/_read_comp4
5 files changed, 60 insertions, 51 deletions
diff --git a/Completion/Commands/_complete_help b/Completion/Commands/_complete_help
new file mode 100644
index 000000000..cfefdcf90
--- /dev/null
+++ b/Completion/Commands/_complete_help
@@ -0,0 +1,35 @@
+#compdef -k complete-word \C-xh
+
+_complete_help() {
+  local _sort_tags=_help_sort_tags text i
+  typeset -A help_tags
+  typeset -U help_contexts
+
+  help_contexts=()
+
+  compadd() { return 1 }
+
+  _main_complete
+
+  unfunction compadd
+
+  for i in "$help_contexts[@]"; do
+    text="${text}
+tags in context \`${i}': ${help_tags[$i]}"
+  done
+
+  compstate[list]=list
+  compstate[force_list]=yes
+  compstate[insert]=''
+
+  compadd -UX "$text[2,-1]" -n ''
+}
+
+_help_sort_tags() {
+  help_contexts=( "$help_contexts[@]" "$curcontext" )
+  help_tags[$curcontext]="${help_tags[$curcontext]}
+    ${argv}"
+  comptry "$@"
+}
+
+_complete_help "$@"
diff --git a/Completion/Commands/_correct_word b/Completion/Commands/_correct_word
index d0abcd4fe..e0fee1fff 100644
--- a/Completion/Commands/_correct_word
+++ b/Completion/Commands/_correct_word
@@ -7,19 +7,8 @@
 # If configurations keys with the prefix `correctword_' are
 # given they override those starting with `correct_'.
 
-local oca="$compconfig[correct_accept]"
-local oco="$compconfig[correct_original]"
-local ocp="$compconfig[correct_prompt]"
-local oci="$compconfig[correct_insert]"
+local curcontext="$curcontext"
 
-compconfig[correct_accept]="${compconfig[correctword_accept]-6n}"
-compconfig[correct_original]="${compconfig[correctword_original]-$oco}"
-compconfig[correct_prompt]="${compconfig[correctword_prompt]-$ocp}"
-compconfig[correct_insert]="${compconfig[correctword_insert]}"
+[[ -z "$curcontext" ]] && curcontext=":correct-word"
 
 _main_complete _correct
-
-compconfig[correct_accept]="$oca"
-compconfig[correct_original]="$oco"
-compconfig[correct_prompt]="$ocp"
-compconfig[correct_insert]="$oci"
diff --git a/Completion/Commands/_expand_word b/Completion/Commands/_expand_word
index d8f5f42f8..b4e22de48 100644
--- a/Completion/Commands/_expand_word
+++ b/Completion/Commands/_expand_word
@@ -5,25 +5,8 @@
 # If configurations keys with the prefix `expandword_' are
 # given they override those starting with `expand_'.
 
-local oes="$compconfig[expand_substitute]"
-local oeg="$compconfig[expand_glob]"
-local oem="$compconfig[expand_menu]"
-local oeo="$compconfig[expand_original]"
-local oep="$compconfig[expand_prompt]"
-local oec="$compconfig[expand_completions]"
+local curcontext="$curcontext"
 
-compconfig[expand_substitute]="${compconfig[expandword_substitute]}"
-compconfig[expand_glob]="${compconfig[expandword_glob]-$oeg}"
-compconfig[expand_menu]="${compconfig[expandword_menu]-$oem}"
-compconfig[expand_original]="${compconfig[expandword_original]-$oeo}"
-compconfig[expand_prompt]="${compconfig[expandword_prompt]-$oep}"
-compconfig[expand_completions]="${compconfig[expandword_completions]-$oec}"
+[[ -z "$curcontext" ]] && curcontext=":expand-word"
 
 _main_complete _expand
-
-compconfig[expand_substitute]="$oes"
-compconfig[expand_glob]="$oeg"
-compconfig[expand_menu]="$oem"
-compconfig[expand_original]="$oeo"
-compconfig[expand_prompt]="$oep"
-compconfig[expand_completions]="$oec"
diff --git a/Completion/Commands/_history_complete_word b/Completion/Commands/_history_complete_word
index 1112339af..ee6ac2de2 100644
--- a/Completion/Commands/_history_complete_word
+++ b/Completion/Commands/_history_complete_word
@@ -7,17 +7,17 @@
 #
 # Available configuration keys:
 #
-#   history_list -- display lists of available matches
-#   history_stop -- prevent looping at beginning and end of matches
-#                   during menu-completion
-#   history_sort -- sort matches lexically (default is to sort by age)
-#   history_remove_all_dups --
-#                   remove /all/ duplicate matches rather than just
-#                   consecutives
+#   :history-entries:list -- display lists of available matches
+#   :history-entries:stop -- prevent looping at beginning and end of matches
+#                            during menu-completion
+#   :history-entries:sort -- sort matches lexically (default is to sort by age)
+#   :history-entries:remove-all-dups --
+#                            remove /all/ duplicate matches rather than just
+#                            consecutives
 #
 
 _history_complete_word () {
-  local expl direction
+  local expl direction stop
 
   if [[ $WIDGET = *newer ]]; then
     direction=older
@@ -25,16 +25,19 @@ _history_complete_word () {
     direction=newer
   fi
 
-  [[ -z "$compconfig[history_list]" ]] && compstate[list]=''
+  _style -s history-entries stop stop
+
+  _style history-entries list || compstate[list]=''
 
   if [[ -n "$compstate[old_list]" &&
-    ( -n "$compconfig[history_stop]" || "$compstate[insert]" = menu ) ]]; then
+        ( -n "$stop" || "$compstate[insert]" = menu ) ]] ; then
     # array of matches is newest -> oldest (reverse of history order)
     if [[ "$direction" == 'older' ]]; then
       if [[ compstate[old_insert] -eq $_hist_menu_length ||
             "$_hist_stop" == 'oldest' ]]; then
         _hist_stop='oldest'
-        [[ "$compconfig[history_stop]" = verbose ]] &&
+	_style history-entries 
+        [[ "$stop" = verbose ]] &&
           _message 'beginning of history reached'
       elif [[ "$_hist_stop" == 'newest' ]]; then
         zle -Rc
@@ -46,8 +49,7 @@ _history_complete_word () {
     elif [[ "$direction" == 'newer' ]]; then
       if [[ compstate[old_insert] -eq 1 || "$_hist_stop" == 'newest' ]]; then
         _hist_stop='newest'
-        [[ "$compconfig[history_stop]" = verbose ]] &&
-          _message 'end of history reached'
+        [[ "$stop" = verbose ]] && _message 'end of history reached'
       elif [[ "$_hist_stop" == 'oldest' ]]; then
         zle -Rc
         _history_complete_word_gen_matches
@@ -66,14 +68,14 @@ _history_complete_word () {
 }
 
 _history_complete_word_gen_matches () {
-  if [[ -n "$compconfig[history_list]" ]]; then
-    if [[ -n "$compconfig[history_sort]" ]]; then
+  if _style history-entries list; then
+    if _style history-entries sort; then
       _description expl 'history word'
     else
       _description -V expl 'history word'
     fi
   else
-    if [[ -n "$compconfig[history_sort]" ]]; then
+    if _style history-entries sort; then
       expl=()
     else
       expl=('-V' '')
@@ -83,7 +85,7 @@ _history_complete_word_gen_matches () {
   [[ -n "$_hist_stop" ]] && PREFIX="$_hist_old_prefix"
 
   local rem_dups
-  if [[ -n "$compconfig[history_remove_all_dups]" ]]; then
+  if _style history-entries remove-all-dups; then
     rem_dups=''
   else
     rem_dups='-1'
diff --git a/Completion/Commands/_read_comp b/Completion/Commands/_read_comp
index 8a46d8af2..a956c65f7 100644
--- a/Completion/Commands/_read_comp
+++ b/Completion/Commands/_read_comp
@@ -22,8 +22,8 @@
 # Global variables used:
 #  _read_comp         Last completion string read from user
 
-emulate -L zsh
-setopt extendedglob nobadpattern # xtrace promptsubst
+# emulate -L zsh
+setopt localoptions extendedglob nobadpattern # xtrace promptsubst
 # local PS4='%N:%i:$((#key))> '
 
 # Took me ages to work this out.  If we're not on the first global