4

I use one synced dotfiles repository for all of my computers, with some system-specific customization built-in. I've got a new high-DPI display on one of my computers, and would like to increase Emacs' font size just for that system. I'm trying to do the customization based on the system name, but I'm not having any success. (string= "Gotham" system-name) should be working, but for some reason it's not properly setting the font size. Here is the relevant section of my dotspacemacs/init:

(defun dotspacemacs/init ()
  (setq-default
   dotspacemacs-default-font
                 `(,(cond
                     ((or (eq 'ms-dos system-type) (eq 'windows-nt system-type)) "Consolas")
                     ((eq 'darwin system-type) "Source Code Pro")
                     (t "Source Code Pro"))
                   :size,(cond
                          ((string= "Gotham" system-name) 30)
                          ((or (eq 'ms-dos system-type) (eq 'windows-nt system-type)) 17)
                          ((eq 'darwin system-type) 12)
                          (t 17))
                   :weight normal
                   :width normal
                   :powerline-scale 1.1)
))

The two lines to set size by system-type work fine, but my system-name will not. I've also tried using (string= "Gotham" (system-name)), but that doesn't do it either. Describing the variable system-name does tell me that the value is "Gotham".

System information:

  • OS: Windows 10
  • Emacs 25.2.1
  • Spacemacs: 0.200.9
  • Can you evaluate the (setq-default ...) form interactively? What does it return? – NickD Jun 14 '17 at 20:14
  • It returns nil – Ryan Jun 14 '17 at 20:17
  • And what happens if you remove the Gotham line from the cond? – NickD Jun 14 '17 at 20:19
  • If I evaluate just the dotspacemacs-default-font expression I get ("Consolas" :size 30 :weight normal :width normal :powerline-scale 1.1) – Ryan Jun 14 '17 at 20:19
  • Let us continue this discussion in chat. – Ryan Jun 14 '17 at 20:22
2

Short answer: During initialization, (system-name) returns an all-caps version of the system's name. Setting (string= (system-name) "GOTHAM") fixes the problem.

Long answer: Following @d1egoaz's suggestion, I added the following to dotspacemacs/user-init:

(if (string= (system-name) "Gotham")
      (setq-default dotspacemacs-default-font
                    '("Consolas"
                      :size 30
                      :weight normal
                      :width normal
                      :powerline-scale 1.1)))

This had no effect. Then I added a (message "System name is") inside the (if ) and before (setq-default), and it works. This led me to believe that, during initialization, (system-name) was not returning "Gotham" Evaluating the expression interactively after initialization properly sets the value, and evaluating (system-name) returned "Gotham".

Adding (message (system-name)) to the init file to execute during initialization revealed that during that stage, the (system-name) is set to "GOTHAM", the all-caps version of the name. This is changed for some reason after initialization. Making the match (string= "GOTHAM" (system-name)) worked fine.

  • nice catch! really crazy that thing about the all-caps version of the system name – Diego Alvarez Jun 19 '17 at 22:15
1

I try to avoid modifying dotspacemacs/init, I prefer to adding my config to: dotspacemacs/user-init

This works for me, just need to add your system's name:

  (if (eq system-type 'gnu/linux)
  (setq-default dotspacemacs-default-font '("Hack"
                                            :size 31
                                            :weight normal
                                            :width normal
                                            :powerline-scale 1.1)))

the default value on dotspacemacs/init is for OSX: my custom value is for my HIDPI linux laptop.

https://github.com/d1egoaz/dotfiles/blob/d1e1b45a6bce14978d19e56baed251907cbc0945/emacs/.spacemacs#L420-L425

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.