[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 5a4f98b 2/3: Add new function mailcap-mime-type-to-extension
From: |
Lars Ingebrigtsen |
Subject: |
master 5a4f98b 2/3: Add new function mailcap-mime-type-to-extension |
Date: |
Sat, 6 Nov 2021 16:59:36 -0400 (EDT) |
branch: master
commit 5a4f98b0b6d503b1ce68bb29937a84acf3ef97da
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>
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'.
---
lisp/net/mailcap.el | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/lisp/net/mailcap.el b/lisp/net/mailcap.el
index df6bdd1..0ad1a53 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)