From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: dapfy@t-online.de (Daniel Pfeiffer) Newsgroups: gmane.emacs.devel Subject: Re: Changes to emacs/lisp/progmodes/grep.el Date: Fri, 25 Jun 2004 22:03:04 +0200 Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: <20040625220304.0f1fd05a@pfdabpc.inhouse.start.de> References: <87isdgnzzi.fsf@mail.jurta.org> Reply-To: Daniel Pfeiffer NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Trace: sea.gmane.org 1088193774 28164 80.91.224.253 (25 Jun 2004 20:02:54 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 25 Jun 2004 20:02:54 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Fri Jun 25 22:02:38 2004 Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1BdwuE-0001ER-00 for ; Fri, 25 Jun 2004 22:02:38 +0200 Original-Received: from lists.gnu.org ([199.232.76.165]) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1BdwuD-000577-00 for ; Fri, 25 Jun 2004 22:02:38 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1Bdwvh-0001ge-6B for emacs-devel@quimby.gnus.org; Fri, 25 Jun 2004 16:04:09 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1BdwvX-0001f5-Hg for emacs-devel@gnu.org; Fri, 25 Jun 2004 16:03:59 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1BdwvW-0001da-5v for emacs-devel@gnu.org; Fri, 25 Jun 2004 16:03:58 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1BdwvV-0001co-QV for emacs-devel@gnu.org; Fri, 25 Jun 2004 16:03:57 -0400 Original-Received: from [194.25.134.85] (helo=mailout11.sul.t-online.com) by monty-python.gnu.org with esmtp (Exim 4.34) id 1Bdwth-0008Mm-9l for emacs-devel@gnu.org; Fri, 25 Jun 2004 16:02:05 -0400 Original-Received: from fwd04.aul.t-online.de by mailout11.sul.t-online.com with smtp id 1Bdwsu-0006IM-02; Fri, 25 Jun 2004 22:01:16 +0200 Original-Received: from pfdabpc.inhouse.start.de (S+TLP6ZcZeitDzQMcYlEt7w3yg-3rUtCYoNiRwsPetdjzJYmHc2Iga@[217.234.57.186]) by fwd04.sul.t-online.com with smtp id 1Bdwsn-0StmgC0; Fri, 25 Jun 2004 22:01:09 +0200 Original-To: Juri Linkov In-Reply-To: <87isdgnzzi.fsf@mail.jurta.org> X-Mailer: Sylpheed version 0.9.10claws (GTK+ 1.2.10; i686-suse-linux) X-Seen: false X-ID: S+TLP6ZcZeitDzQMcYlEt7w3yg-3rUtCYoNiRwsPetdjzJYmHc2Iga X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.4 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:25257 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:25257 Hi Juri, Juri Linkov skribis: > Daniel Pfeiffer writes: > > (grep-regexp-alist): Give it the full functionality of gnu style > > compilation messages with line and column ranges. Ask me for the > > perl script I'm working on, that uses these. > > Requiring Emacs users to use a perl script is not a good solution. I'm not requiring them to just, as Emacs doesn't require GNU grep, which sadly is not omnipresent. Instead grep.el bends over backwards in horrible ways to get something out of simple greps and find. Mine is just an alternative that might or might not be distributed with Emacs. Being in Perl it has the advantage of running as is on very many machines -- no compilation needed. Besides showing column numbers it has some other nice features, like multi-line matches. And it doesn't plonk a 98-character long file-name before some deeply buried file. Instead it uses compile's recognition of "Entering directory" lines, to only give the file name. There's also the possibilty to act upon the file contents with a perl expression. This allows you to drop out of files, e.g. if the first line doesn't look like #! /usr/bin/perl or whatever. Or you can massage the lines to eliminate comments or ignore lines in certain sections, like perl's pod (=xyz ... =cut or EOF). > But what about using the match highlighting feature of GNU grep? > With some changes in `compilation-mode-font-lock-keywords' and > `compilation-error-properties' this will allow to call functions > to compute columns of matches marked by grep. Without having tried it yet, this looks like an interesting approach. Somebody had suggested parsing the grep command and creating font-lock-keywords based on what I think grep matched. Your approach is much more elegant and bound to be correct! + ("^\\(.+?\\)[:(]+\\([0-9]+\\)\\([:)]\\)[^\033\n]*\033\\[01;41m\\([^\033\n]*\\ )\033\\[00m" 1 2 This won't work if the line contains an ESC before or within the match. Better would be ("^\\(.+?\\)[:(]+\\([0-9]+\\)\\([:)]\\).*?\033\\[01;41m\\(.*?\\)\033\\[00m" 1 2 > + ("\033\\[01;41m\\([^\033\n]*\\)\033\\[00m" > + (1 (list 'face compilation-column-face > + 'font-lock-face compilation-column-face) t) > + ((lambda (p)) > + (progn (delete-region (match-end 1) (match-end 0)) > + (delete-region (match-beginning 0) (match-beginning 1)))))) This part is bad, because you are removing the basis for the column determination. So if you save the *grep* buffer, you won't get the same result when reloading it. Likewise if you modify the line. Instead you should put an 'invisble and maybe 'intangible property on the escape sequence. And you don't need to match them twice. Instead you could additionally put normal font-lock HIGHLIGHTs into your grep-regexp-alist rule: (REGEXP FILE [LINE COLUMN TYPE HYPERLINK HIGHLIGHT...]). Something like '(face nil invisble t intangible t). coralament / best Grötens / liebe Grüße / best regards / elkorajn salutojn Daniel Pfeiffer -- lerne / learn / apprends / lär dig / ucz się Esperanto: http://lernu.net/