使终端中的 emacs 使用深色而不是浅色字体锁定颜色
我在 MacOS 10.6 上通过终端使用 emacs。我有一个白色背景。
阅读带引号的 C++ 字符串非常困难。它们呈淡绿色。关键字为绿松石色。
在搜索源代码后,我发现 cpp.el 并确定我使用的是 cpp-face-light-name-list 而不是 cpp-face-dark-name-list。
显然这个函数应该根据背景颜色选择正确的列表:
(defcustom cpp-face-default-list nil
"Alist of faces you can choose from for cpp conditionals.
Each element has the form (STRING . FACE), where STRING
serves as a name (for `cpp-highlight-buffer' only)
and FACE is either a face (a symbol)
or a cons cell (background-color . COLOR)."
:type '(repeat (cons string (choice face (cons (const background-color) string))))
:group 'cpp)
但它似乎不起作用。
我应该在 .emacs 文件中放入什么,以便获得 cpp-face-dark-list 而不是 cpp-face-light-list?
谢谢!
I am using emacs on MacOS 10.6 with Terminal. I have a white background.
It's very hard to read quoted C++ strings. They are coming up in pale green. Keywords are in turquoise.
After searching through the source I cam across cpp.el and have determined that I am using the cpp-face-light-name-list instead of cpp-face-dark-name-list.
Apparently this function is supposed to chose the correct list based on the background color:
(defcustom cpp-face-default-list nil
"Alist of faces you can choose from for cpp conditionals.
Each element has the form (STRING . FACE), where STRING
serves as a name (for `cpp-highlight-buffer' only)
and FACE is either a face (a symbol)
or a cons cell (background-color . COLOR)."
:type '(repeat (cons string (choice face (cons (const background-color) string))))
:group 'cpp)
But it doesn't seem to be working.
What should I put in my .emacs file so that I get the cpp-face-dark-list instead of cpp-face-light-list?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
我有同样的问题,我选择的主题在终端上总是无法读取。答案是使用 color-theme 包,正如其他人所说,然后在终端中为 Emacs 选择一个主题,并为在自己的窗口中运行的 Emacs 选择另一个主题,就像这样:
在 Emacs 中,您可以键入
Mx color-theme-Tab
获取可用主题的列表。同样,您可以为主要模式添加挂钩,以根据您正在编辑的代码类型来更改颜色主题。I have the same problem, my chosen themes are always unreadable on the terminal. The answer is to use the color-theme package, as others have said, then select one theme for Emacs in a terminal, and another theme for Emacs running in its own window, just like this:
In Emacs, you can type
M-x color-theme-Tab
to get a list of available themes. Equally, you could add hooks for major modes to change the color-theme depending on what sort of code you are editing.正如评论之一所建议的 - 查看 color-theme 包。对于像您这样的问题,这是一种更通用的解决方案,并且比手动调整字体更容易使用。
As suggested in one of the comments - check out the color-theme package. It's a much more generic solution to problems such as yours and it's much easier to use than manually adjusting font faces.
如果您明确将默认面孔的前景设置为黑色,背景设置为白色(
Mxcustomize-group basic-faces
),字体锁定将确保所有内容都自动可读。如果您需要的只是足够的对比度以使字体锁定可读,那么这两种颜色是您唯一需要设置的颜色。我尝试过 colortheme.el,尤其是使用 emacs23 时,它往往会使内容变得不那么可读,而不是更具可读性,我最终不得不重新启动才能恢复它设置为不可读的前景/背景组合且未重置的面孔。
If you explicity set the default-face's foreground to black and background to white (
M-x customize-group basic-faces
), font lock will make sure everything is readable automatically. Those two colors are the only ones you need to set if all you need is enough contrast to have font lock be readable.I have tried colortheme.el, and especially with emacs23 it tends to make things less rather than more readable, I ended up having to restart in order to recover faces that it set to unreadable foreground/background combos and did not reset.
可能值得确保您的终端启用了颜色:
导出 TERM=xterm-256color
might be worthwhile to make sure your terminal is color enabled:
export TERM=xterm-256color
这是另一种方法,如果您在 Emacs 23+ 中使用守护进程模式,它会特别方便。在使用守护程序模式时,有时使用图形客户端,有时使用终端客户端。下面的“片段”尝试找出您正在使用的客户端,然后切换到适当的主题(从颜色主题选择)。在 emacswiki 上找到的。
This is another way to do it, and it's especially handy if you use the daemon mode in Emacs 23+. While using daemon mode, one is sometimes using a graphical client and some other times a terminal client. The "snippet" below tries to figure out what client you are using, and then switches to the appropriate theme (from color-theme-choices). Found it on emacswiki.