【问题标题】:Can't change cursor color in emacsclient无法在 emacsclient 中更改光标颜色
【发布时间】:2012-01-02 12:13:39
【问题描述】:

如果我运行emacs --daemon(在.xinitrc 或更高版本中)然后emacsclient -c,则无论颜色主题或任何其他设置如何,新创建的框架都有黑色光标颜色。更准确地说,在我输入任何内容之前,光标颜色为白色(或其他颜色),但第一次按键时它变为黑色,无法通过set-cursor-color 更改。默认和我的自定义颜色主题都是黑色的,所以编辑起来很不舒服。

如果我运行emacsM-x server-start 而不是emacs --daemon,则不会出现此问题。但是这样我需要保留一个 emacs“主”框架而不是偶然杀死它,这似乎不是一个好的解决方案。

我在.emacs.d/init.el 中有以下块,但它没有帮助:

(set-cursor-color "red")
(setq initial-frame-alist '((cursor-color . "red")))
(setq default-frame-alist '((cursor-color . "red")))
(add-hook 'window-setup-hook '(lambda () (set-cursor-color "red")))
(add-hook 'after-make-frame-functions '(lambda (f) (with-selected-frame f (set-cursor-color "red"))))

如果我运行M-x describe-face RET cursor,我会得到:

(...)
Defined in `faces.el'.

        Family: unspecified
       Foundry: unspecified
         Width: unspecified
        Height: unspecified
        Weight: unspecified
         Slant: unspecified
    Foreground: unspecified
    Background: black
     Underline: unspecified
      Overline: unspecified
Strike-through: unspecified
           Box: unspecified
       Inverse: unspecified
       Stipple: unspecified
          Font: unspecified
       Fontset: unspecified
       Inherit: unspecified

【问题讨论】:

  • 关于这件事的任何消息,你最后有没有发现任何有用的东西?我遇到了类似的问题,即 emacsclient 不会加载颜色主题,但 emacs 会很高兴地应用我的紫色光标。

标签: emacs emacs-faces


【解决方案1】:

相信在最近的 Emacsen 中,使用框架属性来设置光标颜色并不是首选的方法。所以而不是使用set-cursor-colorinitial-frame-alist / default-frame-alist,试试:

(set-face-background 'cursor "red")

或者,也许:

(set-face-attribute 'cursor nil :background "red"`)

【讨论】:

  • 嗯,奇怪。我看看能不能重现。
  • 我也试过了,但也没有成功。我也受到这种特殊行为的影响。
【解决方案2】:

好的..这个问题可以通过添加解决

(setq default-frame-alist '((cursor-color . "white")))

虽然我不明白为什么以前没有问题。

请参阅this 论坛帖子。

【讨论】:

    【解决方案3】:

    哇哈哈哈!我认为过去 2 年没有人发布解决方案,因为你们都是 EVIL emacs 用户!

    说实话,我自己现在正在尝试邪恶模式,我刚刚在我的系统上解决了这个问题。把它放在你的 .emacs 文件中并抽它:

    '(evil-default-cursor (quote (t "white")))
    

    我刚刚针对 bitbucket 中的 Evil 存储库打开了 a bug

    就我自己而言,我发现在真正精通 emacs 的 6 年左右之后,多键和弦让我筋疲力尽。 Evil-mode 可能会让我再次使用 emacs,这是一件好事。正如Benedict 所说(在函数式编程的上下文中),“Some evil is often necessary to get work done.”似乎也适用于 Emacs。

    附: 对于任何觉得这个答案只是DH0 或其他不成熟和不恰当的人来说,Emacs 和 VI 用户之间的大多数开玩笑的 feud 已经肆虐多年。 Emacs 有自己的Church of Emacs,VI 有视频游戏World War VI。因此,Emacs 最成功的 VI 键绑定端口被命名为 evil-mode(evil 中包含 VI 一词)也就不足为奇了。我喜欢这两个编辑器,并赞扬最终使 VI 键绑定在 emacs 中工作的邪恶开发人员。

    【讨论】:

    • 感谢 Glen,我已经是 EVIL 用户了(尽管我从不使用正常模式/状态)。我更正了您的命令(将 ' 替换为 setq)。它似乎对我很有效。即使由于某种原因光标再次变黑,我也可以重复该命令。
    • 由于这是唯一适合我的解决方案,我接受您的回答。虽然这对于不是 EVIL 粉丝的 emacs 用户来说有点不公平。
    【解决方案4】:

    这对我有用:

    (setq evil-default-cursor t) ;; Now evil takes the default cursors 
    (set-cursor-color "white") ;; Set it to white
    (set-mouse-color "white") ;; Same
    

    【讨论】:

      【解决方案5】:

      多年来我也有同样的问题。

      就我而言:

      M-x
      set-cursor-color
      "white"<ENTER>
      

      这对我有用,但我每次都必须这样做,这sux..

      回到我的旧工作场所,我已经解决了这个问题,但我没有以前在旧工作场所拥有的 init.el,现在我需要重新解决这个问题,希望这里有人会解决这个问题在我面前出来。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2012-07-23
        • 1970-01-01
        • 2012-07-16
        • 2011-01-12
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多