I thought it would be handy to be able to change the font height of a buffer on the fly by invoking a key press and giving the font height you would want, e.g.
C-t 130
would set the local buffer font size to 130. I've been able to write a function that can change the font size to a preset value like thus:
(defun set-font-low ()
"Lowers the font of this buffer to 70. call `set-font-high` for reverse."
(interactive)
(setq buffer-face-mode-face '( :height 70))
(buffer-face-mode))
A modified version would include the possibility of setting this font height interactively:
(defun set-font-height (size)
"set font height for local buffer"
(interactive "sheight:")
(message size)
(setq buffer-face-mode-face '( :height (size)))
(buffer-face-mode))
However, this code doesn't work. The message shows the correct size, and the font size isn't changed. substituting size with 70 will still produce no change. What's more, regardless of the specific argument used, after this function is executed moving the cursor up or down in that buffer becomes impossible, e.g. C-p
results in a wrong type argument: stringp, nil
error.
I'd guess my problem is that I'm trying to set the attribute to a variable rather than to a number. in jmibanez's answer to this question he seems to be able to do just that, but I can't figure out what the correct syntax is in this problem.
I'm running GNU Emacs 26.0.90 (build 1, x86_64-w64-mingw32) on windows 10.