From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Alex Bochannek Newsgroups: gmane.emacs.bugs 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 Message-ID: References: <87lf4bmj50.fsf@gnus.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="1197"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (darwin) Cc: 50383@debbugs.gnu.org To: Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Sep 06 07:23:13 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mN768-00006o-Gn for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 06 Sep 2021 07:23:12 +0200 Original-Received: from localhost ([::1]:37184 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mN766-0001MQ-FF for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 06 Sep 2021 01:23:10 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:42958) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mN75y-0001MG-6k for bug-gnu-emacs@gnu.org; Mon, 06 Sep 2021 01:23:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:39837) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mN75x-0001HE-Sy for bug-gnu-emacs@gnu.org; Mon, 06 Sep 2021 01:23:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mN75x-0005xZ-PI for bug-gnu-emacs@gnu.org; Mon, 06 Sep 2021 01:23:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Alex Bochannek Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 06 Sep 2021 05:23:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 50383 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 50383-submit@debbugs.gnu.org id=B50383.163090576222869 (code B ref 50383); Mon, 06 Sep 2021 05:23:01 +0000 Original-Received: (at 50383) by debbugs.gnu.org; 6 Sep 2021 05:22:42 +0000 Original-Received: from localhost ([127.0.0.1]:51378 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mN75e-0005wm-0h for submit@debbugs.gnu.org; Mon, 06 Sep 2021 01:22:42 -0400 Original-Received: from ns.lapseofthought.com ([50.0.39.240]:7251 helo=mail.lapseofthought.com) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mN75b-0005we-Vi for 50383@debbugs.gnu.org; Mon, 06 Sep 2021 01:22:40 -0400 Original-Received: from awb-mbp.local (unknown [IPv6:2601:646:4200:b470:382f:21b3:eb32:b8c6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.lapseofthought.com (Postfix) with ESMTPSA id 4H2xcD62yGz3pf6L; Sun, 5 Sep 2021 22:22:36 -0700 (PDT) In-Reply-To: <87lf4bmj50.fsf@gnus.org> (Lars Ingebrigtsen's message of "Sun, 05 Sep 2021 12:06:19 +0200") Authentication-Results: ORIGINATING; auth=pass smtp.auth=alex smtp.mailfrom=alex@bochannek.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:213546 Archived-At: --=-=-= Content-Type: text/plain Lars Ingebrigtsen writes: > Alex Bochannek 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? --=-=-= Content-Type: text/x-patch Content-Disposition: inline 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) --=-=-= Content-Type: text/plain -- Alex. --=-=-=--