help-gnu-emacs
[Top][All Lists]
Advanced

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

log-reading major mode


From: Matzi Kratzi
Subject: log-reading major mode
Date: Tue, 5 Dec 2006 17:30:12 +0100

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
reply via email to

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