Detect resolution of X display and change font accordingly This is my first attempt at anything functioning within elisp. This script is part of my configuration file that I use across multiple machines, one of which is hi-dpi and the other is not. To avoid having to reset my default font size every time I pull from my remote repository, I thought it would be nice to write a function to detect the size of the screen and adjust the font size accordingly.

(if (and (eq 3840 (x-display-pixel-width))
         (eq 2160 (x-display-pixel-height)))
  (setq-default dotspacemacs-default-font '("Source Code Pro" :size 34))
  (setq-default dotspacemacs-default-font '("Source Code Pro" :size 18)))
)


It feels a bit repetitious, but I am not comfortable enough with the language to even see how I could simplify anything. Initially I tried to set a font-size variable, but it did not seem to be able to traverse functions easily (i.e. it was set at a local scope).
You wrote calls to setq-default twice, with blah-blah-size-34-or-18. Call it just once, with a :size of an if expression that evaluates to 34 or 18.

Put another way, your "then / else" clauses are evaluated for side effects. I'm suggesting to exploit the functional aspect of if, where its return value comes either from the "then" clause or from the "else" clause.