突出显示“bool”;在 Java 中使用,在 Emacs 中

发布于 2024-12-14 11:40:46 字数 180 浏览 4 评论 0原文

在当前的工作中,我在 Java 和 C++ 之间来回切换,因此我倾向于在 Java 中使用“bool”而不是“boolean”。我在 Emacs 中编程,它在声明中与任何其他类型一样突出显示“bool”,因此在编译时我不会捕获错误。

有什么方法可以让 java-mode 为我突出显示“bool”,以便我可以在编写代码时捕获错误?

I switch back and forth between Java and C++ in my current job, and as a result I tend to use 'bool' in Java instead of 'boolean'. I program in Emacs, which highlights 'bool' in a declaration the same as any other type, so I don't tend to catch the error until compile time.

Is there any way to get java-mode to highlight 'bool' for me so that I can catch the error while I'm writing the code?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

仅冇旳回忆 2024-12-21 11:40:46

将其添加到您的 .emacs 中:

(font-lock-add-keywords 'java-mode
        '(("\\<bool\\>" . font-lock-warning-face)))

Add this to your .emacs:

(font-lock-add-keywords 'java-mode
        '(("\\<bool\\>" . font-lock-warning-face)))
橘味果▽酱 2024-12-21 11:40:46

最简单的也许

M-x highlight-regexp RET
\_<bool\_> RET
font-lock-warning-face RET

你也可以将其添加到 java-mode-hook 中。当然,缺点是,此方法不提供语法检查,并且还会在字符串和注释中突出显示......

The easiest is perhaps

M-x highlight-regexp RET
\_<bool\_> RET
font-lock-warning-face RET

You can certainly add this to the java-mode-hook too. Downside is, of course, this method provides no syntactic checking and will highlight also in strings and comments...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文