The recent discussion of font choice, coupled with a thread in another forum
discussing the Mozilla Firefox browser inspired me to write up the following
Elisp functions.
;; font-resize.el
;; David Biesack address@hidden
;;
;; This file is not part of GNU Emacs.
;;
;;; Commentary:
;; Functions to change the default font size of the current buffer,
;; similar to how Mozilla Firefox changes the font with C-KP-Add, C-KP-Subtract
;;; Code:
(defun font-increase (arg)
"Increase the current frame's default font by twice arg. Arg may be negative to
decrease the font size."
(interactive "p")
(font-resize (* 2 arg)))
(defun font-decrease (arg)
"Decrease the current frame's default font by twice arg. Arg may be negative to
increase the font size."
(interactive "p")
(font-resize (* -2 arg)))
(defun font-resize (arg)
"Increase the current frame's default font by arg. Arg may be negative to decrease
the font size."
(interactive "p")
(let ((font (cdr (assoc 'font (frame-parameters))))
size
new-font
new-size)
(string-match "\\(-\\w+-[^-]+-\\w+-.-\\w+-\\w+-\\)\\([0-9]+\\)\\(-.*\\)$"
font)
(setq size (string-to-int (substring font (match-beginning 2) (match-end
2))))
(setq new-size (+ size arg))
(setq new-font (concat (substring font (match-beginning 1) (match-end 1))
(int-to-string new-size)
(substring font (match-beginning 3) (match-end 3))))
(set-default-font new-font)
(message "Set default font: %s" new-font)))
;; I bind to Control Keypad Add and Control Keypad Subtract with:
(define-key global-map [C-kp-add] 'font-increase)
(define-key global-map [C-kp-subtract] 'font-decrease)
Now, I can increase or decrease the current frame's font size (in increments of
two),
just like I can in the Firefox browser. I'm not sure if it works for all fonts;
it is provided as is.