简体   繁体   English

如何设置emacs在Ubuntu / Mint上打开当前实例中的新文件?

[英]How to set emacs to open new files in current instance on Ubuntu/Mint?

I want to keep emacs open most of the time, and then whenever I open a text file, python file, etc (from nautilus/finder), I want it to open as a new buffer in my current emacs instance, rather than starting a new instance. 我想在大多数时间保持emacs打开,然后每当我打开文本文件,python文件等(来自nautilus / finder)时,我希望它在我当前的emacs实例中作为新缓冲区打开,而不是启动新实例。

I tried following this guide : 我尝试按照本指南操作

I wasn't really sure about what to do with the file, but what I tried was copying it to /usr/bin/emacs_openfile, adding #!/bin/sh to the first line, and running chmod +x emacs_openfile 我不确定如何处理该文件,但我尝试将其复制到/ usr / bin / emacs_openfile,将#!/ bin / sh添加到第一行,并运行chmod + x emacs_openfile

However, it doesn't work for me and just opens a new instance, even though I was able to associate text files with this program. 但是,它不适合我,只是打开一个新实例,即使我能够将文本文件与此程序关联。

On a sidenote, I set emacs as the default editor using this . 在阿里纳斯,我设置的emacs的使用默认的编辑器

You want emacs client . 你想要emacs客户端

Basically, set emacsclient as your default editor, and add (server-start) somewere in your emacs config. 基本上,将emacsclient设置为默认编辑器,并在emacs配置中添加(server-start)一些。

There needs to be a running Emacs instance for emacsclient to work, but if it's a hassle it's possible to have a headless Emacs launched at login . 需要有一个正在运行的Emacs实例才能使emacsclient正常工作,但如果这很麻烦,可以在登录时启动无头Emacs

Did you start server in emacs? 你有没有在emacs中启动服务器? Make sure that you add (server-start) to your .emacs or do Mx server-start from an existing EMACS session. 确保向.emacs添加(server-start)或从现有EMACS会话Mx server-start

Conceptually, it's really easy, just do emacsclient file-name on the command line or where you name the program. 从概念上讲,它非常简单,只需在命令行上执行emacsclient 文件名或在程序中命名。

仅供参考,如果您在Mac上使用GUI版本,dir os emacsclient如下:

/Applications/Emacs.app/Contents/MacOS/bin/emacsclient

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM