emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 6e796b5: Stop project-root from going into infinite recursion


From: Dmitry Gutov
Subject: master 6e796b5: Stop project-root from going into infinite recursion
Date: Wed, 17 Mar 2021 12:49:28 -0400 (EDT)

branch: master
commit 6e796b52e1e61c67e5d939bfcc77d34b9d735158
Author: Dmitry Gutov <dgutov@yandex.ru>
Commit: Dmitry Gutov <dgutov@yandex.ru>

    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).
---
 lisp/progmodes/project.el | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index 18da439..65897b0 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)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]