问题描述
我写了这个elisp函数:
I wrote this elisp function:
(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模式(这是默认值),所以我可以告诉术语行模式调用没有做任何事情。如果我用(消息foo)替换(术语行模式),我在消息缓冲区中看到消息。
This works nicely except that the new ansi-term buffers remains in char mode (which is the default), so as far as I can tell the term-line-mode call is not doing anything. If I replace (term-line-mode) with (message "foo") I do see the message in the messages buffer.
术语行模式的定义在lisp / term.el中是:
The definition of term-line-mode in lisp/term.el is:
(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)))
我做错了什么? >
What am I doing wrong?
推荐答案
我无法在任何术语挂钩中获得term-line-mode的工作原理;但是,如果您建议ansi-term功能,它将会起作用:
I wasn't able to get "term-line-mode" to work as you want in any of the term hooks; however, it does work if you advise the "ansi-term" function:
(defadvice ansi-term (after advice-term-line-mode activate)
(term-line-mode))
这篇关于为什么我的术语模式挂钩不选择线模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!