Additional vterm improvements: fix consult-yank and add find-file

This commit is contained in:
Jeremy Dormitzer 2022-04-14 09:31:47 -04:00
parent 81ba75c291
commit a49f3c1981
2 changed files with 20 additions and 1 deletions

View File

@ -22,6 +22,21 @@
(run-hooks 'vterm-directory-change-hook))))
(add-hook 'vterm-mode-hook #'hack-dir-local-variables-non-file-buffer)
(add-hook 'vterm-directory-change-hook #'hack-dir-local-variables-non-file-buffer)
(with-eval-after-load 'consult
(defun vterm-consult-yank-from-kill-ring-action (orig-fun &rest args)
(if (equal major-mode 'vterm-mode)
(let ((inhibit-read-only t)
(yank-undo-function (lambda (_start _end) (vterm-undo))))
(cl-letf (((symbol-function 'insert-for-yank)
(lambda (str) (vterm-send-string str t))))
(apply orig-fun args)))
(apply orig-fun args)))
(defun vterm-disable-consult-preview (orig-fun &rest args)
"Disable Consult previews in vterm buffers. Meant to advise consult--insertion-preview."
(unless (equal major-mode 'vterm-mode)
(apply orig-fun args)))
(advice-add 'consult-yank-from-kill-ring :around #'vterm-consult-yank-from-kill-ring-action)
(advice-add 'consult--insertion-preview :around #'vterm-disable-consult-preview))
:general
(leader-map "v" #'project-vterm)
:custom

View File

@ -152,13 +152,17 @@ vterm_cmd() {
vterm_printf "51;E$vterm_elisp"
}
find_file() {
vterm_cmd find-file "$(realpath "${@:-.}")"
}
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'
alias ff='vterm_cmd find-file'
alias ff='find_file'
fi
# This is to change the title of the buffer based on information provided by the