I want to use emacsclient to open files from Thunar in Linux Mint 17 xfce. I have tried right-click+"open with other application"+"emacsclient -c", but this does nothing.

I have also tried writing a custom emacsclient.desktop launcher. Emacs daemon is running and works when emacsclient is invoked from the terminal. Also, using just "emacs" as the preferred program works. Can this be done in Thunar?


Thunar implements Freedesktop's desktop entry specification, so a .desktop entry is the answer you are looking for. Try saving this to $XDG_DATA_HOME/applications/emacs.desktop or $HOME/.local/share/applications/emacs.desktop if you don't have that set.

[Desktop Entry]
GenericName=Text Editor
Comment=Edit text
Exec=emacsclient -c -a "" %F

This will take precedence over any emacs.desktop in /usr/share/applications. You may need to logout and and login again before it works, but now when you select Emacs from "open with" it will either attach to the running daemon, or start one and attach if it was not already running.

  • If this works, fine, but I don't see why this would work and not what the OP tried first. – Stéphane Gourichon Dec 28 '15 at 19:30
  • Thanks for the answer, I use the same with a small change: Exec=emacsclient -na "emacs" %F which opens a new instance of Emacs, if it isn't already running. I don't prefer the silent server start (-a ""), since I have (unless (server-running-p) (server-start)) in my .emacs. – legends2k Aug 27 '18 at 6:34

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.