From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Oleksandr Gavenko Newsgroups: gmane.emacs.help Subject: Re: What's your favourite *under_publicized* editing feature of Emacs? Date: Wed, 09 Feb 2011 01:10:35 +0200 Message-ID: <4D51CD6B.3000205@gmail.com> References: <4D4F0063.10708@gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1297206682 1454 80.91.229.12 (8 Feb 2011 23:11:22 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 8 Feb 2011 23:11:22 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Feb 09 00:11:18 2011 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PmwiM-0006yk-3X for geh-help-gnu-emacs@m.gmane.org; Wed, 09 Feb 2011 00:11:18 +0100 Original-Received: from localhost ([127.0.0.1]:36777 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PmwiL-0000Gt-Fu for geh-help-gnu-emacs@m.gmane.org; Tue, 08 Feb 2011 18:11:17 -0500 Original-Received: from [140.186.70.92] (port=42860 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pmwi0-0000Go-0h for help-gnu-emacs@gnu.org; Tue, 08 Feb 2011 18:10:57 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Pmwhy-0004sx-Sw for help-gnu-emacs@gnu.org; Tue, 08 Feb 2011 18:10:55 -0500 Original-Received: from lo.gmane.org ([80.91.229.12]:54995) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Pmwhy-0004si-Hr for help-gnu-emacs@gnu.org; Tue, 08 Feb 2011 18:10:54 -0500 Original-Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1Pmwhv-0006gh-Pr for help-gnu-emacs@gnu.org; Wed, 09 Feb 2011 00:10:51 +0100 Original-Received: from 94-248-126-53.dynamic.peoplenet.ua ([94.248.126.53]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 09 Feb 2011 00:10:51 +0100 Original-Received: from gavenkoa by 94-248-126-53.dynamic.peoplenet.ua with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 09 Feb 2011 00:10:51 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 102 Original-X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: 94-248-126-53.dynamic.peoplenet.ua User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.2.12) Gecko/20101027 Thunderbird/3.1.6 In-Reply-To: <4D4F0063.10708@gmail.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 80.91.229.12 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:79038 Archived-At: On 2011-02-06 22:11, Oleksandr Gavenko wrote: > On 2011-01-29 14:55, Javier Sanz wrote: >> Some that come to my mind: >> - Using define-generic-mode, I've defined a major mode for my app >> logs, which highlights errors and warnings in different colors and >> makes them easier to see. > How large your log files? > > I set 'grep-mode' on my log file (which follow GNU > error coding convention). On 50-100 KiB logs it take > 10 sec to highlight matches. On larger files I type > C-g to stop matching for highlighting. > Performance penalty because I use grep-mode which based on compilation-mode. In private mail Javier Sanz show me his log mode based on 'define-generic-mode'. I check and found that font-lock mechanism is pretty fast. This become start point to develop some code by hand. And I realize that compilation-mode is dumb as it try set on all matched file/line pairs text properties to allow move to another file by RET. Instead I highlight required patterns and make GOTO error function which analyse only current line: ;;; 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)) (when fname (setq fline (string-to-int (match-string 2 line))) ) ) (when (and fname (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 nil '( ("^\\([^:]+\\):\\([[:digit:]]+\\):[^ ]+$" (1 font-lock-keyword-face) (2 font-lock-type-face)) ("^\\([^:]\\{1,10\\}\\):[^ ]+$" (1 font-lock-function-name-face)) ) ;; '("\\.log$") nil (list (lambda nil ;; (setq buffer-read-only t) (use-local-map my-log-mode-map) (modify-syntax-entry ?' ".") (modify-syntax-entry ?\" ".") )) ) ;;; my-log-mode.el ends here -- Best regards!