Emacs:在终端中禁用主题背景色

Emacs:在终端中禁用主题背景色,emacs,colors,elisp,Emacs,Colors,Elisp,我希望emacs在终端中打开帧时没有背景色。我使用的是半透明背景的终端,背景颜色的字符不是“透明的”。术语设置为“xterm-256color” 如果框架不是图形化的,如何让emacs使用默认的背景色(完全没有颜色) 编辑: 我知道了,有点: (add-to-list 'custom-theme-load-path "~/.emacs.d/themes") (load-theme 'my-awesome-theme t) (defun on-frame-open (frame) (if (

我希望emacs在终端中打开帧时没有背景色。我使用的是半透明背景的终端,背景颜色的字符不是“透明的”。术语设置为“xterm-256color”

如果框架不是图形化的,如何让emacs使用默认的背景色(完全没有颜色)

编辑: 我知道了,有点:

(add-to-list 'custom-theme-load-path "~/.emacs.d/themes")
(load-theme 'my-awesome-theme t)

(defun on-frame-open (frame)
  (if (not (display-graphic-p frame))
    (set-face-background 'default "unspecified-bg" frame)))
(on-frame-open (selected-frame))
(add-hook 'after-make-frame-functions 'on-frame-open)
我将上述代码放在init文件中,但仅在终端中打开EmacClient时抑制背景,而不是emacs本身(即仅当使用
EmacClient-t
调用时,而不是使用
emacs
调用时)。添加额外的
(除非窗口系统(将面背景设置为默认的“未指定背景”(选定帧))
不起作用,只会混淆图形帧

你知道为什么会这样吗

(defun on-after-init ()
  (unless (display-graphic-p (selected-frame))
    (set-face-background 'default "unspecified-bg" (selected-frame))))

(add-hook 'window-setup-hook 'on-after-init)
结合编辑中的代码,它对我来说在EmacTerms和新启动的emacsen中都非常有效。至于为什么
窗口设置挂钩


(除此之外,之前的两个钩子似乎都不起作用。)

我尝试了中建议的方法,但没有成功。不过,这段代码对我很有用

(defun on-frame-open (&optional frame)
  "If the FRAME created in terminal don't load background color."
  (unless (display-graphic-p frame)
    (set-face-background 'default "unspecified-bg" frame)))

(add-hook 'after-make-frame-functions 'on-frame-open)

虽然它有一个倒退,但如果终端的背景设置与我使用的主题不同(暗与亮),则会使用默认的主题面,这在亮或暗背景下可能不太好。但是在我的情况下,终端和主题都是黑色的,它工作得很好。

对于这个问题已经有两个答案,使用启动时调用的
窗口设置钩子
,以及在创建新框架时调用的
后生成框架函数
,包括调用
EmacClient
。为了涵盖所有可能的情况,我发现我需要这样做:

(defun set-background-for-terminal (&optional frame)
  (or frame (setq frame (selected-frame)))
  "unsets the background color in terminal mode"
  (unless (display-graphic-p frame)
    (set-face-background 'default "unspecified-bg" frame)))
(add-hook 'after-make-frame-functions 'set-background-for-terminal)
(add-hook 'window-setup-hook 'set-background-for-terminal)

请注意,我仅在必要时使用
选定帧
;似乎在客户端模式下,钩子是在选择框架之前调用的,因此在这种情况下使用框架参数很重要。

Awesome!这对我来说非常适合iTerm2+Emacs24+Base16主题。很棒的小把戏。我用它将
wombat
主题仅应用于终端Emacs,而不是它看起来不太好的窗口版本。请注意
(设置face background“默认为零(选定帧))
也有效。真棒的人!现在我可以使用透明背景了!(UbuntuBase terminal+Emacs25.2)当我作为守护进程打开
emacs
时,这不起作用
EmacClient-t
有一秒钟的颜色转换时间,这正常吗?我认为在emacs到达之前,配置中的任何东西暂时不加载都是正常的。