shell: add support for `SPC u SPC '` to open shell in current buffer
Works as well for all `SPC a s ...` key bindings.
This commit is contained in:
parent
7a0328929c
commit
63dc8f7ea0
|
@ -264,7 +264,7 @@
|
|||
(defun spacemacs-ui-visual/init-spaceline ()
|
||||
(use-package spaceline-config
|
||||
;; not possible for now, maybe we can add support for it in spaceline itself
|
||||
;; :defer 0.1
|
||||
:defer 0.1
|
||||
:init
|
||||
(progn
|
||||
(spacemacs|do-after-display-system-init
|
||||
|
|
|
@ -145,6 +145,9 @@ Some advanced configuration is setup for =eshell= in this layer:
|
|||
for instance pressing ~2 SPC '~ will a second default shell, the
|
||||
number of shell is indicated on the mode-line.
|
||||
|
||||
*Note:* Use the universal prefix argument ~SPC u SPC '~ to open the shell
|
||||
in the current buffer instead of a popup.
|
||||
|
||||
** Multi-term
|
||||
|
||||
| Key Binding | Description |
|
||||
|
|
|
@ -28,3 +28,44 @@
|
|||
(setq-local eshell-output-filter-functions
|
||||
(remove 'eshell-handle-ansi-color
|
||||
eshell-output-filter-functions)))
|
||||
|
||||
(defun ansi-term-handle-close ()
|
||||
"Close current term buffer when `exit' from term buffer."
|
||||
(when (ignore-errors (get-buffer-process (current-buffer)))
|
||||
(set-process-sentinel (get-buffer-process (current-buffer))
|
||||
(lambda (proc change)
|
||||
(when (string-match "\\(finished\\|exited\\)"
|
||||
change)
|
||||
(kill-buffer (process-buffer proc))
|
||||
(when (> (count-windows) 1)
|
||||
(delete-window)))))))
|
||||
|
||||
(defun spacemacs/default-pop-shell ()
|
||||
"Open the default shell in a popup."
|
||||
(interactive)
|
||||
(let ((shell (if (eq 'multi-term shell-default-shell)
|
||||
'multiterm
|
||||
shell-default-shell)))
|
||||
(call-interactively (intern (format "spacemacs/shell-pop-%S" shell)))))
|
||||
|
||||
(defmacro make-shell-pop-command (func &optional shell)
|
||||
"Create a function to open a shell via the function FUNC.
|
||||
SHELL is the SHELL function to use (i.e. when FUNC represents a terminal)."
|
||||
(let* ((name (symbol-name func)))
|
||||
`(defun ,(intern (concat "spacemacs/shell-pop-" name)) (index)
|
||||
,(format (concat "Toggle a popup window with `%S'.\n"
|
||||
"Multiple shells can be opened with a numerical prefix "
|
||||
"argument. Using the universal prefix argument will "
|
||||
"open the shell in the current buffer instead of a "
|
||||
"popup buffer.") func)
|
||||
(interactive "P")
|
||||
(require 'shell-pop)
|
||||
(if (equal '(4) index)
|
||||
;; no popup
|
||||
(call-interactively ',func)
|
||||
(shell-pop--set-shell-type
|
||||
'shell-pop-shell-type
|
||||
(backquote (,name
|
||||
,(concat "*" name "*")
|
||||
(lambda nil (call-interactively ',func ,shell)))))
|
||||
(shell-pop index)))))
|
||||
|
|
|
@ -226,7 +226,6 @@ is achieved by adding the relevant text properties."
|
|||
:init
|
||||
(progn
|
||||
(spacemacs/register-repl 'multi-term 'multi-term)
|
||||
(spacemacs/set-leader-keys "ast" 'shell-pop-multi-term)
|
||||
(defun multiterm (_)
|
||||
"Wrapper to be able to call multi-term from shell-pop"
|
||||
(interactive)
|
||||
|
@ -291,50 +290,22 @@ is achieved by adding the relevant text properties."
|
|||
shell-pop-window-size shell-default-height
|
||||
shell-pop-term-shell shell-default-term-shell
|
||||
shell-pop-full-span t)
|
||||
(defmacro make-shell-pop-command (type &optional shell)
|
||||
(let* ((name (symbol-name type)))
|
||||
`(defun ,(intern (concat "shell-pop-" name)) (index)
|
||||
(interactive "P")
|
||||
(require 'shell-pop)
|
||||
(shell-pop--set-shell-type
|
||||
'shell-pop-shell-type
|
||||
(backquote (,name
|
||||
,(concat "*" name "*")
|
||||
(lambda nil (funcall ',type ,shell)))))
|
||||
(shell-pop index))))
|
||||
(make-shell-pop-command eshell)
|
||||
(make-shell-pop-command shell)
|
||||
(make-shell-pop-command term shell-pop-term-shell)
|
||||
(make-shell-pop-command multiterm)
|
||||
(make-shell-pop-command ansi-term shell-pop-term-shell)
|
||||
|
||||
(defun ansi-term-handle-close ()
|
||||
"Close current term buffer when `exit' from term buffer."
|
||||
(when (ignore-errors (get-buffer-process (current-buffer)))
|
||||
(set-process-sentinel (get-buffer-process (current-buffer))
|
||||
(lambda (proc change)
|
||||
(when (string-match "\\(finished\\|exited\\)"
|
||||
change)
|
||||
(kill-buffer (process-buffer proc))
|
||||
(when (> (count-windows) 1)
|
||||
(delete-window)))))))
|
||||
(add-hook 'term-mode-hook 'ansi-term-handle-close)
|
||||
(add-hook 'term-mode-hook (lambda () (linum-mode -1)))
|
||||
|
||||
(defun spacemacs/default-pop-shell ()
|
||||
"Open the default shell in a popup."
|
||||
(interactive)
|
||||
(let ((shell (if (eq 'multi-term shell-default-shell)
|
||||
'multiterm
|
||||
shell-default-shell)))
|
||||
(call-interactively (intern (format "shell-pop-%S" shell)))))
|
||||
(spacemacs/set-leader-keys
|
||||
"'" 'spacemacs/default-pop-shell
|
||||
"ase" 'shell-pop-eshell
|
||||
"asi" 'shell-pop-shell
|
||||
"asm" 'shell-pop-multiterm
|
||||
"ast" 'shell-pop-ansi-term
|
||||
"asT" 'shell-pop-term))))
|
||||
"ase" 'spacemacs/shell-pop-eshell
|
||||
"asi" 'spacemacs/shell-pop-shell
|
||||
"asm" 'spacemacs/shell-pop-multiterm
|
||||
"ast" 'spacemacs/shell-pop-ansi-term
|
||||
"asT" 'spacemacs/shell-pop-term))))
|
||||
|
||||
(defun shell/post-init-smooth-scrolling ()
|
||||
(spacemacs/add-to-hooks 'spacemacs//unset-scroll-margin
|
||||
|
|
Loading…
Reference in New Issue