From 57be44144dd486d50344924122dad7e3f0477a08 Mon Sep 17 00:00:00 2001 From: Oleg Pykhalov Date: Thu, 17 Sep 2020 01:43:59 +0300 Subject: [PATCH] Add vterm-dabbrev-expand --- vterm.el | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/vterm.el b/vterm.el index c21cbe7b..14e004be 100644 --- a/vterm.el +++ b/vterm.el @@ -158,6 +158,8 @@ the executable." (require 'color) (require 'compile) (require 'face-remap) +(require 'dabbrev) +(require 'thingatpt) ;;; Options @@ -515,6 +517,7 @@ Exceptions are defined by `vterm-keymap-exceptions'." (define-key map (kbd "S-SPC") #'vterm-send-space) (define-key map (kbd "C-_") #'vterm--self-insert) (define-key map (kbd "C-/") #'vterm-undo) + (define-key map (kbd "M-/") #'vterm-dabbrev-expand) (define-key map (kbd "M-.") #'vterm-send-meta-dot) (define-key map (kbd "M-,") #'vterm-send-meta-comma) (define-key map (kbd "C-c C-y") #'vterm--self-insert) @@ -1259,5 +1262,21 @@ can find them and remove them." (vterm--remove-fake-newlines) (buffer-string))) +(defun vterm-dabbrev-expand-wrapper () + "Return `dabbrev-expand' result." + (save-current-buffer + (setq-local buffer-read-only nil) + (call-interactively #'dabbrev-expand) + (thing-at-point 'symbol))) + +;;;###autoload +(defun vterm-dabbrev-expand () + "Provide similar behavior as `dabbrev-expand'." + (interactive) + (if (thing-at-point 'symbol) + (progn (vterm-send-C-w) + (vterm-send-string (vterm-dabbrev-expand-wrapper) t)) + (vterm-send-string (vterm-dabbrev-expand-wrapper) t))) + (provide 'vterm) ;;; vterm.el ends here