emacs-libvterm
emacs-libvterm copied to clipboard
[Suggestion] interactive vterm-send-key instead of vterm-define-key
Make vterm-send-key interactive, frees out a lot of function definitions, and could be a more flexible approach.
(defun vterm-translate-event-to-args (event)
(let ((modifiers (event-modifiers event))
(base (event-basic-type event)))
(list (char-to-string base)
(memq 'shift modifiers)
(memq 'meta modifiers)
(memq 'control modifiers))))
(defun vterm-send-key ((key &optional shift meta ctrl accept-proc-output))
(interactive (if (string= (this-command-keys) (string last-command-event))
(vterm-translate-event-to-args last-command-event)
(user-error "cannot send this key %s" (this-command-keys))))
...)
Now just bind them to keys, for example:
(define-key vterm-mode-map [?\M-f] #'vterm-send-key)
Pressing M-f
in a vterm buffer will send M-f
approperiately, as it will get translated using last-command-event
with the correct modifier and base flag.
This method is very similar to vterm-send
, except this can send whatever key that is just pressed.
It has been some time since, my suggestion, which I personally would like to see happen to take place in vterm.
This change effectively would eliminate 26 + 78 = 104 vterm-send-
- The macro vterm-define-key is removed and its associated macro expansions
- All vterm-mode-map keys are mapped to the interactive version of #'vterm-send-key
If I had missed anything, please let me know. If there is some potential roadblocks that I may not be aware of, please let me know also.
see #618 #619 #620
Issue closed as it has been addressed.