In Emacs, how do you change Latex mode to treat &l

2019-07-24 23:57发布

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?

标签: latex elisp
3条回答
放我归山
2楼-- · 2019-07-25 00:20

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?!?

查看更多
Luminary・发光体
3楼-- · 2019-07-25 00:43

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

查看更多
Root(大扎)
4楼-- · 2019-07-25 00:44

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)
查看更多
登录 后发表回答