Ron*_*Ron 17 emacs elisp colors
当我在终端中打开一个框架时,我想让emacs没有背景颜色.我正在使用具有半透明背景的终端,而具有背景颜色的字符不是"透视".TERM设置为"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)
Run Code Online (Sandbox Code Playgroud)
我把上面的代码放在我的init文件中,但只是在终端中打开emacsclient时禁止后台,而不是emacs本身(即仅在调用时调用,emacsclient -t而不是在调用时调用emacs).添加额外(unless window-system (set-face-background 'default "unspecified-bg" (selected-frame)))功能不起作用,只会混淆图形帧.
有关为何会发生这种情况的任何想法
Lat*_*ius 27
(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)
Run Code Online (Sandbox Code Playgroud)
结合编辑中的代码,它对我来说非常适用于emacsterms和新启动的emacsen.至于原因window-setup-hook:http:
//www.gnu.org/software/emacs/manual/html_node/elisp/Startup-Summary.html
(除了这个之外,早期的钩子似乎都没有用.)
小智 5
我尝试了这个答案中建议的方法,但我没有运气让它起作用。不过这个片段对我有用
(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)
Run Code Online (Sandbox Code Playgroud)
虽然它有一个挫折,但如果终端的背景设置与我使用的主题(深色与浅色)不同,则使用默认主题面孔,这在浅色或深色背景上可能看起来不太好。但在我的情况下,终端和主题都是黑暗的,它工作正常。
这个问题已经有两个答案,一个是using window-setup-hook,在启动时调用,另一个using,after-make-frame-functions在创建新框架时调用,包括调用之后emacsclient。为了涵盖所有可能的情况,我发现我需要这样做:
(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)
Run Code Online (Sandbox Code Playgroud)
请注意,我仅selected-frame在必要时使用;似乎在客户端模式下,在选择框架之前调用钩子,因此在这种情况下使用框架参数很重要。