summaryrefslogtreecommitdiff
path: root/Functions/MIME
diff options
context:
space:
mode:
Diffstat (limited to 'Functions/MIME')
-rw-r--r--Functions/MIME/zsh-mime-handler23
1 files changed, 21 insertions, 2 deletions
diff --git a/Functions/MIME/zsh-mime-handler b/Functions/MIME/zsh-mime-handler
index 52be70618..83df242af 100644
--- a/Functions/MIME/zsh-mime-handler
+++ b/Functions/MIME/zsh-mime-handler
@@ -48,7 +48,7 @@ suffix=$match[1]
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 @@ local -a exec_asis
# 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 @@ for pattern in $exec_asis; do
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 ||