summaryrefslogtreecommitdiff
path: root/Functions/MIME/zsh-mime-contexts
diff options
context:
space:
mode:
authorFrank Terbeck <ft@bewatermyfriend.org>2011-12-01 10:02:04 +0100
committerFrank Terbeck <ft@bewatermyfriend.org>2011-12-01 10:02:04 +0100
commitd8da5ea2f2bc5f837d0b364fff2636ebdb2f90ca (patch)
tree9fd9a57486ac4702608d92088ffd91f52971244f /Functions/MIME/zsh-mime-contexts
parentaf2bb4fdb09414d21922d3fafe4e3a0ac1332f01 (diff)
parent9d71f4c207fb34e8d64af0443c83231b1cc3b494 (diff)
downloadzsh-d8da5ea2f2bc5f837d0b364fff2636ebdb2f90ca.tar.gz
zsh-d8da5ea2f2bc5f837d0b364fff2636ebdb2f90ca.zip
Merge commit 'zsh-4.3.13' into debian
Diffstat (limited to 'Functions/MIME/zsh-mime-contexts')
-rw-r--r--Functions/MIME/zsh-mime-contexts24
1 files changed, 24 insertions, 0 deletions
diff --git a/Functions/MIME/zsh-mime-contexts b/Functions/MIME/zsh-mime-contexts
new file mode 100644
index 000000000..08f125158
--- /dev/null
+++ b/Functions/MIME/zsh-mime-contexts
@@ -0,0 +1,24 @@
+# Helper for zsh-mime-handler.
+#
+# Pass in a zstyle option, a suffix, which might include multiple parts
+# (e.g. pdf.gz), plus remaining zstyle arguments plus arguments to zstyle.
+# Try to match the style starting with the longest possible suffix.
+
+local context suffix option
+
+option=$1
+shift
+suffix=$1
+shift
+
+while true; do
+ context=":mime:.${suffix}:"
+ zstyle $option $context "$@" && return 0
+ if [[ $suffix = *.* ]]; then
+ suffix=${suffix#*.}
+ else
+ break
+ fi
+done
+
+return 1