【问题标题】:how to check if emacs in frame or in terminal?如何检查emacs是在框架中还是在终端中?
【发布时间】:2012-03-06 11:11:04
【问题描述】:

基于这个问题:How to set emacsclient background as Emacs background?

我只需要框架的背景,而不是终端和控制台。

这是我尝试为控制台添加修复程序的方式

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

但是,我没有获得 emacsclient 的背景知识(即使是框架)。也许检查甚至没有在 emacsclient 中运行?

基本上我不想在终端和控制台中为 emacsclient 添加背景,而是在框架中。

【问题讨论】:

  • 您的代码在哪里被评估?请记住,.emacs 仅在 Emacs 启动时评估一次,而不是在 emacsclient 连接时。
  • 好的,所以您的 .emacs 文件直接评估您的 (nCdy-mode) 函数,这意味着您的 (when (display-graphic-p) ...) 子句的主体最多将被评估一次*,然后仅当 @987654325 @ 在 Emacs 启动时为真。 (*) 除非你也在其他地方调用 (nCdy-mode),但你没有说你是。

标签: linux emacs elisp emacsclient


【解决方案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】:

    也许更简单的解决方案是不触摸 *-frame-alist,也不 set-frame-*,而是改为 Mx customize-face RET default RET 然后中键单击“State”按钮并选择“适用于所有类型的显示器”,此时您将能够为不同的显示器设置不同的面部外观。 UI 的这一部分用得不多,它会显示出来,但你会这样做: 在INS上单击鼠标中键插入第二组设置,然后中键单击“显示”并选择“无”,然后单击“类型”左侧的切换按钮,然后单击“TTY”左侧的切换按钮:这使得第一组设置仅适用于 tty 帧,而另一组设置(可能仍然显示“显示:全部”)适用于其余情况(即非 tty 帧)。

    【讨论】:

    • 啊,太好了! FWIW我发现左键单击与这些小部件的中键单击相同(都绑定到widget-button-click)?对于这个特定的问题,您需要单击“支持属性”和“显示所有属性”来访问前景色和背景色选项。
    • 实际上,我想您确实将新设置留空,而是在默认设置中更改这些颜色。我用 Ubuntu 的默认终端尝试了反转(更改 TTY 设置的前景色/背景色),但无法使其生效(尽管“反转视频”选项确实有效)。 YMMV?
    猜你喜欢
    • 2010-12-05
    • 1970-01-01
    • 1970-01-01
    • 2011-08-13
    • 1970-01-01
    • 2011-05-10
    • 1970-01-01
    • 2013-12-30
    • 1970-01-01
    相关资源
    最近更新 更多