branch: externals/urgrep commit b1cddf3f06e77ab357c6f95f4ac953f33070d09b Author: Jim Porter <jporterb...@gmail.com> Commit: Jim Porter <jporterb...@gmail.com>
Remove unnecessary code in `urgrep--start` --- urgrep-tests.el | 25 +++++++++++++++++++++++-- urgrep.el | 7 ++----- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/urgrep-tests.el b/urgrep-tests.el index 20743cd49e..ed055bb547 100644 --- a/urgrep-tests.el +++ b/urgrep-tests.el @@ -58,7 +58,7 @@ joined to compare against COMMAND." (should (string= command (mapconcat #'urgrep--maybe-shell-quote-argument expected-arguments " ")))) -(defun urgrep-tests/check-match-at-point () +(defun urgrep-tests/check-match-at-point (&optional filename) "In a Urgrep buffer, check that the match at point is consistent." (let* ((line (string-to-number (current-word))) (loc (compilation--message->loc @@ -68,7 +68,7 @@ joined to compare against COMMAND." (match-start (text-property-any text-start text-end 'font-lock-face 'urgrep-match))) (should (equal (caar (compilation--loc->file-struct loc)) - "urgrep-tests.el")) + (or filename "urgrep-tests.el"))) (should (equal (compilation--loc->line loc) line)) (should (equal (compilation--loc->col loc) (- match-start text-start))))) @@ -806,6 +806,27 @@ joined to compare against COMMAND." (re-search-forward "urgrep-tests.el:") (urgrep-tests/check-match-at-point)) +(ert-deftest urgrep-tests/urgrep/repeat-from-urgrep () + (switch-to-buffer (urgrep "urgrep")) + (while (get-buffer-process (current-buffer)) + (accept-process-output)) + (let ((base-name (file-name-nondirectory + (directory-file-name default-directory))) + (parent-dir (file-name-parent-directory default-directory))) + (urgrep "urgrep-tests/" :default-directory parent-dir) + (while (get-buffer-process (current-buffer)) + (accept-process-output)) + (should (and (equal urgrep-current-tool (urgrep-get-tool)) + (local-variable-p 'urgrep-current-tool))) + (should (and (equal urgrep-current-query '("urgrep-tests/")) + (local-variable-p 'urgrep-current-query))) + (should (equal default-directory parent-dir)) + (goto-char (point-min)) + (re-search-forward (concat base-name "/urgrep-tests.el")) + (beginning-of-line 2) + (urgrep-tests/check-match-at-point + (concat base-name "/urgrep-tests.el")))) + (ert-deftest urgrep-tests/urgrep-run-command () (switch-to-buffer (urgrep-run-command (urgrep-command "urgrep"))) (while (get-buffer-process (current-buffer)) diff --git a/urgrep.el b/urgrep.el index 35b2fa17d5..24d6e0a8d0 100644 --- a/urgrep.el +++ b/urgrep.el @@ -1192,15 +1192,12 @@ rerunning the search." ;; consult this let-binding from another buffer. (with-temp-buffer ;; Let-bind `default-directory' here so that the external command knows - ;; where to search... + ;; where to search. `compilation-start' will then set this for us in + ;; the compilation buffer. (let ((urgrep-current-tool tool) (default-directory directory)) (compilation-start (urgrep--hide-abbreviations command) #'urgrep-mode))) - ;; ... and then set `default-directory' here to be sure it's up to date. - ;; This can get out of sync if re-running urgrep from a urgrep buffer, but - ;; with a different search directory set. - (setq default-directory directory) (setq urgrep-current-query query urgrep-current-tool tool) (current-buffer)))