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

PATCH: improve completion of mh sequences



_mh now handles the Sequence-Negation profile option. You may want to
use ignored-patterns to initially suppress these. I use the following
style which also supresses the message numbers:
  zstyle ':completion::(^approximate*):*:sequences' ignored-patterns '(not*|<->)'

It also now copes with '-' for message ranges and `:' which allows the
number of messages to be limited.

I've also corrected the list of pre-defined message sequences. You may
want to use the fake style for the mark command if you have certain
favourite sequence names.

Oliver

Index: Completion/Unix/Command/_mh
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_mh,v
retrieving revision 1.5
diff -u -r1.5 _mh
--- Completion/Unix/Command/_mh	21 Jan 2004 13:53:29 -0000	1.5
+++ Completion/Unix/Command/_mh	19 May 2005 10:13:13 -0000
@@ -1,4 +1,4 @@
-#compdef ali burst dist flist flists folder folders forw comp inc mark refile repl scan show next prev packf rmf rmm pick whom mhn mhpath mhlist mhstore mhshow mhparam mhmail
+#compdef ali anno burst comp dist flist flists folder folders forw inc mark mhlist mhmail mhn mhparam mhpath mhshow mhstore msgchk next packf pick prev refile repl rmf rmm scan show sortm whom
 
 # Completion for all possible MH commands.
 local mymhdir=${$(_call_program mhpath mhpath + 2>/dev/null):-~/Mail}
@@ -61,9 +61,13 @@
     ${${(f)"$(mhparam -all)"}%%:*}
 elif [[ $service = ali ]]; then
   _email_addresses -n MH
+elif compset -P '*:'; then
+  _message -e number 'number of messages'
 else
   # Generate sequences.
-  local foldnam folddir f ret
+  local foldnam folddir f sequences mhneg ret=1
+
+  compset -P '*-' # ignore start of message range
 
   for f in $words; do
     [[ $f = [@+]* ]] && foldnam=$f
@@ -77,13 +81,15 @@
     # leaving foldnam empty works here
   fi
 
+  sequences=( ${${(f)"$(mark $foldnam 2>/dev/null)"}%%:*} )
+  mhneg="$(mhparam Sequence-Negation)" && sequences=( {,$mhneg}$^sequences )
+  sequences+=( all first last prev next )
   _tags sequences
   while _tags; do
     while _next_label 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
-      _path_files "$expl[@]" -W folddir -g '<->(-.)' && ret=0
+      compadd -S ' ' -r '-: \t\n\-' "$expl[@]" -a sequences && ret=0
+      _path_files -S ' ' -r '-: \t\n\-' "$expl[@]" -W folddir -g '<->(-.)' &&
+          ret=0
     done
     (( ret )) || return 0
   done



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