What's a recommended way to set the font size for org-mode (or any other major mode) to a certain value that is different from the global font size?
By looking at documentation C-h k C-x C-+
, this is what I came up with:
(defun scale-up-font ()
(text-scale-increase 2))
(add-hook 'org-mode-hook 'scale-up-font)
With this, I've noticed loading time for org-mode files to be slightly longer. Is there a better way to do this?
face-remap-add-relative
, or you could also go against what the doc string warns about and set the variableface-remapping-alist
directly usingsetq-local
. The approach using theorg-mode-hook
is fine, but with a faster method such as the one suggested in this comment.. The following linked example does not change the font size, but you could modify it to suit your needs: https://emacs.stackexchange.com/a/7283/2287 In a different thread, I learned that the display engine expects a potential setting of theface-remapping-alist
and is fast. – lawlist May 24 '20 at 16:14text-scale-increase
uses functions defined inface-remap.el
, which utilizesface-remap-add-relative
. It is possible that the calculations used to find the appropriate increase are somewhat slow ... If that is the case, then you could make your calculations ahead of time and just set the font size to your liking as suggested in the previous comment. You might also want to read through that library and see if there are any obviously costly functions, e.g.,force-window-update
and the like ... – lawlist May 24 '20 at 16:44