当命令尝试以shell模式打开编辑器时,打开Emacs缓冲区 [英] Open an Emacs buffer when a command tries to open an editor in shell-mode

查看:211
本文介绍了当命令尝试以shell模式打开编辑器时,打开Emacs缓冲区的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我喜欢使用Emacs的shell模式,但它有一些缺陷。其中之一是,当shell命令尝试调用编辑器时,打开新缓冲区不够聪明。例如,环境变量 VISUAL 设置为 vim 我从 svn propedit

 
$ svn propedit svn:externals。
svn-prop.tmp2L,149C [1; 1H
〜[4; 1H〜[5; 1H〜[6; 1H〜[7; 1H〜
...

(可能很难从代表处告诉,但这是一个可怕的,丑陋的混乱。)



使用 VISUAL 设置为emacs -nw,我得到

 
$ svn propedit svn:externals。
emacs:终端类型dumb不够强大,无法运行Emacs。
它缺少定位光标的功能。
如果这不是终端的实际类型,
使用Bourne shell命令TERM = ... export TERM(C-shell:
`setenv TERM ...' )来指定正确的类型。系统('emacs -nw svn-prop.tmp')返回256

pre>

(它适用于 VISUAL 设置为 emacs ,但只能从Emacs X窗口内部,不在终端会话内。)



有没有办法让shell模式在这里做正确的事情,开放代表命令行进程的新缓冲区?

解决方案

您可以通过附加到Emacs会话emacsclient 。首先,使用

 启动emacs服务器Mx服务器启动

或添加(server-start)到您的 .emacs 。然后,

 导出VISUAL = emacsclient 

编辑。



注意:




  • emacs emacsclient 的版本必须同意。如果您安装了多个版本的Emacs,请确保您调用与运行服务器的Emacs版本对应的 emacsclient 版本。

  • 如果您在多个Emacs进程/框架中启动服务器(例如,因为(server-start)在您的 .emacs ),将在最后一帧中创建缓冲区以启动服务器。


I like to use Emacs' shell mode, but it has a few deficiencies. One of those is that it's not smart enough to open a new buffer when a shell command tries to invoke an editor. For example with the environment variable VISUAL set to vim I get the following from svn propedit:

$ svn propedit svn:externals . 
"svn-prop.tmp" 2L, 149C[1;1H
~                                                                               [4;1H~                                                                               [5;1H~                                                                               [6;1H~                                                                               [7;1H~            
...

(It may be hard to tell from the representation, but it's a horrible, ugly mess.)

With VISUAL set to "emacs -nw", I get

$ 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

(It works with VISUAL set to just emacs, but only from inside an Emacs X window, not inside a terminal session.)

Is there a way to get shell mode to do the right thing here and open up a new buffer on behalf of the command line process?

解决方案

You can attach to an Emacs session through emacsclient. First, start the emacs server with

M-x server-start

or add (server-start) to your .emacs. Then,

export VISUAL=emacsclient

Edit away.

Note:

  • The versions of emacs and emacsclient must agree. If you have multiple versions of Emacs installed, make sure you invoke the version of emacsclient corresponding to the version of Emacs running the server.
  • If you start the server in multiple Emacs processes/frames (e.g., because (server-start) is in your .emacs), the buffer will be created in the last frame to start the server.

这篇关于当命令尝试以shell模式打开编辑器时,打开Emacs缓冲区的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆