How to set emacs to open new files in current inst

2020-05-18 15:20发布

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.

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

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 ubuntu
3条回答
Melony?
2楼-- · 2020-05-18 15:43

Did you start server in emacs? Make sure that you add (server-start) to your .emacs or do M-x server-start from an existing EMACS session.

Conceptually, it's really easy, just do emacsclient file-name on the command line or where you name the program.

查看更多
不美不萌又怎样
3楼-- · 2020-05-18 15:46

You want emacs client.

Basically, set emacsclient as your default editor, and add (server-start) somewere in your emacs config.

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.

查看更多
Luminary・发光体
4楼-- · 2020-05-18 15:49

Just for your information, If you are using GUI version on Mac, the dir os emacsclient is below:

/Applications/Emacs.app/Contents/MacOS/bin/emacsclient
查看更多
登录 后发表回答