【问题标题】:Make emacs never open up a new frame让emacs永远不会打开一个新框架
【发布时间】:2013-09-19 13:17:37
【问题描述】:

你会如何设置 emacs 从不创建任何新框架。如果我想要框架,我会在 emacs 内部进行。

令人讨厌的是,每当我从 emacs 外部的文件管理器中单击一个文件时,都会打开一个全新的 emacs 实例,并且伴随着所有较长的加载时间。

打开一堆文件,每个文件都需要大约 5 秒才能最终加载,这不是很方便。 所以我想要做的是:每当我在文件管理器上单击一个文件时,我希望该文件在一个已经作为新缓冲区运行的 emacs 实例中打开。

我该怎么做?

在带有 Gnome 3.8.4 的 Fedora 19 上使用 emacs 24.3.1

【问题讨论】:

  • 假设 Basile Starynkevitch 的假设是正确的,那么您的描述并不完全正确;您实际上是在启动多个 Emacs 实例(每个实例都有一个 single 框架),而不是打开新框架(这意味着单个实例)。由于每个都需要大约 5 秒才能打开,因此这几乎可以肯定正在发生的事情。 (如果你热衷于,你无疑也可以将启动时间减少到不超过一秒左右,使用eval-after-load 并尽可能自动加载。另见stackoverflow.com/questions/778716/…

标签: emacs window


【解决方案1】:

您想启动一个emacs 的单个实例(它应该在您的~/.emacs 中使用(server-start) 启动一个服务器),然后使用emacsclient。你可能应该

  export EDITOR=emacsclient

在例如你的~/.bashrc

请参阅 invoking emacsclient(在 Emacs 文档中)和 EmacsClient(在 Emacs Wiki 中)。

【讨论】:

  • 好吧,我已经在服务器模式下设置了一些东西,但没有任何改善。不仅我的 .emacs 文件在我打开文件时被忽略(没有自定义加载告诉我这里有问题),我现在还必须始终右键单击文件以使用 emacs-client 而不是使用 emacs 打开。即使这样做,我仍然会得到新的帧(我不想要帧!!!我想要新的缓冲区!!!)顺便说一句:速度无论如何都没有增加。有谁知道的更好吗??
  • 确保您的桌面正在启动emacsclient(或$EDITOR)而不是emacs;使用ps auxwtop 找出您是否有多个emacs 进程......
  • 好的,我知道了。但这并没有改变守护程序模式被破坏并且启动文件被忽略。这些怎么办??
  • emacsclient 不会评估您的初始化文件——服务器实例已经完成了。在服务器中加载和评估的所有内容都可供该服务器的每个客户端使用。这就是 emacsclient/server 安排的全部目的。
  • emacsclient 应该重用现有的框架,除非您已将 -c 参数传递给它以要求它创建一个新框架。
【解决方案2】:

这就是我所做的。我有 Ubuntu,但我很确定 侏儒也uses /usr/share/applications/.

这是我的/usr/local/share/applications/emacsclient.desktop

[Desktop Entry]
Name=Emacsclient
GenericName=Text Editor
Comment=View and edit files
MimeType=text/english;text/plain;text/x-makefile;text/x-c++hdr;text/x-c++src;text/x-chdr;text/x-csrc;text/x-java;text/x-moc;text/x-pascal;text/x-tcl;text/x-tex;application/x-shellscript;text/x-c;text/x-c++;
Exec=/usr/local/bin/emacsclient %F
Icon=emacs
Type=Application
Terminal=false
Categories=Development;TextEditor;
StartupWMClass=Emacs

这是我的/usr/local/share/applications/emacs.desktop(为了完整起见):

[Desktop Entry]
Name=Emacs
GenericName=Text Editor
Comment=Edit text
MimeType=text/english;text/plain;text/x-makefile;text/x-c++hdr;text/x-c++src;text/x-chdr;text/x-csrc;text/x-java;text/x-moc;text/x-pascal;text/x-tcl;text/x-tex;application/x-shellscript;text/x-c;text/x-c++;
Exec=emacs %F
Icon=emacs
Type=Application
Terminal=false
Categories=Development;TextEditor;
StartupWMClass=Emacs

无需重启即可更新这些快捷方式的命令是:

sudo update-desktop-database

现在您的文件管理器“打开方式”对话框中应该有一个Emacsclient 条目。 建立关联,只需单击鼠标,文件将在 emacs 中打开。 只要确保在您的~/.emacs 中有:

(require 'server)
(or (server-running-p) (server-start))

【讨论】:

    猜你喜欢
    • 2012-01-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-01-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多