* PATCH: non-existent files in MIME handler
@ 2006-08-09 15:17 Peter Stephenson
0 siblings, 0 replies; only message in thread
From: Peter Stephenson @ 2006-08-09 15:17 UTC (permalink / raw)
To: Zsh hackers list
I have the numbers 1 to 8 registered as suffixes that use the MIME
handler, in order to show manual pages. Then I needed to run
"evolution-2.4" (except that didn't work anyway, but that's another
story).
The fix here is reasonably straightforward and configurable, I think,
although there may be arguments about suitable a default.
It also fixes the bug that the status of commands passed through by the
similar execute-as-is mechanism was lost, since the handler always
returned 0.
Index: Doc/Zsh/contrib.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/contrib.yo,v
retrieving revision 1.59
diff -u -r1.59 contrib.yo
--- Doc/Zsh/contrib.yo 28 Jul 2006 09:52:35 -0000 1.59
+++ Doc/Zsh/contrib.yo 9 Aug 2006 15:11:18 -0000
@@ -1432,6 +1432,15 @@
Defines flags to go with a handler; the context is as for the
tt(handler) style, and the format is as for the flags in tt(mailcap).
)
+item(tt(handle-nonexistent))(
+By default, arguments that don't correspond to files are not passed
+to the MIME handler in order to prevent it from intercepting commands found
+in the path that happen to have suffixes. This style may be set to
+an array of extended glob patterns for arguments that will be passed to the
+handler even if they don't exist. If it is not explicitly set it
+defaults to tt([[:alpha:]]:/*) which allows URLs to be passed to the MIME
+handler even though they don't exist in that format in the file system.
+)
item(tt(handler))(
Specifies a handler for a suffix; the suffix is given by the context as
tt(:mime:.)var(suffix)tt(:), and the format of the handler is exactly
Index: Functions/MIME/zsh-mime-handler
===================================================================
RCS file: /cvsroot/zsh/zsh/Functions/MIME/zsh-mime-handler,v
retrieving revision 1.8
diff -u -r1.8 zsh-mime-handler
--- Functions/MIME/zsh-mime-handler 11 Apr 2006 18:49:05 -0000 1.8
+++ Functions/MIME/zsh-mime-handler 9 Aug 2006 15:11:18 -0000
@@ -48,7 +48,7 @@
context=":mime:.${suffix}:"
local handler flags no_sh no_bg
-local -a exec_asis
+local -a exec_asis hand_nonex
# Set to a list of patterns which are ignored and executed as they are,
# despite being called for interpretation by the mime handler.
@@ -56,6 +56,11 @@
# they are, even if they have a suffix.
zstyle -a $context execute-as-is exec_asis || exec_asis=('*(*)' '*(/)')
+# Set to a list of patterns for which the handler will be used even
+# if the file doesn't exist on the disk.
+zstyle -a $context handle-nonexistent hand_nonex ||
+ hand_nonex=('[[:alpha:]]#:/*')
+
local pattern
local -a files
@@ -74,10 +79,24 @@
files=(${dirpref}${~pattern})
if [[ -n ${files[(r)$1]} ]]; then
"$@"
- return 0
+ return
fi
done
+if [[ ! -e $1 ]]; then
+ local nonex_ok
+ for pattern in $hand_nonex; do
+ if [[ $1 = ${~pattern} ]]; then
+ nonex_ok=1
+ break
+ fi
+ done
+ if [[ -z $nonex_ok ]]; then
+ "$@"
+ return
+ fi
+fi
+
zstyle -s $context handler handler ||
handler="${zsh_mime_handlers[$suffix]}"
zstyle -s $context flags flags ||
--
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
To access the latest news from CSR copy this link into a web browser: http://www.csr.com/email_sig.php
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2006-08-09 15:20 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-08-09 15:17 PATCH: non-existent files in MIME handler 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).