Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: completion for MUAs
- X-seq: zsh-workers 13982
- From: Oliver Kiddle <opk@xxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxx
- Subject: PATCH: completion for MUAs
- Date: Fri, 13 Apr 2001 19:31:59 +0100
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- Sender: kiddleo@xxxxxxxxxxxxxxxx
On 20th March, Peter Stephenson wrote:
> - There are no completions for standard mail programmes or common
> tools like elm and pine.
This patch adds these.
I used pine 4.21 and elm 2.4ME+ PL66 which are the versions which
happened to be on a machine at work. It is fairly probable that there
have since been changes to either of these. I've never been an elm user,
ever, so it might be useful if someone else checked the completion. I
left out the UWIN options for pine but they can always be added.
The UNIX `standard mail programmes' are unfortunately not as standard as
they maybe used to be. Linux has one programme which mostly resembles
BSD Mail. What I've done is made it complete the common options which
take an argument so that we are basically completing the right thing
even if all the options aren't listed. This does mean that for AT&T
mail, it completes some extra options but it isn't really doing any
harm. Both mush and zmail are basically supersets of BSD mail so I've
included them in the completion. I actually have a more complete mush
completion but it would probably be fairly pointless to add it.
The one thing which hasn't been done for any MUA is to parse the
addressbook/alias list and use it for generating the e-mail addresses.
I'm planning to look at this sometime soonish along with the stuff I
recently mentioned about completing hostnames.
I think that the best thing to do, rather than adding this separately
into each of _pine, _mutt etc would be to have one _email_addresses
which parses all the addressbooks it can find. Obviously we would only
want to complete aliases and nicknames for the appropriate MUA but it
could be useful to be able to complete e-mail addresses in other places
so for example mailto: urls would work and so if you use Mail to quickly
e-mail a file, e-mail addresses from the Netscape addressbook would be
available for completion.
Does anyone have suggestions for getting at or parsing the addressbooks
of different MUAs (apart from MH which is easy)?
Some MUAs are happy with addresses in forms like 'Name <user@host>' and
'user@host (Name)'. Any thoughts on how to deal with these (such as
whether it would be useful to expand to these) and other complications
such as distribution lists would be helpful.
Also in this patch, I've fixed _mutt, _ncftp and _multi_parts where they
weren't declaring a variable local but should have been.
Oliver
Index: Completion/Base/Utility/_multi_parts
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Base/Utility/_multi_parts,v
retrieving revision 1.1
diff -u -r1.1 _multi_parts
--- Completion/Base/Utility/_multi_parts 2001/04/02 11:12:56 1.1
+++ Completion/Base/Utility/_multi_parts 2001/04/13 18:28:50
@@ -7,7 +7,7 @@
# The parts of words from the array that are separated by the
# separator character are then completed independently.
-local sep pref npref i tmp2 group expl menu pre suf opre osuf cpre
+local sep pref npref i tmp2 group expl menu pre suf opre osuf orig cpre
local opts sopts matcher imm
typeset -U tmp1 matches
Index: Completion/Unix/Command/.distfiles
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/.distfiles,v
retrieving revision 1.2
diff -u -r1.2 .distfiles
--- Completion/Unix/Command/.distfiles 2001/04/02 19:21:18 1.2
+++ Completion/Unix/Command/.distfiles 2001/04/13 18:28:50
@@ -11,7 +11,7 @@
_configure _gdb _look _patch _su _zcat
_cpio _getconf _lp _pbm _sudo _zdump
_cvs _gnu_generic _ls _perl _tar _zip
-_dd _gprof _lynx _perldoc _telnet
-_dict _grep _lzop _prcs _tiff
-_diff _gs _make _psutils _tin _apm
+_dd _gprof _lynx _perldoc _telnet _pine
+_dict _grep _lzop _prcs _tiff _elm
+_diff _gs _make _psutils _tin _apm _mail
'
Index: Completion/Unix/Command/_elm
===================================================================
RCS file: _elm
diff -N _elm
--- /dev/null Mon Dec 11 17:26:27 2000
+++ _elm Fri Apr 13 11:28:50 2001
@@ -0,0 +1,33 @@
+#compdef elm
+
+local curcontext="$curcontext" state line expl suf
+
+_arguments -C -s \
+ '::recipient:->userhost' \
+ '-a[use the arrow pointer regardless]' \
+ '-A+[attach file]:file attachment:_files' \
+ '-c[check the given aliases only]:*:alias' \
+ '-d+[set debug level]:debug level' \
+ '-f+[specify mailbox to load]:mailbox: _mailboxes' \
+ '-h[display help]' \
+ '-i+[specify file to include in message]:include file:_files' \
+ '-m[turn off menu, using more of the screen]' \
+ '-s+[specify a subject]:subject:' \
+ "-t[don't use termcap/terminfo ti/te entries]" \
+ '-V[enable sendmail voyeur mode]' \
+ '-v[display elm version]' \
+ '-w[write .elm/elmrc]' \
+ '-z[start only if new messages]' && return 0
+
+if [[ "$state" = userhost ]]; then
+ if compset -P '*@'; then
+ _description hosts expl 'remote host name'
+ _hosts "$expl[@]" && return 0
+ else
+ compset -S '@*' || suf='@'
+ _description users expl 'login name'
+ _users "$expl[@]" -q -S "$suf" && return 0
+ fi
+fi
+
+return 1
Index: Completion/Unix/Command/_mail
===================================================================
RCS file: _mail
diff -N _mail
--- /dev/null Mon Dec 11 17:26:27 2000
+++ _mail Fri Apr 13 11:28:50 2001
@@ -0,0 +1,24 @@
+#compdef mail mailx Mail mush zmail
+
+local curcontext="$curcontext" state line expl suf
+
+_arguments -C -s \
+ '(-f -u)*-b[specify a BCC recipient]:BCC recipient:->userhost' \
+ '(-f -u)*-c[specify a CC recipient]:CC recipient:->userhost' \
+ '(-b -c -u -s *)-f+[specify mail folder]:mailbox:_mailboxes' \
+ '(-f -u)-s+[specify a subject]:subject:' \
+ "(-b -c -f -s *)-u+[read specified user's mail]:user:_users" \
+ '(-f -u)*:recipient:->userhost' && return 0
+
+if [[ "$state" = userhost ]]; then
+ if compset -P '*@'; then
+ _description hosts expl 'remote host name'
+ _hosts "$expl[@]" && return 0
+ else
+ compset -S '@*' || suf='@'
+ _description users expl 'login name'
+ _users "$expl[@]" -q -S "$suf" && return 0
+ fi
+fi
+
+return 1
Index: Completion/Unix/Command/_mutt
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_mutt,v
retrieving revision 1.1
diff -u -r1.1 _mutt
--- Completion/Unix/Command/_mutt 2001/04/02 11:57:59 1.1
+++ Completion/Unix/Command/_mutt 2001/04/13 18:28:50
@@ -1,12 +1,12 @@
#compdef mutt
-local curcontext="$curcontext" state line suf
+local curcontext="$curcontext" state line expl suf
typeset -A opt_args
_arguments -C -s \
'::recipient:->userhost' \
'*-a[attach file using MIME]:file attachment:_files' \
- '*-b[specify a BCC recipient]:BCC recepient:->userhost' \
+ '*-b[specify a BCC recipient]:BCC recipient:->userhost' \
'*-c[specify a CC recipient]:CC recipient:->userhost' \
'-e+[specify a post-init configuration command]:post-init configuration:' \
'-f+[specify mailbox to load]:mailbox: _mailboxes' \
Index: Completion/Unix/Command/_ncftp
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_ncftp,v
retrieving revision 1.1
diff -u -r1.1 _ncftp
--- Completion/Unix/Command/_ncftp 2001/04/02 11:58:34 1.1
+++ Completion/Unix/Command/_ncftp 2001/04/13 18:28:50
@@ -1,6 +1,6 @@
#compdef ncftp lftp
-local bookmarks=$HOME/.$service/bookmarks
+local expl bookmarks=$HOME/.$service/bookmarks
if [[ -f $bookmarks ]]; then
bookmarks=(${"${(f)$(<$bookmarks)}"%%[[:space:],]*})
Index: Completion/Unix/Command/_pine
===================================================================
RCS file: _pine
diff -N _pine
--- /dev/null Mon Dec 11 17:26:27 2000
+++ _pine Fri Apr 13 11:28:50 2001
@@ -0,0 +1,68 @@
+#compdef pine pinef
+
+local curcontext="$curcontext" state line expl suf
+local optfile getopts='pine -conf' sortorder lusortorder opts send idx
+
+if [[ -n $+_cache_pine_options ]]; then
+ for optfile in ~/.pinerc /etc/pine.conf; do
+ if [[ -f $optfile ]]; then
+ getopts="cat $optfile"
+ break
+ fi
+ done
+ _cache_pine_options=( $($=getopts | sed -n 's/^\([^#]*=\).*/-\1/p') )
+fi
+
+sortorder=( {subject,arrival,date,from,size}{,/reverse} )
+lusortorder=( dont-sort {nickname,fullname}{,-with-lists-last} )
+
+opts=( -h -F -conf -create_lu -pinerc ) # exclusive options
+idx=( -f -c -i -I -n -o -sort ) # options used when viewing messages
+send=( -attach -attachlist -attach_and_delete -url ) # options when sending
+
+_arguments -C -s \
+ "($opts $idx $send -bail -k -z -r -p -P *)-h[display help]" \
+ "($opts $idx $send -r *)-F+[specify file to open and page through]:file:_files" \
+ "($opts $idx $send *)-conf[print out fresh global configuration]" \
+ "($opts $idx $send *)-pinerc[put fresh pinerc configuration in file]:file:_files" \
+ "($opts $idx $send *)-create_lu[create .lu from script]:addressbook file:_files:sort order:(${(j: :)lusortorder})" \
+ "($opts $idx -url)-attach[go directly into composer with given file]:file:_files" \
+ "($opts $idx -url)-attachlist[go to composer with given files]:file:_files" \
+ "($opts $idx -url)-attach_and_delete[go to composer, attach file, delete when finished]:file:_files" \
+ "($opts $idx $send)-url[open the given URL]:url:->url" \
+ "($opts $send)-f+[specify mailbox to load]:mailbox: _mailboxes" \
+ "($opts $send)-c+[specify context to apply to -f arg]:number" \
+ "($opts $send)-sort[specify sort order of folder]:sort order:(${(j: :)sortorder})" \
+ "($opts $send)-i[go directly to index, bypassing main menu]" \
+ "($opts $send)-I+[specify initial keystrokes to be executed]:keystrokes" \
+ "($opts $send)-n+[entry in index to begin on]:number" \
+ "($opts $send)-o[open first folder read-only]" \
+ "(-F -h)-r[restricted - can only send mail to oneself]" \
+ "(${opts#-F})-k[force use of function keys]" \
+ "(${opts#-F})-z[allow use of ^Z suspension]" \
+ "(${opts#-F})-p+[use alternate .pinerc file]:alternate pinerc:_files" \
+ "(${opts#-F})-P+[use alternate pine.conf file]:alternate pine.conf:_files" \
+ "(${opts#-F})-bail[exit if pinerc file doesn't already exist]" \
+ '*::recipient:->userhost' \
+ ${^_cache_pine_options}':option value' && return 0
+
+if [[ "$state" = url ]]; then
+ if compset -P 'mailto:'; then
+ state=userhost
+ else
+ compadd -S: mailto && return 0
+ fi
+fi
+
+if [[ "$state" = userhost ]]; then
+ if compset -P '*@'; then
+ _description hosts expl 'remote host name'
+ _hosts "$expl[@]" && return 0
+ else
+ compset -S '@*' || suf='@'
+ _description users expl 'login name'
+ _users "$expl[@]" -q -S "$suf" && return 0
+ fi
+fi
+
+return 1
_____________________________________________________________________
This message has been checked for all known viruses by the
MessageLabs Virus Control Centre. For further information visit
http://www.messagelabs.com/stats.asp
Messages sorted by:
Reverse Date,
Date,
Thread,
Author