mirror of
https://github.com/doomemacs/doomemacs
synced 2025-08-05 12:37:33 -05:00
Revise term/vterm/eshell commands & keybinds
The semantics of SPC o t and SPC o T (or SPC o e and SPC o E in eshell's case) have been reversed. The lowercase keybind toggles the popup (and the prefix arg forciby recreates the popup), and the uppercase keybind switches to that terminal in the current buffer (whose prefix arg will open the terminal in default-directory, rather than the project root). - +{term,vterm,eshell}/open have been replaced with +X/here commands and are bound to SPC o T (and SPC o E in eshell's case). - +{term,vterm,eshell}/popup* have been replaced with +x/toggle commands and are bound to SPC o t (and SPC o e in eshell's case). The "toggle" behavior will do as the name implies, except will select the popup if it is visible but unfocused.
This commit is contained in:
@ -1,33 +1,50 @@
|
||||
;;; term/term/autoload.el -*- lexical-binding: t; -*-
|
||||
|
||||
;;;###autoload
|
||||
(defun +term/open (arg)
|
||||
"Open a terminal buffer in the current window. If ARG (universal argument) is
|
||||
non-nil, cd into the current project's root."
|
||||
(defun +term/toggle (arg)
|
||||
"Toggle a persistent terminal popup window at project's root.
|
||||
|
||||
If popup is visible but unselected, select it.
|
||||
|
||||
If prefix ARG, recreate term buffer in the current project's root."
|
||||
(interactive "P")
|
||||
(require 'multi-term)
|
||||
(let ((default-directory (or (doom-project-root) default-directory))
|
||||
(multi-term-dedicated-buffer-name "doom:term-popup")
|
||||
(multi-term-dedicated-select-after-open-p t)
|
||||
confirm-kill-processes
|
||||
current-prefix-arg)
|
||||
(cl-letf (((symbol-function #'multi-term-dedicated-get-window)
|
||||
(lambda () (setq multi-term-dedicated-window
|
||||
(display-buffer-in-side-window
|
||||
multi-term-dedicated-buffer
|
||||
`((window-height . ,multi-term-dedicated-window-height)))))))
|
||||
(when arg
|
||||
(when (multi-term-window-exist-p multi-term-dedicated-window)
|
||||
(delete-window multi-term-dedicated-window))
|
||||
(when (multi-term-buffer-exist-p multi-term-dedicated-buffer)
|
||||
(when-let (process (get-buffer-process multi-term-dedicated-buffer))
|
||||
(kill-process process))
|
||||
(kill-buffer multi-term-dedicated-buffer)))
|
||||
(if (multi-term-dedicated-exist-p)
|
||||
(if (eq (selected-window) multi-term-dedicated-window)
|
||||
(multi-term-dedicated-close)
|
||||
(select-window multi-term-dedicated-window))
|
||||
(multi-term-dedicated-open)))))
|
||||
|
||||
;;;###autoload
|
||||
(defun +term/here (arg)
|
||||
"Open a terminal buffer in the current window at project's root.
|
||||
|
||||
If prefix ARG is non-nil, cd into `default-directory' instead of the project
|
||||
root."
|
||||
(interactive "P")
|
||||
(let ((default-directory
|
||||
(if arg
|
||||
(or (doom-project-root) default-directory)
|
||||
default-directory)))
|
||||
default-directory
|
||||
(or (doom-project-root) 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")
|
||||
(let ((default-directory
|
||||
(if arg
|
||||
(or (doom-project-root) default-directory)
|
||||
default-directory)))
|
||||
(pop-to-buffer (save-window-excursion (multi-term)))))
|
||||
|
||||
;;;###autoload
|
||||
(defun +term/open-popup-in-project ()
|
||||
"Open a terminal popup window in the root of the current project."
|
||||
(interactive)
|
||||
(+term/open-popup t))
|
||||
|
Reference in New Issue
Block a user