如何在 emacs 的 shell 模式下向 bash 发送文字选项卡?

Chr*_*s R 8 emacs

我想完全绕过comint-mode的完成支持,而不是依靠从属进程来为我做。具体来说,如果我正在运行:

  • 电子书
    • 外壳模式
      • 猛击

然后我想TAB被传递给bash进程并被它扩展。

如果我正在运行:

  • 电子书
    • 外壳模式
      • 猛击
        • 查询语句

然后我想TAB由 psql 处理。

我已经在 shell-mode-hook 中尝试过这个,但无济于事:

(define-key shell-mode-map "\t" 'self-insert-command)
Run Code Online (Sandbox Code Playgroud)

设置后,该TAB键会在命令行上插入一个文字选项卡,这对我来说一点用处都没有。

我也试过这个,但是当我TAB没有任何反应时:

(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)
Run Code Online (Sandbox Code Playgroud)

我怎样才能做到这一点?

Fra*_*ran 7

Emacsshell-mode缓冲区不是终端(即,它们不使用 pty(伪终端)),因此在此类缓冲区中运行的任何程序(外壳程序、外壳程序运行的程序等)都不能执行 character-at-a-时间输入。每一行都是完整输入的,只有在ENTER按下时才会发送。要查看证据,请ttyshell-mode缓冲区中运行该命令,它的输出将为not a tty.