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?
Asked
Active
Viewed 250 times
1
-
2As far as I can see, the problem with this is that _LaTeX_ doesn't treat that as comment. – Svante May 01 '10 at 17:49
-
Are you trying to get it to syntax highlight that for some reason? – Sep 27 '12 at 19:17
3 Answers
0
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
0
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)

Stefan
- 27,908
- 4
- 53
- 82
0
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?!?

dmckee --- ex-moderator kitten
- 98,632
- 24
- 142
- 234
-
There are some template systems that use `<%` and `%>` as their delimiters. – Michael Hoffman Jul 18 '12 at 22:31