tools/term: change +term/open-popup* universal-arg behavior

+ +term/open-popup: opens a term in default-directory. If ARG, opens
  term in project root.
+ +term/open-popup-in-project: opens term in project root. If ARG, opens
  term in default-directory.
This commit is contained in:
Henrik Lissner 2018-04-10 06:12:03 -04:00
parent 22d99c9321
commit 94138a686b
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -9,19 +9,21 @@ non-nil, cd into the current project's root."
(call-interactively #'multi-term))) (call-interactively #'multi-term)))
;;;###autoload ;;;###autoload
(defun +term/open-popup (&optional project-root) (defun +term/open-popup (arg)
"Open a terminal popup window. If PROJECT-ROOT (C-u) is non-nil, cd into the "Open a terminal popup window. If ARG (universal argument) is
current project's root." non-nil, cd into the current project's root."
(interactive "P") (interactive "P")
(require 'multi-term) (require 'multi-term)
(let ((default-directory (if project-root (doom-project-root 'nocache) default-directory)) (let ((default-directory (if arg (doom-project-root 'nocache) default-directory))
(buffer (multi-term-get-buffer current-prefix-arg))) (buffer (multi-term-get-buffer current-prefix-arg)))
(pop-to-buffer buffer) (pop-to-buffer buffer)
(setq multi-term-buffer-list (nconc multi-term-buffer-list (list buffer))) (setq multi-term-buffer-list (nconc multi-term-buffer-list (list buffer)))
(multi-term-internal))) (multi-term-internal)))
;;;###autoload ;;;###autoload
(defun +term/open-popup-in-project () (defun +term/open-popup-in-project (arg)
"Open a terminal popup window in the root of the current project." "Open a terminal popup window in the root of the current project.
(interactive)
(+term/open-popup t)) If ARG (universal argument) is non-nil, open it in `default-directory' instead."
(interactive "P")
(+term/open-popup (not arg)))