Fix multi-term buffers missing from buffer list

Caused because switch buffer hooks weren't triggering, due to
multi-term's odd use of set-buffer before switch-to-buffer.
This commit is contained in:
Henrik Lissner 2018-06-04 21:08:19 +02:00
parent 3027ed2f7f
commit 625a8a9056
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -5,20 +5,26 @@
"Open a terminal buffer in the current window. If PROJECT-ROOT (C-u) is
non-nil, cd into the current project's root."
(interactive "P")
(let ((default-directory (if project-root (doom-project-root 'nocache) default-directory)))
(call-interactively #'multi-term)))
(let ((default-directory
(if project-root
(doom-project-root 'nocache)
default-directory)))
;; Doom's switch-buffer hooks prevent themselves from triggering when
;; switching from buffer A back to A. Because `multi-term' uses `set-buffer'
;; before `switch-to-buffer', the hooks don't trigger, so we use this
;; roundabout way to trigger them properly.
(switch-to-buffer (save-window-excursion (multi-term)))))
;;;###autoload
(defun +term/open-popup (arg)
"Open a terminal popup window. If ARG (universal argument) is
non-nil, cd into the current project's root."
(interactive "P")
(require 'multi-term)
(let ((default-directory (if arg (doom-project-root 'nocache) default-directory))
(buffer (multi-term-get-buffer current-prefix-arg)))
(pop-to-buffer buffer)
(setq multi-term-buffer-list (nconc multi-term-buffer-list (list buffer)))
(multi-term-internal)))
(let ((default-directory
(if arg
(doom-project-root 'nocache)
default-directory)))
(pop-to-buffer (save-window-excursion (multi-term)))))
;;;###autoload
(defun +term/open-popup-in-project (arg)