2

I want to open the currently viewed buffer in an external application using "xdg-open". What I tried is:

(start-process "" nil "xdg-open" (buffer-file-name))

But that only returns #<process >.

If I replace "xdg-open" with the actual application (in my case it's xppaut) everything works. That seems only to happen with programs that I call through the terminal. If I want to open the currently viewed buffer in another editor, everything works with xdg-open, i.e. I change the default application for that file extension to gedit then.

But at the same time xdg-open works when I try to call open a file with xppaut through Gnome Files (Nautilus). So I'm not really sure if that is an Emacs issue or xdg one.

2

Try this snippet:

(defun counsel-locate-action-extern (x)
  "Use xdg-open shell command on X."
  (call-process shell-file-name nil
                nil nil
                shell-command-switch
                (format "%s %s"
                        (if (eq system-type 'darwin)
                            "open"
                          "xdg-open")
                        (shell-quote-argument x))))

The trick is to use shell-file-name for the process call.

  • It works, amazing, thank you! I see now, so I was using the wrong (default) shell, that makes sense. – itsok-dontworry Feb 22 '16 at 16:45

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.