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:
parent
750d7629e1
commit
4fec3eb698
8 changed files with 150 additions and 91 deletions
|
@ -1,37 +1,48 @@
|
|||
;;; term/vterm/autoload.el -*- lexical-binding: t; -*-
|
||||
|
||||
;;;###autoload
|
||||
(defun +vterm/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 +vterm/toggle (arg)
|
||||
"Toggles a terminal popup window at project root.
|
||||
|
||||
If prefix ARG is non-nil, recreate vterm buffer in the current project's root."
|
||||
(interactive "P")
|
||||
(unless (fboundp 'module-load)
|
||||
(user-error "Your build of Emacs lacks dynamic modules support and cannot load vterm"))
|
||||
(let ((buffer-name "*doom:vterm-popup*")
|
||||
confirm-kill-processes
|
||||
current-prefix-arg)
|
||||
(when arg
|
||||
(let ((buffer (get-buffer buffer-name))
|
||||
(window (get-buffer-window buffer-name)))
|
||||
(when (buffer-live-p buffer)
|
||||
(kill-buffer buffer))
|
||||
(when (window-live-p window)
|
||||
(delete-window window))))
|
||||
(if-let (win (get-buffer-window buffer-name))
|
||||
(if (eq (selected-window) win)
|
||||
(delete-window win)
|
||||
(select-window win))
|
||||
(let* ((default-directory (or (doom-project-root) default-directory))
|
||||
(buffer (get-buffer-create buffer-name)))
|
||||
(with-current-buffer buffer
|
||||
(vterm-mode))
|
||||
(pop-to-buffer buffer)))))
|
||||
|
||||
;;;###autoload
|
||||
(defun +vterm/here (arg)
|
||||
"Open a terminal buffer in the current window at project root.
|
||||
|
||||
If prefix ARG is non-nil, cd into `default-directory' instead of project root."
|
||||
(interactive "P")
|
||||
(unless (fboundp 'module-load)
|
||||
(user-error "Your build of Emacs lacks dynamic modules support and cannot load vterm"))
|
||||
(when (eq major-mode 'vterm-mode)
|
||||
(user-error "Already in a vterm buffer"))
|
||||
;; This hack forces vterm to redraw, fixing strange artefacting in the tty.
|
||||
;; Don't ask me why it works.
|
||||
(save-window-excursion
|
||||
(pop-to-buffer "*scratch*"))
|
||||
(let ((default-directory
|
||||
(if arg
|
||||
(or (doom-project-root) default-directory)
|
||||
default-directory)))
|
||||
default-directory
|
||||
(or (doom-project-root) default-directory))))
|
||||
(vterm)))
|
||||
|
||||
;;;###autoload
|
||||
(defun +vterm/open-popup (arg)
|
||||
"Open a terminal popup window. If ARG (universal argument) is
|
||||
non-nil, cd into the current project's root."
|
||||
(interactive "P")
|
||||
(unless (fboundp 'module-load)
|
||||
(user-error "Your build of Emacs lacks dynamic modules support and cannot load vterm"))
|
||||
(let ((default-directory
|
||||
(if arg
|
||||
(or (doom-project-root) default-directory)
|
||||
default-directory)))
|
||||
(vterm-other-window)))
|
||||
|
||||
;;;###autoload
|
||||
(defun +vterm/open-popup-in-project ()
|
||||
"Open a terminal popup window in the root of the current project."
|
||||
(interactive)
|
||||
(+vterm/open-popup t))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue