3

When I double click to open a file, a new Emacs session is launched, like this:

enter image description here

So now there are two sessions. What I want to do is that when I double click a file, it will be opened in another window in the existing session, so there is only one session. I know I can use C-x C-f to open a file, but the point is "double click".

I am using emacs 25.1.1, linuxmint 18.1. How can I do this?

  • From what program and what OS are you double-clicking? Please also state which version of Emacs you are using. – lawlist Dec 25 '16 at 19:52
  • Is it really a new frame in an existing emacs (using emacsclient) or is it a new emacs? Can you switch to the other buffer from the new frame? – Uwe Koloska Dec 25 '16 at 20:01
  • @UweKoloska, oh actually it was a new emacs, sorry for not clarifying these because I am new to emacs. I searched for emacsclient, and I found that it could solve my problem. Thank you very much! – Zimou Zhang Dec 25 '16 at 20:23
7

Run this in terminal (copy-paste it, then press Enter):

cat - <<EOFEOF > ~/.local/share/applications/my_emacsclient.desktop
[Desktop Entry]
Name=my Emacsclient
Exec=/usr/bin/emacsclient --alternate-editor="" %F
Icon=emacs
Type=Application
EOFEOF

Then open your file-manager and change the default program for opening that file type(s) you desire, to my emacsclient.

This will open your files in your current frame.

Or, if you want to open your files in your current emacs session, but in another frame, run this, and open your files with my emacsclient new frame

cat - <<EOFEOF > ~/.local/share/applications/my_emacsclient_new_frame.desktop
[Desktop Entry]
Name=my Emacsclient new frame
Exec=/usr/bin/emacsclient -c --alternate-editor="" %F
Icon=emacs
Type=Application
EOFEOF
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.