使用颜色主题在 Emacs 下的 c 模式下设置浮点值的颜色?
我正在使用 EmacsForMacOsX v23.3.1,我想知道如何将浮点值的颜色 celsiusFloat = (5.0/9.0);
更改为与我当前获得的颜色不同的颜色color-theme-billw
整数主题age = 23;
。
我怀疑 StackOverflow 给它们上色的方式不同。
EDIT: My initial approach to add a regex for the floating point
d*\.d*
in cc-mode.el
was apparently not the way Emacs work with syntax highlighting (also known as font locking) - further research has led me to the following website: http://www.gnu.org/software/emacs/elisp/html_node/Customizing-Keywords.html编辑2: 我似乎在 http://www.emacswiki.org/emacs/AddKeywords 找到了答案和
http://www.gnu.org/software/emacs/manual/html_node/emacs/Font-Lock.html#Font-Lock
(add-hook 'c-mode -钩 (拉姆达() (字体锁定添加关键字 nil '(("[0-9]+\\.[0-9]+" 1 字体锁定警告面 t)))))
I'm using EmacsForMacOsX, v23.3.1, and I wonder how I can change the color for floating point values celsiusFloat = (5.0/9.0);
to be a different color than those I get from my currentcolor-theme-billw
theme for integers age = 23;
.
I doubt that StackOverflow colours them differently.
EDIT:
My initial approach to add a regex for the floating point
d*\.d*
in cc-mode.el
was apparently not the way Emacs work with syntax highlighting (also known as font locking) - further research has led me to the following website: http://www.gnu.org/software/emacs/elisp/html_node/Customizing-Keywords.htmlEdit 2:
I seem to have found my answer at http://www.emacswiki.org/emacs/AddKeywords and
http://www.gnu.org/software/emacs/manual/html_node/emacs/Font-Lock.html#Font-Lock
(add-hook 'c-mode-hook
(lambda ()
(font-lock-add-keywords nil
'(("[0-9]+\\.[0-9]+" 1 font-lock-warning-face t)))))
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我在以下位置找到了解决方案: http://hbfs.wordpress。 com/2010/03/02/adding-keywords-in-emacs/
首先:
然后我们继续将正则表达式添加到关键字列表中,并将每个正则表达式与一个面孔相关联:
最后我们将其挂接到我们的模式:
I found a solution at: http://hbfs.wordpress.com/2010/03/02/adding-keywords-in-emacs/
First:
Then we proceed to add regular expressions to the list of keywords and associate each regexp with a face:
Last we hook it to our mode: