简体   繁体   English

根据连接的显示器更改Emacs 24主题

[英]Change Emacs 24 theme depending on connected monitors

I'm using Emacs 24 on my Ubuntu Linux running laptop, which is usually connected to a very nice external monitor, where I like one color theme (using deftheme). 我在运行Ubuntu Linux的笔记本电脑上使用Emacs 24,该笔记本电脑通常连接到非常漂亮的外部显示器,在该显示器上我喜欢一种颜色主题(使用deftheme)。 But when I'm on the road, I like another deftheme. 但是当我在旅途中时,我喜欢另一个主题。

How can I make Emacs listen to monitor connection events, and set the theme accordingly? 如何使Emacs监听监听连接事件,并相应地设置主题?

I doubt that there is an easy way to react on changes to the display configuration. 我怀疑是否有一种简单的方法可以对显示配置的更改做出反应。 On Linux, you may be lucky to find a DBus service that signals such changes, which you can react upon by means of the Emacs D-Bus library , but on OS X and Windows I doubt that there is such a simple way. 在Linux上,您可能会很幸运地找到一个发出信号通知此类更改的DBus服务,您可以通过Emacs D-Bus库对它进行响应,但是在OS X和Windows上,我怀疑是否有这种简单的方法。

You may be better off with a simple key binding that toggles between your two favorite themes: 您可以通过在两个喜欢的主题之间进行切换的简单按键绑定来实现更好的效果:

(defvar my-current-theme nil
  "The last used theme.")

(defun my-toggle-themes ()
  "Toggle between my favorite themes."
  (let ((new-theme (if (eq my-current-theme 'solarized-light)
                       'zenburn 'solarized-light)))
    (load-theme new-theme :no-confirm)
    (setq my-current-theme new-theme)))

(global-set-key (kbd "C-c t") #'my-toggle-themes)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM