FIX: 'html-tag-alist' is not defined in 'psgml' mode.
;;; my-log-mode.el --- major mode for error logs
;; Copyright (C) 2010 by Oleksandr Gavenko <gavenkoa@gmail.com>
;; You can do anything with this file without any warranty.
;; Author: Oleksandr Gavenko <gavenkoa@gmail.com>
;; Maintainer: Oleksandr Gavenko <gavenkoa@gmail.com>
;; Created: 2011-02-09
;; Version: 0.1
;; Keywords: logging
;;; Commentary:
;;
;; Very pure release.
;;; Code:
(defun my-log-goto (point)
""
(interactive "d")
(let ( start stop line fname fline (fregex "^\\([^:]+\\):\\([[:digit:]]+\\):") )
(save-excursion
(move-beginning-of-line 1)
(setq start (point))
(move-end-of-line 1)
(setq stop (point))
(setq line (filter-buffer-substring start stop nil t))
(string-match fregex line)
(setq fname (match-string 1 line))
(when fname
(setq fline (string-to-int (match-string 2 line)))
)
)
(cond
( (and fname (file-exists-p fname))
(find-file-other-window fname)
(goto-line fline)
)
( t
(if fname
(message "File '%s' is not found (default directory is '%s')." fname default-directory)
(message "No file under current line.")
)
)
)
))
(setq my-log-mode-map (make-sparse-keymap))
(define-key my-log-mode-map (kbd "RET") 'my-log-goto)
(require 'generic-x)
;;;###autoload
(define-generic-mode
'my-log-mode
nil
nil
'(
("^\\([^:]+\\):\\([[:digit:]]+\\):[^
]+$" (1 font-lock-function-name-face) (2 font-lock-type-face))
("^\\([^:]\\{1,10\\}\\):[^
]+$" (1 font-lock-keyword-face))
)
;; '("\\.log$")
nil
(list
(lambda nil
(use-local-map my-log-mode-map)
(modify-syntax-entry ?' ".")
(modify-syntax-entry ?\" ".")
))
)
;;; my-log-mode.el ends here