* bug#48307: Feature request: provide default keybindings to change the font size in all windows @ 2021-05-09 7:09 Clément Pit-Claudel 2021-05-09 8:23 ` Eli Zaretskii ` (3 more replies) 0 siblings, 4 replies; 52+ messages in thread From: Clément Pit-Claudel @ 2021-05-09 7:09 UTC (permalink / raw) To: 48307 Hi all, Emacs has keybindings to change the font size in the current buffer (C-x C-=, etc which use text-scale-adjust). We don't have keybindings for commands to change the font size globally, and in fact we don't have commands for that purpose at all, AFAICT. My students keep running into this issue, and it seems pretty common online, too: - https://stackoverflow.com/questions/18783227/emacs-zoom-in-out-globally - https://stackoverflow.com/questions/24705984/increase-decrease-font-size-in-an-emacs-frame-not-just-buffer - https://www.reddit.com/r/emacs/comments/dip6e6/zoom_in_zoom_out/ … and there are many libraries that reimplement solutions to this issue: - https://www.emacswiki.org/emacs/download/zoom-frm.el - https://practicalli.github.io/spacemacs/install-spacemacs/change-font.html - https://github.com/purcell/default-text-scale - https://www.emacswiki.org/emacs/GlobalTextScaleMode - https://www.emacswiki.org/emacs/SetFonts#ZoomFrame I'm sure many more people have custom code for this (I do). Not all the implementations are good, and it would be very nice if such a feature were available out of the box. Currently mouse-wheel-text-scale is bound to C-<mouse-5> and C-<mouse-4>; could we have an equivalent command for all buffers, maybe on C-S-<mouse-5> and C-S-<mouse-4>? Clément. ^ permalink raw reply [flat|nested] 52+ messages in thread
* bug#48307: Feature request: provide default keybindings to change the font size in all windows 2021-05-09 7:09 bug#48307: Feature request: provide default keybindings to change the font size in all windows Clément Pit-Claudel @ 2021-05-09 8:23 ` Eli Zaretskii 2021-05-09 15:31 ` Clément Pit-Claudel 2021-05-09 8:43 ` martin rudalics ` (2 subsequent siblings) 3 siblings, 1 reply; 52+ messages in thread From: Eli Zaretskii @ 2021-05-09 8:23 UTC (permalink / raw) To: Clément Pit-Claudel; +Cc: 48307 > From: Clément Pit-Claudel <cpitclaudel@gmail.com> > Date: Sun, 9 May 2021 03:09:45 -0400 > > Emacs has keybindings to change the font size in the current buffer (C-x C-=, etc which use text-scale-adjust). We don't have keybindings for commands to change the font size globally, and in fact we don't have commands for that purpose at all, AFAICT. > > My students keep running into this issue, and it seems pretty common online, too: It is not clear what should the requested feature do, and the links you provided each talk about different aspects of the problem without actually completely defining the requested functionality. So: what should be the effect of this "global" change of the "font size"? Some thought-provoking questions: . should this affect only the faces whose fonts don't define their own size, or should it affect _all_ fonts? . should this really affect _all_ the buffers? e.g., what about the minibuffer and the echo-area buffers? . should this affect all the frames or just the currently selected frame? what about future frames? . should this affect the mode line? . should this affect tooltips? . should this affect the fringes and their bitmaps? . should this affect the menu bar, the drop-down menus, and the GUI dialogs? We need a clear understanding of the feature before we implement it, IMO. Thanks. ^ permalink raw reply [flat|nested] 52+ messages in thread
* bug#48307: Feature request: provide default keybindings to change the font size in all windows 2021-05-09 8:23 ` Eli Zaretskii @ 2021-05-09 15:31 ` Clément Pit-Claudel 2021-05-09 16:08 ` Eli Zaretskii 2021-05-09 16:30 ` Drew Adams 0 siblings, 2 replies; 52+ messages in thread From: Clément Pit-Claudel @ 2021-05-09 15:31 UTC (permalink / raw) To: Eli Zaretskii; +Cc: 48307 On 5/9/21 4:23 AM, Eli Zaretskii wrote: > So: what should be the effect of this "global" change of the "font > size"? Some thought-provoking questions: Thanks. Some wild guesses: > . should this affect only the faces whose fonts don't define their > own size, or should it affect _all_ fonts? Probably all of them except the ones that specify an absolute height? > . should this really affect _all_ the buffers? e.g., what about the > minibuffer and the echo-area buffers? Yes, certainly. > . should this affect all the frames or just the currently selected > frame? what about future frames? I'm guessing all frames. > . should this affect the mode line? Absolutely. > . should this affect tooltips? Yes, to the extent that we have control over that. > . should this affect the fringes and their bitmaps? That would be nice. > . should this affect the menu bar, the drop-down menus, and the GUI > dialogs? That's extra credit; I guess it could be nice? > We need a clear understanding of the feature before we implement it, > IMO. Indeed, although starting with an implementation and refining it over time could be good, too (to some extent I think the specifics matter less than having something available). For example, just including any one of the short implementations into Emacs by default would work to solve the concrete issue that I'm talking about (with the pandemic we do screen-sharing all the time, and I hear "how do I resize the font in Emacs again?" more than once a week these days ^^). A good approximation of what I would like that command to do is what menu-set-font does if you ignore the part about changing the face and only change the size part. Something similar to doing text-scale-adjust in every buffer would also work, too (I've noticed that changing the :height attribute of the default face is slow, while text-scale-adjust is fast). ^ permalink raw reply [flat|nested] 52+ messages in thread
* bug#48307: Feature request: provide default keybindings to change the font size in all windows 2021-05-09 15:31 ` Clément Pit-Claudel @ 2021-05-09 16:08 ` Eli Zaretskii 2021-05-09 16:39 ` bug#48307: [External] : " Drew Adams 2021-05-09 16:30 ` Drew Adams 1 sibling, 1 reply; 52+ messages in thread From: Eli Zaretskii @ 2021-05-09 16:08 UTC (permalink / raw) To: Clément Pit-Claudel; +Cc: 48307 > Cc: 48307@debbugs.gnu.org > From: Clément Pit-Claudel <cpitclaudel@gmail.com> > Date: Sun, 9 May 2021 11:31:57 -0400 > > Indeed, although starting with an implementation and refining it over time could be good, too (to some extent I think the specifics matter less than having something available). For example, just including any one of the short implementations into Emacs by default would work to solve the concrete issue that I'm talking about (with the pandemic we do screen-sharing all the time, and I hear "how do I resize the font in Emacs again?" more than once a week these days ^^). Why not point them to Options->Set Default Font menu item? That does almost everything you asked for in your answer to my questions. In fact, given that we already have that menu item, it could be argued we already have the feature implemented. ^ permalink raw reply [flat|nested] 52+ messages in thread
* bug#48307: [External] : bug#48307: Feature request: provide default keybindings to change the font size in all windows 2021-05-09 16:08 ` Eli Zaretskii @ 2021-05-09 16:39 ` Drew Adams 2021-05-09 16:58 ` Eli Zaretskii 0 siblings, 1 reply; 52+ messages in thread From: Drew Adams @ 2021-05-09 16:39 UTC (permalink / raw) To: Eli Zaretskii, Clément Pit-Claudel; +Cc: 48307@debbugs.gnu.org > > I hear "how do I resize the font in Emacs again?" > > more than once a week these days ^^). > > Why not point them to Options->Set Default Font menu item? That does > almost everything you asked for in your answer to my questions. In > fact, given that we already have that menu item, it could be argued we > already have the feature implemented. For only that use case, that suffices, indeed. But this enhancement request is about _incrementally_ zooming (I think); that is, the kind of thing you do with `C-x (+|-)'. Users of other apps, especially browsers, are used to using, say, `C-(+-)' or `C-wheel-(up|down)' to zoom the browser window. (You can also a mouse wheel for frame zooming with zoom-frm.el. I use that most of the time, not `C-x (+|-)'.) ^ permalink raw reply [flat|nested] 52+ messages in thread
* bug#48307: [External] : bug#48307: Feature request: provide default keybindings to change the font size in all windows 2021-05-09 16:39 ` bug#48307: [External] : " Drew Adams @ 2021-05-09 16:58 ` Eli Zaretskii 2021-05-09 22:30 ` Clément Pit-Claudel 0 siblings, 1 reply; 52+ messages in thread From: Eli Zaretskii @ 2021-05-09 16:58 UTC (permalink / raw) To: Drew Adams; +Cc: cpitclaudel, 48307 > From: Drew Adams <drew.adams@oracle.com> > CC: "48307@debbugs.gnu.org" <48307@debbugs.gnu.org> > Date: Sun, 9 May 2021 16:39:33 +0000 > > > > I hear "how do I resize the font in Emacs again?" > > > more than once a week these days ^^). > > > > Why not point them to Options->Set Default Font menu item? That does > > almost everything you asked for in your answer to my questions. In > > fact, given that we already have that menu item, it could be argued we > > already have the feature implemented. > > For only that use case, that suffices, indeed. > > But this enhancement request is about _incrementally_ > zooming (I think); that is, the kind of thing you do > with `C-x (+|-)'. When you click on that menu item, Emacs pops up a GUI font selection dialog, where you can increase or decrease the font size. So if the font you selected doesn't fit, you can do the same again and pick up a different size. IOW, no one said that this has to be done with a key sequence that has "+" or "-" as its part. Of course writing a wrapper for that command whcih is bound to mouse wheel with some modifier should be trivial if that's the main issue here; patches welcome. I thought the request was for a non-existing feature, so I pointed out that it already exists. ^ permalink raw reply [flat|nested] 52+ messages in thread
* bug#48307: [External] : bug#48307: Feature request: provide default keybindings to change the font size in all windows 2021-05-09 16:58 ` Eli Zaretskii @ 2021-05-09 22:30 ` Clément Pit-Claudel 0 siblings, 0 replies; 52+ messages in thread From: Clément Pit-Claudel @ 2021-05-09 22:30 UTC (permalink / raw) To: Eli Zaretskii, Drew Adams; +Cc: 48307 On 5/9/21 12:58 PM, Eli Zaretskii wrote: > Of course writing a wrapper for that command whcih is bound to mouse > wheel with some modifier should be trivial if that's the main issue > here; patches welcome. I thought the request was for a non-existing > feature, so I pointed out that it already exists. Sorry, it sounds like the original request was unclear. Drew's description is pretty good. The request is specifically for a new keybinding; it may well be that the code that goes behind it is trivial. I'd love to provide a patch, but I have no idea what it should say. I've counted 5 different implementations of the functionality (6 now with Gregory's). All are acceptable, and I don't know enough about Emacs' fonts to judge which one is best, or whether they're all equally reasonable (for example Gregory uses set-face-attribute, and Steve uses face-spec-set in default-text-scale.el). On 5/9/21 12:08 PM, Eli Zaretskii wrote: > In fact, given that we already have that menu item, it could be argued we > already have the feature implemented. Almost, yes. What we're missing are commands for incrementing and decrementing the size interactively; we only menu-set-font. It's indeed what I recommend that people use when they ask. It's pretty good, even though sometimes (depending on how the user configured fonts in the first place) it starts with the wrong size and font, so you have to scroll through the list. Sorry for not mentioning menu-set-font explicitly in the original message. ^ permalink raw reply [flat|nested] 52+ messages in thread
* bug#48307: [External] : bug#48307: Feature request: provide default keybindings to change the font size in all windows 2021-05-09 15:31 ` Clément Pit-Claudel 2021-05-09 16:08 ` Eli Zaretskii @ 2021-05-09 16:30 ` Drew Adams 1 sibling, 0 replies; 52+ messages in thread From: Drew Adams @ 2021-05-09 16:30 UTC (permalink / raw) To: Clément Pit-Claudel, Eli Zaretskii; +Cc: 48307@debbugs.gnu.org > > . should this affect only the faces whose fonts don't define their > > own size, or should it affect _all_ fonts? > > Probably all of them except the ones that specify > an absolute height? Frame zooming does that. > > . should this really affect _all_ the buffers? e.g., > > what about the minibuffer and the echo-area buffers? > > Yes, certainly. Frame zooming does that. > > . should this affect the mode line? > > Absolutely. Frame zooming does that. > > . should this affect tooltips? > > Yes, to the extent that we have control over that. Frame zooming does not do that. (And I, for one, don't think I would want that. Maybe it could be an optional behavior, if there's really a use case for it.) > > . should this affect the fringes and their bitmaps? > > That would be nice. Frame zooming does not do that. Likewise, it doesn't zoom scroll bar width. But it would certainly be possible to zoom such things (and tooltips). That should likely be optional - be able to specify for _each_ such non-font thing whether to zoom it when zooming a frame. > > . should this affect the menu bar, the drop-down menus, and the GUI > > dialogs? > > That's extra credit; I guess it could be nice? Frame zooming does not do that. > I hear "how do I resize the font in Emacs again?" > more than once a week these days There are likely many things in Emacs that people learn and forget, if they don't use them often. And not just Emacs. I'm sure you're used to that, as a teacher. > A good approximation of what I would like that > command to do is what menu-set-font does if you > ignore the part about changing the face and only > change the size part. Frame zooming does that. > Something similar to doing text-scale-adjust in > every buffer would also work, too That wouldn't let you show parts of the same buffer in different windows with text show at different sizes. ^ permalink raw reply [flat|nested] 52+ messages in thread
* bug#48307: Feature request: provide default keybindings to change the font size in all windows 2021-05-09 7:09 bug#48307: Feature request: provide default keybindings to change the font size in all windows Clément Pit-Claudel 2021-05-09 8:23 ` Eli Zaretskii @ 2021-05-09 8:43 ` martin rudalics 2021-05-09 15:18 ` Clément Pit-Claudel 2021-05-09 15:58 ` bug#48307: [External] : " Drew Adams 2021-05-09 20:16 ` Gregory Heytings 3 siblings, 1 reply; 52+ messages in thread From: martin rudalics @ 2021-05-09 8:43 UTC (permalink / raw) To: Clément Pit-Claudel, 48307 > Currently mouse-wheel-text-scale is bound to C-<mouse-5> and > C-<mouse-4>; could we have an equivalent command for all buffers, > maybe on C-S-<mouse-5> and C-S-<mouse-4>? I suppose you mean a command for all _frames_. Any buffer-local text scaling would still override that. martin ^ permalink raw reply [flat|nested] 52+ messages in thread
* bug#48307: Feature request: provide default keybindings to change the font size in all windows 2021-05-09 8:43 ` martin rudalics @ 2021-05-09 15:18 ` Clément Pit-Claudel 2021-05-09 16:05 ` bug#48307: [External] : " Drew Adams 2021-05-10 8:24 ` martin rudalics 0 siblings, 2 replies; 52+ messages in thread From: Clément Pit-Claudel @ 2021-05-09 15:18 UTC (permalink / raw) To: martin rudalics, 48307 On 5/9/21 4:43 AM, martin rudalics wrote: >> Currently mouse-wheel-text-scale is bound to C-<mouse-5> and >> C-<mouse-4>; could we have an equivalent command for all buffers, >> maybe on C-S-<mouse-5> and C-S-<mouse-4>? > > I suppose you mean a command for all _frames_. Any buffer-local text > scaling would still override that. Sure: I meant something that scales the font in every window (and possibly in every frame, too, indeed) ^ permalink raw reply [flat|nested] 52+ messages in thread
* bug#48307: [External] : bug#48307: Feature request: provide default keybindings to change the font size in all windows 2021-05-09 15:18 ` Clément Pit-Claudel @ 2021-05-09 16:05 ` Drew Adams 2021-05-10 8:24 ` martin rudalics 1 sibling, 0 replies; 52+ messages in thread From: Drew Adams @ 2021-05-09 16:05 UTC (permalink / raw) To: Clément Pit-Claudel, martin rudalics, 48307@debbugs.gnu.org > >> Currently mouse-wheel-text-scale is bound to C-<mouse-5> and > >> C-<mouse-4>; could we have an equivalent command for all buffers, > >> maybe on C-S-<mouse-5> and C-S-<mouse-4>? > > > > I suppose you mean a command for all _frames_. Any buffer-local text > > scaling would still override that. > > Sure: I meant something that scales the font in every window (and possibly in > every frame, too, indeed) That's what frame-zooming does (in zoom-frm.el). It just zooms in or out on a frame (or all frames). (To be clear, zoom-frm.el doesn't zoom images etc. It just affects font size.) ^ permalink raw reply [flat|nested] 52+ messages in thread
* bug#48307: Feature request: provide default keybindings to change the font size in all windows 2021-05-09 15:18 ` Clément Pit-Claudel 2021-05-09 16:05 ` bug#48307: [External] : " Drew Adams @ 2021-05-10 8:24 ` martin rudalics 2021-05-10 14:17 ` bug#48307: [External] : " Drew Adams 2021-05-10 14:17 ` Gregory Heytings 1 sibling, 2 replies; 52+ messages in thread From: martin rudalics @ 2021-05-10 8:24 UTC (permalink / raw) To: Clément Pit-Claudel, 48307 >> I suppose you mean a command for all _frames_. Any buffer-local text >> scaling would still override that. > > Sure: I meant something that scales the font in every window (and > possibly in every frame, too, indeed) There is one subtle difference you should be aware of: (1) If you change the size of the default font of a live frame, that frame's size may change unless you rule out implied resizing for it. (2) If you change the font in all windows showing a buffer by adjusting that buffer's text scaling, frame sizes will stay the same. So you have to be precise about the "something that scales" you want. martin ^ permalink raw reply [flat|nested] 52+ messages in thread
* bug#48307: [External] : bug#48307: Feature request: provide default keybindings to change the font size in all windows 2021-05-10 8:24 ` martin rudalics @ 2021-05-10 14:17 ` Drew Adams 2021-05-10 14:17 ` Gregory Heytings 1 sibling, 0 replies; 52+ messages in thread From: Drew Adams @ 2021-05-10 14:17 UTC (permalink / raw) To: martin rudalics, Clément Pit-Claudel, 48307@debbugs.gnu.org > There is one subtle difference you should be aware of: > > (1) If you change the size of the default font of a live frame, that > frame's size may change unless you rule out implied resizing for > it. > > (2) If you change the font in all windows showing a buffer by adjusting > that buffer's text scaling, frame sizes will stay the same. > > So you have to be precise about the "something that scales" you want. Indeed. Zooming (text scaling or frame zooming) and fitting windows or frames to buffer text are different things. There should be ways to get different combinations (e.g. autofit window/frame or not). To enable windows to show the same text (e.g. without wrapping or introducing extra blank space at the right), I introduced option `text-scale-resize-window'. It lets you automatically resize the selected window (horizontally, vertically, or both) when text is resized, so that the way the window fits the buffer text remains relatively constant. Shrinking the text in one window shrinks that window, giving more space to adjacent windows. If you also use library `fit-frame.el', then 1-window frames also respond to text resizing by scaling. If not, then the text-scale commands have no effect on frame size for one-window frames. (I tried to get Emacs to add such an option, but had no luck with that.) https://www.emacswiki.org/emacs/download/face-remap%2b.el ^ permalink raw reply [flat|nested] 52+ messages in thread
* bug#48307: Feature request: provide default keybindings to change the font size in all windows 2021-05-10 8:24 ` martin rudalics 2021-05-10 14:17 ` bug#48307: [External] : " Drew Adams @ 2021-05-10 14:17 ` Gregory Heytings 2021-05-10 14:26 ` Eli Zaretskii 2021-05-10 16:45 ` Clément Pit-Claudel 1 sibling, 2 replies; 52+ messages in thread From: Gregory Heytings @ 2021-05-10 14:17 UTC (permalink / raw) To: martin rudalics; +Cc: Clément Pit-Claudel, 48307 [-- Attachment #1: Type: text/plain, Size: 269 bytes --] Thanks for mentioning frame-inhibit-implied-resize, I did not know it exists. I attach a patch that does, I believe, what Clément has in mind. Comments and feedback welcome. Note that this patch can't be applied yet, my paperwork is still not finished :( [-- Attachment #2: Type: text/x-diff, Size: 7718 bytes --] From d0316d6264ab0ccbfe7fcb77aae8549a25fc14ff Mon Sep 17 00:00:00 2001 From: Gregory Heytings <gregory@heytings.org> Date: Mon, 10 May 2021 14:06:37 +0000 Subject: [PATCH] Global adjustments to the default face * lisp/face-remap.el (global-text-scale-adjust): New command. (text-scale-adjust): Refer to the new related command. * lisp/mwheel.el (mouse-wheel-scroll-amount): Add the new command to the mouse wheel scrolling events. (mouse-wheel-global-text-scale): New function. (mouse-wheel-mode): Use the new function with mouse-wheel-mode. * doc/emacs/display.texi (Text Scale): Document the new command. * etc/NEWS: Mention the new command and its bindings. --- doc/emacs/display.texi | 11 +++++++++ etc/NEWS | 10 ++++++++ lisp/face-remap.el | 56 +++++++++++++++++++++++++++++++++++++++++- lisp/mwheel.el | 19 +++++++++++++- 4 files changed, 94 insertions(+), 2 deletions(-) diff --git a/doc/emacs/display.texi b/doc/emacs/display.texi index 58d08b43c0..1e499f247c 100644 --- a/doc/emacs/display.texi +++ b/doc/emacs/display.texi @@ -837,6 +837,17 @@ Text Scale to the @code{text-scale-adjust} command restores the default height, the same as typing @kbd{C-x C-0}. +@cindex ajust global face height +@findex global-text-scale-adjust +@kindex C-x C-M-+ +@kindex C-x C-M-- +@kindex C-x C-M-0 +@kindex C-M-wheel-down +@kindex C-M-wheel-up + Similarly, to change the height of the default face globally, type +@kbd{C-x C-M-+}, @kbd{C-x C-M--} or @kbd{C-x C-M-0}, or scroll the +mouse wheel with the @kbd{Ctrl} and @kbd{Meta} modifiers pressed. + @cindex increase buffer face height @findex text-scale-increase @cindex decrease buffer face height diff --git a/etc/NEWS b/etc/NEWS index c759b333b6..2a1161b75f 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -399,6 +399,16 @@ When this option is set, direction changes in Isearch move to another search match, if there is one, instead of moving point to the other end of the current match. ++++ +** New command to change the default face height globally. +To increase it, type 'C-x C-M-+'; to decrease it, type 'C-x C-M--'; +to restore the default face height, type 'C-x C-M-0'. The final key +in these commands may be repeated without the leading 'C-x' and without +the modifier, e.g. 'C-x C-M-+ C-M-+ C-M-+' and 'C-x C-M-+ + +' increase +the default face height by three steps. When mouse-wheel-mode is +enabled, 'C-M-wheel-up' and 'C-M-wheel-down' also increase and decrease +the default face height globally. + ** Outline +++ diff --git a/lisp/face-remap.el b/lisp/face-remap.el index 5914ee4a20..f4a52dfb54 100644 --- a/lisp/face-remap.el +++ b/lisp/face-remap.el @@ -371,7 +371,9 @@ text-scale-adjust `text-scale-increase' command which makes repetition convenient even when it is bound in a non-top-level keymap. For binding in a top-level keymap, `text-scale-increase' or -`text-scale-decrease' may be more appropriate." +`text-scale-decrease' may be more appropriate. + +See also the related command `global-text-scale-adjust'." (interactive "p") (let ((ev last-command-event) (echo-keystrokes nil)) @@ -393,6 +395,58 @@ text-scale-adjust (lambda () (interactive) (text-scale-adjust (abs inc)))))) map))))) ;; ) +(defvar global-text-scale-adjust--default-height nil) + +;;;###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 ?0)] 'global-text-scale-adjust) +;;;###autoload +(defun global-text-scale-adjust (increment) + "Globally adjust the height of the default face by INCREMENT. + +INCREMENT may be passed as a numeric prefix argument. + +The adjustment made depends on the final component of the key binding +used to invoke the command, with all modifiers removed: + + + Globally increase the height of the default face + - Globally decrease the height of the default face + 0 Globally reset the height of the default face + +After adjusting, further adjust the default face height as long as the +key, with all modifiers removed, is one of the above characters. + +Buffer-local face adjustements remain in effect when global face +adjustments are made. + +See also the related command `text-scale-adjust'." + (interactive "p") + (when (display-graphic-p) + (unless global-text-scale-adjust--default-height + (setq global-text-scale-adjust--default-height + (face-attribute 'default :height))) + (let ((event last-command-event) + (echo-keystrokes nil)) + (let* ((key (event-basic-type event)) + (inc + (pcase key + (?+ (* increment 5)) + (?- (* (- increment) 5)) + (?0 (- global-text-scale-adjust--default-height + (face-attribute 'default :height))) + (_ (* increment 5))))) + (let ((frame-inhibit-implied-resize t)) + (set-face-attribute 'default nil :height + (+ (face-attribute 'default :height) inc))) + (message "Use +,-,0 for further adjustment") + (set-transient-map + (let ((map (make-sparse-keymap))) + (dolist (mod '(() (control meta))) + (dolist (key '(?+ ?- ?0)) + (define-key map (vector (append mod (list key))) + 'global-text-scale-adjust))) + map)))))) + \f ;; ---------------------------------------------------------------- ;; buffer-face-mode diff --git a/lisp/mwheel.el b/lisp/mwheel.el index 048f50c772..d5944fef7e 100644 --- a/lisp/mwheel.el +++ b/lisp/mwheel.el @@ -84,7 +84,10 @@ mouse-wheel-inhibit-click-time :type 'number) (defcustom mouse-wheel-scroll-amount - '(1 ((shift) . hscroll) ((meta) . nil) ((control) . text-scale)) + '(1 ((shift) . hscroll) + ((meta) . nil) + ((control meta) . global-text-scale) + ((control) . text-scale)) "Amount to scroll windows by when spinning the mouse wheel. This is an alist mapping the modifier key to the amount to scroll when the wheel is moved with the modifier key depressed. @@ -377,6 +380,16 @@ mouse-wheel-text-scale (text-scale-decrease 1))) (select-window selected-window)))) +(defun mouse-wheel-global-text-scale (event) + "Increase or decrease the global height of the default face according to the EVENT." + (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.") @@ -433,6 +446,10 @@ mouse-wheel-mode (dolist (event (list mouse-wheel-down-event mouse-wheel-up-event)) (mouse-wheel--add-binding `[,(list (caar binding) 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)) + (mouse-wheel--add-binding `[,(append (car binding) (list event))] + 'mouse-wheel-global-text-scale))) ;; Bindings for scrolling. (t (dolist (event (list mouse-wheel-down-event mouse-wheel-up-event -- 2.30.2 ^ permalink raw reply related [flat|nested] 52+ messages in thread
* bug#48307: Feature request: provide default keybindings to change the font size in all windows 2021-05-10 14:17 ` Gregory Heytings @ 2021-05-10 14:26 ` Eli Zaretskii 2021-05-10 14:34 ` Gregory Heytings 2021-05-10 14:53 ` Clément Pit-Claudel 2021-05-10 16:45 ` Clément Pit-Claudel 1 sibling, 2 replies; 52+ messages in thread From: Eli Zaretskii @ 2021-05-10 14:26 UTC (permalink / raw) To: Gregory Heytings; +Cc: cpitclaudel, 48307 > Date: Mon, 10 May 2021 14:17:55 +0000 > From: Gregory Heytings <gregory@heytings.org> > Cc: Clément Pit-Claudel <cpitclaudel@gmail.com>, > 48307@debbugs.gnu.org > > + (let ((frame-inhibit-implied-resize t)) > + (set-face-attribute 'default nil :height > + (+ (face-attribute 'default :height) inc))) Why does it make sense to inhibit frame resizing in this case? I think it will make an ugly display: mode-line text will spill over, lines will become wrapped, etc. ^ permalink raw reply [flat|nested] 52+ messages in thread
* bug#48307: Feature request: provide default keybindings to change the font size in all windows 2021-05-10 14:26 ` Eli Zaretskii @ 2021-05-10 14:34 ` Gregory Heytings 2021-05-10 14:42 ` bug#48307: [External] : " Drew Adams 2021-05-10 14:53 ` Clément Pit-Claudel 1 sibling, 1 reply; 52+ messages in thread From: Gregory Heytings @ 2021-05-10 14:34 UTC (permalink / raw) To: Eli Zaretskii; +Cc: cpitclaudel, 48307 >> + (let ((frame-inhibit-implied-resize t)) >> + (set-face-attribute 'default nil :height >> + (+ (face-attribute 'default :height) inc))) > > Why does it make sense to inhibit frame resizing in this case? I think > it will make an ugly display: mode-line text will spill over, lines will > become wrapped, etc. > Because (1) it's what other programs do, (2) it's also what text-scale-adjust does, (3) it's much faster, (4) if you do not inhibit frame resizing the frame can easily become larger than your screen. Note that global-text-scale-adjust uses smaller steps than text-scale-adjust, so the user can more easily control the potential undesirable effects. ^ permalink raw reply [flat|nested] 52+ messages in thread
* bug#48307: [External] : bug#48307: Feature request: provide default keybindings to change the font size in all windows 2021-05-10 14:34 ` Gregory Heytings @ 2021-05-10 14:42 ` Drew Adams 2021-05-10 15:07 ` Gregory Heytings 0 siblings, 1 reply; 52+ messages in thread From: Drew Adams @ 2021-05-10 14:42 UTC (permalink / raw) To: Gregory Heytings, Eli Zaretskii Cc: cpitclaudel@gmail.com, 48307@debbugs.gnu.org > > Why does it make sense to inhibit frame resizing in this case? I > > think it will make an ugly display: mode-line text will spill over, > > lines will become wrapped, etc. > > > > Because (1) it's what other programs do, See what I wrote. That can be good and bad. Why limit Emacs to what other programs do? > (2) it's also what text-scale-adjust does, See what I wrote. Text scaling too can benefit from being able to fit window size to text, to keep what you see pretty much the same regardless of zoom factor. > (3) it's much faster, (4) if you do not inhibit > frame resizing the frame can easily become larger > than your screen. Depends on what the code resizing the frame does. Nothing requires frame resizing not to respect screen boundaries. (But yes, usually it's a _feature_ that you can have part of a window-mgr window (frame) off-screen.) ^ permalink raw reply [flat|nested] 52+ messages in thread
* bug#48307: [External] : bug#48307: Feature request: provide default keybindings to change the font size in all windows 2021-05-10 14:42 ` bug#48307: [External] : " Drew Adams @ 2021-05-10 15:07 ` Gregory Heytings 2021-05-10 15:26 ` Drew Adams 0 siblings, 1 reply; 52+ messages in thread From: Gregory Heytings @ 2021-05-10 15:07 UTC (permalink / raw) To: Drew Adams; +Cc: cpitclaudel, 48307 [-- Attachment #1: Type: text/plain, Size: 731 bytes --] >>> Why does it make sense to inhibit frame resizing in this case? I >>> think it will make an ugly display: mode-line text will spill over, >>> lines will become wrapped, etc. >> >> Because (1) it's what other programs do, > > See what I wrote. That can be good and bad. Why limit Emacs to what > other programs do? > I don't want to limit Emacs to anything... but not everything can be bound to a key or a mouse event. Perhaps this could become a defcustom, defaulting to t? I tried to understand what Clément had in mind, and IIUC my understanding was right. I will not use that feature, but I tried both frame-inhibit-implied-resize nil and t, and I'd guess that t is what most users would want. ^ permalink raw reply [flat|nested] 52+ messages in thread
* bug#48307: [External] : bug#48307: Feature request: provide default keybindings to change the font size in all windows 2021-05-10 15:07 ` Gregory Heytings @ 2021-05-10 15:26 ` Drew Adams 0 siblings, 0 replies; 52+ messages in thread From: Drew Adams @ 2021-05-10 15:26 UTC (permalink / raw) To: Gregory Heytings; +Cc: cpitclaudel@gmail.com, 48307@debbugs.gnu.org > >>> Why does it make sense to inhibit frame resizing in this case? I > >>> think it will make an ugly display: mode-line text will spill over, > >>> lines will become wrapped, etc. > >> > >> Because (1) it's what other programs do, > > > > See what I wrote. That can be good and bad. Why limit Emacs to what > > other programs do? > > I don't want to limit Emacs to anything... but not everything can be > bound to a key or a mouse event. Perhaps this could become a defcustom, > defaulting to t? ,---- | text-scale-resize-window is a variable defined in `face-remap+.el'. | | Its value is t | | Documentation: | Non-nil means text scaling resizes the window or frame accordingly. | For example, if you use `C-x C--' (`text-scale-decrease')' to make the | text smaller, then the window or frame is made smaller by a similar | factor. | | If the window is not alone in its frame, then the window is resized. | Otherwise, the frame is resized (provided you also use library | `fit-frame.el'). The frame is always resized both horizontally and | vertically. | | You can customize this variable. `---- ^ permalink raw reply [flat|nested] 52+ messages in thread
* bug#48307: Feature request: provide default keybindings to change the font size in all windows 2021-05-10 14:26 ` Eli Zaretskii 2021-05-10 14:34 ` Gregory Heytings @ 2021-05-10 14:53 ` Clément Pit-Claudel 2021-05-10 15:22 ` bug#48307: [External] : " Drew Adams 2021-05-10 16:16 ` Eli Zaretskii 1 sibling, 2 replies; 52+ messages in thread From: Clément Pit-Claudel @ 2021-05-10 14:53 UTC (permalink / raw) To: Eli Zaretskii, Gregory Heytings; +Cc: 48307 On 5/10/21 10:26 AM, Eli Zaretskii wrote: >> Date: Mon, 10 May 2021 14:17:55 +0000 >> From: Gregory Heytings <gregory@heytings.org> >> Cc: Clément Pit-Claudel <cpitclaudel@gmail.com>, >> 48307@debbugs.gnu.org >> >> + (let ((frame-inhibit-implied-resize t)) >> + (set-face-attribute 'default nil :height >> + (+ (face-attribute 'default :height) inc))) > > Why does it make sense to inhibit frame resizing in this case? I > think it will make an ugly display: mode-line text will spill over, > lines will become wrapped, etc. I think preventing frame resizing is the right move, at least in the context that I had in mind (screen sharing): if you scale the frame and the font at once, then nothing changes on the recipient's screen (since the videoconferencing software scales the frame to a constant size). (Besides, that's what menu-set-font does; and it's easy to resize the frame after scaling the font, no?) ^ permalink raw reply [flat|nested] 52+ messages in thread
* bug#48307: [External] : bug#48307: Feature request: provide default keybindings to change the font size in all windows 2021-05-10 14:53 ` Clément Pit-Claudel @ 2021-05-10 15:22 ` Drew Adams 2021-05-10 15:36 ` Clément Pit-Claudel 2021-05-10 16:16 ` Eli Zaretskii 1 sibling, 1 reply; 52+ messages in thread From: Drew Adams @ 2021-05-10 15:22 UTC (permalink / raw) To: Clément Pit-Claudel, Eli Zaretskii, Gregory Heytings Cc: 48307@debbugs.gnu.org > > Why does it make sense to inhibit frame resizing in this case? I > > think it will make an ugly display: mode-line text will spill over, > > lines will become wrapped, etc. > > I think preventing frame resizing is the right move, There's no single "right" move, here, IMO. Which behavior should be the _default_ one is a different question. But both behaviors should be possible - each has its uses. > at least in the context that I had in mind (screen sharing) Exactly - see above. That's a particular context. > (Besides, that's what menu-set-font does; Not very relevant, IMO, but OK. Again, this is a consideration, perhaps, for which behavior to choose as default. > and it's easy to resize the frame after scaling the font, no?) No. It's not so easy to get right, e.g. to keep the same fit as before zooming (text scaling or frame zooming). And someone who wants that likely doesn't want to have to do it manually each time. ^ permalink raw reply [flat|nested] 52+ messages in thread
* bug#48307: [External] : bug#48307: Feature request: provide default keybindings to change the font size in all windows 2021-05-10 15:22 ` bug#48307: [External] : " Drew Adams @ 2021-05-10 15:36 ` Clément Pit-Claudel 0 siblings, 0 replies; 52+ messages in thread From: Clément Pit-Claudel @ 2021-05-10 15:36 UTC (permalink / raw) To: Drew Adams, Eli Zaretskii, Gregory Heytings; +Cc: 48307@debbugs.gnu.org On 5/10/21 11:22 AM, Drew Adams wrote: >>> Why does it make sense to inhibit frame resizing in this case? I >>> think it will make an ugly display: mode-line text will spill over, >>> lines will become wrapped, etc. >> >> I think preventing frame resizing is the right move, > > There's no single "right" move, here, IMO. Which > behavior should be the _default_ one is a different > question. But both behaviors should be possible - > each has its uses. Well, there's a concrete request that stems from a concrete need — my students and colleagues running into trouble when sharing their screen. Of course, I don't have objections to including other features. ^ permalink raw reply [flat|nested] 52+ messages in thread
* bug#48307: Feature request: provide default keybindings to change the font size in all windows 2021-05-10 14:53 ` Clément Pit-Claudel 2021-05-10 15:22 ` bug#48307: [External] : " Drew Adams @ 2021-05-10 16:16 ` Eli Zaretskii 2021-05-10 16:26 ` Clément Pit-Claudel 1 sibling, 1 reply; 52+ messages in thread From: Eli Zaretskii @ 2021-05-10 16:16 UTC (permalink / raw) To: Clément Pit-Claudel; +Cc: gregory, 48307 > Cc: rudalics@gmx.at, 48307@debbugs.gnu.org > From: Clément Pit-Claudel <cpitclaudel@gmail.com> > Date: Mon, 10 May 2021 10:53:57 -0400 > > (Besides, that's what menu-set-font does No, it doesn't, at least not here. My frame is resized when I choose the same font of a different size. ^ permalink raw reply [flat|nested] 52+ messages in thread
* bug#48307: Feature request: provide default keybindings to change the font size in all windows 2021-05-10 16:16 ` Eli Zaretskii @ 2021-05-10 16:26 ` Clément Pit-Claudel 0 siblings, 0 replies; 52+ messages in thread From: Clément Pit-Claudel @ 2021-05-10 16:26 UTC (permalink / raw) To: Eli Zaretskii; +Cc: gregory, 48307 On 5/10/21 12:16 PM, Eli Zaretskii wrote: >> Cc: rudalics@gmx.at, 48307@debbugs.gnu.org >> From: Clément Pit-Claudel <cpitclaudel@gmail.com> >> Date: Mon, 10 May 2021 10:53:57 -0400 >> >> (Besides, that's what menu-set-font does > > No, it doesn't, at least not here. My frame is resized when I choose > the same font of a different size. Good catch. But not past the size of the screen, it seems. ^ permalink raw reply [flat|nested] 52+ messages in thread
* bug#48307: Feature request: provide default keybindings to change the font size in all windows 2021-05-10 14:17 ` Gregory Heytings 2021-05-10 14:26 ` Eli Zaretskii @ 2021-05-10 16:45 ` Clément Pit-Claudel 2021-05-10 18:16 ` Gregory Heytings 1 sibling, 1 reply; 52+ messages in thread From: Clément Pit-Claudel @ 2021-05-10 16:45 UTC (permalink / raw) To: Gregory Heytings, martin rudalics; +Cc: 48307 On 5/10/21 10:17 AM, Gregory Heytings wrote: > Thanks for mentioning frame-inhibit-implied-resize, I did not know it exists. > > I attach a patch that does, I believe, what Clément has in mind. Comments and feedback welcome. > > Note that this patch can't be applied yet, my paperwork is still not finished :( The patch looks good, thanks!. You could bind combinations with '=', too, since text-scale-adjust does that (you can press = instead of +). More complicated: I wonder if it'd be easy to ignore repeated delayed input. As it stands, keeping '+' pressed will zoom in continuously, and continue zooming in after '+' is released, until all buffered repeated '+' inputs are processed. ^ permalink raw reply [flat|nested] 52+ messages in thread
* bug#48307: Feature request: provide default keybindings to change the font size in all windows 2021-05-10 16:45 ` Clément Pit-Claudel @ 2021-05-10 18:16 ` Gregory Heytings 2021-05-10 18:34 ` Clément Pit-Claudel 0 siblings, 1 reply; 52+ messages in thread From: Gregory Heytings @ 2021-05-10 18:16 UTC (permalink / raw) To: Clément Pit-Claudel; +Cc: 48307 > > More complicated: I wonder if it'd be easy to ignore repeated delayed > input. As it stands, keeping '+' pressed will zoom in continuously, and > continue zooming in after '+' is released, until all buffered repeated > '+' inputs are processed. > What do you mean exactly by "ignore repeated delayed input"? Do you want to "throw away" the remaining "+" keys when "+" is released? Or do you want to disable the zoom effect, count the "+" keypresses, and apply the effect of all the keys in one go? (My computer is a bit too fast I guess, I cannot see what you see.) ^ permalink raw reply [flat|nested] 52+ messages in thread
* bug#48307: Feature request: provide default keybindings to change the font size in all windows 2021-05-10 18:16 ` Gregory Heytings @ 2021-05-10 18:34 ` Clément Pit-Claudel 2021-05-10 18:46 ` Eli Zaretskii 0 siblings, 1 reply; 52+ messages in thread From: Clément Pit-Claudel @ 2021-05-10 18:34 UTC (permalink / raw) To: Gregory Heytings; +Cc: 48307 On 5/10/21 2:16 PM, Gregory Heytings wrote: > >> >> More complicated: I wonder if it'd be easy to ignore repeated delayed input. As it stands, keeping '+' pressed will zoom in continuously, and continue zooming in after '+' is released, until all buffered repeated '+' inputs are processed. >> > > What do you mean exactly by "ignore repeated delayed input"? Do you want to "throw away" the remaining "+" keys when "+" is released? This one. > (My computer is a bit too fast I guess, I cannot see what you see.) Either that, or my keyboard is fast :) Try adding (sleep-for 1) right before the font size adjustment, then press "+" for a second or so and release it. Emacs will keep processing the delayed "+" input and keep zooming. Not sure that it matters much. ^ permalink raw reply [flat|nested] 52+ messages in thread
* bug#48307: Feature request: provide default keybindings to change the font size in all windows 2021-05-10 18:34 ` Clément Pit-Claudel @ 2021-05-10 18:46 ` Eli Zaretskii 2021-05-10 19:04 ` Clément Pit-Claudel 0 siblings, 1 reply; 52+ messages in thread From: Eli Zaretskii @ 2021-05-10 18:46 UTC (permalink / raw) To: Clément Pit-Claudel; +Cc: gregory, 48307 > From: Clément Pit-Claudel <cpitclaudel@gmail.com> > Date: Mon, 10 May 2021 14:34:58 -0400 > Cc: 48307@debbugs.gnu.org > > Either that, or my keyboard is fast :) Try adding (sleep-for 1) right before the font size adjustment, then press "+" for a second or so and release it. Emacs will keep processing the delayed "+" input and keep zooming. I don't think that Emacs can know when the user stopped pressing the keys. Without that, how can we know when to discard keypresses still in the queue. ^ permalink raw reply [flat|nested] 52+ messages in thread
* bug#48307: Feature request: provide default keybindings to change the font size in all windows 2021-05-10 18:46 ` Eli Zaretskii @ 2021-05-10 19:04 ` Clément Pit-Claudel 2021-05-10 19:35 ` Gregory Heytings 0 siblings, 1 reply; 52+ messages in thread From: Clément Pit-Claudel @ 2021-05-10 19:04 UTC (permalink / raw) To: Eli Zaretskii; +Cc: gregory, 48307 On 5/10/21 2:46 PM, Eli Zaretskii wrote: >> From: Clément Pit-Claudel <cpitclaudel@gmail.com> >> Date: Mon, 10 May 2021 14:34:58 -0400 >> Cc: 48307@debbugs.gnu.org >> >> Either that, or my keyboard is fast :) Try adding (sleep-for 1) right before the font size adjustment, then press "+" for a second or so and release it. Emacs will keep processing the delayed "+" input and keep zooming. > > I don't think that Emacs can know when the user stopped pressing the > keys. Without that, how can we know when to discard keypresses still > in the queue. Got it, thanks. ^ permalink raw reply [flat|nested] 52+ messages in thread
* bug#48307: Feature request: provide default keybindings to change the font size in all windows 2021-05-10 19:04 ` Clément Pit-Claudel @ 2021-05-10 19:35 ` Gregory Heytings 2021-05-10 19:41 ` Clément Pit-Claudel 0 siblings, 1 reply; 52+ messages in thread From: Gregory Heytings @ 2021-05-10 19:35 UTC (permalink / raw) To: Clément Pit-Claudel; +Cc: 48307 [-- Attachment #1: Type: text/plain, Size: 134 bytes --] Here is the updated patch with, as discussed, a new user option to control the frame resizing, and the additional C-x C-M-= binding. [-- Attachment #2: Type: text/x-diff, Size: 8768 bytes --] From e1d50941106519fd0b2ad97adbd66cb4ee9c621b Mon Sep 17 00:00:00 2001 From: Gregory Heytings <gregory@heytings.org> Date: Mon, 10 May 2021 19:28:43 +0000 Subject: [PATCH] Global adjustments to the default face * lisp/face-remap.el (global-text-scale-adjust): New command. (text-scale-adjust): Refer to the new related command. (global-text-scale-adjust-resizes-frames): New user option. * lisp/mwheel.el (mouse-wheel-scroll-amount): Add the new command to the mouse wheel scrolling events. (mouse-wheel-global-text-scale): New function. (mouse-wheel-mode): Use the new function with mouse-wheel-mode. * doc/emacs/display.texi (Text Scale): Document the new command and the new user option. * etc/NEWS: Mention the new command and its bindings, and the new user option. --- doc/emacs/display.texi | 16 ++++++++++ etc/NEWS | 12 ++++++++ lisp/face-remap.el | 68 +++++++++++++++++++++++++++++++++++++++++- lisp/mwheel.el | 19 +++++++++++- 4 files changed, 113 insertions(+), 2 deletions(-) diff --git a/doc/emacs/display.texi b/doc/emacs/display.texi index 58d08b43c0..44c27e7db8 100644 --- a/doc/emacs/display.texi +++ b/doc/emacs/display.texi @@ -837,6 +837,22 @@ Text Scale to the @code{text-scale-adjust} command restores the default height, the same as typing @kbd{C-x C-0}. +@cindex ajust global face height +@findex global-text-scale-adjust +@kindex C-x C-M-+ +@kindex C-x C-M-= +@kindex C-x C-M-- +@kindex C-x C-M-0 +@kindex C-M-wheel-down +@kindex C-M-wheel-up + Similarly, to change the height of the default face globally, type +@kbd{C-x C-M-+}, @kbd{C-x C-M-=}, @kbd{C-x C-M--} or @kbd{C-x C-M-0}, +or scroll the mouse wheel with both the @kbd{Ctrl} and @kbd{Meta} +modifiers pressed. To enable frame resizing when the height of the +default face is changed globally, customize the variable +@code{global-text-scale-adjust-resizes-frames} (@pxref{Easy +Customization}). + @cindex increase buffer face height @findex text-scale-increase @cindex decrease buffer face height diff --git a/etc/NEWS b/etc/NEWS index c759b333b6..7f7a0d8669 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -399,6 +399,18 @@ When this option is set, direction changes in Isearch move to another search match, if there is one, instead of moving point to the other end of the current match. ++++ +** New command to change the default face height globally. +To increase it, type 'C-x C-M-+' or 'C-x C-M-='; to decrease it, type +'C-x C-M--'; to restore the default face height, type 'C-x C-M-0'. +The final key in these commands may be repeated without the leading +'C-x' and without the modifier, e.g. 'C-x C-M-+ C-M-+ C-M-+' and 'C-x +C-M-+ + +' increase the default face height by three steps. When +mouse-wheel-mode is enabled, 'C-M-wheel-up' and 'C-M-wheel-down' also +increase and decrease the default face height globally. Additionally, +the variable 'global-text-scale-adjust-resizes-frames' controls +whether the frames are resized when the default face height is changed. + ** Outline +++ diff --git a/lisp/face-remap.el b/lisp/face-remap.el index 5914ee4a20..eae2bfc3c7 100644 --- a/lisp/face-remap.el +++ b/lisp/face-remap.el @@ -371,7 +371,9 @@ text-scale-adjust `text-scale-increase' command which makes repetition convenient even when it is bound in a non-top-level keymap. For binding in a top-level keymap, `text-scale-increase' or -`text-scale-decrease' may be more appropriate." +`text-scale-decrease' may be more appropriate. + +See also the related command `global-text-scale-adjust'." (interactive "p") (let ((ev last-command-event) (echo-keystrokes nil)) @@ -393,6 +395,70 @@ text-scale-adjust (lambda () (interactive) (text-scale-adjust (abs inc)))))) map))))) ;; ) +(defcustom global-text-scale-adjust-resizes-frames nil + "Whether `global-text-scale-adjust' resizes the frames." + :type '(choice (const :tag "Off" nil) + (const :tag "On" t)) + :group 'display + :version "28.1") + +(defvar global-text-scale-adjust--default-height nil) + +;;;###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) +;;;###autoload (define-key ctl-x-map [(control meta ?0)] 'global-text-scale-adjust) +;;;###autoload +(defun global-text-scale-adjust (increment) + "Globally adjust the height of the default face by INCREMENT. + +INCREMENT may be passed as a numeric prefix argument. + +The adjustment made depends on the final component of the key binding +used to invoke the command, with all modifiers removed: + + +, = Globally increase the height of the default face + - Globally decrease the height of the default face + 0 Globally reset the height of the default face + +After adjusting, further adjust the default face height as long as the +key, with all modifiers removed, is one of the above characters. + +Buffer-local face adjustements remain in effect when global face +adjustments are made. + +The variable `global-text-scale-adjust-resizes-frames', which controls +whether the frames are resized when the default face is adjusted. + +See also the related command `text-scale-adjust'." + (interactive "p") + (when (display-graphic-p) + (unless global-text-scale-adjust--default-height + (setq global-text-scale-adjust--default-height + (face-attribute 'default :height))) + (let* ((key (event-basic-type last-command-event)) + (echo-keystrokes nil) + (inc + (pcase key + ((or ?+ ?=) (* increment 5)) + (?- (* (- increment) 5)) + (?0 (- global-text-scale-adjust--default-height + (face-attribute 'default :height))) + (_ (* increment 5))))) + (let ((frame-inhibit-implied-resize + (not global-text-scale-adjust-resizes-frames))) + (set-face-attribute 'default nil :height + (+ (face-attribute 'default :height) inc))) + (when (characterp key) + (message "Use +,-,0 for further adjustment") + (set-transient-map + (let ((map (make-sparse-keymap))) + (dolist (mod '(() (control meta))) + (dolist (key '(?+ ?= ?- ?0)) + (define-key map (vector (append mod (list key))) + 'global-text-scale-adjust))) + map)))))) + \f ;; ---------------------------------------------------------------- ;; buffer-face-mode diff --git a/lisp/mwheel.el b/lisp/mwheel.el index 048f50c772..d5944fef7e 100644 --- a/lisp/mwheel.el +++ b/lisp/mwheel.el @@ -84,7 +84,10 @@ mouse-wheel-inhibit-click-time :type 'number) (defcustom mouse-wheel-scroll-amount - '(1 ((shift) . hscroll) ((meta) . nil) ((control) . text-scale)) + '(1 ((shift) . hscroll) + ((meta) . nil) + ((control meta) . global-text-scale) + ((control) . text-scale)) "Amount to scroll windows by when spinning the mouse wheel. This is an alist mapping the modifier key to the amount to scroll when the wheel is moved with the modifier key depressed. @@ -377,6 +380,16 @@ mouse-wheel-text-scale (text-scale-decrease 1))) (select-window selected-window)))) +(defun mouse-wheel-global-text-scale (event) + "Increase or decrease the global height of the default face according to the EVENT." + (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.") @@ -433,6 +446,10 @@ mouse-wheel-mode (dolist (event (list mouse-wheel-down-event mouse-wheel-up-event)) (mouse-wheel--add-binding `[,(list (caar binding) 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)) + (mouse-wheel--add-binding `[,(append (car binding) (list event))] + 'mouse-wheel-global-text-scale))) ;; Bindings for scrolling. (t (dolist (event (list mouse-wheel-down-event mouse-wheel-up-event -- 2.30.2 ^ permalink raw reply related [flat|nested] 52+ messages in thread
* bug#48307: Feature request: provide default keybindings to change the font size in all windows 2021-05-10 19:35 ` Gregory Heytings @ 2021-05-10 19:41 ` Clément Pit-Claudel 2021-05-10 19:47 ` Gregory Heytings 0 siblings, 1 reply; 52+ messages in thread From: Clément Pit-Claudel @ 2021-05-10 19:41 UTC (permalink / raw) To: Gregory Heytings; +Cc: 48307 On 5/10/21 3:35 PM, Gregory Heytings wrote: > Here is the updated patch with, as discussed, a new user option to control the frame resizing, and the additional C-x C-M-= binding. Looks good! A small stylistic comment: + (pcase key + ((or ?+ ?=) (* increment 5)) + (?- (* (- increment) 5)) + (?0 (- global-text-scale-adjust--default-height + (face-attribute 'default :height))) + (_ (* increment 5))))) Do you need the first branch? If you remove it, those cases will be caught by the default fall-through. ^ permalink raw reply [flat|nested] 52+ messages in thread
* bug#48307: Feature request: provide default keybindings to change the font size in all windows 2021-05-10 19:41 ` Clément Pit-Claudel @ 2021-05-10 19:47 ` Gregory Heytings 2021-05-25 7:58 ` Gregory Heytings 0 siblings, 1 reply; 52+ messages in thread From: Gregory Heytings @ 2021-05-10 19:47 UTC (permalink / raw) To: Clément Pit-Claudel; +Cc: 48307 > > Looks good! A small stylistic comment: > > + (pcase key > + ((or ?+ ?=) (* increment 5)) > + (?- (* (- increment) 5)) > + (?0 (- global-text-scale-adjust--default-height > + (face-attribute 'default :height))) > + (_ (* increment 5))))) > > Do you need the first branch? If you remove it, those cases will be > caught by the default fall-through. > Oh yes, indeed! Thanks :-) ^ permalink raw reply [flat|nested] 52+ messages in thread
* bug#48307: Feature request: provide default keybindings to change the font size in all windows 2021-05-10 19:47 ` Gregory Heytings @ 2021-05-25 7:58 ` Gregory Heytings 2021-05-25 12:31 ` Eli Zaretskii 2022-07-02 13:41 ` Lars Ingebrigtsen 0 siblings, 2 replies; 52+ messages in thread From: Gregory Heytings @ 2021-05-25 7:58 UTC (permalink / raw) To: Clément Pit-Claudel; +Cc: 48307 [-- Attachment #1: Type: text/plain, Size: 108 bytes --] Updated patch attached. The main added feature is that face resizing is now bounded (between 10 and 500). [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: Type: text/x-diff; name=Global-adjustments-to-the-default-face.patch, Size: 8716 bytes --] From d47e46a0108aa3499cdf4ff61da5134650a96818 Mon Sep 17 00:00:00 2001 From: Gregory Heytings <gregory@heytings.org> Date: Tue, 25 May 2021 07:56:38 +0000 Subject: [PATCH] Global adjustments to the default face * lisp/face-remap.el (global-text-scale-adjust): New command. (text-scale-adjust): Refer to the new related command. (global-text-scale-adjust-resizes-frames): New user option. * lisp/mwheel.el (mouse-wheel-scroll-amount): Add the new command to the mouse wheel scrolling events. (mouse-wheel-global-text-scale): New function. (mouse-wheel-mode): Use the new function with mouse-wheel-mode. * doc/emacs/display.texi (Text Scale): Document the new command and the new user option. * etc/NEWS: Mention the new command and its bindings, and the new user option. --- doc/emacs/display.texi | 16 ++++++++++ etc/NEWS | 12 ++++++++ lisp/face-remap.el | 68 +++++++++++++++++++++++++++++++++++++++++- lisp/mwheel.el | 19 +++++++++++- 4 files changed, 113 insertions(+), 2 deletions(-) diff --git a/doc/emacs/display.texi b/doc/emacs/display.texi index 5fccdaa834..01121ffee6 100644 --- a/doc/emacs/display.texi +++ b/doc/emacs/display.texi @@ -837,6 +837,22 @@ Text Scale to the @code{text-scale-adjust} command restores the default height, the same as typing @kbd{C-x C-0}. +@cindex ajust global face height +@findex global-text-scale-adjust +@kindex C-x C-M-+ +@kindex C-x C-M-= +@kindex C-x C-M-- +@kindex C-x C-M-0 +@kindex C-M-wheel-down +@kindex C-M-wheel-up + Similarly, to change the height of the default face globally, type +@kbd{C-x C-M-+}, @kbd{C-x C-M-=}, @kbd{C-x C-M--} or @kbd{C-x C-M-0}, +or scroll the mouse wheel with both the @kbd{Ctrl} and @kbd{Meta} +modifiers pressed. To enable frame resizing when the height of the +default face is changed globally, customize the variable +@code{global-text-scale-adjust-resizes-frames} (@pxref{Easy +Customization}). + @cindex increase buffer face height @findex text-scale-increase @cindex decrease buffer face height diff --git a/etc/NEWS b/etc/NEWS index e11b860616..c5c4a93d90 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -416,6 +416,18 @@ When this option is set, direction changes in Isearch move to another search match, if there is one, instead of moving point to the other end of the current match. ++++ +** New command to change the default face height globally. +To increase it, type 'C-x C-M-+' or 'C-x C-M-='; to decrease it, type +'C-x C-M--'; to restore the default face height, type 'C-x C-M-0'. +The final key in these commands may be repeated without the leading +'C-x' and without the modifiers, e.g. 'C-x C-M-+ C-M-+ C-M-+' and 'C-x +C-M-+ + +' increase the default face height by three steps. When +mouse-wheel-mode is enabled, 'C-M-wheel-up' and 'C-M-wheel-down' also +increase and decrease the default face height globally. Additionally, +the variable 'global-text-scale-adjust-resizes-frames' controls +whether the frames are resized when the default face height is changed. + ** Outline +++ diff --git a/lisp/face-remap.el b/lisp/face-remap.el index 5914ee4a20..5e136e368b 100644 --- a/lisp/face-remap.el +++ b/lisp/face-remap.el @@ -371,7 +371,9 @@ text-scale-adjust `text-scale-increase' command which makes repetition convenient even when it is bound in a non-top-level keymap. For binding in a top-level keymap, `text-scale-increase' or -`text-scale-decrease' may be more appropriate." +`text-scale-decrease' may be more appropriate. + +See also the related command `global-text-scale-adjust'." (interactive "p") (let ((ev last-command-event) (echo-keystrokes nil)) @@ -393,6 +395,70 @@ text-scale-adjust (lambda () (interactive) (text-scale-adjust (abs inc)))))) map))))) ;; ) +(defcustom global-text-scale-adjust-resizes-frames nil + "Whether `global-text-scale-adjust' resizes the frames." + :type '(choice (const :tag "Off" nil) + (const :tag "On" t)) + :group 'display + :version "28.1") + +(defvar global-text-scale-adjust--default-height nil) + +;;;###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) +;;;###autoload (define-key ctl-x-map [(control meta ?0)] 'global-text-scale-adjust) +;;;###autoload +(defun global-text-scale-adjust (increment) + "Globally adjust the height of the default face by INCREMENT. + +INCREMENT may be passed as a numeric prefix argument. + +The adjustment made depends on the final component of the key binding +used to invoke the command, with all modifiers removed: + + +, = Globally increase the height of the default face + - Globally decrease the height of the default face + 0 Globally reset the height of the default face + +After adjusting, further adjust the default face height as long as the +key, with all modifiers removed, is one of the above characters. + +Buffer-local face adjustements remain in effect when global face +adjustments are made. + +The variable `global-text-scale-adjust-resizes-frames' controls whether +the frames are resized when the default face is adjusted. + +See also the related command `text-scale-adjust'." + (interactive "p") + (when (display-graphic-p) + (unless global-text-scale-adjust--default-height + (setq global-text-scale-adjust--default-height + (face-attribute 'default :height))) + (let* ((key (event-basic-type last-command-event)) + (echo-keystrokes nil) + (cur (face-attribute 'default :height)) + (inc + (pcase key + (?- (* (- increment) 5)) + (?0 (- global-text-scale-adjust--default-height cur)) + (_ (* increment 5)))) + (new (+ cur inc))) + (when (< 10 new 500) + (let ((frame-inhibit-implied-resize + (not global-text-scale-adjust-resizes-frames))) + (set-face-attribute 'default nil :height new))) + (when (characterp key) + (message "Use +,-,0 for further adjustment") + (set-transient-map + (let ((map (make-sparse-keymap))) + (dolist (mod '(() (control meta))) + (dolist (key '(?+ ?= ?- ?0)) + (define-key map (vector (append mod (list key))) + 'global-text-scale-adjust))) + map)))))) + \f ;; ---------------------------------------------------------------- ;; buffer-face-mode diff --git a/lisp/mwheel.el b/lisp/mwheel.el index b31805a575..8fb38c3d84 100644 --- a/lisp/mwheel.el +++ b/lisp/mwheel.el @@ -84,7 +84,10 @@ mouse-wheel-inhibit-click-time :type 'number) (defcustom mouse-wheel-scroll-amount - '(1 ((shift) . hscroll) ((meta) . nil) ((control) . text-scale)) + '(1 ((shift) . hscroll) + ((meta) . nil) + ((control meta) . global-text-scale) + ((control) . text-scale)) "Amount to scroll windows by when spinning the mouse wheel. This is an alist mapping the modifier key to the amount to scroll when the wheel is moved with the modifier key depressed. @@ -380,6 +383,16 @@ mouse-wheel-text-scale (text-scale-decrease 1))) (select-window selected-window)))) +(defun mouse-wheel-global-text-scale (event) + "Increase or decrease the global height of the default face according to the EVENT." + (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.") @@ -436,6 +449,10 @@ mouse-wheel-mode (dolist (event (list mouse-wheel-down-event mouse-wheel-up-event)) (mouse-wheel--add-binding `[,(list (caar binding) 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)) + (mouse-wheel--add-binding `[,(append (car binding) (list event))] + 'mouse-wheel-global-text-scale))) ;; Bindings for scrolling. (t (dolist (event (list mouse-wheel-down-event mouse-wheel-up-event -- 2.30.2 ^ permalink raw reply related [flat|nested] 52+ messages in thread
* bug#48307: Feature request: provide default keybindings to change the font size in all windows 2021-05-25 7:58 ` Gregory Heytings @ 2021-05-25 12:31 ` Eli Zaretskii 2021-05-25 12:58 ` Gregory Heytings 2022-07-02 13:41 ` Lars Ingebrigtsen 1 sibling, 1 reply; 52+ messages in thread From: Eli Zaretskii @ 2021-05-25 12:31 UTC (permalink / raw) To: Gregory Heytings; +Cc: cpitclaudel, 48307 > Date: Tue, 25 May 2021 07:58:42 +0000 > From: Gregory Heytings <gregory@heytings.org> > Cc: 48307@debbugs.gnu.org > > Updated patch attached. Thanks. > The main added feature is that face resizing is now bounded (between > 10 and 500). Hmm, the GCS frowns on arbitrary limits, so perhaps we should have a defcustom to control the limits? > +@kindex C-M-wheel-up > + Similarly, to change the height of the default face globally, type > +@kbd{C-x C-M-+}, @kbd{C-x C-M-=}, @kbd{C-x C-M--} or @kbd{C-x C-M-0}, > +or scroll the mouse wheel with both the @kbd{Ctrl} and @kbd{Meta} > +modifiers pressed. To enable frame resizing when the height of the > +default face is changed globally, customize the variable > +@code{global-text-scale-adjust-resizes-frames} (@pxref{Easy > +Customization}). The last part should explain why frame resizing is related to font size changes, it isn't obvious. Also, I wonder whether we should say "height of the default face's font", because this is what this actually does. I'm not sure every user will understand the notion of the height of a face. And finally, "height" or "size"? > +(defun global-text-scale-adjust (increment) > + "Globally adjust the height of the default face by INCREMENT. > + > +INCREMENT may be passed as a numeric prefix argument. The last sentence should start with "Interactively, ". Also, the doc string should tell what are the units of INCREMENT. > +The adjustment made depends on the final component of the key binding > +used to invoke the command, with all modifiers removed: I wonder if we could rephrase this to be less awkward and more clear. > +After adjusting, further adjust the default face height as long as the > +key, with all modifiers removed, is one of the above characters. And this. > +Buffer-local face adjustements remain in effect when global face > +adjustments are made. I don't think I understand what this means, so it would be good to clarify that. > +The variable `global-text-scale-adjust-resizes-frames' controls whether > +the frames are resized when the default face is adjusted. Suggest to say "... resized to keep the same number of lines and characters per line ...". > + (inc > + (pcase key > + (?- (* (- increment) 5)) > + (?0 (- global-text-scale-adjust--default-height cur)) > + (_ (* increment 5)))) Do we really need pcase here? > +(defun mouse-wheel-global-text-scale (event) > + "Increase or decrease the global height of the default face according to the EVENT." This sentence is too long to fit on a single line. Suggest to make it shorter: "Increase or decrease the height of the default face according to EVENT." ^ permalink raw reply [flat|nested] 52+ messages in thread
* bug#48307: Feature request: provide default keybindings to change the font size in all windows 2021-05-25 12:31 ` Eli Zaretskii @ 2021-05-25 12:58 ` Gregory Heytings 2021-05-25 13:12 ` Eli Zaretskii 0 siblings, 1 reply; 52+ messages in thread From: Gregory Heytings @ 2021-05-25 12:58 UTC (permalink / raw) To: Eli Zaretskii; +Cc: cpitclaudel, 48307 Thanks for your feedback, a few comments before updating the patch: >> The main added feature is that face resizing is now bounded (between 10 >> and 500). > > Hmm, the GCS frowns on arbitrary limits, > What is "the GCS"? > > so perhaps we should have a defcustom to control the limits? > I'd rather wait for a feature request to add a defcustom for this. IMO 10-500 is a reasonable range for that feature, 10 is really small and 500 is really huge. > > Also, I wonder whether we should say "height of the default face's > font", because this is what this actually does. I'm not sure every user > will understand the notion of the height of a face. > I used "height" because it's what text-scale-{adjust,increase,decrease} use. Otherwise I would have used the word "size" indeed. WDYT? >> +Buffer-local face adjustements remain in effect when global face >> +adjustments are made. > > I don't think I understand what this means, so it would be good to > clarify that. > It means that if you C-x C-+ in a buffer B (buffer-local face adjustment), and then C-x C-M-+, the buffer-local adjustment in B remains in effect, or IOW that after C-x C-M-+ the buffer B will still have a larger font than the other buffers. ^ permalink raw reply [flat|nested] 52+ messages in thread
* bug#48307: Feature request: provide default keybindings to change the font size in all windows 2021-05-25 12:58 ` Gregory Heytings @ 2021-05-25 13:12 ` Eli Zaretskii 2021-05-25 13:16 ` Gregory Heytings 2021-05-25 19:43 ` Lars Ingebrigtsen 0 siblings, 2 replies; 52+ messages in thread From: Eli Zaretskii @ 2021-05-25 13:12 UTC (permalink / raw) To: Gregory Heytings; +Cc: cpitclaudel, 48307 > Date: Tue, 25 May 2021 12:58:59 +0000 > From: Gregory Heytings <gregory@heytings.org> > cc: cpitclaudel@gmail.com, 48307@debbugs.gnu.org > > Thanks for your feedback, a few comments before updating the patch: > > >> The main added feature is that face resizing is now bounded (between 10 > >> and 500). > > > > Hmm, the GCS frowns on arbitrary limits, > > > > What is "the GCS"? GNU Coding Standards. > > so perhaps we should have a defcustom to control the limits? > > > > I'd rather wait for a feature request to add a defcustom for this. IMO > 10-500 is a reasonable range for that feature, 10 is really small and 500 > is really huge. We could avoid arguing about what's reasonable by providing an option. Lars, WDYT? > > Also, I wonder whether we should say "height of the default face's > > font", because this is what this actually does. I'm not sure every user > > will understand the notion of the height of a face. > > > > I used "height" because it's what text-scale-{adjust,increase,decrease} > use. Otherwise I would have used the word "size" indeed. WDYT? I prefer "size". > >> +Buffer-local face adjustements remain in effect when global face > >> +adjustments are made. > > > > I don't think I understand what this means, so it would be good to > > clarify that. > > > > It means that if you C-x C-+ in a buffer B (buffer-local face adjustment), > and then C-x C-M-+, the buffer-local adjustment in B remains in effect, or > IOW that after C-x C-M-+ the buffer B will still have a larger font than > the other buffers. I think what's missing is the last part you wrote, or some variant thereof. "Remains in effect" is ambiguous because it isn't clear whether the absolute size remains in effect or the relative size does. ^ permalink raw reply [flat|nested] 52+ messages in thread
* bug#48307: Feature request: provide default keybindings to change the font size in all windows 2021-05-25 13:12 ` Eli Zaretskii @ 2021-05-25 13:16 ` Gregory Heytings 2021-05-25 13:42 ` Eli Zaretskii 2021-05-25 19:43 ` Lars Ingebrigtsen 1 sibling, 1 reply; 52+ messages in thread From: Gregory Heytings @ 2021-05-25 13:16 UTC (permalink / raw) To: Eli Zaretskii; +Cc: cpitclaudel, 48307 >>> Also, I wonder whether we should say "height of the default face's >>> font", because this is what this actually does. I'm not sure every >>> user will understand the notion of the height of a face. >> >> I used "height" because it's what text-scale-{adjust,increase,decrease} >> use. Otherwise I would have used the word "size" indeed. WDYT? > > I prefer "size". > Okay, so should I also replace the word "height" by "size" in text-scale-{adjust,increase,decrease}? ^ permalink raw reply [flat|nested] 52+ messages in thread
* bug#48307: Feature request: provide default keybindings to change the font size in all windows 2021-05-25 13:16 ` Gregory Heytings @ 2021-05-25 13:42 ` Eli Zaretskii 0 siblings, 0 replies; 52+ messages in thread From: Eli Zaretskii @ 2021-05-25 13:42 UTC (permalink / raw) To: Gregory Heytings; +Cc: cpitclaudel, 48307 > Date: Tue, 25 May 2021 13:16:42 +0000 > From: Gregory Heytings <gregory@heytings.org> > cc: cpitclaudel@gmail.com, 48307@debbugs.gnu.org > > > >>> Also, I wonder whether we should say "height of the default face's > >>> font", because this is what this actually does. I'm not sure every > >>> user will understand the notion of the height of a face. > >> > >> I used "height" because it's what text-scale-{adjust,increase,decrease} > >> use. Otherwise I would have used the word "size" indeed. WDYT? > > > > I prefer "size". > > Okay, so should I also replace the word "height" by "size" in > text-scale-{adjust,increase,decrease}? I guess so, yes. ^ permalink raw reply [flat|nested] 52+ messages in thread
* bug#48307: Feature request: provide default keybindings to change the font size in all windows 2021-05-25 13:12 ` Eli Zaretskii 2021-05-25 13:16 ` Gregory Heytings @ 2021-05-25 19:43 ` Lars Ingebrigtsen 1 sibling, 0 replies; 52+ messages in thread From: Lars Ingebrigtsen @ 2021-05-25 19:43 UTC (permalink / raw) To: Eli Zaretskii; +Cc: Gregory Heytings, cpitclaudel, 48307 Eli Zaretskii <eliz@gnu.org> writes: >> >> The main added feature is that face resizing is now bounded (between 10 >> >> and 500). [...] >> I'd rather wait for a feature request to add a defcustom for this. IMO >> 10-500 is a reasonable range for that feature, 10 is really small and 500 >> is really huge. > > We could avoid arguing about what's reasonable by providing an option. I can definitely see people wanting to go below 10, so I think a user option here would be nice. -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no ^ permalink raw reply [flat|nested] 52+ messages in thread
* bug#48307: Feature request: provide default keybindings to change the font size in all windows 2021-05-25 7:58 ` Gregory Heytings 2021-05-25 12:31 ` Eli Zaretskii @ 2022-07-02 13:41 ` Lars Ingebrigtsen 1 sibling, 0 replies; 52+ messages in thread From: Lars Ingebrigtsen @ 2022-07-02 13:41 UTC (permalink / raw) To: Gregory Heytings; +Cc: Clément Pit-Claudel, 48307 Gregory Heytings <gregory@heytings.org> writes: > From d47e46a0108aa3499cdf4ff61da5134650a96818 Mon Sep 17 00:00:00 2001 > From: Gregory Heytings <gregory@heytings.org> > Date: Tue, 25 May 2021 07:56:38 +0000 > Subject: [PATCH] Global adjustments to the default face > > * lisp/face-remap.el (global-text-scale-adjust): New command. > (text-scale-adjust): Refer to the new related command. > (global-text-scale-adjust-resizes-frames): New user option. I've now respun the patch for Emacs 29, and it seems to work well, so I've now pushed, adjusting for the comments that arrived after the patch, and general changes in the terminology in this area that have been done lately. -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no ^ permalink raw reply [flat|nested] 52+ messages in thread
* bug#48307: [External] : bug#48307: Feature request: provide default keybindings to change the font size in all windows 2021-05-09 7:09 bug#48307: Feature request: provide default keybindings to change the font size in all windows Clément Pit-Claudel 2021-05-09 8:23 ` Eli Zaretskii 2021-05-09 8:43 ` martin rudalics @ 2021-05-09 15:58 ` Drew Adams 2021-05-09 21:38 ` Clément Pit-Claudel 2021-05-09 20:16 ` Gregory Heytings 3 siblings, 1 reply; 52+ messages in thread From: Drew Adams @ 2021-05-09 15:58 UTC (permalink / raw) To: Clément Pit-Claudel, 48307@debbugs.gnu.org > and there are many libraries that reimplement > solutions to this issue: Except for zoom-frm.el, which dates from 2005, those all seem to date from at least 2013. It doesn't really look like zoom-frm.el RE-implements this. It also looks to be the only one that lets you use the same commands to text-scale (zoom individual buffers - in all of their windows) or zoom frames (zoom all windows in a frame). As for zooming all frames together, zoom-frm.el has commands `zoom-all-frames-(in|out)' for that. But when it comes to zooming all frames in some way, the questions Eli raised seem relevant, in general. IMO, it's particularly useful to be able to optionally (1) zoom a buffer everywhere, so all its windows show its text at the same size _OR_ (2) show a buffer's text at different sizes in different windows. Text-scaling does (only) #1. Frame zooming allows #2. ^ permalink raw reply [flat|nested] 52+ messages in thread
* bug#48307: [External] : bug#48307: Feature request: provide default keybindings to change the font size in all windows 2021-05-09 15:58 ` bug#48307: [External] : " Drew Adams @ 2021-05-09 21:38 ` Clément Pit-Claudel 0 siblings, 0 replies; 52+ messages in thread From: Clément Pit-Claudel @ 2021-05-09 21:38 UTC (permalink / raw) To: Drew Adams, 48307@debbugs.gnu.org On 5/9/21 11:58 AM, Drew Adams wrote: > It doesn't really look like zoom-frm.el RE-implements this. Sorry if the term RE-implementing ruffled feathers. If zoom-frm works well and can be merged into Emacs, then it would fit the bill perfectly, I expect. ^ permalink raw reply [flat|nested] 52+ messages in thread
* bug#48307: Feature request: provide default keybindings to change the font size in all windows 2021-05-09 7:09 bug#48307: Feature request: provide default keybindings to change the font size in all windows Clément Pit-Claudel ` (2 preceding siblings ...) 2021-05-09 15:58 ` bug#48307: [External] : " Drew Adams @ 2021-05-09 20:16 ` Gregory Heytings 2021-05-09 21:36 ` Clément Pit-Claudel 3 siblings, 1 reply; 52+ messages in thread From: Gregory Heytings @ 2021-05-09 20:16 UTC (permalink / raw) To: Clément Pit-Claudel; +Cc: 48307 > > Not all the implementations are good, and it would be very nice if such > a feature were available out of the box. > Would the following do what you want? (defun global-text-scale-adjust-do (increment) (set-face-attribute 'default nil :height (+ (face-attribute 'default :height) increment)) (message "Use + and - for further adjustment") (set-transient-map (let ((map (make-sparse-keymap))) (define-key map (kbd "+") 'global-text-scale-adjust-increase) (define-key map (kbd "-") 'global-text-scale-adjust-decrease) map))) (defun global-text-scale-adjust-increase () (interactive) (global-text-scale-adjust-do +5)) (defun global-text-scale-adjust-decrease () (interactive) (global-text-scale-adjust-do -5)) (global-set-key (kbd "C-x M-+") 'global-text-scale-adjust-increase) (global-set-key (kbd "C-x M--") 'global-text-scale-adjust-decrease) ^ permalink raw reply [flat|nested] 52+ messages in thread
* bug#48307: Feature request: provide default keybindings to change the font size in all windows 2021-05-09 20:16 ` Gregory Heytings @ 2021-05-09 21:36 ` Clément Pit-Claudel 2021-05-09 22:03 ` Gregory Heytings 0 siblings, 1 reply; 52+ messages in thread From: Clément Pit-Claudel @ 2021-05-09 21:36 UTC (permalink / raw) To: Gregory Heytings; +Cc: 48307 On 5/9/21 4:16 PM, Gregory Heytings wrote: >> Not all the implementations are good, and it would be very nice if such a feature were available out of the box. >> > > Would the following do what you want? > > (defun global-text-scale-adjust-do (increment) > (set-face-attribute 'default nil :height > (+ (face-attribute 'default :height) increment)) > (message "Use + and - for further adjustment") > (set-transient-map > (let ((map (make-sparse-keymap))) > (define-key map (kbd "+") 'global-text-scale-adjust-increase) > (define-key map (kbd "-") 'global-text-scale-adjust-decrease) > map))) > (defun global-text-scale-adjust-increase () > (interactive) > (global-text-scale-adjust-do +5)) > (defun global-text-scale-adjust-decrease () > (interactive) > (global-text-scale-adjust-do -5)) > (global-set-key (kbd "C-x M-+") 'global-text-scale-adjust-increase) > (global-set-key (kbd "C-x M--") 'global-text-scale-adjust-decrease) Yup, probably. The performance isn't great, but that's more or less what I have in my .emacs. ^ permalink raw reply [flat|nested] 52+ messages in thread
* bug#48307: Feature request: provide default keybindings to change the font size in all windows 2021-05-09 21:36 ` Clément Pit-Claudel @ 2021-05-09 22:03 ` Gregory Heytings 2021-05-09 22:15 ` Clément Pit-Claudel 0 siblings, 1 reply; 52+ messages in thread From: Gregory Heytings @ 2021-05-09 22:03 UTC (permalink / raw) To: Clément Pit-Claudel; +Cc: 48307 > > Yup, probably. > Why "probably"? Is something missing? > > The performance isn't great, > Of course, if you need to recalculate all fonts and redisplay all frames, it takes some time. But AFAICS the performance is similar to the one of, say, Chromium or Visual Studio when you press C-+ and C--. The effect is not immediate. ^ permalink raw reply [flat|nested] 52+ messages in thread
* bug#48307: Feature request: provide default keybindings to change the font size in all windows 2021-05-09 22:03 ` Gregory Heytings @ 2021-05-09 22:15 ` Clément Pit-Claudel 2021-05-09 22:56 ` Gregory Heytings 0 siblings, 1 reply; 52+ messages in thread From: Clément Pit-Claudel @ 2021-05-09 22:15 UTC (permalink / raw) To: Gregory Heytings; +Cc: 48307 On 5/9/21 6:03 PM, Gregory Heytings wrote: > >> >> Yup, probably. >> > > Why "probably"? Is something missing? I'm not sure: I don't know if this is the right implementation, or if there's something subtly wrong about it. It looks good to me (though it's missing a command to go back to the original size), but since there are many implementations that use different strategies I had concluded that there must be some subtlety. >> The performance isn't great, >> > > Of course, if you need to recalculate all fonts and redisplay all frames, it takes some time. But AFAICS the performance is similar to the one of, say, Chromium or Visual Studio when you press C-+ and C--. The effect is not immediate. There's something more subtle happening, because using text-scale-adjust is much faster, even on a frame with a single buffer. ^ permalink raw reply [flat|nested] 52+ messages in thread
* bug#48307: Feature request: provide default keybindings to change the font size in all windows 2021-05-09 22:15 ` Clément Pit-Claudel @ 2021-05-09 22:56 ` Gregory Heytings 2021-05-10 14:19 ` Eli Zaretskii 0 siblings, 1 reply; 52+ messages in thread From: Gregory Heytings @ 2021-05-09 22:56 UTC (permalink / raw) To: Clément Pit-Claudel; +Cc: 48307 > > I'm not sure: I don't know if this is the right implementation, or if > there's something subtly wrong about it. It looks good to me (though > it's missing a command to go back to the original size), but since there > are many implementations that use different strategies I had concluded > that there must be some subtlety. > I don't know. It's certainly possible to do something more complex, but this is equivalent to changing the size with Options -> Set Default Font. > > There's something more subtle happening, because using text-scale-adjust > is much faster, even on a frame with a single buffer. > Again I don't know, but I don't think so. AFAICS it's faster because redisplaying a single buffer without changing the window and frame size is faster than redisplaying all buffers in a frame and resizing the frame itself. ^ permalink raw reply [flat|nested] 52+ messages in thread
* bug#48307: Feature request: provide default keybindings to change the font size in all windows 2021-05-09 22:56 ` Gregory Heytings @ 2021-05-10 14:19 ` Eli Zaretskii 2021-05-10 14:24 ` Gregory Heytings 0 siblings, 1 reply; 52+ messages in thread From: Eli Zaretskii @ 2021-05-10 14:19 UTC (permalink / raw) To: Gregory Heytings; +Cc: cpitclaudel, 48307 > Date: Sun, 09 May 2021 22:56:34 +0000 > From: Gregory Heytings <gregory@heytings.org> > Cc: 48307@debbugs.gnu.org > > > There's something more subtle happening, because using text-scale-adjust > > is much faster, even on a frame with a single buffer. > > Again I don't know, but I don't think so. AFAICS it's faster because > redisplaying a single buffer without changing the window and frame size is > faster than redisplaying all buffers in a frame and resizing the frame > itself. Enlarging the frame means we also interact with the WM and await its response, no? ^ permalink raw reply [flat|nested] 52+ messages in thread
* bug#48307: Feature request: provide default keybindings to change the font size in all windows 2021-05-10 14:19 ` Eli Zaretskii @ 2021-05-10 14:24 ` Gregory Heytings 2021-05-10 14:33 ` Eli Zaretskii 2021-05-10 14:33 ` bug#48307: [External] : " Drew Adams 0 siblings, 2 replies; 52+ messages in thread From: Gregory Heytings @ 2021-05-10 14:24 UTC (permalink / raw) To: Eli Zaretskii; +Cc: cpitclaudel, 48307 >>> There's something more subtle happening, because using >>> text-scale-adjust is much faster, even on a frame with a single >>> buffer. >> >> Again I don't know, but I don't think so. AFAICS it's faster because >> redisplaying a single buffer without changing the window and frame size >> is faster than redisplaying all buffers in a frame and resizing the >> frame itself. > > Enlarging the frame means we also interact with the WM and await its > response, no? > The patch I just sent avoids that problem, and does what other programs do when the user zooms: their frames are not resized. ^ permalink raw reply [flat|nested] 52+ messages in thread
* bug#48307: Feature request: provide default keybindings to change the font size in all windows 2021-05-10 14:24 ` Gregory Heytings @ 2021-05-10 14:33 ` Eli Zaretskii 2021-05-10 16:24 ` Gregory Heytings 2021-05-10 14:33 ` bug#48307: [External] : " Drew Adams 1 sibling, 1 reply; 52+ messages in thread From: Eli Zaretskii @ 2021-05-10 14:33 UTC (permalink / raw) To: Gregory Heytings; +Cc: cpitclaudel, 48307 > Date: Mon, 10 May 2021 14:24:35 +0000 > From: Gregory Heytings <gregory@heytings.org> > cc: cpitclaudel@gmail.com, 48307@debbugs.gnu.org > > The patch I just sent avoids that problem, and does what other programs do > when the user zooms: their frames are not resized. I think it's a mistake. Other programs don't change all the fonts on display, only the one in the main window, which is more similar to text-scale-adjust. This feature was supposed to change _everything_, which is why it modifies the default face. ^ permalink raw reply [flat|nested] 52+ messages in thread
* bug#48307: Feature request: provide default keybindings to change the font size in all windows 2021-05-10 14:33 ` Eli Zaretskii @ 2021-05-10 16:24 ` Gregory Heytings 0 siblings, 0 replies; 52+ messages in thread From: Gregory Heytings @ 2021-05-10 16:24 UTC (permalink / raw) To: Eli Zaretskii; +Cc: cpitclaudel, 48307 [-- Attachment #1: Type: text/plain, Size: 863 bytes --] >> The patch I just sent avoids that problem, and does what other programs >> do when the user zooms: their frames are not resized. > > I think it's a mistake. Other programs don't change all the fonts on > display, only the one in the main window, which is more similar to > text-scale-adjust. This feature was supposed to change _everything_, > which is why it modifies the default face. > Indeed, but that feature is already present on C-x C-{+-0}. And I don't know any other program that changes its frame size when a zoom factor is applied. What the existing C-x C-{+-0} does is what C-{+-0} does in Atom. What the proposed C-x C-M-{+-0} does is what C-{+-0} does in Visual Studio. As I said, I would not object to make this configurable with a defcustom, which would default to "do not resize". Would you agree with that? ^ permalink raw reply [flat|nested] 52+ messages in thread
* bug#48307: [External] : bug#48307: Feature request: provide default keybindings to change the font size in all windows 2021-05-10 14:24 ` Gregory Heytings 2021-05-10 14:33 ` Eli Zaretskii @ 2021-05-10 14:33 ` Drew Adams 1 sibling, 0 replies; 52+ messages in thread From: Drew Adams @ 2021-05-10 14:33 UTC (permalink / raw) To: Gregory Heytings, Eli Zaretskii Cc: cpitclaudel@gmail.com, 48307@debbugs.gnu.org > The patch I just sent avoids that problem, and does what other > programs do when the user zooms: their frames are not resized. Doing just what other programs do can be good or bad - a blessing or a curse. It's often better to be able to do so, but not be limited to doing so. Not resizing the frame to continue to show the buffer in the same way within it (e.g. perhaps no wrapping and no wasted blank space at the right) is not necessarily what a given user wants in a given context. I use automatic fitting of frames to the (single) buffer shown in them, by default. Zooming a frame, and having it continue to fit the text the same way, is a feature, not a bug. Like most features, it should of course be optional. As I mentioned in a earlier mail in this thread today, I provided similar optional behavior for text scaling. Zooming out by text scaling shouldn't necessarily add, in effect, a lot of blank space at the right. (I like to avoid such wasted space, whether it's for windows or frames, in general.) ^ permalink raw reply [flat|nested] 52+ messages in thread
end of thread, other threads:[~2022-07-02 13:41 UTC | newest] Thread overview: 52+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2021-05-09 7:09 bug#48307: Feature request: provide default keybindings to change the font size in all windows Clément Pit-Claudel 2021-05-09 8:23 ` Eli Zaretskii 2021-05-09 15:31 ` Clément Pit-Claudel 2021-05-09 16:08 ` Eli Zaretskii 2021-05-09 16:39 ` bug#48307: [External] : " Drew Adams 2021-05-09 16:58 ` Eli Zaretskii 2021-05-09 22:30 ` Clément Pit-Claudel 2021-05-09 16:30 ` Drew Adams 2021-05-09 8:43 ` martin rudalics 2021-05-09 15:18 ` Clément Pit-Claudel 2021-05-09 16:05 ` bug#48307: [External] : " Drew Adams 2021-05-10 8:24 ` martin rudalics 2021-05-10 14:17 ` bug#48307: [External] : " Drew Adams 2021-05-10 14:17 ` Gregory Heytings 2021-05-10 14:26 ` Eli Zaretskii 2021-05-10 14:34 ` Gregory Heytings 2021-05-10 14:42 ` bug#48307: [External] : " Drew Adams 2021-05-10 15:07 ` Gregory Heytings 2021-05-10 15:26 ` Drew Adams 2021-05-10 14:53 ` Clément Pit-Claudel 2021-05-10 15:22 ` bug#48307: [External] : " Drew Adams 2021-05-10 15:36 ` Clément Pit-Claudel 2021-05-10 16:16 ` Eli Zaretskii 2021-05-10 16:26 ` Clément Pit-Claudel 2021-05-10 16:45 ` Clément Pit-Claudel 2021-05-10 18:16 ` Gregory Heytings 2021-05-10 18:34 ` Clément Pit-Claudel 2021-05-10 18:46 ` Eli Zaretskii 2021-05-10 19:04 ` Clément Pit-Claudel 2021-05-10 19:35 ` Gregory Heytings 2021-05-10 19:41 ` Clément Pit-Claudel 2021-05-10 19:47 ` Gregory Heytings 2021-05-25 7:58 ` Gregory Heytings 2021-05-25 12:31 ` Eli Zaretskii 2021-05-25 12:58 ` Gregory Heytings 2021-05-25 13:12 ` Eli Zaretskii 2021-05-25 13:16 ` Gregory Heytings 2021-05-25 13:42 ` Eli Zaretskii 2021-05-25 19:43 ` Lars Ingebrigtsen 2022-07-02 13:41 ` Lars Ingebrigtsen 2021-05-09 15:58 ` bug#48307: [External] : " Drew Adams 2021-05-09 21:38 ` Clément Pit-Claudel 2021-05-09 20:16 ` Gregory Heytings 2021-05-09 21:36 ` Clément Pit-Claudel 2021-05-09 22:03 ` Gregory Heytings 2021-05-09 22:15 ` Clément Pit-Claudel 2021-05-09 22:56 ` Gregory Heytings 2021-05-10 14:19 ` Eli Zaretskii 2021-05-10 14:24 ` Gregory Heytings 2021-05-10 14:33 ` Eli Zaretskii 2021-05-10 16:24 ` Gregory Heytings 2021-05-10 14:33 ` bug#48307: [External] : " Drew Adams
Code repositories for project(s) associated with this public inbox https://git.savannah.gnu.org/cgit/emacs.git This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).