[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Irritation in C-u M-x grep, caused by overprotectiveness
From: |
Stefan Monnier |
Subject: |
Re: Irritation in C-u M-x grep, caused by overprotectiveness |
Date: |
Sun, 29 Jul 2007 13:33:06 -0400 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.1.50 (gnu/linux) |
>> 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.
Yes, the code could be improved.
>> 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.
Again, I agree that the implementation of the heuristic can be improved, but
in any case the implementation won't be perfect and the heuristic isn't
always correct, so it seems that if the heuristic doesn't apply to the
original case (either because of imperfect implementation or for some other
reason), then there's no reason to think it'll apply to the next case.
Stefan