1

I run graphical GNU/Emacs on macOS and also emacs in Mac Terminal installed via Homebrew.

I would like to customize the default face for only the graphical display.

I used M-x customize-face default, which produced the following in my ~/.emacs file

(custom-set-faces
 ;; custom-set-faces was added by Custom.                                                                                                                                                                
 ;; If you edit it by hand, you could mess it up, so be careful.                                                                                                                                         
 ;; Your init file should contain only one such instance.                                                                                                                                                
 ;; If there is more than one, they won't work right.                                                                                                                                                    

 '(default ((t (:inherit nil :stipple nil :background "White" :foreground "Black" :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant normal :weight normal :height 180 \
:width normal :foundry "nil" :family "Menlo")))))   

Unfortunately, this configuration also applies to emacs in the Terminal (and makes the background grey for some reason). I do not want the config applied to emacs in the Terminal.

I've read that display-graphic-p would be a good way to distinguish between my two emacs versions.

How can I modify my ~/.emacs file to only customize the default face when display-graphic-p is true?

I attempted wrapping the inside of custom-set-faces with (when (display-graphic-p) ... ) but it caused the customization to be lost in both display modes.

1

Use a face spec that specifies (graphic) instead of t as the type. You can use face-spec-set to do this.

See the Elisp manual, node Defining Faces.

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.