10

When working with others around a shared monitor or via screen-sharing (e.g. Google Hangout), I often use text-scale-adjust (C-x C-+) to let others more easily read my screen.

I would love to be able to also transiently increase the text size of the mode line and minibuffer in the selected frame. Does such capability already exist? If not, I might puzzle out how to write it myself...eventually.

2 Answers 2

10

Text scaling zooms the text of a particular buffer, everywhere that the buffer is displayed.

What you want to do is zoom a particular frame and not just scale the text of a particular buffer.

Commands zoom-in, zoom-out, and zoom-in/out of library zoom-frm.el let you do both of these things easily and incrementally.

From the keyboard, command zoom-in/out is all you need - use it as a replacement for text-scale-adjust:

(define-key ctl-x-map [(control ?+)] 'zoom-in/out)
(define-key ctl-x-map [(control ?-)] 'zoom-in/out)
(define-key ctl-x-map [(control ?=)] 'zoom-in/out)
(define-key ctl-x-map [(control ?0)] 'zoom-in/out)

You can bind zoom-in and zoom-out to mouse-wheel rotations:

(global-set-key (vector (list 'control mouse-wheel-down-event)) 'zoom-in)
(global-set-key (vector (list 'control mouse-wheel-up-event))   'zoom-out)

I bind these as well, for zooming by mouse clicking:

(global-set-key [S-mouse-1]    'zoom-in)
(global-set-key [C-S-mouse-1]  'zoom-out)
;; Get rid of `mouse-set-font' or `mouse-appearance-menu':
(global-set-key [S-down-mouse-1] nil)

The zoom-frm.el commands can behave like text-scale-adjust, zooming a buffer wherever it is displayed, or they can zoom an entire single frame (all of its windows, including minibuffers; its mode line; its scroll bars; etc.).

Hit C-u at any time while using these commands to toggle between buffer zooming and frame zooming. The kind of zooming (buffer or frame) you get by default is defined by option zoom-frame/buffer. C-u with a zoom command toggles the option.

5

The default C-x C-0/-/= bindings do an excellent job of font resizing. But they apply only to the buffer where they are used. They do not change the font sizes for the text outside the buffer, for example in the mode-line, mini-buffer or other buffers.

Below function changes the font size in those areas too, globally.

You can use the default-font-size-pt variable to set the default font size for each emacs session.

(setq default-font-size-pt 12)

(defun modi/font-size-adj (&optional arg)
  "The default C-x C-0/-/= bindings do an excellent job of font resizing.
They, though, do not change the font sizes for the text outside the buffer,
example in mode-line. Below function changes the font size in those areas too.

M-<NUM> M-x modi/font-size-adj increases font size by NUM points if NUM is +ve,
                               decreases font size by NUM points if NUM is -ve
                               resets    font size if NUM is 0."
  (interactive "p")
  (if (= arg 0)
      (setq font-size-pt default-font-size-pt)
    (setq font-size-pt (+ font-size-pt arg)))
  ;; The internal font size value is 10x the font size in points unit.
  ;; So a 10pt font size is equal to 100 in internal font size value.
  (set-face-attribute 'default nil :height (* font-size-pt 10)))

(defun modi/font-size-incr ()  (interactive) (modi/font-size-adj +1))
(defun modi/font-size-decr ()  (interactive) (modi/font-size-adj -1))
(defun modi/font-size-reset () (interactive) (modi/font-size-adj 0))

(modi/font-size-reset) ; Initialize font-size-pt var to the default value

Font adjusting can be made a breeze with the help of hydra package.

(require 'hydra)
(defhydra hydra-font-resize
    (global-map "C-M-=")
  "font-resize"
  ("-"   modi/font-size-decr  "Decrease")
  ("="   modi/font-size-incr  "Increase")
  ("0"   modi/font-size-reset "Reset to default size"))

Usage examples:

  • Increase font by 4 points C-M-= = = = =
  • Decrease font by 6 points C-M-= - - - - - -
  • Reset font to the set default point size C-M-= 0
  • You are not exactly sure how big or small you want the fonts to be :) C-M-= = = = - - = = - - 0 - - = =

Feel free to change the C-M-= prefix to anything else of your liking.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.