From: Dmitry Gutov Date: Wed, 17 Mar 2021 16:49:14 +0000 (+0200) Subject: Stop project-root from going into infinite recursion X-Git-Tag: emacs-28.0.90~3252 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=6e796b52e1e61c67e5d939bfcc77d34b9d735158;p=emacs.git Stop project-root from going into infinite recursion * lisp/progmodes/project.el (project--within-roots-fallback): New variable. (project-root, project-roots): Use it (bug#47168). --- diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el index 18da4398f46..65897b008ca 100644 --- a/lisp/progmodes/project.el +++ b/lisp/progmodes/project.el @@ -208,6 +208,8 @@ of the project instance object." (defun project--find-in-directory (dir) (run-hook-with-args-until-success 'project-find-functions dir)) +(defvar project--within-roots-fallback nil) + (cl-defgeneric project-root (project) "Return root directory of the current project. @@ -215,7 +217,9 @@ It usually contains the main build file, dependencies configuration file, etc. Though neither is mandatory. The directory name must be absolute." - (car (project-roots project))) + (if project--within-roots-fallback + (signal 'cl-no-applicable-method (list 'project-root project)) + (car (project-roots project)))) (cl-defgeneric project-roots (project) "Return the list containing the current project root. @@ -226,7 +230,8 @@ and the rest should be possible to express through ;; FIXME: Can we specify project's version here? ;; FIXME: Could we make this affect cl-defmethod calls too? (declare (obsolete project-root "0.3.0")) - (list (project-root project))) + (let ((project--within-roots-fallback t)) + (list (project-root project)))) ;; FIXME: Add MODE argument, like in `ede-source-paths'? (cl-defgeneric project-external-roots (_project)