about summary refs log tree commit diff
path: root/Completion/User/_mh
diff options
context:
space:
mode:
Diffstat (limited to 'Completion/User/_mh')
-rw-r--r--Completion/User/_mh31
1 files changed, 17 insertions, 14 deletions
diff --git a/Completion/User/_mh b/Completion/User/_mh
index f02aee9b5..aacde38a1 100644
--- a/Completion/User/_mh
+++ b/Completion/User/_mh
@@ -17,13 +17,16 @@ if compset -P 1 -; then
   # get list of options, which MH commands can generate themselves
   # awk is just too icky to use for this, sorry.  send me one if
   # you come up with it.
-  _wanted options expl option &&
-      compadd "$expl[@]" - $($words[1] -help | perl -ne 'if (/^\s*-\(?(\S+)/) {
+  if _wanted options; then
+    _loop options expl option \
+        compadd - $($words[1] -help | perl -ne 'if (/^\s*-\(?(\S+)/) {
             $n = $1;
             $n =~ s/\)//g;
             print $n =~ s/^\[([a-z]+)\]// ? "$n\n$1$n\n" : "$n\n";
           }')
-  return
+    return
+  fi
+  return 1
 elif compset -P 1 '[+@]' || [[ "$prev" = -draftfolder ]]; then
   # Complete folder names.
   local mhpath
@@ -35,7 +38,7 @@ elif compset -P 1 '[+@]' || [[ "$prev" = -draftfolder ]]; then
     mhpath=$(mhpath)
   fi
 
-  _wanted files expl 'MH folder' && _path_files "$expl[@]" -W mhpath -/
+  _wanted files expl 'MH folder' _path_files -W mhpath -/
 elif [[ "$prev" = -(editor|(whatnow|rmm|show|more)proc) ]]; then
   _command_names -e
 elif [[ "$prev" = -file ]]; then
@@ -48,14 +51,11 @@ elif [[ "$prev" = -(form|audit|filter) ]]; then
   [[ -d $mhlib ]] || { mhlib=$(mhparam mhlproc); mhlib=$mhlib:h; }
   mhfpath=($mymhdir $mhlib)
 
-  _wanted files expl 'MH template file' &&
-    _files "$expl[@]" -W mhfpath -g '*(.)'
+  _wanted files expl 'MH template file' _files -W mhfpath -g '*(.)'
 elif [[ "$prev" = -(no|)cc ]]; then
-  _wanted -C "$prev" values expl 'CC address' &&
-      compadd "$expl[@]" all to cc me
+  _wanted -C "$prev" values expl 'CC address' compadd all to cc me
 elif [[ "$prev" = -[rw]cache ]]; then
-  _wanted -C "$prev" values expl cache &&
-      compadd "$expl[@]" public private never ask
+  _wanted -C "$prev" values expl cache compadd public private never ask
 else
   # Generate sequences.
   local foldnam folddir f ret
@@ -72,11 +72,14 @@ else
     # leaving foldnam empty works here
   fi
 
-  if _wanted sequences expl sequence; then
-    compadd "$expl[@]" $(mark $foldnam 2>/dev/null | awk -F: '{ print $1 }') &&
+  if _wanted sequences; then
+    while _try sequences expl sequence; do
+      compadd "$expl[@]" $(mark $foldnam 2>/dev/null | awk -F: '{ print $1 }') &&
         ret=0
-    compadd "$expl[@]" reply next cur prev first last all unseen && ret=0
-    _files "$expl[@]" -W folddir -g '<->' && ret=0
+      compadd "$expl[@]" reply next cur prev first last all unseen && ret=0
+      _files "$expl[@]" -W folddir -g '<->' && ret=0
+      (( ret )) || return 0
+    done
   fi
   return ret
 fi