summaryrefslogtreecommitdiff
path: root/lisp/net/mailcap.el
diff options
context:
space:
mode:
authorLars Ingebrigtsen <larsi@gnus.org>2017-12-25 11:29:41 +0100
committerLars Ingebrigtsen <larsi@gnus.org>2017-12-25 16:05:06 +0100
commit4ddf0b8e43537626aa5aa49122b1fe7a9ad3adc3 (patch)
tree708a52966897e508e837483ddf9555a1bf8ea4fe /lisp/net/mailcap.el
parent53a32e6636f391212c662f2f3d4b671e96610b7a (diff)
downloademacs-4ddf0b8e43537626aa5aa49122b1fe7a9ad3adc3.tar.gz
emacs-4ddf0b8e43537626aa5aa49122b1fe7a9ad3adc3.tar.bz2
emacs-4ddf0b8e43537626aa5aa49122b1fe7a9ad3adc3.zip
lisp/net/mailcap.el (mailcap-file-name-to-mime-type): New function.
* lisp/net/mailcap.el (mailcap-file-name-to-mime-type): New function.
Diffstat (limited to 'lisp/net/mailcap.el')
-rw-r--r--lisp/net/mailcap.el8
1 files changed, 8 insertions, 0 deletions
diff --git a/lisp/net/mailcap.el b/lisp/net/mailcap.el
index be1a171cd48..197d233ddad 100644
--- a/lisp/net/mailcap.el
+++ b/lisp/net/mailcap.el
@@ -1006,6 +1006,14 @@ If FORCE, re-parse even if already parsed."
(setq extn (concat "." extn)))
(cdr (assoc (downcase extn) mailcap-mime-extensions)))
+(defun mailcap-file-name-to-mime-type (file-name)
+ "Return the MIME content type based on the FILE-NAME's extension.
+For instance, \"foo.png\" will result in \"image/png\"."
+ (mailcap-extension-to-mime
+ (if (string-match "\\(\\.[^.]+\\)\\'" file-name)
+ (match-string 1 file-name)
+ "")))
+
(defun mailcap-mime-types ()
"Return a list of MIME media types."
(mailcap-parse-mimetypes)