]> git.eshelyaron.com Git - emacs.git/commitdiff
* lisp/mwheel.el: More fixes for global-text-scale (bug#48307)
authorJuri Linkov <juri@linkov.net>
Sun, 3 Jul 2022 17:00:11 +0000 (20:00 +0300)
committerJuri Linkov <juri@linkov.net>
Sun, 3 Jul 2022 17:00:11 +0000 (20:00 +0300)
(mouse-wheel-global-text-scale): Move down closer to mouse-wheel-text-scale.
(mouse-wheel-scroll-amount): Add :value global-text-scale and mention it
in the docstring.
(mouse-wheel-global-text-scale, mouse-wheel--setup-bindings):
Add mouse-wheel-down-alternate-event and mouse-wheel-up-alternate-event.
Allow a list of modifiers for 'text-scale'.

lisp/mwheel.el

index 062c98b53ec0c52244d49d9901f8a08116ee6dd1..401922bd0b6846037ee3df0587de14a57328b97f 100644 (file)
 
 (defvar mouse-wheel-mode)
 
-(defun mouse-wheel-global-text-scale (event)
-  "Increase or decrease the global font size according to the EVENT.
-This invokes `global-text-scale-adjust', which see."
-  (interactive (list last-input-event))
-  (let ((button (mwheel-event-button event)))
-    (unwind-protect
-        (cond ((eq button mouse-wheel-down-event)
-               (global-text-scale-adjust 1))
-              ((eq button mouse-wheel-up-event)
-               (global-text-scale-adjust -1))))))
-
 (defvar mouse-wheel--installed-bindings-alist nil
   "Alist of all installed mouse wheel key bindings.")
 
@@ -143,10 +132,11 @@ less than a full screen.
 If AMOUNT is the symbol `hscroll', this means that with MODIFIER,
 the mouse wheel will scroll horizontally instead of vertically.
 
-If AMOUNT is the symbol `text-scale', this means that with
-MODIFIER, the mouse wheel will change the font size instead of
-scrolling (by adjusting the font height of the default face).
-For more information, see `text-scale-adjust'."
+If AMOUNT is the symbol `text-scale' or `global-text-scale', this
+means that with MODIFIER, the mouse wheel will change the font size
+instead of scrolling (by adjusting the font height of the buffer or
+global face).  For more information, see `text-scale-adjust' and
+`global-text-scale-adjust'."
   :group 'mouse
   :type '(cons
          (choice :tag "Normal"
@@ -171,7 +161,8 @@ For more information, see `text-scale-adjust'."
                     (integer :tag "Scroll specific # of lines")
                     (float :tag "Scroll fraction of window")
                     (const :tag "Scroll horizontally" :value hscroll)
-                    (const :tag "Change face size" :value text-scale)))))
+                    (const :tag "Change buffer face size" :value text-scale)
+                    (const :tag "Change global face size" :value global-text-scale)))))
   :set 'mouse-wheel-change-button
   :version "28.1")
 
@@ -450,6 +441,19 @@ See also `text-scale-adjust'."
                (text-scale-decrease 1)))
       (select-window selected-window))))
 
+(defun mouse-wheel-global-text-scale (event)
+  "Increase or decrease the global font size according to the EVENT.
+This invokes `global-text-scale-adjust', which see."
+  (interactive (list last-input-event))
+  (let ((button (mwheel-event-button event)))
+    (unwind-protect
+        (cond ((memq button (list mouse-wheel-down-event
+                                  mouse-wheel-down-alternate-event))
+               (global-text-scale-adjust 1))
+              ((memq button (list mouse-wheel-up-event
+                                  mouse-wheel-up-alternate-event))
+               (global-text-scale-adjust -1))))))
+
 (defun mouse-wheel--add-binding (key fun)
   "Bind mouse wheel button KEY to function FUN.
 Save it for later removal by `mouse-wheel--remove-bindings'."
@@ -502,12 +506,15 @@ an event used for scrolling, such as `mouse-wheel-down-event'."
                            mouse-wheel-down-alternate-event
                            mouse-wheel-up-alternate-event))
         (when event
-          (mouse-wheel--add-binding `[,(list (caar binding) event)]
+          (mouse-wheel--add-binding `[,(append (car binding) (list event))]
                                     'mouse-wheel-text-scale))))
-       ((and (consp binding) (eq (cdr binding) 'global-text-scale))
-        (dolist (event (list mouse-wheel-down-event mouse-wheel-up-event))
+     ((and (consp binding) (eq (cdr binding) 'global-text-scale))
+      (dolist (event (list mouse-wheel-down-event mouse-wheel-up-event
+                           mouse-wheel-down-alternate-event
+                           mouse-wheel-up-alternate-event))
+        (when event
           (mouse-wheel--add-binding `[,(append (car binding) (list event))]
-                                    'mouse-wheel-global-text-scale)))
+                                    'mouse-wheel-global-text-scale))))
      ;; Bindings for scrolling.
      (t
       (dolist (event (list mouse-wheel-down-event mouse-wheel-up-event