how to check if emacs in frame or in terminal?

▼魔方 西西 提交于 2019-12-23 09:23:43

问题


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.


回答1:


(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)



回答2:


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).



来源:https://stackoverflow.com/questions/9287815/how-to-check-if-emacs-in-frame-or-in-terminal

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!