summary refs log tree commit diff
path: root/Functions/MIME
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2011-11-20 16:05:12 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2011-11-20 16:05:12 +0000
commit6e29de366cadd79b66b8e8eb1426cff06d407074 (patch)
treee5ee63987a2a62a247bcf07fdc2946ff3060a02f /Functions/MIME
parent7c4a81113448b4177bd9c35fd5b04b60dcaf35a7 (diff)
downloadzsh-6e29de366cadd79b66b8e8eb1426cff06d407074.tar.gz
zsh-6e29de366cadd79b66b8e8eb1426cff06d407074.tar.xz
zsh-6e29de366cadd79b66b8e8eb1426cff06d407074.zip
Missed file.
Diffstat (limited to 'Functions/MIME')
-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