unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#56552: [PATCH] Make gnus display webp images inline
@ 2022-07-14 12:33 Visuwesh
  2022-07-14 13:42 ` Stefan Kangas
  2022-07-14 17:42 ` Lars Ingebrigtsen
  0 siblings, 2 replies; 5+ messages in thread
From: Visuwesh @ 2022-07-14 12:33 UTC (permalink / raw)
  To: 56552

[-- Attachment #1: Type: text/plain, Size: 423 bytes --]

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).  ]


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Make-gnus-display-webp-images-inline.patch --]
[-- Type: text/patch, Size: 1504 bytes --]

From d4ed7bae076319cae3d9b0dd82ded37539f4039c Mon Sep 17 00:00:00 2001
From: Visuwesh <visuweshm@gmail.com>
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


[-- Attachment #3: Type: text/plain, Size: 483 bytes --]


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'

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* bug#56552: [PATCH] Make gnus display webp images inline
  2022-07-14 12:33 bug#56552: [PATCH] Make gnus display webp images inline Visuwesh
@ 2022-07-14 13:42 ` Stefan Kangas
  2022-07-14 13:53   ` Visuwesh
  2022-07-14 17:44   ` Lars Ingebrigtsen
  2022-07-14 17:42 ` Lars Ingebrigtsen
  1 sibling, 2 replies; 5+ messages in thread
From: Stefan Kangas @ 2022-07-14 13:42 UTC (permalink / raw)
  To: Visuwesh; +Cc: 56552

Visuwesh <visuweshm@gmail.com> writes:

> 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)

Maybe this comment belongs in a separate wishlist item, but why isn't
this all using the `image-file-name-regexp' function?

I'm looking at `org-display-inline-images', and it seems to me that
org-mode didn't need any additional changes at all to get support for
inline webp images once Emacs had it?  So would it be better if Gnus did
things more like org-mode?

> 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

This part LGTM.





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#56552: [PATCH] Make gnus display webp images inline
  2022-07-14 13:42 ` Stefan Kangas
@ 2022-07-14 13:53   ` Visuwesh
  2022-07-14 17:44   ` Lars Ingebrigtsen
  1 sibling, 0 replies; 5+ messages in thread
From: Visuwesh @ 2022-07-14 13:53 UTC (permalink / raw)
  To: Stefan Kangas; +Cc: 56552

[வியாழன் ஜூலை 14, 2022] Stefan Kangas wrote:

> Visuwesh <visuweshm@gmail.com> writes:
>
>> 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)
>
> Maybe this comment belongs in a separate wishlist item, but why isn't
> this all using the `image-file-name-regexp' function?
>
> I'm looking at `org-display-inline-images', and it seems to me that
> org-mode didn't need any additional changes at all to get support for
> inline webp images once Emacs had it?  So would it be better if Gnus did
> things more like org-mode?

I will leave this to a Gnus expert to answer.  I arrived at that answer
after edebugging around in the relevant Gnus functions.

>> diff --git a/lisp/net/mailcap.el b/lisp/net/mailcap.el
>
> This part LGTM.

Thanks.





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#56552: [PATCH] Make gnus display webp images inline
  2022-07-14 12:33 bug#56552: [PATCH] Make gnus display webp images inline Visuwesh
  2022-07-14 13:42 ` Stefan Kangas
@ 2022-07-14 17:42 ` Lars Ingebrigtsen
  1 sibling, 0 replies; 5+ messages in thread
From: Lars Ingebrigtsen @ 2022-07-14 17:42 UTC (permalink / raw)
  To: Visuwesh; +Cc: 56552

Visuwesh <visuweshm@gmail.com> writes:

> 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).  ]

Thanks; pushed to Emacs 29.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#56552: [PATCH] Make gnus display webp images inline
  2022-07-14 13:42 ` Stefan Kangas
  2022-07-14 13:53   ` Visuwesh
@ 2022-07-14 17:44   ` Lars Ingebrigtsen
  1 sibling, 0 replies; 5+ messages in thread
From: Lars Ingebrigtsen @ 2022-07-14 17:44 UTC (permalink / raw)
  To: Stefan Kangas; +Cc: 56552, Visuwesh

Stefan Kangas <stefan@marxist.se> writes:

>>    `(("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)
>
> Maybe this comment belongs in a separate wishlist item, but why isn't
> this all using the `image-file-name-regexp' function?

I think this code is this way for historical reasons -- different image
types were handled differently at one time (I think), but they now all
call `mm-valid-and-fit-image-p'.  So, yes, it should all be rewritten.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-07-14 17:44 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-14 12:33 bug#56552: [PATCH] Make gnus display webp images inline Visuwesh
2022-07-14 13:42 ` Stefan Kangas
2022-07-14 13:53   ` Visuwesh
2022-07-14 17:44   ` Lars Ingebrigtsen
2022-07-14 17:42 ` Lars Ingebrigtsen

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).