9

I want to open a.html in a browser from emacs (v. 24.5.1, using -Q [updated after comment]).

M-x shell-command
xdg-open a.html

works as expected, but

M-x eshell
$ xdg-open a.html

does not seem to do anything. There is no error message. This problem also occurs when exporting and directly opening html files from org-mode.

7
  • This seems to work in my config. Does it not work for you in emacs -Q?
    – PythonNut
    Commented Jan 7, 2016 at 17:53
  • I've updated the question -- I was already using emacs -q -Q Commented Jan 7, 2016 at 17:58
  • 1
    @JannisTeunissen Unless I am mistaken, -Q includes the -q option, so -q -Q will be the same as -Q
    – elethan
    Commented Jan 7, 2016 at 18:41
  • Also, this does not answer the question as to why xdg-open does not work in eshell, but you can use the command browse-url-of-file called from a buffer visiting a.html to open that file in your default browser.
    – elethan
    Commented Jan 7, 2016 at 18:44
  • 2
    Try setting process-connection-type to nil (you can just type (setq process-connection-type nil) at the eshell prompt). (By the way, while this works on my machine, I don't understand why it works.)
    – Omar
    Commented Jan 7, 2016 at 23:01

2 Answers 2

5

Set process-connection-type to nil. To be honest I don't understand why xdg-open doesn't work when that variable has the value t and I also can't remember how I learned that changing the value let me use xdg-open from Emacs. (If someone knows, I'd love to hear about it.)

2
  • Hm, can't reproduce this here on my Linux machine. Is this by any chance linked to the operating system Emacs runs on?
    – wasamasa
    Commented Jan 8, 2016 at 8:43
  • The problem occurred on Debian unstable and Fedora 22 Commented Jan 8, 2016 at 14:10
1

Using setsid -w $shell_cmd is better, because of (setq process-connection-type nil) causing some problems like sudo: no tty present and no askpass program specified when using M-& sudo $shell_cmd.

REF

1
  • I face this problem when opening links to external files in org-mode (links of type file+sys) Could you elaborate on what do you mean by "using setsid -w ..."? how/where do I use that? Also, I don't want to just open 1.pdf (as seen in the link you post), but any file.
    – onlycparra
    Commented Feb 14, 2022 at 21:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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