aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCecilio Pardo2024-10-27 14:39:34 +0100
committerEli Zaretskii2024-10-31 12:36:31 +0200
commitbf395fd8bcc68499479cd6df31319eca93509359 (patch)
treee9c2a3624b553ec608b395c51b61c7584cd81412
parent9c5b6e88e7f851e239721a0fd855fbcd10b5b0a3 (diff)
downloademacs-bf395fd8bcc68499479cd6df31319eca93509359.tar.gz
emacs-bf395fd8bcc68499479cd6df31319eca93509359.zip
Fix 'yank-media' to allow yanking SVG data
* lisp/net/mailcap.el (mailcap-mime-type-to-extension): Return "svg" for mime type 'image/svg+xml'. Org-mode uses this. * lisp/yank-media.el (yank-media--find-matching-media): If svg is supported, don't filter out 'image/svg+xml'. (Bug#74044)
-rw-r--r--lisp/net/mailcap.el15
-rw-r--r--lisp/yank-media.el7
2 files changed, 17 insertions, 5 deletions
diff --git a/lisp/net/mailcap.el b/lisp/net/mailcap.el
index 3e847c758c2..d3ca899216a 100644
--- a/lisp/net/mailcap.el
+++ b/lisp/net/mailcap.el
@@ -1084,10 +1084,17 @@ For instance, \"foo.png\" will result in \"image/png\"."
1084(defun mailcap-mime-type-to-extension (mime-type) 1084(defun mailcap-mime-type-to-extension (mime-type)
1085 "Return a file name extension based on a MIME-TYPE. 1085 "Return a file name extension based on a MIME-TYPE.
1086For instance, `image/png' will result in `png'." 1086For instance, `image/png' will result in `png'."
1087 (intern (cadr (split-string (if (symbolp mime-type) 1087 (intern
1088 (symbol-name mime-type) 1088 (let ((e (cadr (split-string (if (symbolp mime-type)
1089 mime-type) 1089 (symbol-name mime-type)
1090 "/")))) 1090 mime-type)
1091 "/"))))
1092 ;; Usually, the normal extension is the same as the MIME subtype.
1093 ;; But for SVG files, the extension is "svg" and the MIME type is
1094 ;; "svg+xml".
1095 (if (string= e "svg+xml")
1096 "svg"
1097 e))))
1091 1098
1092(defun mailcap-mime-types () 1099(defun mailcap-mime-types ()
1093 "Return a list of MIME media types." 1100 "Return a list of MIME media types."
diff --git a/lisp/yank-media.el b/lisp/yank-media.el
index 6655bb705ef..17981c37c0e 100644
--- a/lisp/yank-media.el
+++ b/lisp/yank-media.el
@@ -67,7 +67,12 @@ all the different selection types."
67 (lambda (type) 67 (lambda (type)
68 (pcase-let ((`(,major ,minor) (split-string (symbol-name type) "/"))) 68 (pcase-let ((`(,major ,minor) (split-string (symbol-name type) "/")))
69 (if (and (equal major "image") 69 (if (and (equal major "image")
70 (not (image-type-available-p (intern minor)))) 70 (not (image-type-available-p
71 ;; Usually, MIME subtype is the same as Emacs'
72 ;; identifier for an image type. But for SVG, the
73 ;; identifier is 'svg, while the MIME type is
74 ;; image/svg+xml. So we make the exception here.
75 (intern (if (string= minor "svg+xml") "svg" minor)))))
71 ;; Just filter out all the image types that Emacs doesn't 76 ;; Just filter out all the image types that Emacs doesn't
72 ;; support, because the clipboard is full of things like 77 ;; support, because the clipboard is full of things like
73 ;; `image/x-win-bitmap'. 78 ;; `image/x-win-bitmap'.