2

I am using emacs s 23.1.1.
I have started to really use in real-earnest the shell, in order to minimize the amounts of time I am out of emacs. However, the bind-keys are emacs based. Which is good, but has its' limitations. if I want to use CTRL-r in the shell-context (loop backward over commands input), and not in the emacs context, how do I do that?
Having a preceding bind-key is O.K. I.e. press bindy key ALT-CTRL-S, and then CTRL-r.

3
  • Sorry, but I have no idea what you are asking. Are you asking how to unbind particular keys in shell mode? If so, then just bind them to nil in shell-mode-map.
    – Drew
    Mar 27, 2017 at 17:24
  • Try using term or ansi-term.
    – user12563
    Mar 27, 2017 at 19:16
  • Hello drew. I am trying to get the normal shell bind keys to override the emacs bind-keys, automatically. Mar 28, 2017 at 9:26

2 Answers 2

3

By default the binding to do this in Emacs' shell-mode is M-r which runs the command comint-history-isearch-backward-regexp. This allows you to search backwards though your input history using a regular expression.

Personally I prefer the comint-previous-matching-input-from-input command, which is by default bound to C-c M-r. I have it bound to the slightly more convenient M-p and it allows me to type the first few characters of the command I want, and to then use M-p to cycle through all previous inputs that begin with this prefix.

3

Consider using term-mode rather than shell-mode. In term-mode you can switch between "character mode" (where commands like C-r go directly to the terminal) and "line mode" (where commands are first interpreted by Emacs). C-c C-j activates line mode and C-c C-k character mode. Character mode gives C-r the behavior you want while line mode makes the terminal act more like a normal Emacs buffer.

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.