--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mylisp/my-log-mode.el Sat Jan 02 00:33:04 2021 +0200
@@ -0,0 +1,72 @@
+;;; 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)
+ "Visit file according to error specification at 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))
+ (when fname
+ (setq fline (string-to-number (match-string 2 line))))
+ )
+ (cond
+ ( (and fname (file-exists-p fname))
+ (find-file-other-window fname)
+ (goto-char (point-min))
+ (forward-line (1- fline)) )
+ ( t
+ (if fname
+ (message "File '%s' is not found (default directory is '%s')." fname default-directory)
+ (message "No file under current line.") ) )
+ )
+ ))
+
+(defvar 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