Function: text-scale-adjust
text-scale-adjust is an autoloaded, interactive and byte-compiled
function defined in face-remap.el.gz.
Signature
(text-scale-adjust INC)
Documentation
Adjust the font size in the current buffer by INC steps.
Interactively, INC is the prefix numeric argument, and defaults to 1.
The actual adjustment made depends on the final component of the keybinding used to invoke the command, with all modifiers removed:
\+, \= Increase font size in current buffer by one step
\- Decrease font size in current buffer by one step
\0 Reset the font size to the global default
After adjusting, continue to read input events and further adjust the font size as long as the input event (with all modifiers removed) is one of the above characters.
Each step scales the height of the default face by the factor that
is the value of text-scale-mode-step (a negative number of steps
decreases the height by that factor). As a special case, an argument
of 0 will remove any scaling currently active, thus resetting the
font size to the original value.
This command is a special-purpose wrapper around the
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.
Most faces are affected by these font size changes, but not faces
that have an explicit :height setting. The two exceptions to
this are the default and header-line faces: they will both be
scaled even if they have an explicit :height setting.
See also the related command global-text-scale-adjust. Unlike
that command, which scales the font size with a increment (and can
also optionally resize frames to keep the same number of lines and
characters per line), text-scale-adjust scales the font size with
a factor, text-scale-mode-step. With a small text-scale-mode-step
factor, the two commands behave similarly.
Probably introduced at or before Emacs version 28.1.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/face-remap.el.gz
;;;###autoload (define-key ctl-x-map [(control ?+)] 'text-scale-adjust)
;;;###autoload (define-key ctl-x-map [(control ?-)] 'text-scale-adjust)
;;;###autoload (define-key ctl-x-map [(control ?=)] 'text-scale-adjust)
;;;###autoload (define-key ctl-x-map [(control ?0)] 'text-scale-adjust)
;;;###autoload
(defun text-scale-adjust (inc)
"Adjust the font size in the current buffer by INC steps.
Interactively, INC is the prefix numeric argument, and defaults to 1.
The actual adjustment made depends on the final component of the
keybinding used to invoke the command, with all modifiers removed:
\\`+', \\`=' Increase font size in current buffer by one step
\\`-' Decrease font size in current buffer by one step
\\`0' Reset the font size to the global default
After adjusting, continue to read input events and further adjust
the font size as long as the input event (with all modifiers removed)
is one of the above characters.
Each step scales the height of the default face by the factor that
is the value of `text-scale-mode-step' (a negative number of steps
decreases the height by that factor). As a special case, an argument
of 0 will remove any scaling currently active, thus resetting the
font size to the original value.
This command is a special-purpose wrapper around the
`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.
Most faces are affected by these font size changes, but not faces
that have an explicit `:height' setting. The two exceptions to
this are the `default' and `header-line' faces: they will both be
scaled even if they have an explicit `:height' setting.
See also the related command `global-text-scale-adjust'. Unlike
that command, which scales the font size with a increment (and can
also optionally resize frames to keep the same number of lines and
characters per line), `text-scale-adjust' scales the font size with
a factor, `text-scale-mode-step'. With a small `text-scale-mode-step'
factor, the two commands behave similarly."
(interactive "p")
(let ((ev last-command-event)
(echo-keystrokes nil))
(let* ((base (event-basic-type ev))
(step
(pcase base
((or ?+ ?=) inc)
(?- (- inc))
(?0 0)
(_ inc))))
(text-scale-increase step)
(set-transient-map
(let ((map (make-sparse-keymap)))
(dolist (mods '(() (control)))
(dolist (key '(?+ ?= ?- ?0)) ;; = is often unshifted +.
(define-key map (vector (append mods (list key)))
(lambda () (interactive) (text-scale-adjust (abs inc))))))
map)
nil nil
"Use %k for further adjustment"))))