Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: list handled MIME types by suffix
- X-seq: zsh-workers 25236
- From: Peter Stephenson <pws@xxxxxxx>
- To: zsh-workers@xxxxxxxxxx (Zsh hackers list)
- Subject: PATCH: list handled MIME types by suffix
- Date: Mon, 23 Jun 2008 14:30:34 +0100
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
This is a small enhancement for "zsh-mime-setup -l" to take arguments.
I thought about expanding completion for suffix aliases in verbose mode
to show what handler would be executed, but unfortunately completion for
suffix aliases disappaers into _path_files, from which no one has ever
returned. Possibly I can persuade _list_files to do something clever
(since I wrote that for the purpose of a software trick called "code
reusability" that the completion system doesn't generally implement).
Index: Doc/Zsh/contrib.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/contrib.yo,v
retrieving revision 1.80
diff -u -r1.80 contrib.yo
--- Doc/Zsh/contrib.yo 13 Jun 2008 13:57:04 -0000 1.80
+++ Doc/Zsh/contrib.yo 23 Jun 2008 13:24:52 -0000
@@ -1504,7 +1504,7 @@
startitem()
findex(zsh-mime-setup)
findex(zsh-mime-handler)
-xitem(tt(zsh-mime-setup [-flv]))
+xitem(tt(zsh-mime-setup) [ tt(-fv) ] [ tt(-l) [ var(suffix ...) ] ])
item(tt(zsh-mime-handler))(
These two functions use the files tt(~/.mime.types) and tt(/etc/mime.types),
which associate types and extensions, as well as tt(~/.mailcap) and
@@ -1525,8 +1525,14 @@
mapping between suffixes and executable files unless the option tt(-f)
is given. Note, however, that this does not override existing suffix
aliases assigned to handlers other than tt(zsh-mime-handler).
+
Calling tt(zsh-mime-setup) with the option tt(-l) lists the existing
-mappings without altering them. Calling tt(zsh-mime-setup) with the option
+mappings without altering them. Suffixes to list (which may contain
+pattern characters that should be quoted from immediate interpretation
+on the command line) may be given as additional arguments, otherwise
+all suffixes are listed.
+
+Calling tt(zsh-mime-setup) with the option
tt(-v) causes verbose output to be shown during the setup operation.
The system respects the tt(mailcap) flags tt(needsterminal) and
Index: Functions/MIME/zsh-mime-setup
===================================================================
RCS file: /cvsroot/zsh/zsh/Functions/MIME/zsh-mime-setup,v
retrieving revision 1.5
diff -u -r1.5 zsh-mime-setup
--- Functions/MIME/zsh-mime-setup 19 Feb 2006 21:20:43 -0000 1.5
+++ Functions/MIME/zsh-mime-setup 23 Jun 2008 13:24:52 -0000
@@ -37,7 +37,13 @@
# so we don't need to search styles for suffixes that aren't
# handled. Yet.
local list_word
- for suffix in ${(ko)zsh_mime_handlers}; do
+ local -a handlers
+ if (( $# )); then
+ handlers=(${(k)zsh_mime_handlers[(I)${(j.|.)*}]})
+ else
+ handlers=(${(k)zsh_mime_handlers})
+ fi
+ for suffix in ${(o)handlers}; do
zstyle -s ":mime:.$suffix:" handler list_word ||
list_word=${zsh_mime_handlers[$suffix]}
print ${(r.10.)suffix}$list_word
--
Peter Stephenson <pws@xxxxxxx> Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070
Messages sorted by:
Reverse Date,
Date,
Thread,
Author