all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: dapfy@t-online.de (Daniel Pfeiffer)
Cc: emacs-devel@gnu.org
Subject: Re: Changes to emacs/lisp/progmodes/grep.el
Date: Fri, 25 Jun 2004 22:03:04 +0200	[thread overview]
Message-ID: <20040625220304.0f1fd05a@pfdabpc.inhouse.start.de> (raw)
In-Reply-To: <87isdgnzzi.fsf@mail.jurta.org>

Hi Juri,

Juri Linkov <juri@jurta.org> skribis:

> Daniel Pfeiffer <occitan@esperanto.org> 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/

  reply	other threads:[~2004-06-25 20:03 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <E1BdGt8-0003Tg-Qb@lists.gnu.org>
2004-06-24 23:16 ` Changes to emacs/lisp/progmodes/grep.el Juri Linkov
2004-06-25 20:03   ` Daniel Pfeiffer [this message]
2004-06-26  0:03     ` Juri Linkov
2004-06-27 10:43       ` Daniel Pfeiffer
2004-06-26  6:03     ` Richard Stallman
2004-06-27 10:33       ` Daniel Pfeiffer
2004-06-27 11:58         ` Adrian Aichner
2004-06-28  2:23         ` Richard Stallman
2004-06-28  2:37           ` Miles Bader
2004-06-28  4:44           ` David Kastrup
2004-06-28  8:40             ` Daniel Pfeiffer
2004-06-28 18:00               ` Eli Zaretskii
2004-06-28 21:22                 ` Daniel Pfeiffer
2004-06-29  5:10                   ` Eli Zaretskii
2004-06-29 20:08                     ` Daniel Pfeiffer
2004-06-29 21:19                       ` Eli Zaretskii
2004-06-30  5:16                         ` Juri Linkov
2004-07-01 22:20                         ` Daniel Pfeiffer
2004-06-30  5:08                       ` Juri Linkov
2004-07-02 21:58                         ` Daniel Pfeiffer
2004-07-01 23:31                           ` Stefan
2004-07-01 23:38                             ` David Kastrup
2004-07-01 23:46                               ` Stefan
2004-07-03 18:20                               ` Richard Stallman
2004-07-04 10:47                                 ` Mark handling (Was: Changes to emacs/lisp/progmodes/grep.el) Daniel Pfeiffer
2004-07-05 16:56                                   ` Richard Stallman
2004-07-05 19:57                                     ` Daniel Pfeiffer
2004-07-06 22:00                                       ` Richard Stallman
2004-07-07 19:47                                         ` Daniel Pfeiffer
2004-07-08 23:18                                           ` Richard Stallman
2004-07-10 19:54                                             ` Daniel Pfeiffer
2004-07-06 22:00                                       ` Richard Stallman
2004-07-07 20:58                                         ` Richard Stallman
2004-07-02  0:20                             ` Transient mark mode (was: " Paul Pogonyshev
2004-07-03  8:28                             ` Changes to emacs/lisp/progmodes/grep.el Daniel Pfeiffer
2004-07-02  9:07                               ` Juri Linkov
2004-07-03 11:35                                 ` Daniel Pfeiffer
2004-07-02  8:48                           ` Juri Linkov
2004-07-06 16:55                         ` Juri Linkov
2004-07-06 18:16                           ` Luc Teirlinck
2004-07-07 20:57                           ` Richard Stallman
2004-06-30 18:52                       ` Richard Stallman
2004-07-01  5:08                         ` Juri Linkov

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=20040625220304.0f1fd05a@pfdabpc.inhouse.start.de \
    --to=dapfy@t-online.de \
    --cc=emacs-devel@gnu.org \
    --cc=occitan@esperanto.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.