如何更改 emacs 上的光标颜色
我对 Emacs 的颜色做了一些更改,现在唯一的问题是光标在黑色背景上为黑色,我必须更改它。我该怎么办?
I made some changes in Emacs's colors and the only thing wrong now is the cursor that is black on black background and I will have to change that. What do I do?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(9)
如果您运行的是最新版本的 emacs,您可以使用:
您可以使用任何您喜欢的颜色,而不是
#ffffff
。对于十六进制代码列表,谷歌说: http://www.tayloredmktg.com/rgb/也许你喜欢这个...以下代码会更改每次闪烁时的光标颜色。只需评估代码及其运行:
请注意,此代码替换了“frame.el”中的 emacs 函数“blink-cursor-timer-function”。
If you are running a recent version of emacs you can use:
Instead of
#ffffff
you can use any color you like. For a list of hex code google Says: http://www.tayloredmktg.com/rgb/Maybe you like this one... the following code changes the cursor color on each blink. Just eval code and its running:
Note that this code replaces the emacs function 'blink-cursor-timer-function' from 'frame.el'.
以上都不适合我,所以我自己做了一些研究。来自Emacs 手册:
所以方法如下:
Mxcustomize-face
,输入cursor
回车屏幕截图位于:
None of above worked for me, so I did a little research on my own. From the Emacs Manual:
So here is the way to do it:
M-x customize-face
, entercursor
enterScreenshots here:
试试这个:
如果您想保留
default-frame-alist
中的其他值,您可以使用 Mark 的建议:Try this:
If you want to preserve the other values in
default-frame-alist
you can us Mark's suggestion:如果您使用 X 窗口系统,请尝试将类似的内容放入
.Xdefaults
中:If you use X window system, try out put something like this to
.Xdefaults
:您可以使用它来自定义 emacs 颜色:
You can use this for customize emacs colors:
对我来说,根据其他答案的建议在 init 上设置光标颜色实际上并不起作用,因为可能会干扰我正在加载的主题和包。我的解决方案是添加以下内容:
此解决方案使得对 set-cursor-color 的调用仅在 init 完成后 5 秒发生,从而为所有其他包和主题更改提供足够的时间来完全加载。
For me, setting the cursor color on init with the recommendation from the other answers wouldn't really work because of some possible interference with the themes and packages I was loading. My solution was to add the following instead:
This solution makes it so that a call to set-cursor-color will only happen 5 seconds after init finishes, allowing enough time for all the other packages and theme changes to fully load.
还有一个命令行选项:
There is also a command line option:
请记住,如果您使用的是
iTerm2
,则必须对其设置进行更改,否则不会对.emacs
配置文件进行更改。首选项=>个人资料 =>颜色=>光标颜色
Keep in mind if you are using
iTerm2
you have to make changes on its settings, otherwise changes on the.emacs
config file does not take place.Preferences => Profiles => Color => Cursor Colors
我将
(set-face-attribute 'cursor nil :background "#A0F")
添加到我的.emacs
文件中,使我的光标变成漂亮的紫罗兰色。我不确定版本和系统信息有多重要,但我在 Ubuntu 22.04.1 LTS 上以 GUI 模式运行 GNU Emacs 27.1。 (Emacs 28.2 可从 GNU 网站获取,所以 YMMV。)
I added
(set-face-attribute 'cursor nil :background "#A0F")
to my.emacs
file, making my cursor a nice violet color.I'm not sure how critical version and system info are, but I'm running GNU Emacs 27.1 in GUI mode on Ubuntu 22.04.1 LTS. (Emacs 28.2 is available from the GNU website, so YMMV.)