Vterm ediff integration and ability to send ESC sequences

This commit is contained in:
Jeremy Dormitzer 2021-03-03 09:26:58 -05:00
parent c2e2e9e780
commit 4ddf25b19c
3 changed files with 30 additions and 9 deletions

View File

@ -35,7 +35,20 @@
:defer t
:straight (:type built-in)
:config
(setq ediff-window-setup-function #'ediff-setup-windows-plain))
(setq ediff-window-setup-function #'ediff-setup-windows-plain)
(evil-collection-ediff-setup)
;; Restore window configuration after an ediff session
(defvar ediff-last-windows nil)
(defun store-pre-ediff-winconfig ()
(setq ediff-last-windows (current-window-configuration)))
(defun restore-pre-ediff-winconfig ()
(set-window-configuration ediff-last-windows))
(add-hook 'ediff-before-setup-hook #'store-pre-ediff-winconfig)
(add-hook 'ediff-quit-hook #'restore-pre-ediff-winconfig))
(use-package replace
:defer t

View File

@ -8,13 +8,14 @@
(call-interactively #'vterm)))
:config
(evil-collection-vterm-setup)
(general-def 'insert vterm-mode-map "C-<escape>" #'vterm-send-escape)
;; Add a hook when vterm changes the directory
(defvar vterm-directory-change-hook nil
"Hooks to be run after vterm changes the directory")
(defun vterm--set-directory (path)
"Set `default-directory' to PATH."
(let ((dir (vterm--get-directory path)))
(when dir
(when (and dir (eq major-mode 'vterm-mode))
(setq default-directory dir)
(run-hooks 'vterm-directory-change-hook))))
(add-hook 'vterm-mode-hook #'hack-dir-local-variables-non-file-buffer)
@ -23,6 +24,11 @@
(leader-map "v" #'project-vterm)
:custom
(vterm-environment '("TYPEWRITTEN_CURSOR=terminal"))
(vterm-ignore-blink-cursor t))
(vterm-ignore-blink-cursor t)
(vterm-eval-cmds '(("find-file" find-file)
("message" message)
("vterm-clear-scrollback" vterm-clear-scrollback)
("man" man)
("ediff" ediff))))
(provide 'init-vterm)

View File

@ -122,12 +122,6 @@ function vterm_printf(){
fi
}
# Completely clear the buffer. With this, everything that is not on screen
# is erased.
if [[ "$INSIDE_EMACS" = 'vterm' ]]; then
alias clear='vterm_printf "51;Evterm-clear-scrollback";tput clear'
fi
# With vterm_cmd you can execute Emacs commands directly from the shell.
# For example, vterm_cmd message "HI" will print "HI".
# To enable new commands, you have to customize Emacs's variable
@ -142,6 +136,14 @@ vterm_cmd() {
vterm_printf "51;E$vterm_elisp"
}
if [[ "$INSIDE_EMACS" = 'vterm' ]]; then
# Completely clear the buffer. With this, everything that is not on screen
# is erased.
alias clear='vterm_printf "51;Evterm-clear-scrollback";tput clear'
alias man='vterm_cmd man'
alias ediff='vterm_cmd ediff'
fi
# This is to change the title of the buffer based on information provided by the
# shell. See, http://tldp.org/HOWTO/Xterm-Title-4.html, for the meaning of the
# various symbols.