gpt4 book ai didi

emacs - 在 Emacs 21.3.1 中以 C/C++ 模式更改 #if 0 ... #endif block 中代码的颜色

转载 作者:行者123 更新时间:2023-12-01 04:09:24 25 4
gpt4 key购买 nike

引用链接,
In C/C++ mode in Emacs, change face of code in #if 0...#endif block to comment face .

我尝试了代码,但它似乎不起作用。我的 emacs 版本是 Linux 上的 GNU Emacs 21.3.1。

请你让我知道我哪里出错了。

TIA

最佳答案

cpp-highlight-mode可以在没有用户交互的情况下工作。这是我的设置方式:

(defun cpp-highlight-if-0/1 ()
"Modify the face of text in between #if 0 ... #endif."
(interactive)
(setq cpp-known-face '(background-color . "dim gray"))
(setq cpp-unknown-face 'default)
(setq cpp-face-type 'dark)
(setq cpp-known-writable 't)
(setq cpp-unknown-writable 't)
(setq cpp-edit-list
'((#("1" 0 1
(fontified nil))
nil
(background-color . "dim gray")
both nil)
(#("0" 0 1
(fontified nil))
(background-color . "dim gray")
nil
both nil)))
(cpp-highlight-buffer t))

(defun jpk/c-mode-hook ()
(cpp-highlight-if-0/1)
(add-hook 'after-save-hook 'cpp-highlight-if-0/1 'append 'local)
)

(add-hook 'c-mode-common-hook 'jpk/c-mode-hook)

关键是弄清楚 cpp-highlight-mode看着 cpp-edit-list .我按照我想要的交互方式进行设置,然后查看 cpp-edit-list结果是 C-h v .

关于emacs - 在 Emacs 21.3.1 中以 C/C++ 模式更改 #if 0 ... #endif block 中代码的颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7189742/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com