summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--terminal-here.el11
-rw-r--r--test/terminal-here-test.el17
2 files changed, 28 insertions, 0 deletions
diff --git a/terminal-here.el b/terminal-here.el
index 707ebb5..ec461ea 100644
--- a/terminal-here.el
+++ b/terminal-here.el
@@ -62,6 +62,17 @@ changed it by running `cd'."
(interactive)
(terminal-here-launch-in-directory default-directory))
+
+(defun terminal-here-project-launch ()
+ (interactive)
+ "Launch a terminal in the current project root.
+
+If projectile is installed the projectile root will be used,
+ Otherwise `vc-root-dir' will be used."
+ (terminal-here-launch-in-directory (if (functionp 'projectile-project-root)
+ (projectile-project-root)
+ (vc-root-dir))))
+
(provide 'terminal-here)
diff --git a/test/terminal-here-test.el b/test/terminal-here-test.el
index 2eb9471..e30a238 100644
--- a/test/terminal-here-test.el
+++ b/test/terminal-here-test.el
@@ -21,6 +21,8 @@
(custom-reevaluate-setting 'terminal-here-terminal-command)
(terminal-here-launch-in-directory "adir"))))
+
+
(ert-deftest custom-terminal-command-as-list ()
(with-mock
(mock (start-process "1" * "1" "2" "3"))
@@ -38,3 +40,18 @@
(should-error
(validate-setq terminal-here-terminal-command "astring")
:type 'user-error)))
+
+
+
+(ert-deftest projectile-root ()
+ (with-mock
+ (mock (projectile-project-root) => "project-root")
+ (mock (terminal-here-launch-in-directory "project-root"))
+ (terminal-here-project-launch)))
+
+(ert-deftest non-projectile-project-root ()
+ (with-mock
+ (should (not (boundp 'projectile-project-root)))
+ (mock (vc-root-dir) => "vc-root")
+ (mock (terminal-here-launch-in-directory "vc-root"))
+ (terminal-here-project-launch)))