emacs:在另一个实例中自动打开相应的文件

emacs: Automatically open corresponding file in another instance

本文关键字:文件 另一个 实例 emacs      更新时间:2023-10-16

我想要类似于Emacs C++的东西,打开相应的头文件,除了我想

1(始终自动打开相应的标题;和

2(在另一个 emacs 实例中执行此操作(如果有人想出了一个解决方案,让所有其他 emacs 实例都这样做,那也没问题。

请注意,我在终端模式下使用 emacs,所以我无法 https://superuser.com/questions/102163/how-to-split-emacs-over-a-dual-monitor(或者至少我不知道如何做(。

2(的一个简单解决方案是运行一个emacs实例 server-mode第二个终端中启用并从主 Emacs 实例通过使用 server-eval-at .

要启动从属服务器,请运行:

$ emacs --eval '(progn (setq server-name "ff-slave") (server-mode 1))'

然后使用以下代码来命令它:

(require 'server)
(require 'find-file)
(defun command-ff-slave ()
  (interactive)
  (save-excursion
    (let ((b (ff-other-file-name)))
      (if (null b)
          (message "Found no other file")
          (server-eval-at "ff-slave"
                          `(find-file ,b))))))

从主 emacs 实例调用command-ff-slave应该在从属服务器上的新缓冲区中打开任何相关文件。

相关文章: