Subject: bug#59122: 29.0.50; global-text-scale-adjust not working

From: Gregory Heytings <[email-masked]>
Date: Sun, 13 Nov 2022 09:18:00 +0000

>
> I guess the idea is that you should invoke it with `C-x C-M-0'?  But 
> that seems to have another problem with the patch - when I type it I 
> get:
>

Thanks.  This bug is fixed in the attached patch.

>> Also, the two function now scale super-duper differently. :-/
>
> Do you mean 'text-scale-adjust' and 'global-text-scale-adjust'?  I see 
> the same here.
>

Yes.  As I said earlier, global-text-scale-adjust scales smoothly, and 
text-scale-adjust scales fast.  That was a design choice when implementing 
global-text-scale-adjust.  It should of course be possible to make 
text-scale-adjust scale smoothly too.

From 3a277b9756499a392b70b74324e4e746b0ae066d Mon Sep 17 00:00:00 2001
From: Gregory Heytings <[email-masked]>
Date: Sun, 13 Nov 2022 09:14:03 +0000
Subject: [PATCH] Fix global face scaling bug due to rounding.

* lisp/face-remap.el (global-text-scale-adjust): Try again if the face
height should have changed but did not actually change.
(global-text-scale-adjust--increment-factor): New internal variable.
Fixes bug#59122.
---
 lisp/face-remap.el | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/lisp/face-remap.el b/lisp/face-remap.el
index 432385587b..33ffb41ec9 100644
--- a/lisp/face-remap.el
+++ b/lisp/face-remap.el
@@ -461,6 +461,8 @@ global-text-scale-adjust-limits
 
 (defvar global-text-scale-adjust--default-height nil)
 
+(defvar global-text-scale-adjust--increment-factor 5)
+
 ;;;###autoload (define-key ctl-x-map [(control meta ?+)] 'global-text-scale-adjust)
 ;;;###autoload (define-key ctl-x-map [(control meta ?=)] 'global-text-scale-adjust)
 ;;;###autoload (define-key ctl-x-map [(control meta ?-)] 'global-text-scale-adjust)
@@ -499,16 +501,24 @@ global-text-scale-adjust
            (cur (face-attribute 'default :height))
            (inc
             (pcase key
-              (?- (* (- increment) 5))
+              (?- (* (- increment)
+                     global-text-scale-adjust--increment-factor))
               (?0 (- global-text-scale-adjust--default-height cur))
-              (_ (* increment 5))))
+              (_ (* increment
+                    global-text-scale-adjust--increment-factor))))
            (new (+ cur inc)))
       (when (< (car global-text-scale-adjust-limits)
                new
                (cdr global-text-scale-adjust-limits))
         (let ((frame-inhibit-implied-resize
                (not global-text-scale-adjust-resizes-frames)))
-          (set-face-attribute 'default nil :height new)))
+          (set-face-attribute 'default nil :height new)
+          (redisplay 'force)
+          (when (and (not (= key ?0))
+                     (= cur (face-attribute 'default :height)))
+            (setq global-text-scale-adjust--increment-factor
+                  (1+ global-text-scale-adjust--increment-factor))
+            (global-text-scale-adjust increment))))
       (when (characterp key)
         (set-transient-map
          (let ((map (make-sparse-keymap)))
-- 
2.35.1