0

Occasionally, I want to send a keystroke to a program in my ansi-term buffer that is already mapped to something in emacs. I know that for one I use often I could change my configuration to always send it, but in this case I just need a one-off.

Is there any way I can set some key combination to "send the next key as raw" ?

  • Most characters are sent as raw in term char mode, which is the default. Are you using line mode? Any reason not to use the default? – phils Apr 21 at 8:04
  • In principle, prefixing the key with C-q avoids all keyboard translations. But, I do not know whether this works in your case. E.g., in line-mode you need the final RET to send the input to the terminal. – Tobias Apr 21 at 20:18
  • I am in char mode, in evil-insert-mode under spacemacs. C-q C-c does not seem to send a C-c to my terminal for example -- but maybe there is a different key in evil mode? Nope, C-q C-c in hybrid mode doesn't send to the terminal either. – singpolyma Apr 22 at 0:31
0

This worked:

(defun singpolyma/term-insert-literal (key)
    "Take a keypress and insert it literally into a terminal."
    (interactive "cPress key:")
    (term-send-raw-string (format "%c" key))
    )

(add-hook 'term-mode-hook (lambda ()
        (define-key evil-insert-state-map (kbd "C-`") 'singpolyma/term-insert-literal)
        )
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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