Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add vterm-dabbrev-expand #401

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions vterm.el
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@ the executable."
(require 'color)
(require 'compile)
(require 'face-remap)
(require 'dabbrev)
(require 'thingatpt)

;;; Options

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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