In Emacs, is there some short code that you can write (in .emacs, latex.el, or some other file) so that Latex mode treats code of form <% ... %> as a comment?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
See this tutorial on writing syntax highlighting support for new modes (wayback machine link to material orriginally found at http://two-wugs.net/emacs/mode-tutorial.html and attibuted to Scott Andrew Borton), then dig into what the latex mode you are using (tex-mode? auctex? something else?) is doing and fix it.
Which only leaves the question: Why?!?
回答2:
You need to use the font-lock-add-keyword
function; give it a major mode to add keywords too, and a association list of regex / face:
(font-lock-add-keywords 'latex-mode
'(("\<\%.*\%\>" . font-lock-comment-face)))
More details here on emacswiki: http://www.emacswiki.org/emacs/AddKeywords
Note this answer was copied over from the previous version of this question
回答3:
Something like the following might work:
(modify-syntax-entry ?< "_ 1n" latex-mode-syntax-table)
(modify-syntax-entry ?% "< 23" latex-mode-syntax-table)
(modify-syntax-entry ?> "_ 4n" latex-mode-syntax-table)