From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: myrkraverk@users.sourceforge.net Newsgroups: gmane.emacs.help Subject: How do I setup an extremely simple font-lock mode? Date: Thu, 22 May 2003 21:11:30 +0000 Sender: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: <16077.15618.129314.900191@jin.tekken> References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: main.gmane.org 1053638280 32174 80.91.224.249 (22 May 2003 21:18:00 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Thu, 22 May 2003 21:18:00 +0000 (UTC) Cc: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Thu May 22 23:17:59 2003 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 19IxRm-0008Mf-00 for ; Thu, 22 May 2003 23:17:59 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.20) id 19IxRP-0006nq-2D for gnu-help-gnu-emacs@m.gmane.org; Thu, 22 May 2003 17:17:35 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.20) id 19IxRG-0006lj-GR for help-gnu-emacs@gnu.org; Thu, 22 May 2003 17:17:26 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.20) id 19IxNC-0004KN-35 for help-gnu-emacs@gnu.org; Thu, 22 May 2003 17:13:46 -0400 Original-Received: from adsl1-61.du.heimsnet.is ([62.145.142.61] helo=jin.tekken) by monty-python.gnu.org with esmtp (Exim 4.20) id 19IxLO-0003ae-3M for help-gnu-emacs@gnu.org; Thu, 22 May 2003 17:11:22 -0400 Original-Received: (from myrkraverk@localhost) by jin.tekken (8.11.6/8.11.6) id h4MLBUX15131; Thu, 22 May 2003 21:11:30 GMT X-Authentication-Warning: jin.tekken: myrkraverk set sender to myrkraverk@users.sourceforge.net using -f Original-To: Matt Noel In-Reply-To: X-Mailer: VM 7.15 under Emacs 21.3.1 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1b5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Help: List-Post: List-Subscribe: , List-Archive: List-Unsubscribe: , Errors-To: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.help:10068 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:10068 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