From: Oleksandr Gavenko <gavenkoa@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: What's your favourite *under_publicized* editing feature of Emacs?
Date: Wed, 09 Feb 2011 01:10:35 +0200 [thread overview]
Message-ID: <4D51CD6B.3000205@gmail.com> (raw)
In-Reply-To: <4D4F0063.10708@gmail.com>
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 <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))
(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!
next prev parent reply other threads:[~2011-02-08 23:10 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <mailman.0.1296117403.8303.help-gnu-emacs@gnu.org>
2011-01-28 9:54 ` What's your favourite *under_publicized* editing feature of Emacs? Simón Ortiz
2011-01-28 21:22 ` Ken Goldman
[not found] ` <mailman.21.1296249764.1176.help-gnu-emacs@gnu.org>
2011-01-28 22:59 ` Stefan Monnier
2011-01-29 14:46 ` Oleksandr Gavenko
2011-01-29 15:00 ` Eli Zaretskii
2011-01-29 15:02 ` Perry Smith
[not found] ` <mailman.10.1296313340.8933.help-gnu-emacs@gnu.org>
2011-01-29 16:08 ` Stefan Monnier
2011-02-17 10:53 ` Giorgos Keramidas
2011-02-17 13:43 ` Perry Smith
2011-02-17 14:01 ` Thien-Thi Nguyen
[not found] ` <mailman.9.1297951684.6316.help-gnu-emacs@gnu.org>
2011-02-17 19:04 ` view/edit large files (was: What's your favourite *under_publicized* editing feature of Emacs?) Ted Zlatanov
2011-02-18 0:09 ` What's your favourite *under_publicized* editing feature of Emacs? Tim X
2011-01-29 12:55 ` Javier Sanz
2011-02-06 20:11 ` Oleksandr Gavenko
2011-02-08 23:10 ` Oleksandr Gavenko [this message]
[not found] ` <mailman.11.1297206657.16135.help-gnu-emacs@gnu.org>
2011-02-09 4:37 ` Stefan Monnier
2011-02-09 20:51 ` Oleksandr Gavenko
2011-02-09 21:31 ` Oleksandr Gavenko
2011-02-09 22:32 ` Thien-Thi Nguyen
2011-02-14 20:44 ` Oleksandr Gavenko
[not found] ` <mailman.10.1297284733.9144.help-gnu-emacs@gnu.org>
2011-02-10 17:24 ` Stefan Monnier
2011-03-01 21:30 What's your favourite *under_publicized* editing feature ofEmacs? Cthun
2011-03-02 1:00 ` What's your favourite *under_publicized* editing feature of Emacs? Steve
2011-03-02 5:34 ` PJ Weisberg
-- strict thread matches above, loose matches on Subject: below --
2011-01-27 8:33 Le Wang
2011-01-27 9:29 ` Deniz Dogan
2011-01-27 12:03 ` Wang Lei
2011-01-27 14:13 ` suvayu ali
2011-01-27 14:12 ` Ken Goldman
2011-01-27 18:11 ` Erik Iverson
[not found] ` <mailman.0.1296137574.27610.help-gnu-emacs@gnu.org>
2011-01-27 22:23 ` Joe Fineman
2011-01-28 6:40 ` Jason Rumney
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4D51CD6B.3000205@gmail.com \
--to=gavenkoa@gmail.com \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.