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: Mon, 06 Sep 2021 15:41:25 -0700 Message-ID: References: <87lf4bmj50.fsf@gnus.org> <87wnnuje4m.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="40912"; 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 Tue Sep 07 00:42:11 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 1mNNJa-000ARA-Lg for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 07 Sep 2021 00:42:10 +0200 Original-Received: from localhost ([::1]:54528 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mNNJZ-0000Zi-9v for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 06 Sep 2021 18:42:09 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:46304) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNNJS-0000ZY-Ms for bug-gnu-emacs@gnu.org; Mon, 06 Sep 2021 18:42:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:43146) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mNNJS-0003nV-FW for bug-gnu-emacs@gnu.org; Mon, 06 Sep 2021 18:42:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mNNJS-00014D-BI for bug-gnu-emacs@gnu.org; Mon, 06 Sep 2021 18:42:02 -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 22:42:02 +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.16309680924062 (code B ref 50383); Mon, 06 Sep 2021 22:42:02 +0000 Original-Received: (at 50383) by debbugs.gnu.org; 6 Sep 2021 22:41:32 +0000 Original-Received: from localhost ([127.0.0.1]:54692 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mNNIx-00013S-V3 for submit@debbugs.gnu.org; Mon, 06 Sep 2021 18:41:32 -0400 Original-Received: from ns.lapseofthought.com ([50.0.39.240]:57085 helo=mail.lapseofthought.com) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mNNIv-00013J-Gs for 50383@debbugs.gnu.org; Mon, 06 Sep 2021 18:41:30 -0400 Original-Received: from awb-mbp.local (unknown [IPv6:2601:646:4200:b470:255a:f50d:433e:2f16]) (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 4H3Nft2RK6z3pk8B; Mon, 6 Sep 2021 15:41:26 -0700 (PDT) In-Reply-To: <87wnnuje4m.fsf@gnus.org> (Lars Ingebrigtsen's message of "Mon, 06 Sep 2021 10:35:05 +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:213648 Archived-At: --=-=-= Content-Type: text/plain Lars Ingebrigtsen writes: > Alex Bochannek 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! --=-=-= Content-Type: text/x-patch Content-Disposition: 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] --=-=-= Content-Type: text/plain -- Alex. --=-=-=--