3

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?

6

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]
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=emacsclient -c -a "" %F
Icon=emacs
Type=Application
Terminal=false
Categories=Development;TextEditor;
StartupWMClass=Emacs

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.