Created
March 11, 2021 10:37
-
-
Save nxtr/9da0a1505b8adc101529f6b01ccb5542 to your computer and use it in GitHub Desktop.
Advice counsel-yank-pop for proper vterm-mode yank-pop using emacs-libvterm, ivy and counsel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(define-advice counsel-yank-pop (:around (fun &rest args)) | |
(if (equal major-mode 'vterm-mode) | |
(let ((counsel-yank-pop-action-fun (symbol-function | |
'counsel-yank-pop-action)) | |
(last-command-yank-p (eq last-command 'yank))) | |
(cl-letf (((symbol-function 'counsel-yank-pop-action) | |
(lambda (s) | |
(let ((inhibit-read-only t) | |
(last-command (if (memq last-command | |
'(counsel-yank-pop | |
ivy-previous-line | |
ivy-next-line)) | |
'yank | |
last-command)) | |
(yank-undo-function (when last-command-yank-p | |
(lambda (_start _end) | |
(vterm-undo))))) | |
(cl-letf (((symbol-function 'insert-for-yank) | |
'vterm-insert)) | |
(funcall counsel-yank-pop-action-fun s)))))) | |
(apply fun args))) | |
(apply fun args))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment