From 06edfeb677927d8094eda4352dbf99b45cb17f36 Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Sat, 1 Mar 2025 03:22:30 +0100 Subject: [PATCH] grep: Signal error if unable to access directory * lisp/progmodes/grep.el (lgrep, rgrep): grep: Signal error if unable to access directory, instead of just trying to use default-directory, because that level of DWIMishness is confusing. (Bug#71078) (cherry picked from commit c0ca272bd7cbab5a2013e112f171e1d7fda65216) --- lisp/progmodes/grep.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lisp/progmodes/grep.el b/lisp/progmodes/grep.el index 207f5da0ed9..eee88faf21e 100644 --- a/lisp/progmodes/grep.el +++ b/lisp/progmodes/grep.el @@ -1329,7 +1329,7 @@ command before it's run." (list regexp files dir confirm)))))) (when (and (stringp regexp) (> (length regexp) 0)) (unless (and dir (file-accessible-directory-p dir)) - (setq dir default-directory)) + (user-error "Unable to open directory: %s" dir)) (unless (string-equal (file-remote-p dir) (file-remote-p default-directory)) (let ((default-directory dir)) (grep-compute-defaults))) @@ -1434,7 +1434,7 @@ to indicate whether the grep should be case sensitive or not." (grep-compute-defaults)) (when (and (stringp regexp) (> (length regexp) 0)) (unless (and dir (file-accessible-directory-p dir)) - (setq dir default-directory)) + (user-error "Unable to open directory: %s" dir)) (unless (string-equal (file-remote-p dir) (file-remote-p default-directory)) (let ((default-directory dir)) (grep-compute-defaults))) -- 2.39.5