我喜欢使用Emacs的shell模式,但它有一些不足之处.其中之一是,当shell命令试图调用编辑器时,打开新缓冲区并不够智能.例如,将环境变量VISUAL设置为vimI ,我将从中获取以下内容svn propedit:
$ svn propedit svn:externals . "svn-prop.tmp" 2L, 149C[1;1H ~ [4;1H~ [5;1H~ [6;1H~ [7;1H~ ...
(从表示中可能很难说,但这是一个可怕的,丑陋的混乱.)
随着VISUAL设置为"emacs -nw",我得到
$ svn propedit svn:externals .
emacs: Terminal type "dumb" is not powerful enough to run Emacs.
It lacks the ability to position the cursor.
If that is not the actual type of terminal you have,
use the Bourne shell command `TERM=... export TERM' (C-shell:
`setenv TERM ...') to specify the correct type. It may be necessary
to do `unset TERMINFO' (C-shell: `unsetenv TERMINFO') as well.svn: system('emacs -nw svn-prop.tmp') returned 256
(它可以VISUAL设置为just emacs,但仅限于Emacs X窗口内部,而不是终端会话内部.)
有没有办法让shell模式在这里做正确的事情并代表命令行进程打开一个新的缓冲区?
小智 20
您可以通过附加到Emacs会话emacsclient.首先,启动emacs服务器
M-x server-start
Run Code Online (Sandbox Code Playgroud)
或添加(server-start)到您的.emacs.然后,
export VISUAL=emacsclient
Run Code Online (Sandbox Code Playgroud)
编辑.
注意:
emacs和emacsclient必须同意.如果安装了多个版本的Emacs,请确保调用与emacsclient运行服务器的Emacs 版本对应的版本.(server-start)在您的中.emacs),将在最后一帧中创建缓冲区以启动服务器.