From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Matzi Kratzi" Newsgroups: gmane.emacs.help Subject: making a log-reading mode Date: Tue, 5 Dec 2006 08:02:00 +0100 Message-ID: <7f9b11c90612042302w64fccdc9x92f3803bed206a74@mail.gmail.com> NNTP-Posting-Host: dough.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0092049726==" X-Trace: sea.gmane.org 1165349253 12462 80.91.229.10 (5 Dec 2006 20:07:33 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 5 Dec 2006 20:07:33 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Dec 05 21:07:32 2006 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by dough.gmane.org with esmtp (Exim 4.50) id 1GrgZd-0002Fe-Of for geh-help-gnu-emacs@m.gmane.org; Tue, 05 Dec 2006 21:07:30 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GrgZd-0000Dn-Am for geh-help-gnu-emacs@m.gmane.org; Tue, 05 Dec 2006 15:07:29 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1GrUJX-00085s-8G for help-gnu-emacs@gnu.org; Tue, 05 Dec 2006 02:02:03 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1GrUJW-00084k-Nb for help-gnu-emacs@gnu.org; Tue, 05 Dec 2006 02:02:02 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GrUJW-00084a-JC for help-gnu-emacs@gnu.org; Tue, 05 Dec 2006 02:02:02 -0500 Original-Received: from [64.233.182.190] (helo=nf-out-0910.google.com) by monty-python.gnu.org with esmtp (Exim 4.52) id 1GrUJW-0002Yo-0a for help-gnu-emacs@gnu.org; Tue, 05 Dec 2006 02:02:02 -0500 Original-Received: by nf-out-0910.google.com with SMTP id d4so143090nfe for ; Mon, 04 Dec 2006 23:02:00 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:mime-version:content-type; b=VcDPagaBLfadHTzqyIngTCKAFGnRw3B6FxjiECpJZzDUgRQpmIddyWFqHlo1RtmhPaH0+2PJak4VVCnIBBlAYLJFLj0XTsSGlusUQoF9IE9K6QBoAwxHklhR0BKRWZqgrduR8EzTcUkCh136ymbBAsjqAg+1+M6JgX+AEhAJaQs= Original-Received: by 10.49.75.2 with SMTP id c2mr490891nfl.1165302120522; Mon, 04 Dec 2006 23:02:00 -0800 (PST) Original-Received: by 10.48.246.17 with HTTP; Mon, 4 Dec 2006 23:02:00 -0800 (PST) Original-To: help-gnu-emacs@gnu.org X-Mailman-Approved-At: Tue, 05 Dec 2006 15:06:35 -0500 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:39266 Archived-At: --===============0092049726== Content-Type: multipart/alternative; boundary="----=_Part_1741_23443409.1165302120481" ------=_Part_1741_23443409.1165302120481 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi. I am trying to make me a log reading major mode. I want to be able to change face of text matching certain regexps. To achieve this, I set font-lock-defaults and this works. My problem is that I would like to be able to change what text that is to be specially faced as I go along, i.e. identify interesting texts and add - or subtract - them from the regexps without having to revisit the file. Let say I usually want to highlight write, read and weblog. I use this: (defvar log-font-lock-keywords '(("\\(\\write\\)" . font-lock-function-name-face) ("\\(\\weblog\\)" . font-lock-doc-face) ("\\(\\read\\)" . font-lock-keyword-face) ) "Keyword highlighting specification for `log-mode'.") As I read 061205.log, I decide not to highlight "weblog" any more. How do I disable it? Later on, I want to highlight "user" instead, now with font-lock-comment-face. How do I do that? I do not want to close the file to reopen it again. Best Regards Matzi This is my attempt so far. It is a surprisingly small amount of code, but then again, it does not do what I want. =) (defvar log-font-lock-keywords '(("\\(\\write\\)" . font-lock-function-name-face) ("\\(\\weblog\\)" . font-lock-doc-face) ("\\(\\read\\)" . font-lock-keyword-face) ) "Keyword highlighting specification for `log-mode'.") ;;;###autoload (define-derived-mode log-mode fundamental-mode "log" "A major mode for editing log files." (set (make-local-variable 'font-lock-defaults) '(log-font-lock-keywords)) ) (provide 'log) ;;; log.el ends here ------=_Part_1741_23443409.1165302120481 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi.
I am trying to make me a log reading major mode.
I want to be able to change face of text matching certain regexps. To achieve this, I set font-lock-defaults and this works.

My problem is that I would like to be able to change what text that is to be specially faced as I go along, i.e. identify interesting texts and add - or subtract - them from the regexps without having to revisit the file.

Let say I usually want to highlight write, read and weblog. I use this:
(defvar log-font-lock-keywords
  '(("\\(\\write\\)"    . font-lock-function-name-face)
    ("\\(\\weblog\\)"     . font-lock-doc-face)
    ("\\(\\read\\)"      . font-lock-keyword-face)
    )
  "Keyword highlighting specification for `log-mode'.")

As I read 061205.log, I decide not to highlight "weblog" any more. How do I disable it? Later on, I want to highlight "user" instead, now with font-lock-comment-face. How do I do that? I do not want to close the file to reopen it again.

Best Regards
Matzi

This is my attempt so far. It is a surprisingly small amount of code, but then again, it does not do what I want. =)

(defvar log-font-lock-keywords
  '(("\\(\\write\\)"    . font-lock-function-name-face)
    ("\\(\\weblog\\)"     . font-lock-doc-face)
    ("\\(\\read\\)"      . font-lock-keyword-face)
    )
  "Keyword highlighting specification for `log-mode'.")

;;;###autoload
(define-derived-mode log-mode fundamental-mode "log"
  "A major mode for editing log files."
  (set (make-local-variable 'font-lock-defaults)
       '(log-font-lock-keywords))
  )

(provide 'log)
;;; log.el ends here


------=_Part_1741_23443409.1165302120481-- --===============0092049726== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ help-gnu-emacs mailing list help-gnu-emacs@gnu.org http://lists.gnu.org/mailman/listinfo/help-gnu-emacs --===============0092049726==--