emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master bf395fd8bcc: Fix 'yank-media' to allow yanking SVG data


From: Eli Zaretskii
Subject: master bf395fd8bcc: Fix 'yank-media' to allow yanking SVG data
Date: Thu, 31 Oct 2024 06:37:30 -0400 (EDT)

branch: master
commit bf395fd8bcc68499479cd6df31319eca93509359
Author: Cecilio Pardo <cpardo@imayhem.com>
Commit: Eli Zaretskii <eliz@gnu.org>

    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)
---
 lisp/net/mailcap.el | 15 +++++++++++----
 lisp/yank-media.el  |  7 ++++++-
 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\"."
 (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)
-                              "/"))))
+  (intern
+   (let ((e (cadr (split-string (if (symbolp mime-type)
+                                    (symbol-name mime-type)
+                                  mime-type)
+                                "/"))))
+     ;; Usually, the normal extension is the same as the MIME subtype.
+     ;; But for SVG files, the extension is "svg" and the MIME type is
+     ;; "svg+xml".
+     (if (string= e "svg+xml")
+         "svg"
+       e))))
 
 (defun mailcap-mime-types ()
   "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."
    (lambda (type)
      (pcase-let ((`(,major ,minor) (split-string (symbol-name type) "/")))
        (if (and (equal major "image")
-                (not (image-type-available-p (intern minor))))
+                (not (image-type-available-p
+                      ;; Usually, MIME subtype is the same as Emacs'
+                      ;; identifier for an image type.  But for SVG, the
+                      ;; identifier is 'svg, while the MIME type is
+                      ;; image/svg+xml. So we make the exception here.
+                      (intern (if (string= minor "svg+xml") "svg" minor)))))
            ;; Just filter out all the image types that Emacs doesn't
            ;; support, because the clipboard is full of things like
            ;; `image/x-win-bitmap'.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]