如何让emacsclient找到它执行的emacs守护进程

时间:2011-01-05 14:35:07

标签: unix shell emacs

我正在尝试将大部分编辑和shell活动转移到emacs中,以便我可以轻松地从不同的计算机继续我的工作流程。我的不同项目也有不同的emacs实例。例如,我开始了:

emacs --daemon=project1
emacs --daemon=project2

然后每当我想开始一个框架来处理project1时,我都会这样做:

emacsclient -s project1 -c

大多数情况下它的效果很好,但我在使用$ EDITOR试图启动编辑器的emacs shell中执行工具时遇到了麻烦。当然,在这种情况下我想要的是在我当前的emacs实例中打开一个新的缓冲区,正是emacsclient的设计目的。所以如果在project1的emacs中的shell缓冲区中我说:

export EDITOR='emacsclient -s project1'

然后在特定的 shell中,一切都运行良好。

我的问题是,如何以指向当前shell运行的emacs实例的方式自动设置EDITOR变量?

1 个答案:

答案 0 :(得分:3)

这是一种方法:

(add-hook 'shell-mode-hook
      (lambda ()
        (comint-send-string 
         (get-buffer-process (current-buffer))
         (concat "export EDITOR='emacsclient -s " 
             (daemonp)
             " -c'\n"))))