]> git.eshelyaron.com Git - emacs.git/commitdiff
(rgrep): Set default directory of *grep*
authorKim F. Storm <storm@cua.dk>
Tue, 9 May 2006 12:47:12 +0000 (12:47 +0000)
committerKim F. Storm <storm@cua.dk>
Tue, 9 May 2006 12:47:12 +0000 (12:47 +0000)
buffer if we start M-x rgrep in the *grep* buffer and choose
a different base directory.

lisp/progmodes/grep.el

index 301ae3dca5b43f7725029ce71c4eba204f9cb087..410a973d1b4a8f435fc40d58035e8aa0339236e1 100644 (file)
@@ -721,16 +721,16 @@ This command shares argument histories with \\[lgrep] and \\[grep-find]."
     (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 @@ This command shares argument histories with \\[lgrep] and \\[grep-find]."
                    (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)