From 9a160399650632493ab143380941dd6881062593 Mon Sep 17 00:00:00 2001 From: Ivan Malison Date: Mon, 12 Sep 2016 15:33:09 -0700 Subject: [PATCH] Improve font adjustment --- dotfiles/emacs.d/README.org | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/dotfiles/emacs.d/README.org b/dotfiles/emacs.d/README.org index 2aead9f2..4ecd32b4 100644 --- a/dotfiles/emacs.d/README.org +++ b/dotfiles/emacs.d/README.org @@ -570,7 +570,7 @@ the ~:around~ keyword of advice-add. ** Font Size This was taken from [[http://emacs.stackexchange.com/questions/7583/transiently-adjust-text-size-in-mode-line-and-minibuffer][here]]. It is primarily invoked from a hydra defined below. It would be cool if it got the default font size from whatever the default font was but it does not currently do that. #+BEGIN_SRC emacs-lisp -(setq imalison:default-font-size-pt 14) +(setq imalison:default-font-size-pt 100) (defun imalison:font-size-adj (&optional arg) "The default C-x C-0/-/= bindings do an excellent job of font resizing. @@ -581,16 +581,18 @@ This was taken from [[http://emacs.stackexchange.com/questions/7583/transiently- 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 imalison: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))) + (let ((current-height + (plist-get (custom-face-attributes-get 'default nil) :height))) + (set-face-attribute 'default nil :height + (+ current-height arg)))) -(defun imalison:font-size-incr () (interactive) (imalison:font-size-adj +1)) -(defun imalison:font-size-decr () (interactive) (imalison:font-size-adj -1)) -(defun imalison:font-size-reset () (interactive) (imalison:font-size-adj 0)) + + +(defun imalison:font-size-incr () (interactive) (imalison:font-size-adj +10)) +(defun imalison:font-size-decr () (interactive) (imalison:font-size-adj -10)) +(defun imalison:font-size-reset () (interactive) + (set-face-attribute 'default nil + :height imalison:default-font-size-pt)) #+END_SRC ** Message Result Builder This macro is useful when writing emacs-lisp. It creates a new interactive command that shows you the result of evaluating a function, with optionally provided arguments.