3

I know there is xdg-open, but it does not run in the background. It is not as easy as appending & at the end when calling this command from emacs.

I often use ! then open in emacs dired, or C-! and then open filename for emacs shell-command. Is there another command which will allow me to continue using emacs while this file (often a pdf) is open?

hatmatrix
  • 131
  • 1
    I'm surprised that you say that xdg-open doesn't run in the background, because for me it does. I don't know anything about emacs, but I've tested this in both bash and in vi. Can you give an example of what kind of file you're trying to open? – Timo Kluck Aug 10 '12 at 12:06
  • An example is just a pdf file, and I type ! then xdg-open from dired-mode in Emacs (dired-mode isn't a command-line tool). Emacs will not allow me to proceed unless I close the document viewer... – hatmatrix Aug 10 '12 at 13:41

1 Answers1

1

I don't know anything about xdg-open, but I do know something about Emacs. Does async-shell-command not work for you? If not, one of the low-level Emacs async commands should definitely do the trick. See http://www.gnu.org/software/emacs/manual/html_node/elisp/Asynchronous-Processes.html#Asynchronous-Processes for info on that.

If you can't get those to work, lemme know; if start-process can't do it for you, there is a bug in Emacs (or xdg-open is a seriously weird command!)

  • Is there a way to specify dired-mode to run programs asynchronously? I do program in emacs lisp but for this it is not a programming application - only want to invoke a few programs from dired-mode or mini-buffer. – hatmatrix Aug 10 '12 at 13:42
  • There isn't a setting for this, unfortunately. C-x h f dired-run-shell-command, and find the location in dired-aux.el. It should be a ~5 line function; copy and paste this command into your .emacs and replace (shell-command command) with (async-shell-command command). – Christopher Monsanto Aug 12 '12 at 02:22
  • (or use advice and flet shell-command async-shell-command) – Christopher Monsanto Aug 12 '12 at 02:23