I want to write a syntax highlighting extension for Emacs, but I Googling of variations on "emacs syntax highlight tutorial" have all failed. How do I go about learning how to write an Emacs highlighter? What good resources are there for learning how to do such things?
+13
A:
You're looking in the wrong place. Look at "font-lock-mode".
Charlie Martin
2009-05-15 04:15:28
This looks awesome. I will definitely investigate this further when it's not 1:40 in the morning.
Chris Lutz
2009-05-15 05:42:49
+5
A:
There's a related question, on how to define a major mode with syntax highlighting using 'define-generic-mode
. The question focuses on figuring out how to get the syntax highlighting working.
Trey Jackson
2009-05-15 06:23:59
+1
A:
Hi,
unfortunately you were searching for the wrong terms, "syntax highlighting" is not emacs vocabulary :). You should have searched for something like "write emacs mode".
There was already a question for this: "How to write an emacs mode for a new language" with some good pointers.
danielpoe
2009-05-15 06:48:19
+1
A:
If you are interested in writing your own highlighting, another question covered this and may be of value to you. It included this code snippet:
(defun django-highlight-comments ()
(interactive "p")
(highlight-regexp "{%.*?%}" 'hi-orange))
(add-hook 'html-mode-hook 'django-highlight-comments)
Code courtesy of Ashutosh Mehra's answer.
Alex B
2009-05-18 15:21:15