# HG changeset patch # User Oleksandr Gavenko # Date 1297205083 -7200 # Node ID a9f4afeefe2ad93ef3b485b72e57523e7955bbaa # Parent 0eae7b87c27aef7567f68525ef671313bd8e60a4 Major mode for error logs. diff -r 0eae7b87c27a -r a9f4afeefe2a my-log-mode.el --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/my-log-mode.el Wed Feb 09 00:44:43 2011 +0200 @@ -0,0 +1,61 @@ +;;; my-log-mode.el --- major mode for error logs + +;; Copyright (C) 2010 by Oleksandr Gavenko + +;; You can do anything with this file without any warranty. + +;; Author: Oleksandr Gavenko +;; Maintainer: Oleksandr Gavenko +;; 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)) + (string-match fregex line) + (setq fname (match-string 1 line)) + (setq fline (string-to-int (match-string 2 line))) + ) + (when (file-exists-p fname) + (find-file-other-window fname) + (goto-line fline) + ) + )) + +(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 + '("INT" "WM") + '( + ("^\\([^:]+\\):\\([[:digit:]]+\\):" (1 font-lock-constant-face) (2 font-lock-constant-face)) + ) + ;; '("\\.log$") + nil + (list + (lambda nil + ;; (setq buffer-read-only t) + (use-local-map my-log-mode-map) + )) + ) + +;;; my-log-mode.el ends here