# Emacs: Increase text size and adjust window width proportionally. -rw-r--r-- 1.2 KiB View raw
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
(defun increase-text-and-pane ()
  "Increase text size and adjust window width proportionally."
  (interactive)
  (let* ((orig-scale (or (car (get 'text-scale-mode-amount 'customized-value))
                        text-scale-mode-amount))
         (new-scale (+ orig-scale 1))
         (scale-factor (/ (float (expt text-scale-mode-step new-scale))
                          (float (expt text-scale-mode-step orig-scale)))))
    (text-scale-increase 1)
    (enlarge-window-horizontally (round (* (window-width) (- scale-factor 1))))))

(global-set-key (kbd "C-M-+") 'increase-text-and-pane)

(defun decrease-text-and-pane ()
  "Decrease text size and adjust window width proportionally."
  (interactive)
  (let* ((orig-scale (or (car (get 'text-scale-mode-amount 'customized-value))
                        text-scale-mode-amount))
         (new-scale (- orig-scale 1))
         (scale-factor (/ (float (expt text-scale-mode-step new-scale))
                          (float (expt text-scale-mode-step orig-scale)))))
    (text-scale-decrease 1)
    (shrink-window-horizontally (round (* (window-width) (- 1 scale-factor))))))

(global-set-key (kbd "C-M-_") 'decrease-text-and-pane)