branch: master commit ac696cd960a7237c07deabb325f2fdb4187971f4 Author: João Távora <joaotav...@gmail.com> Commit: João Távora <joaotav...@gmail.com>
Fix search directly from *ack* but in different dir C-u C-u ack allows us to choose a directory. If we happen to do that from an *ack* buffer, the resulting *ack* buffer which replaces the previous one, didn't have a correct value for default-directory, preventing the hyperlinks from working (and further searches from having a suitable default). * ack.el (ack): Correctly set default-directory in the *ack* buffer. --- ack.el | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/ack.el b/ack.el index e226e05..8f9101d 100644 --- a/ack.el +++ b/ack.el @@ -405,8 +405,8 @@ minibuffer: \\{ack-minibuffer-local-map}" (interactive (let ((ack--project-root (or (funcall ack-default-directory-function - current-prefix-arg) - default-directory)) + current-prefix-arg) + default-directory)) ;; Disable completion cycling; see http://debbugs.gnu.org/12221 (completion-cycle-threshold nil)) (list (minibuffer-with-setup-hook 'ack-minibuffer-setup-function @@ -415,13 +415,19 @@ minibuffer: ack-minibuffer-local-map nil 'ack-history)) ack--project-root))) - (let ((default-directory (expand-file-name - (or directory default-directory)))) - ;; Change to the compilation buffer so that `ack-buffer-name-function' can - ;; make use of `compilation-arguments'. - (with-current-buffer (compilation-start command-args 'ack-mode) + (let* ((lexical-default-directory + (expand-file-name + (or directory default-directory)))) + ;; Change to the compilation to ensure a correct + ;; `default-directory' there and to ensure + ;; `ack-buffer-name-function' can make use of + ;; `compilation-arguments'. + (with-current-buffer + (let ((default-directory lexical-default-directory)) + (compilation-start command-args 'ack-mode)) (when ack-buffer-name-function (rename-buffer (funcall ack-buffer-name-function "ack"))) + (setq default-directory lexical-default-directory) (current-buffer)))) (provide 'ack)