From: Peter Stephenson <pws@csr.com>
To: zsh-workers@sunsite.dk (Zsh hackers list)
Subject: PATCH: list handled MIME types by suffix
Date: Mon, 23 Jun 2008 14:30:34 +0100 [thread overview]
Message-ID: <6745.1214227834@csr.com> (raw)
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
reply other threads:[~2008-06-23 13:31 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6745.1214227834@csr.com \
--to=pws@csr.com \
--cc=zsh-workers@sunsite.dk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).