tools/term: refactor + better term popup support

This commit is contained in:
Henrik Lissner 2017-05-15 14:08:04 +02:00
parent dbceec4149
commit 4105c26b2a
3 changed files with 24 additions and 8 deletions

View file

@ -396,6 +396,10 @@ the command buffer."
(advice-add #'mu4e~temp-window :override #'doom*mu4e-popup-window)) (advice-add #'mu4e~temp-window :override #'doom*mu4e-popup-window))
(after! multi-term
(setq multi-term-buffer-name "doom:terminal"))
(after! neotree (after! neotree
;; Neotree has its own window/popup management built-in, which is difficult to ;; Neotree has its own window/popup management built-in, which is difficult to
;; police. For example, switching perspectives will cause neotree to forget it ;; police. For example, switching perspectives will cause neotree to forget it

View file

@ -1,16 +1,28 @@
;;; tools/term/autoload.el ;;; tools/term/autoload.el
;;;###autoload ;;;###autoload
(defun +term () (defun +term (&optional project-root)
(interactive) "Open a terminal buffer in the current window. If PROJECT-ROOT (C-u) is
(call-interactively 'multi-term)) non-nil, cd into the current project's root."
(interactive "P")
(let ((default-directory (if project-root (doom-project-root) default-directory)))
(call-interactively 'multi-term)))
;;;###autoload ;;;###autoload
(defun +term/popup () (defun +term/popup (&optional project-root)
(interactive) "Open a terminal popup window. If PROJECT-ROOT (C-u) is non-nil, cd into the
current project's root."
(interactive "P")
(require 'multi-term) (require 'multi-term)
(let* ((buffer (multi-term-get-buffer current-prefix-arg)) (let* ((default-directory (if project-root (doom-project-root) default-directory))
(window (doom-popup-buffer buffer :popup t :align t :size 25 :select t :autokill t :noesc t))) (buffer (multi-term-get-buffer current-prefix-arg))
(window (doom-popup-buffer buffer)))
(select-window window) (select-window window)
(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
(defun +term/popup-in-project ()
"Open a terminal popup window in the root of the current project."
(interactive)
(+term/popup t))

View file

@ -4,4 +4,4 @@
:commands (multi-term multi-term-next multi-term-prev) :commands (multi-term multi-term-next multi-term-prev)
:config :config
(setq multi-term-program (getenv "SHELL") (setq multi-term-program (getenv "SHELL")
multi-term-switch-after-close nil)) multi-term-switch-after-close 'PREVIOUS))