aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim F. Storm2006-05-09 12:47:12 +0000
committerKim F. Storm2006-05-09 12:47:12 +0000
commitc0b87c3fdb5d85a5dd5393be2d7c00afa20b810b (patch)
tree720fd210cd8e0c7b5d2b199403750e5ff1b40914
parent8ebb843c159186a1bb17b7b4e07cc1dc03efa940 (diff)
downloademacs-c0b87c3fdb5d85a5dd5393be2d7c00afa20b810b.tar.gz
emacs-c0b87c3fdb5d85a5dd5393be2d7c00afa20b810b.zip
(rgrep): Set default directory of *grep*
buffer if we start M-x rgrep in the *grep* buffer and choose a different base directory.
-rw-r--r--lisp/progmodes/grep.el26
1 files changed, 15 insertions, 11 deletions
diff --git a/lisp/progmodes/grep.el b/lisp/progmodes/grep.el
index 301ae3dca5b..410a973d1b4 100644
--- a/lisp/progmodes/grep.el
+++ b/lisp/progmodes/grep.el
@@ -721,16 +721,16 @@ This command shares argument histories with \\[lgrep] and \\[grep-find]."
721 (if (null files) 721 (if (null files)
722 (if (not (string= regexp grep-find-command)) 722 (if (not (string= regexp grep-find-command))
723 (compilation-start regexp 'grep-mode)) 723 (compilation-start regexp 'grep-mode))
724 (let* ((default-directory (file-name-as-directory (expand-file-name dir))) 724 (setq dir (file-name-as-directory (expand-file-name dir)))
725 (command (grep-expand-template 725 (let ((command (grep-expand-template
726 grep-find-template 726 grep-find-template
727 regexp 727 regexp
728 (concat "\\( -name " 728 (concat "\\( -name "
729 (mapconcat #'shell-quote-argument 729 (mapconcat #'shell-quote-argument
730 (split-string files) 730 (split-string files)
731 " -o -name ") 731 " -o -name ")
732 " \\)") 732 " \\)")
733 default-directory 733 dir
734 (and grep-find-ignored-directories 734 (and grep-find-ignored-directories
735 (concat "\\( -path '*/" 735 (concat "\\( -path '*/"
736 (mapconcat #'identity 736 (mapconcat #'identity
@@ -743,7 +743,11 @@ This command shares argument histories with \\[lgrep] and \\[grep-find]."
743 (read-from-minibuffer "Confirm: " 743 (read-from-minibuffer "Confirm: "
744 command nil nil 'grep-find-history)) 744 command nil nil 'grep-find-history))
745 (add-to-history 'grep-find-history command)) 745 (add-to-history 'grep-find-history command))
746 (compilation-start command 'grep-mode)))))) 746 (let ((default-directory dir))
747 (compilation-start command 'grep-mode))
748 ;; Set default-directory if we started rgrep in the *grep* buffer.
749 (if (eq next-error-last-buffer (current-buffer))
750 (setq default-directory dir)))))))
747 751
748 752
749(provide 'grep) 753(provide 'grep)