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.
This commit is contained in:
parent
194bc97879
commit
128a999bfe
2 changed files with 15 additions and 2 deletions
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue