1

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?

Winston C. Yang
  • 1,497
  • 2
  • 18
  • 27

3 Answers3

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

Community
  • 1
  • 1
snim2
  • 4,004
  • 27
  • 44
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