xdg-open doesn't work inside gvim #172

Closed
aripollak opened this Issue Jul 26, 2012 · 11 comments

Comments

Projects
None yet
3 participants
@aripollak
Contributor

aripollak commented Jul 26, 2012

I was able to reproduce my :!xdg-open problem again, but only inside gvim. It seems to work fine if I do :!xdg-open URL &, though I don't know why. This was the only thing I could find about it:
http://superuser.com/questions/386646/xdg-open-url-doesnt-open-the-website-in-my-default-browser

@tpope

This comment has been minimized.

Show comment
Hide comment
@tpope

tpope Mar 29, 2014

Owner

Does call netrw#NetrwBrowseX('http://google.com', 0) work for you? I think it might be easier to just leverage that.

Owner

tpope commented Mar 29, 2014

Does call netrw#NetrwBrowseX('http://google.com', 0) work for you? I think it might be easier to just leverage that.

@aripollak

This comment has been minimized.

Show comment
Hide comment
@aripollak

aripollak Mar 29, 2014

Contributor

Nope, that doesn't seem to do anything either.

Contributor

aripollak commented Mar 29, 2014

Nope, that doesn't seem to do anything either.

@tpope

This comment has been minimized.

Show comment
Hide comment
@tpope

tpope Mar 29, 2014

Owner

Can you try throwing a ; sleep 5 on the end and see if that fixes it? I'm wondering if this is a very different manifestation of tpope/vim-fugitive#351.

Also, remind me your original solution?

Owner

tpope commented Mar 29, 2014

Can you try throwing a ; sleep 5 on the end and see if that fixes it? I'm wondering if this is a very different manifestation of tpope/vim-fugitive#351.

Also, remind me your original solution?

@aripollak

This comment has been minimized.

Show comment
Hide comment
@aripollak

aripollak Mar 29, 2014

Contributor

Adding the sleep does fix the problem as well.
It's been a long time, but I believe the problem is related to #166 and OpenURL.

I'm guessing this has to do with the fact that xdg-open calls gvfs-open, and gvfs-open exits immediately, before the underlying browser command is executed, though I'm not sure why that would matter. By contrast, sensible-browser does not exit immediately.

ari@ari:~$ xdg-open http://google.com
ari@ari:~$ Created new window in existing browser session.

ari@ari:~$ sensible-browser http://google.com
Created new window in existing browser session.
ari@ari:~$ 
Contributor

aripollak commented Mar 29, 2014

Adding the sleep does fix the problem as well.
It's been a long time, but I believe the problem is related to #166 and OpenURL.

I'm guessing this has to do with the fact that xdg-open calls gvfs-open, and gvfs-open exits immediately, before the underlying browser command is executed, though I'm not sure why that would matter. By contrast, sensible-browser does not exit immediately.

ari@ari:~$ xdg-open http://google.com
ari@ari:~$ Created new window in existing browser session.

ari@ari:~$ sensible-browser http://google.com
Created new window in existing browser session.
ari@ari:~$ 
@aripollak

This comment has been minimized.

Show comment
Hide comment
@aripollak

aripollak Mar 29, 2014

Contributor

It does seem likely that it's another manifestation of that vim-fugitive issue.

Contributor

aripollak commented Mar 29, 2014

It does seem likely that it's another manifestation of that vim-fugitive issue.

@tpope

This comment has been minimized.

Show comment
Hide comment
@tpope

tpope Mar 30, 2014

Owner

Yeah I remember the original issue, but you initially submitted a different patch that has since vanished.

Owner

tpope commented Mar 30, 2014

Yeah I remember the original issue, but you initially submitted a different patch that has since vanished.

@aripollak

This comment has been minimized.

Show comment
Hide comment
@aripollak

aripollak Mar 30, 2014

Contributor

I think I had been using sh -c 'xdg-open ...', but that doesn't seem to work now.

Contributor

aripollak commented Mar 30, 2014

I think I had been using sh -c 'xdg-open ...', but that doesn't seem to work now.

@tpope

This comment has been minimized.

Show comment
Hide comment
@tpope

tpope Mar 30, 2014

Owner

Let me know if you figure it out; I want to try to dissect and generalize it.

Owner

tpope commented Mar 30, 2014

Let me know if you figure it out; I want to try to dissect and generalize it.

@wchargin

This comment has been minimized.

Show comment
Hide comment
@wchargin

wchargin Oct 10, 2014

I've also been having problems with !xdg-open [...] or !gnome-open [...] in gvim, and appending & works fine for me too. This is a problem when using Netrw, though—I should be able to press x on a file and have it open, but this doesn't work, and (AFAIK) I can't change how Netrw executes files. (I can change the command, but not make it background.) Thoughts, workarounds?

I've also been having problems with !xdg-open [...] or !gnome-open [...] in gvim, and appending & works fine for me too. This is a problem when using Netrw, though—I should be able to press x on a file and have it open, but this doesn't work, and (AFAIK) I can't change how Netrw executes files. (I can change the command, but not make it background.) Thoughts, workarounds?

@aripollak

This comment has been minimized.

Show comment
Hide comment
@aripollak

aripollak Jun 20, 2015

Contributor

Any reason not to just add the & to the xdg-open command? The underlying issue seems to be that gnome-open or gvfs-open, called by xdg-open, backgrounds itself but GVim closes its fake terminal before gnome-open can finish its business.

Contributor

aripollak commented Jun 20, 2015

Any reason not to just add the & to the xdg-open command? The underlying issue seems to be that gnome-open or gvfs-open, called by xdg-open, backgrounds itself but GVim closes its fake terminal before gnome-open can finish its business.

@tpope

This comment has been minimized.

Show comment
Hide comment
@tpope

tpope Jun 20, 2015

Owner

I'd actually like to switch to delegating to netrw and wash my hands of the matter, but in the meantime, I'd merge a pull request and see if it helps.

Owner

tpope commented Jun 20, 2015

I'd actually like to switch to delegating to netrw and wash my hands of the matter, but in the meantime, I'd merge a pull request and see if it helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment