[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
emacs-29 128a999bfe7: Make project-current not error out inside non-exis
From: |
Dmitry Gutov |
Subject: |
emacs-29 128a999bfe7: Make project-current not error out inside non-existent dirs |
Date: |
Fri, 27 Jan 2023 20:24:51 -0500 (EST) |
branch: emacs-29
commit 128a999bfe7ebafd78e2b463586156fc6972181d
Author: Dmitry Gutov <dgutov@yandex.ru>
Commit: Dmitry Gutov <dgutov@yandex.ru>
Make project-current not error out inside non-existent dirs
* lisp/progmodes/project.el (project-try-vc):
Use condition-case to catch 'file-missing' (bug#61107).
* test/lisp/progmodes/project-tests.el
(project-vc-nonexistent-directory-no-error): New test.
---
lisp/progmodes/project.el | 7 +++++--
test/lisp/progmodes/project-tests.el | 10 ++++++++++
2 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index 59270070484..2343adf4698 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -1,7 +1,7 @@
;;; project.el --- Operations on the current project -*- lexical-binding: t;
-*-
;; Copyright (C) 2015-2023 Free Software Foundation, Inc.
-;; Version: 0.9.5
+;; Version: 0.9.6
;; Package-Requires: ((emacs "26.1") (xref "1.4.0"))
;; This is a GNU ELPA :core package. Avoid using functionality that
@@ -530,7 +530,10 @@ project backend implementation of
`project-external-roots'.")
dir
(lambda (d)
;; Maybe limit count to 100 when we can drop Emacs < 28.
- (setq last-matches (directory-files d nil marker-re t)))))
+ (setq last-matches
+ (condition-case nil
+ (directory-files d nil marker-re t)
+ (file-missing nil))))))
(backend
(cl-find-if
(lambda (b)
diff --git a/test/lisp/progmodes/project-tests.el
b/test/lisp/progmodes/project-tests.el
index aea0666629d..5a206b67db1 100644
--- a/test/lisp/progmodes/project-tests.el
+++ b/test/lisp/progmodes/project-tests.el
@@ -152,4 +152,14 @@ When `project-ignores' includes a name matching project
dir."
(should (equal '(".dir-locals.el" "foo")
(mapcar #'file-name-nondirectory (project-files
project))))))
+(ert-deftest project-vc-nonexistent-directory-no-error ()
+ "Check that is doesn't error out when the current dir does not exist."
+ (skip-unless (eq (vc-responsible-backend default-directory) 'Git))
+ (let* ((dir (expand-file-name "foo-456/bar/" (ert-resource-directory)))
+ (_ (vc-file-clearprops dir))
+ (project-vc-extra-root-markers '(".dir-locals.el"))
+ (project (project-current nil dir)))
+ (should-not (null project))
+ (should (string-match-p "/test/lisp/progmodes/project-resources/\\'"
(project-root project)))))
+
;;; project-tests.el ends here
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- emacs-29 128a999bfe7: Make project-current not error out inside non-existent dirs,
Dmitry Gutov <=