* PATCH: list handled MIME types by suffix
@ 2008-06-23 13:30 Peter Stephenson
0 siblings, 0 replies; only message in thread
From: Peter Stephenson @ 2008-06-23 13:30 UTC (permalink / raw)
To: Zsh hackers list
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@csr.com> Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2008-06-23 13:31 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-06-23 13:30 PATCH: list handled MIME types by suffix Peter Stephenson
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).