为什么我的term-mode-hook没有选择行模式?

时间:2011-07-25 13:29:47

标签: emacs elisp

我写了这个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调用没有做任何事情。如果我用(消息“foo”)替换(term-line-mode),我确实在消息缓冲区中看到了消息。

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)))

我做错了什么?

1 个答案:

答案 0 :(得分:5)

我无法在任何术语钩子中使用“term-line-mode”工作;但是,如果您建议使用“ansi-term”函数,它确实有效:

(defadvice ansi-term (after advice-term-line-mode activate)
  (term-line-mode))