0

vterm can search the command history by sending C-r to terminal process, but the command line cannot be modified unless it is executed as it is once. In other words, the string to search keeps changing by my editing because I can't get out of searching state. Is there a way to quit searching to start editing? It doesn't seem to be C-g, it shows "Quit" in minibuffer as usual but the prompt "bck-i-search:"(from my terminal zsh) remains.

Update:

It was due to disabling these keys in vterm-mode-map itself that can be used to quit the prompt, by myself stupidly:

(define-key vterm-mode-map (kbd "C-a") nil)
(define-key vterm-mode-map (kbd "C-b") nil)
(define-key vterm-mode-map (kbd "C-e") nil)
(define-key vterm-mode-map (kbd "C-f") nil)
(define-key vterm-mode-map (kbd "C-n") nil)
(define-key vterm-mode-map (kbd "C-p") nil)

These are originally bound to vterm--self-insert for passing raw input to terminal. Because I still want to move around in vterm buffer in the same way as in normal buffer using normal keys for moving cursor, is there a way to keep the keys quitable and movable, by detecting whether the cursor position is on the command line or not, after leaving the command line using isearch etc?

2
  • 1
    Do you see the same problem if you start Emacs with emacs -Q (no init file)? If not then bisect your init file to find the culprit.
    – Drew
    Apr 3, 2023 at 15:11
  • 1
    exactly as you guessed, I can quit the prompt easily with any key for moving cursor under minimum settings. Thank you so much!
    – roomworoof
    Apr 3, 2023 at 16:09

1 Answer 1

0

I'll define a key only for quiting the prompt and use it for a while..

(define-key vterm-mode-map (kbd "M-q") #'vterm-send-C-e)

Update: It's not very good, but I chose the easy way to prioritize the normal keybindings and change the prefix (using vterm-send-* for sending a specific key) for inline moving (also for quiting from the prompt) on the command line.

(define-key vterm-mode-map (kbd "C-a") nil) ;; disable to move around everywhere in the buffer by the key in global-map.
(define-key vterm-mode-map (kbd "C-b") nil)
(define-key vterm-mode-map (kbd "C-e") nil)
(define-key vterm-mode-map (kbd "C-f") nil)
(define-key vterm-mode-map (kbd "C-n") nil)
(define-key vterm-mode-map (kbd "C-p") nil)
(define-key vterm-mode-map (kbd "C-s") nil) ;; for isearch.
(define-key vterm-mode-map (kbd "C-v") nil)
(define-key vterm-mode-map (kbd "M-v") nil)
(define-key vterm-mode-map (kbd "M-a") 'vterm-send-C-a) ;; change the prefix key C to M for moving on the command line.
(define-key vterm-mode-map (kbd "M-b") 'vterm-send-C-b)
(define-key vterm-mode-map (kbd "M-e") 'vterm-send-C-e)
(define-key vterm-mode-map (kbd "M-f") 'vterm-send-C-f)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.