代码之家  ›  专栏  ›  技术社区  ›  Charles Duffy

当命令试图在shell模式下打开编辑器时,打开Emacs缓冲区

  •  19
  • Charles Duffy  · 技术社区  · 17 年前

    VISUAL 着手 vim 我从中得到以下信息 svn propedit

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

    具有 视力的 着手 "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
    

    (它与 视力的 设置为 emacs ,但只能从Emacs X窗口内部,而不能从终端会话内部。)

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

    6 回复  |  直到 17 年前
        1
  •  21
  •   Charles Duffy    17 年前

    您可以通过连接到Emacs会话 emacsclient . 首先,使用以下命令启动emacs服务器:

    M-x server-start
    

    (server-start) 给你 .emacs . 然后

    export VISUAL=emacsclient
    

    注:

    • emacs EmacClient 我必须同意。如果安装了多个版本的Emacs,请确保调用的版本 EmacClient 对应于运行服务器的Emacs版本。
    • 如果在多个Emacs进程/帧中启动服务器(例如,因为 在你的房间里 .emacs ),将在启动服务器的最后一帧中创建缓冲区。
        2
  •  3
  •   jfm3    17 年前

        3
  •  0
  •   jrockway    17 年前

    不完全正确。 ansi-term 可以很好地运行emacs(尽管我通常运行mg来提交日志,但在极少数情况下,我不会直接从emacs提交)。 eshell 如果您启动了一个 screen 首先,从内部运行它。

        4
  •  0
  •   killdash10    16 年前

    除了使用emacs客户机/服务器,我还使用这个脚本来调用emacs。

    如果emacs尚未运行,这将启动emacs,或者只是在运行的emacs中打开一个新的emacs缓冲区(使用gnuclient)。默认情况下,它在后台运行,但对于需要某些输入的进程,它可以在前台运行。例如,在输入更改列表描述时,我将其用作源代码管理编辑器。我有“SVN_EDITOR=emacs sync”,因此我可以在emacs shell中执行“SVN commit”,它将在同一emacs中的新emacs缓冲区中打开SVN编辑器。当我关闭缓冲区时,“svn提交”继续。非常有用。

    #!/bin/sh
    
    if [ -z $EMACS_CMD ]; then
      EMACS_CMD="/usr/bin/emacs"
    fi
    
    if [ -z $GNUCLIENT_CMD ]; then
      GNUCLIENT_CMD="/usr/bin/gnuclient"
    fi
    
    if [ "$1" = "sync" ]; then
        shift 1
        sync=true
    else
        sync=false
    fi
    
    cmd="${EMACS_CMD} $*"
    lsof $EMACS_CMD | grep $USER >/dev/null 2>&1
    if [ "$?" -ne "1" ]; then
        cmd="${GNUCLIENT_CMD} $*"
    fi
    
    if [ $sync = "true" ]; then
        $cmd
    else
        $cmd &
    fi
    
    
        5
  •  0
  •   T Collins    16 年前

    1. 在.emacs文件中添加:(启动服务器)(记住在更改后加载文件)

    2. 在您的hgrc中:

      [merge-tools]
      emacs.executable = emacsclient
      emacs.premerge = False
      emacs.args = --eval "(ediff-merge-with-ancestor \"$local\" \"$other\" \"$base\" nil \"$output\")"
      
        6
  •  0
  •   Community Mohan Dere    5 年前

    当我的.emacs中有(启动服务器)时,我得到了这个错误。。。。

    Debugger entered--Lisp error: (void-function start-server)
      (start-server)
      eval-buffer(#<buffer  *load*> nil "/Users/jarrold/.emacs" nil t)  ; Reading at buffer position 22768
      load-with-code-conversion("/Users/jarrold/.emacs" "/Users/jarrold/.emacs" t t)
      load("~/.emacs" t t)
      #[nil "^H\205\276^@   \306=\203^Q^@\307^H\310Q\202A^@ \311=\2033^@\312\307\313\314#\203#^@\315\202A^@\312\307\$
      command-line()
      normal-top-level()
    

    …我正在使用GNU Emacs 22.1.1

    这是我正在使用的Mac OS-X版本:

    达尔文内核版本10.8.0:Tue Jun 7 16:33:36 PDT 2011;

    根目录:xnu-1504.15.3~1/RELEASE_I386 I386