我写了这个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)))
这工作得很好,除了新的单术语缓冲区保持char模式(这是默认的),所以据我所知,术语行模式调用没有做任何事情。如果我将(term-line-mode)替换为(message "foo"),我确实可以在消息缓冲区中看到消息。
lisp/term中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)))
我做错了什么?
我无法让"term-line-mode"在任何术语钩子中都像你想的那样工作;但是,如果您建议使用"ansi-term"函数,它确实可以工作:
(defadvice ansi-term (after advice-term-line-mode activate)
(term-line-mode))