how to check if emacs in frame or in terminal?

2019-06-17 08:42发布

Based on this question : How to set emacsclient background as Emacs background?

I need background only for frames, not for terminal and not for console.

Here is how I'm trying to add fix for console

(when (display-graphic-p)
    (tool-bar-mode -1)
    (scroll-bar-mode t)
    (require 'nyan-mode)
    (nyan-mode)
    (nyan-start-animation)
    (mouse-wheel-mode t)
    (setq default-frame-alist
          '((background-color . "#101416")
            (foreground-color . "#f6f3e8"))
          ) 
)

But with that I don't get background on emacsclient (even for frames). Maybe the check doesn't even run in emacsclient?

Basically I want to not add background to emacsclient in terminal and console but in frames.

2条回答
萌系小妹纸
2楼-- · 2019-06-17 09:20
(defun my-frame-config (frame)
  "Custom behaviours for new frames."
  (with-selected-frame frame
    (when (display-graphic-p)
      (set-background-color "#101416")
      (set-foreground-color "#f6f3e8"))))
;; run now
(my-frame-config (selected-frame))
;; and later
(add-hook 'after-make-frame-functions 'my-frame-config)
查看更多
再贱就再见
3楼-- · 2019-06-17 09:34

Maybe the simpler solution is to not touch *-frame-alist, nor set-frame-*, but instead to M-x customize-face RET default RET and then middle click on the "State" button and select "For all kinds of displays" at which point you'll be able to set the face appearence differently for different displays. This part of the UI is not used very much, and it shows, but you'd do: middle click on INS to insert a second set of settings, then middle-click on "Display" and select "nil", then click on the toggle to the left of "Type" and then on the toggle on the left of "TTY": this makes the first set of settings only apply to tty frames while the other one (which presumably still says "Display: all") applies to the remaining cases (i.e. non-tty frames).

查看更多
登录 后发表回答