Commit 4ddf0b8e authored by Lars Ingebrigtsen's avatar Lars Ingebrigtsen

lisp/net/mailcap.el (mailcap-file-name-to-mime-type): New function.

* lisp/net/mailcap.el (mailcap-file-name-to-mime-type): New function.
parent 53a32e66
......@@ -210,6 +210,11 @@ a multibyte string even if its second argument is an ASCII character.
'json-insert', 'json-parse-string', and 'json-parse-buffer'. These
are implemented in C using the Jansson library.
** The new function `mailcap-file-name-to-mime-type' has been added.
It's a simple convenience function for looking up MIME types based on
file name extensions.
* Changes in Emacs 27.1 on Non-Free Operating Systems
......@@ -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\"."
(if (string-match "\\(\\.[^.]+\\)\\'" file-name)
(match-string 1 file-name)
(defun mailcap-mime-types ()
"Return a list of MIME media types."
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment