]> git.eshelyaron.com Git - emacs.git/commitdiff
grep: Signal error if unable to access directory
authorStefan Kangas <stefankangas@gmail.com>
Sat, 1 Mar 2025 02:22:30 +0000 (03:22 +0100)
committerEshel Yaron <me@eshelyaron.com>
Tue, 4 Mar 2025 20:56:24 +0000 (21:56 +0100)
* 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

index 207f5da0ed9ce475b3931ffcaebea686cfa41eea..eee88faf21e972e332d281de29883ef7f75c4308 100644 (file)
@@ -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)))