GNU bug report logs -
#50383
28.0.50; [PATCH] Feature suggestion, gnus-article-toggle-fonts to toggle fonts for HTML articles
Previous Next
Reported by: Alex Bochannek <alex <at> bochannek.com>
Date: Sat, 4 Sep 2021 20:55:01 UTC
Severity: normal
Tags: patch
Found in version 28.0.50
Fixed in version 28.1
Done: Lars Ingebrigtsen <larsi <at> gnus.org>
Bug is archived. No further changes may be made.
Full log
Message #20 received at 50383 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Lars Ingebrigtsen <larsi <at> gnus.org> writes:
> Alex Bochannek <alex <at> bochannek.com> writes:
>
>> Just like this then?
>
> Yup, if that does indeed work. :-)
>
>> + ;; Shadow global shr-use-fonts to support font toggling.
>> + (setq-local shr-use-fonts shr-use-fonts)
>
> But perhaps this should be set only if the user uses this command. Can
> you respin the entire patch and we'll get it applied...
I thought about it some more and I don't think it's necessary at all to
initialize the local variable, because it will happen automatically the
first time the command is used. The below should be enough. I tested it
a bit and it works for me.
New Gnus article washing function to toggle HTML fonts
* lisp/gnus/gnus-sum.el (gnus-summary-wash-display-map),
(gnus-summary-make-menu-bar): Add mode mapping and menu item for
article HTML font toggle.
* lisp/gnus/gnus-art.el (gnus-article-toggle-fonts): Toggle
shr-use-fonts and redisplay message.
* doc/misc/gnus.texi (Article Washing): Document new HTML font
toggle function.
Thanks!
[Message part 2 (text/x-patch, inline)]
diff --git a/doc/misc/gnus.texi b/doc/misc/gnus.texi
index 5f3fba00df..c8aec4eea1 100644
--- a/doc/misc/gnus.texi
+++ b/doc/misc/gnus.texi
@@ -9374,6 +9374,12 @@ Article Washing
@end table
+@item W D F
+@kindex W D F @r{(Summary)}
+@findex gnus-article-toggle-fonts
+Toggle proportional fonts for @acronym{HTML} articles. This temporarily
+changes the @code{shr-use-fonts} variable in the current buffer.
+
@item W b
@kindex W b @r{(Summary)}
@findex gnus-article-add-buttons
diff --git a/lisp/gnus/gnus-art.el b/lisp/gnus/gnus-art.el
index 3c1403e155..a962b06372 100644
--- a/lisp/gnus/gnus-art.el
+++ b/lisp/gnus/gnus-art.el
@@ -2243,6 +2243,15 @@ gnus-article-show-images
(funcall function (get-text-property start 'image-url)
start end)))))))
+(defun gnus-article-toggle-fonts ()
+ "Toggle the use of proportional fonts for HTML articles."
+ (interactive nil gnus-article-mode gnus-summary-mode)
+ (gnus-with-article-buffer
+ (if (eq mm-text-html-renderer 'shr)
+ (progn
+ (setq-local shr-use-fonts (not shr-use-fonts))
+ (gnus-summary-show-article)))))
+
(defun gnus-article-treat-fold-newsgroups ()
"Fold the Newsgroups and Followup-To message headers."
(interactive nil gnus-article-mode gnus-summary-mode)
diff --git a/lisp/gnus/gnus-sum.el b/lisp/gnus/gnus-sum.el
index 856e95c0ba..c28e38e315 100644
--- a/lisp/gnus/gnus-sum.el
+++ b/lisp/gnus/gnus-sum.el
@@ -2252,6 +2252,7 @@ gnus-summary-mode-map
"s" gnus-treat-smiley
"D" gnus-article-remove-images
"W" gnus-article-show-images
+ "F" gnus-article-toggle-fonts
"f" gnus-treat-from-picon
"m" gnus-treat-mail-picon
"n" gnus-treat-newsgroups-picon
@@ -2561,6 +2562,7 @@ gnus-summary-make-menu-bar
["Unfold headers" gnus-article-treat-unfold-headers t]
["Fold newsgroups" gnus-article-treat-fold-newsgroups t]
["Html" gnus-article-wash-html t]
+ ["Toggle HTML fonts" gnus-article-toggle-fonts t]
["Unsplit URLs" gnus-article-unsplit-urls t]
["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
["Decode HZ" gnus-article-decode-HZ t]
[Message part 3 (text/plain, inline)]
--
Alex.
This bug report was last modified 3 years and 252 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.