changeset 70534:afe3317800c2

(rgrep): Set default directory of *grep* buffer if we start M-x rgrep in the *grep* buffer and choose a different base directory.
author Kim F. Storm <storm@cua.dk>
date Tue, 09 May 2006 12:47:12 +0000
parents f7861ffc739a
children 8003a30510ee
files lisp/progmodes/grep.el
diffstat 1 files changed, 15 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/progmodes/grep.el	Tue May 09 12:46:42 2006 +0000
+++ b/lisp/progmodes/grep.el	Tue May 09 12:47:12 2006 +0000
@@ -721,16 +721,16 @@
     (if (null files)
 	(if (not (string= regexp grep-find-command))
 	    (compilation-start regexp 'grep-mode))
-      (let* ((default-directory (file-name-as-directory (expand-file-name dir)))
-	     (command (grep-expand-template
-		       grep-find-template
-		       regexp
-		       (concat "\\( -name "
-			       (mapconcat #'shell-quote-argument
-					  (split-string files)
-					  " -o -name ")
-			       " \\)")
-		       default-directory
+      (setq dir (file-name-as-directory (expand-file-name dir)))
+      (let ((command (grep-expand-template
+		      grep-find-template
+		      regexp
+		      (concat "\\( -name "
+			      (mapconcat #'shell-quote-argument
+					 (split-string files)
+					 " -o -name ")
+			      " \\)")
+		       dir
 		       (and grep-find-ignored-directories
 			    (concat "\\( -path '*/"
 				    (mapconcat #'identity
@@ -743,7 +743,11 @@
 		    (read-from-minibuffer "Confirm: "
 					  command nil nil 'grep-find-history))
 	    (add-to-history 'grep-find-history command))
-	  (compilation-start command 'grep-mode))))))
+	  (let ((default-directory dir))
+	    (compilation-start command 'grep-mode))
+	  ;; Set default-directory if we started rgrep in the *grep* buffer.
+	  (if (eq next-error-last-buffer (current-buffer))
+	      (setq default-directory dir)))))))
 
 
 (provide 'grep)