I want to bypass comint-mode's completion support completely, instead relying on the subordinate process to do it for me. Specifically, if I'm running:

  • emacs
    • shell-mode
      • bash

Then I want TAB to be passed to the bash process and expanded by it.

If I'm running:

  • emacs
    • shell-mode
      • bash
        • psql

Then I'd want TAB to be handled by psql.

I've tried this in a shell-mode-hook to no avail:

(define-key shell-mode-map "\t" 'self-insert-command)

When this is set, the TAB key inserts a literal tab on the command line, which is not at all useful to me.

I've also tried this, but when I hit TAB nothing happens:

(defun cr/comint-send-tab ()
  "Send a tab character to the current buffer's process"
  (interactive)
  (comint-send-input t t)
  (process-send-string (current-buffer) "\t"))

(define-key shell-mode-map "\t" 'cr/comint-send-tab)

How can I do this?

link|improve this question

33% accept rate
+1: I had been exploring almost exactly the same use case when I found this question! – SetJmp Sep 27 '11 at 16:12
feedback

2 Answers

Try quoted-insert which is (by default) bound to C-q. The next character you type will be literally inserted into the buffer.

So C-qTAB will insert a literal tab.

I don't know what this does in comint modes (in regard to bash completion) and am not in a position to test it.

link|improve this answer
That has the same effect as my second attempt, above. No go, sadly. – Chris R Jan 24 '11 at 7:36
feedback

How about trying Emacs' terminal (instead of shell).

M-x term

link|improve this answer
Term has its own set of issues, starting with some interesting interactions with my extant set of bashrc tweaks. – Chris R Jan 23 '11 at 3:10
feedback

Your Answer

 
or
required, but never shown

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