|
From: | Matt Noel |
Subject: | Re: How do I setup an extremely simple font-lock mode? |
Date: | Thu, 22 May 2003 17:48:39 -0700 |
Hi,
Matt Noel writes:
I want to setup a very simple mode for colorizing a log file. All I
need to do is highlight any lines with the string ERROR on them. I've
tried reading the documentation for font-lock but it's not clear how to
do this.
Could someone point me to a simple example, or send one?
Here is an example, it doesn't though specify how you use the mode on
the log file. Maybe you can edit it to suit your need.
;; This is basically a list of lists with a regular expression and
;; then the font name (or face name). The numbers below refer to \\(
;; ... \\) constructs that mark what part of the re you want
;; highlighted
(defconst masp-font-lock-keywords
'(("^\\(\\(\\sw\\|\\s_\\)+\\)\\>:?[ \t]*\\(\\sw+\\(\\.[lLwWbBsS]\\)?\\)?"
(1 font-lock-function-name-face) (3 font-lock-keyword-face nil t))
("^\\s +\\(\\(\\sw\\|\\s_\\)+\\(\\.[lLwWbBsS]\\)?\\)" 1 font-lock-keyword-face)
("^\\(\\s-+\\|\\sw+:\\s-+\\)\\(\\\\[a-zA-Z0-9]+\\)"
(2 font-lock-constant-face))
("\\(\\\\\\sw+\\)"
(1 font-lock-variable-name-face)))
"Additional expressions to highlight in Assembler mode.")
(defun masp-mode ()
;;...
(setq font-lock-defaults '(masp-font-lock-keywords))
;;...
)
Hope this helps,
Johann
--
This line is left blank intentionally
[Prev in Thread] | Current Thread | [Next in Thread] |