emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Irritation in C-u M-x grep, caused by overprotectiveness


From: Alan Mackenzie
Subject: Re: Irritation in C-u M-x grep, caused by overprotectiveness
Date: Sun, 29 Jul 2007 15:30:27 +0000
User-agent: Mutt/1.5.9i

Hi, Stefan!

On Sun, Jul 29, 2007 at 09:49:33AM -0400, Stefan Monnier wrote:
> > If I give an environment variable as "filename", the chances are I'll
> > want to use it in subsequent greps.

> I don't see why that'd generally be the case, but I guess it's just as
> good a default as the current one.

Well, there's nothing certain in Emacs users other than taxes and death.
I think it's a reasonable assumption, because setting up such a variable
is a lot of work; much more than just typing a list of filenames into the
minibuffer - anybody who does this will be expecting to use the variable
more than once.

> Maybe a better and more general approach to the problem goes as follows:

> Currently the code checks whether the previous "list of files"
> (typically a global pattern) matches the current buffer's file name.

No, it doesn't quite do this.  If several "filenames" have been given on
the top command line of grep's history, it only uses the first one,
(match-string 3 grep-default).  Maybe it should be using (substring
grep-default (match-begin 3)) instead.  But this is a separate issue.

> If it does then the previous list of files is reused, otherwise the
> previous list of files is ignored and replaced by a new glob pattern.

> Now in your case, the list of files which *you* wrote did not "match"
> the current buffer's file name, so clearly, the above heuristic
> shouldn't be applied anyway.  I.e. we should only check "does it match
> the current file?" if it did match the current file in its previous
> use.

Maybe $VARIABLEs should be evaluated first.  What do you think?
Something like (getenv (substring grep-default (1+ (match-begin 3)))) fed
into `regexp-opt', each element having been through `wildcard-to-regexp'.
That might be heavy overkill, though.

>         Stefan

-- 
Alan.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]