【发布时间】:2014-03-27 16:50:59
【问题描述】:
我有这段代码可以突出显示制表符,并希望使用项目特定宏来禁用它们:
(require 'highlight-chars)
(make-variable-buffer-local 'prevent-highlight-tabs)
(setq highlight-chars-disable '(term-mode erc-mode fundamental-mode))
(setq-default prevent-highlight-tabs nil)
(add-hook 'font-lock-mode-hook
(lambda()
(message "lock")
(when (and (null (memql major-mode highlight-chars-disable))
(not prevent-highlight-tabs))
(message "%s" prevent-highlight-tabs)
(hc-highlight-tabs))))
(custom-set-faces '(hc-tab ((t (:background "red")))))
和project-specifics 是一个宏,它定义了从这个question 添加find-file-hook 和dired-after-readin-hook
(project-specifics "projects/test"
(message "specific")
(setq prevent-highlight-tabs t)
(setq indent-tabs-mode t))
我想要做的是禁用项目/测试中文件的红色标签(我想要它们,因为在大多数项目中我只想要空格,并希望看到标签),但我有一个问题,因为来自 font-lock-mode-hook 的代码在project-specifics (find-file-hook) 之前执行,并且 prevent-highlight-tabs 在 font-lock-mode-hook 中始终为 nil。为什么会这样,如何解决?
【问题讨论】:
-
内置的
whitespace-mode可能对你有用。 (根据您的需要,它也可能过于杀戮和过于复杂,但当然值得一玩。) -
@phils 我想在第一次尝试时使用空白模式,但后来有人建议改用
highlight-chars。
标签: emacs elisp whitespace font-lock