summaryrefslogtreecommitdiff
path: root/lisp/progmodes/grep.el
diff options
context:
space:
mode:
authorKim F. Storm <storm@cua.dk>2006-04-28 23:39:02 +0000
committerKim F. Storm <storm@cua.dk>2006-04-28 23:39:02 +0000
commit208cc91ffb7056436702310670e338edc0426c5d (patch)
tree83631a7a2025576b97447fc5f4ebd4ed4301e5ed /lisp/progmodes/grep.el
parent0acfb7cea6841c511cab1f30fca63b92e4fa9ce6 (diff)
downloademacs-208cc91ffb7056436702310670e338edc0426c5d.tar.gz
(grep-read-files): Use buffer-name if no buffer-file-name.
Default to *.ext if no alias matches. No default if no extension.
Diffstat (limited to 'lisp/progmodes/grep.el')
-rw-r--r--lisp/progmodes/grep.el19
1 files changed, 13 insertions, 6 deletions
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))