Subject: bug#66317: Project mode-line

From: [email-masked]
Date: Sun, 15 Oct 2023 22:42:52 +0000 (UTC)

An issue with this as installed in master:  If I navigate to a file and
one of its ancestors is not readable by emacs, I'll get an error.

For example, when I visit /home/other/foo.txt, which is readable by me
even though /home/other is not, I get:

Error during redisplay: (eval (project-mode-line-format)) signaled
(permission-denied "Opening directory" "Permission denied"
"/home/other")

Here's one idea for a patch... but maybe we should be just flat-out
wrapping it in ignore-errors?

(BTW, I actually discovered this class of bug through
project-uniquify-dirname-transform, which is also affected by it, since
like project-mode-line, it runs project-current for basically every
buffer.  So if we ignore-errors in project-mode-line-format, we also
need that in project-uniquify-dirname-transform.  Maybe they should
share the lookup?)

diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index fd9c146a1fd..8bf1f4d0738 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -245,7 +245,8 @@ project-current
     pr))
 
 (defun project--find-in-directory (dir)
-  (run-hook-with-args-until-success 'project-find-functions dir))
+  (ignore-error (permission-denied)
+    (run-hook-with-args-until-success 'project-find-functions dir)))
 
 (defvar project--within-roots-fallback nil)