Mercurial > emacs
comparison lisp/progmodes/grep.el @ 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 | 0c5d2102f71a |
children | 070ab453b31f 146cd8369025 |
comparison
equal
deleted
inserted
replaced
70533:f7861ffc739a | 70534:afe3317800c2 |
---|---|
719 (list regexp files dir)))))) | 719 (list regexp files dir)))))) |
720 (when (and (stringp regexp) (> (length regexp) 0)) | 720 (when (and (stringp regexp) (> (length regexp) 0)) |
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 |
737 grep-find-ignored-directories | 737 grep-find-ignored-directories |
738 "' -o -path '*/") | 738 "' -o -path '*/") |
741 (if current-prefix-arg | 741 (if current-prefix-arg |
742 (setq command | 742 (setq command |
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) |
750 | 754 |
751 ;; arch-tag: 5a5b9169-a79d-4f38-9c38-f69615f39c4d | 755 ;; arch-tag: 5a5b9169-a79d-4f38-9c38-f69615f39c4d |