[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How do I setup an extremely simple font-lock mode?

From: myrkraverk
Subject: How do I setup an extremely simple font-lock mode?
Date: Thu, 22 May 2003 21:11:30 +0000


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 
    (2 font-lock-constant-face))
    (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,


This line is left blank intentionally

reply via email to

[Prev in Thread] Current Thread [Next in Thread]