我写了这个elisp函数:
(defun run (command)
"Open a terminal running a command."
(interactive "sCommand: ")
(if (buffer-exists (concat "*" command "*" )) (kill-buffer (concat "*" command "*")))
(let ((term-mode-hook (cons (lambda () (term-line-mode)) term-mode-hook)))
(ansi-term (cons "sh" (cons "-i" (list "-c" command))) command)))
这很好地工作,除了新的 ansi-term 缓冲区保持在 char 模式(这是默认值),据我所知, term-line-mode 调用没有做任何事情。如果我将 (term-line-mode) 替换为 (message "foo") 我确实会在消息缓冲区中看到该消息。
lisp/term.el 中 term-line-mode 的定义是:
(defun term-line-mode ()
"Switch to line (\"cooked\") sub-mode of term mode.
This means that Emacs editing commands work as normally, until
you type \\[term-send-input] which sends the current line to the inferior."
(interactive)
(when (term-in-char-mode)
(use-local-map term-old-mode-map)
(term-update-mode-line)))
我究竟做错了什么?
最佳答案
在任何术语 Hook 中,我都无法让“术语行模式”按照您的意愿工作;但是,如果您建议使用“ansi-term”功能,它确实有效:
(defadvice ansi-term (after advice-term-line-mode activate)
(term-line-mode))
关于emacs - 为什么我的 term-mode-hook 没有选择行模式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6816877/