Subject: bug#34621: Patch Update

From: Christopher Thorne <[email-masked]>
Date: Tue, 05 Mar 2019 10:49:18 +0000

Thanks Drew, I agree derived-mode-p is better.

The reason for special casing dired is to stop rgrep taking extension 
suggestions from dired buffers, e.g. suggesting "*.11" as the rgrep file 
pattern in a dired buffer called "django-1.11".

Here is the same fix but using derived-mode-p:

diff --git a/lisp/progmodes/grep.el b/lisp/progmodes/grep.el
index 3fd2a7e701..83154872aa 100644
--- a/lisp/progmodes/grep.el
+++ b/lisp/progmodes/grep.el
@@ -963,6 +963,7 @@ grep-read-files
                   (file-name-nondirectory bn)))
          (default-alias
            (and fn
+               (not (derived-mode-p 'dired-mode))
                 (let ((aliases (remove (assoc "all" grep-files-aliases)
                                        grep-files-aliases))
                       alias)
@@ -979,6 +980,7 @@ grep-read-files
                   (cdr alias))))
          (default-extension
            (and fn
+               (not (derived-mode-p 'dired-mode))
                 (let ((ext (file-name-extension fn)))
                   (and ext (concat "*." ext)))))
          (default

Changelog entry:
* lisp/progmodes/grep.el (grep-read-files): Disable default extension in
dired buffers

On 2019-03-04 15:26, Drew Adams wrote:
>> +               (not (eq major-mode 'dired-mode))
>> +               (not (eq major-mode 'dired-mode))
> 
> I haven't followed this thread at all - dunno
> what the problem is that you're trying to solve.
> But I'm a bit surprised that Dired needs to be
> special-cased for grep in any way.
> 
> Anyway, the reasom I'm writing is to suggest
> that you probably don't want
> (eq major-mode 'dired-mode).  You probably
> want (derived-mode-p 'dired-mode).