akermu / emacs-libvterm

Emacs libvterm integration
GNU General Public License v3.0
1.69k stars 135 forks source link

Unable to edit command line in evil normal mode #156

Open qleguennec opened 5 years ago

qleguennec commented 5 years ago

This is probably intended behavior, but when I switch in evil normal mode, I am unable to use evil editing commands. Example with cw for deleting the current word: (apply: Buffer is read-only: #<buffer *vterm-dedicated*>)

clhodapp commented 4 years ago

I suspect that that's kind of impossible to get around, given that the underlying vterm and the shell connected to it are responsible for updates. You might want to try using a shell that supports vi bindings... but it might be tricky to integrate in a satisfying way with evil (you end up having to juggle both the shell's normal mode and evil's normal state).

alextremblay commented 4 years ago

Is it possible to set up a mechanism whereby lines of text can be inserted into the buffer, and have vterm send each such line to the underlying shell for processing?

I'm thinking we could set up some kind of function whereby the current line is yanked into a temporary buffer or something, and normal emacs / evil text editing can be done, and on close, the contents of that buffer are pasted into the vterm buffer to be processed by the shell as a series of command lines. Would that be possible?

alextremblay commented 4 years ago

This would also enable the use of vterm snippets with something like yasnippet, which would (i think) be very useful (especially if you have commands you use often that you want to be able to insert into ssh sessions, for example)

Sbozzolo commented 4 years ago

Could vterm-send-string be used for this? The following function

(defun test-vterm-insert-string ()
  (interactive)
(vterm-send-string (read-from-minibuffer "What do you want do send? ")))

inserts a command in the current vterm buffer. If you want to be immediately executed you can add vterm-send-return:

(defun test-vterm-insert-string ()
  (interactive)
  (vterm-send-string (read-from-minibuffer "What do you want do send? "))
  (vterm-send-return))

I suppose one could easily generalize this to:

  1. create a new buffer (with maybe sh-mode)
  2. do the editing you want to do
  3. copy the content of the buffer
  4. close the buffer
  5. send the string to vterm

Is this what you are looking for?

akater commented 4 years ago

Note: for those who bind C-h to delete-backward-char (or to something equivalent), this will be handy:

(use-package vterm
  :bind
  (:map vterm-mode-map
        ([remap delete-backward-char] . vterm-send-C-h)))

It might make sense to do something like this on lower level in vterm.

Sbozzolo commented 4 years ago

Is it possible to set up a mechanism whereby lines of text can be inserted into the buffer, and have vterm send each such line to the underlying shell for processing?

I'm thinking we could set up some kind of function whereby the current line is yanked into a temporary buffer or something, and normal emacs / evil text editing can be done, and on close, the contents of that buffer are pasted into the vterm buffer to be processed by the shell as a series of command lines. Would that be possible?

I implemented a rudimentary version of this here.

noctuid commented 4 years ago

Ideally there would be an option to do this directly in the vterm buffer. Nothing would be sent until you hit RET or whatever keybinding.

blahgeek commented 3 years ago

https://github.com/akermu/emacs-libvterm/issues/313#issuecomment-708883758