emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[nongnu] elpa/inf-clojure 9a0323d 028/313: [Fix #4] Start subprocess in


From: ELPA Syncer
Subject: [nongnu] elpa/inf-clojure 9a0323d 028/313: [Fix #4] Start subprocess in the root of lein and boot projects
Date: Wed, 11 Aug 2021 09:59:39 -0400 (EDT)

branch: elpa/inf-clojure
commit 9a0323d5a2777a0d7b4b611b12d4c6af65ae8d30
Author: Bozhidar Batsov <bozhidar@batsov.com>
Commit: Bozhidar Batsov <bozhidar@batsov.com>

    [Fix #4] Start subprocess in the root of lein and boot projects
---
 inf-clojure.el | 30 +++++++++++++++++++++++-------
 1 file changed, 23 insertions(+), 7 deletions(-)

diff --git a/inf-clojure.el b/inf-clojure.el
index 37ab3b1..b5d4e28 100644
--- a/inf-clojure.el
+++ b/inf-clojure.el
@@ -265,6 +265,21 @@ to continue it."
     (inf-clojure-chomp (concat "\n" str)))
    (t str)))
 
+(defvar inf-clojure-project-root-files
+  '("project.clj" "build.boot")
+  "A list of files that can be considered project markers.")
+
+(defun inf-clojure-project-root ()
+  "Retrieve the root directory of a project if available.
+
+Fallback to `default-directory.' if not within a project."
+  (or (car (remove nil
+                   (mapcar (lambda
+                             (file)
+                             (locate-dominating-file default-directory file))
+                           inf-clojure-project-root-files)))
+      default-directory))
+
 ;;;###autoload
 (defun inf-clojure (cmd)
   "Run an inferior Clojure process, input and output via buffer 
`*inf-clojure*'.
@@ -277,13 +292,14 @@ of `inf-clojure-program').  Runs the hooks from
   (interactive (list (if current-prefix-arg
                          (read-string "Run Clojure: " inf-clojure-program)
                        inf-clojure-program)))
-  (if (not (comint-check-proc "*inf-clojure*"))
-      (let ((cmdlist (split-string cmd)))
-        (set-buffer (apply (function make-comint)
-                           "inf-clojure" (car cmdlist) nil (cdr cmdlist)))
-        (inf-clojure-mode)))
-  (setq inf-clojure-buffer "*inf-clojure*")
-  (pop-to-buffer-same-window "*inf-clojure*"))
+  (let ((default-directory (inf-clojure-project-root)))
+    (if (not (comint-check-proc "*inf-clojure*"))
+        (let ((cmdlist (split-string cmd)))
+          (set-buffer (apply (function make-comint)
+                             "inf-clojure" (car cmdlist) nil (cdr cmdlist)))
+          (inf-clojure-mode)))
+    (setq inf-clojure-buffer "*inf-clojure*")
+    (pop-to-buffer-same-window "*inf-clojure*")))
 
 ;;;###autoload
 (defalias 'run-clojure 'inf-clojure)



reply via email to

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