Subject: [PATCH] Make gnus display webp images inline

From: Visuwesh <[email-masked]>
Date: Thu, 14 Jul 2022 18:03:13 +0530

Tags: patch

Severity: wishlist

Now that Emacs has native support for display webp images, we should add
a handler to display it inline.

I also added image/webp to mailcap-mime-extensions since in my Debian
installation, I had no entry for it in /etc/mime.types.  
[ Since *.webp wasn't in that variable, nneething didn't do the Right
  Thing™ to display webp file (it inserted the file as plain text).  ]

>From d4ed7bae076319cae3d9b0dd82ded37539f4039c Mon Sep 17 00:00:00 2001
From: Visuwesh <[email-masked]>
Date: Thu, 14 Jul 2022 17:45:31 +0530
Subject: [PATCH] Make gnus display webp images inline

* lisp/gnus/mm-decode.el (mm-inline-media-tests): Add webp handler.
* lisp/net/mailcap.el (mailcap-mime-extensions): Add webp mimetype.
---
 lisp/gnus/mm-decode.el | 6 +++++-
 lisp/net/mailcap.el    | 1 +
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/lisp/gnus/mm-decode.el b/lisp/gnus/mm-decode.el
index 7256e5a2f7..79217d3400 100644
--- a/lisp/gnus/mm-decode.el
+++ b/lisp/gnus/mm-decode.el
@@ -193,7 +193,11 @@ mm-inline-media-tests
   `(("image/p?jpeg"
      mm-inline-image
      ,(lambda (handle)
-       (mm-valid-and-fit-image-p 'jpeg handle)))
+        (mm-valid-and-fit-image-p 'jpeg handle)))
+    ("image/webp"
+     mm-inline-image
+     ,(lambda (handle)
+       (mm-valid-and-fit-image-p 'webp handle)))
     ("image/png"
      mm-inline-image
      ,(lambda (handle)
diff --git a/lisp/net/mailcap.el b/lisp/net/mailcap.el
index 8ba7f1bec3..ee72eba35d 100644
--- a/lisp/net/mailcap.el
+++ b/lisp/net/mailcap.el
@@ -974,6 +974,7 @@ mailcap-mime-extensions
     (".ai"    . "application/postscript")
     (".jpe"   . "image/jpeg")
     (".jpeg"  . "image/jpeg")
+    (".webp"  . "image/webp")
     (".org"   . "text/x-org"))
   "An alist of file extensions and corresponding MIME content-types.
 This exists for you to customize the information in Lisp.  It is
-- 
2.35.1

In GNU Emacs 29.0.50 (build 11, x86_64-pc-linux-gnu, X toolkit, Xaw scroll bars)
 of 2022-07-14 built on astatine
Repository revision: d37ba6f259b972aa44c66ecb76210e03a3084183
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12101003
System Description: Debian GNU/Linux bookworm/sid

Configured using:
 'configure --with-sound=alsa --with-x-toolkit=lucid --with-json
 --without-xaw3d --without-gconf --without-libsystemd --without-cairo'