diff options
| author | David Shepherd <davidshepherd7@gmail.com> | 2017-03-16 12:20:28 +0000 |
|---|---|---|
| committer | David Shepherd <davidshepherd7@gmail.com> | 2017-03-16 12:22:33 +0000 |
| commit | 80ae26bd0aadec284e382303b7a83abd35ae8797 (patch) | |
| tree | e8e903a03e029e891fa5bc6014e4057a1ae8961c | |
| parent | Fix TODOs (diff) | |
| download | emacs-terminal-here-80ae26bd0aadec284e382303b7a83abd35ae8797.tar.gz | |
Add function to launch in project root
| -rw-r--r-- | terminal-here.el | 11 | ||||
| -rw-r--r-- | test/terminal-here-test.el | 17 |
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))) |
