[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#50383: 28.0.50; [PATCH] Feature suggestion, gnus-article-toggle-font
From: |
Alex Bochannek |
Subject: |
bug#50383: 28.0.50; [PATCH] Feature suggestion, gnus-article-toggle-fonts to toggle fonts for HTML articles |
Date: |
Sun, 05 Sep 2021 22:22:35 -0700 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (darwin) |
Lars Ingebrigtsen <larsi@gnus.org> writes:
> Alex Bochannek <alex@bochannek.com> writes:
>
>> I am proposing the below `gnus-article-toggle-fonts' function with a
>> keybinding of `W D F'.
>
> Sounds good to me.
>
>
> [...]
>
>> + (setq-local gnus-article-shr-use-fonts
>> + (not gnus-article-shr-use-fonts))
>
> [...]
>
>> The patch did not keep the fonts toggled when selecting the next message
>> or reloading the current one. I am proposing the below change. I am not
>> sure how you feel about buffer-local Gnus variables in `mm-decode.el',
>> so please let me know if an alternative approach would be better.
>
> Yeah, it would be best to avoid doing that. How about changing the
> patch to have a buffer-local `shr-use-fonts' in the Gnus article buffer
> and use that instead?
Just like this then?
diff --git a/lisp/gnus/gnus-art.el b/lisp/gnus/gnus-art.el
index 3c1403e155..05d0be8ca2 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)
@@ -4494,6 +4503,8 @@ gnus-article-mode
(setq-local nobreak-char-display nil)
;; Enable `gnus-article-remove-images' to delete images shr.el renders.
(setq-local shr-put-image-function #'gnus-shr-put-image)
+ ;; Shadow global shr-use-fonts to support font toggling.
+ (setq-local shr-use-fonts shr-use-fonts)
(unless gnus-article-show-cursor
(setq cursor-in-non-selected-windows nil))
(gnus-set-default-directory)
--
Alex.
- bug#50383: 28.0.50; [PATCH] Feature suggestion, gnus-article-toggle-fonts to toggle fonts for HTML articles, Alex Bochannek, 2021/09/04
- bug#50383: 28.0.50; [PATCH] Feature suggestion, gnus-article-toggle-fonts to toggle fonts for HTML articles, Alex Bochannek, 2021/09/04
- bug#50383: 28.0.50; [PATCH] Feature suggestion, gnus-article-toggle-fonts to toggle fonts for HTML articles, Lars Ingebrigtsen, 2021/09/05
- bug#50383: 28.0.50; [PATCH] Feature suggestion, gnus-article-toggle-fonts to toggle fonts for HTML articles,
Alex Bochannek <=
- bug#50383: 28.0.50; [PATCH] Feature suggestion, gnus-article-toggle-fonts to toggle fonts for HTML articles, Lars Ingebrigtsen, 2021/09/06
- bug#50383: 28.0.50; [PATCH] Feature suggestion, gnus-article-toggle-fonts to toggle fonts for HTML articles, Alex Bochannek, 2021/09/06
- bug#50383: 28.0.50; [PATCH] Feature suggestion, gnus-article-toggle-fonts to toggle fonts for HTML articles, Lars Ingebrigtsen, 2021/09/07
- bug#50383: 28.0.50; [PATCH] Feature suggestion, gnus-article-toggle-fonts to toggle fonts for HTML articles, Alex Bochannek, 2021/09/07