From: Lars Ingebrigtsen Date: Sat, 6 Nov 2021 20:14:54 +0000 (+0100) Subject: Add new function mailcap-mime-type-to-extension X-Git-Tag: emacs-29.0.90~3671^2~171 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=5a4f98b0b6d503b1ce68bb29937a84acf3ef97da;p=emacs.git Add new function mailcap-mime-type-to-extension * lisp/net/mailcap.el (mailcap-mime-type-to-extension): Add a new helper function to do the reverse of `mailcap-file-name-to-mime-type'. --- diff --git a/lisp/net/mailcap.el b/lisp/net/mailcap.el index df6bdd1aba5..0ad1a53e846 100644 --- a/lisp/net/mailcap.el +++ b/lisp/net/mailcap.el @@ -1068,6 +1068,14 @@ For instance, \"foo.png\" will result in \"image/png\"." (match-string 1 file-name) ""))) +(defun mailcap-mime-type-to-extension (mime-type) + "Return a file name extension based on a mime type. +For instance, `image/png' will result in `png'." + (intern (cadr (split-string (if (symbolp mime-type) + (symbol-name mime-type) + mime-type) + "/")))) + (defun mailcap-mime-types () "Return a list of MIME media types." (mailcap-parse-mimetypes)