From: Juri Linkov Date: Sun, 3 Jul 2022 17:00:11 +0000 (+0300) Subject: * lisp/mwheel.el: More fixes for global-text-scale (bug#48307) X-Git-Tag: emacs-29.0.90~1447^2~1229 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=1c3c8b6d58c91ceaac90ebe800ec365983ae81a2;p=emacs.git * lisp/mwheel.el: More fixes for global-text-scale (bug#48307) (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'. --- diff --git a/lisp/mwheel.el b/lisp/mwheel.el index 062c98b53ec..401922bd0b6 100644 --- a/lisp/mwheel.el +++ b/lisp/mwheel.el @@ -42,17 +42,6 @@ (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