From: Kim F. Storm Date: Fri, 28 Apr 2006 23:39:02 +0000 (+0000) Subject: (grep-read-files): Use buffer-name if no buffer-file-name. X-Git-Tag: emacs-pretest-22.0.90~2919 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=208cc91ffb7056436702310670e338edc0426c5d;p=emacs.git (grep-read-files): Use buffer-name if no buffer-file-name. Default to *.ext if no alias matches. No default if no extension. --- diff --git a/lisp/progmodes/grep.el b/lisp/progmodes/grep.el index e100910e8cf..7d8cc9d5c64 100644 --- a/lisp/progmodes/grep.el +++ b/lisp/progmodes/grep.el @@ -599,10 +599,13 @@ substitution string. Note dynamic scoping of variables.") (defun grep-read-files (regexp) "Read files arg for interactive grep." - (let* ((default - (or (and (stringp (buffer-file-name)) - (let ((fn (file-name-nondirectory (buffer-file-name))) - (aliases grep-files-aliases) + (let* ((bn (or (buffer-file-name) (buffer-name))) + (fn (and bn + (stringp bn) + (file-name-nondirectory bn))) + (default + (or (and fn + (let ((aliases grep-files-aliases) alias) (while aliases (setq alias (car aliases) @@ -611,10 +614,14 @@ substitution string. Note dynamic scoping of variables.") (setq aliases nil) (setq alias nil))) (cdr alias))) - (car grep-files-history))) + (and fn + (let ((ext (file-name-extension fn))) + (and ext (concat "*." ext)))))) (files (read-string (concat "Search for \"" regexp - "\" in files (default " default "): ") + "\" in files" + (if default (concat " (default " default ")")) + ": ") nil 'grep-files-history default))) (and files (or (cdr (assoc files grep-files-aliases))