1

Due to DPI differences, every time I switch between working on my laptop screen vs external display, I need to adjust frame zoom levels (SPC z f in spacemacs). I would love to be able to persist the zoom levels by e.g. writing them to a file, so that I'm able to programmatically save/restore them.

I briefly looked at the docs for set-all-frame-alist-parameters-from-frame in frame-cmds.el, but the usage seems a bit opaque to me. Can anyone provide a straightforward recipe for persisting zoom levels?

0

To always start out with the text size you want:

  1. Zoom a frame to the text size you like (e.g. using command zoom-in/out from zoom-frm.el or in some other way)

  2. Use M-: (frame-parameters) and look for the value of parameter font. Or use M-: (frame-parameter nil 'font) and get the value from buffer *Messages*. This whole string is the font name you want - it includes the size of the font.

  3. M-x customize option default-frame-alist and add a font entry with that font-name value. For example, you might add an entry such as this, which specifies font Lucida Console with size 15:

"-outline-Lucida Console-normal-normal-normal-mono-15-*-*-*-c-*-iso8859-1"

  1. In Customize, save the customization of default-frame-alist.

But that only helps if you always want the same default font size. If you want a different default font size depending on what monitor you use, then you need to either save such a setting, for each desired font size, to different files, and load the right file for the given monitor, or automatically detect the monitor characteristics and automatically set the right font.

The overall point is to save the full name of the font you want, and then set that for your default-frame-alist in your init file for a given session.

There are also other frame alists, besides default-frame-alist, which you might want to customize, but that's the main one.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.