When there is a `kdeinit4` process, but `kfmclient` is not installed `BrowseX` fails to open an URL (it falls through to the last else block).
This happened on a non-KDE system, where `kdeinit4` was installed/started for an unknown reason, but konqueror/kfmclient is not available. This patch also makes the `system()` call only when necessary (via a function), and will prefer `xdg-open` unconditionally also for potential KDE systems. After all, `xdg-open` is better aware of the current desktop environment and is designed for use cases like this. The old code was primarily meant to handle edge cases when `gnome-open` was used. I have left it as a fallback in case `xdg-open` might not be available. The patch is available in a branch at: https://github.com/blueyed/vim/compare/fix-netrw-with-kdeinit (which includes a commit to fix trailing whitespace). I am attaching the patch from the main commit (https://github.com/blueyed/vim/commit/b5e13acebc11c13290d3f3dd9940b1ab181f47a3). -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
>From b5e13acebc11c13290d3f3dd9940b1ab181f47a3 Mon Sep 17 00:00:00 2001 From: Daniel Hahler <[email protected]> Date: Wed, 27 Aug 2014 00:58:58 +0200 Subject: [PATCH] Fix netrw#NetrwBrowseX with `kdeinit` running, but no `kfmclient` When there is a `kdeinit4` process, but `kfmclient` is not installed `BrowseX` fails to open an URL (it falls through to the last else block). This happened on a non-KDE system, where `kdeinit4` was installed/started for an unknown reason. This patch also makes the `system()` call only when necessary (via a function), and will prefer `xdg-open` unconditionally. After all, `xdg-open` is better aware of the current desktop environment and is meant for use cases like this. I have left the old code for kfmclient in case `xdg-open` might not be available. --- runtime/autoload/netrw.vim | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/runtime/autoload/netrw.vim b/runtime/autoload/netrw.vim index 441e371..c67108a 100644 --- a/runtime/autoload/netrw.vim +++ b/runtime/autoload/netrw.vim @@ -4680,19 +4680,22 @@ fun! netrw#NetrwBrowseX(fname,remote) endif " call Decho("exten<".exten.">") - " seems kde systems often have gnome-open due to dependencies, even though - " gnome-open's subsidiary display tools are largely absent. Kde systems - " usually have "kdeinit" running, though... (tnx Mikolaj Machowski) - if !exists("s:haskdeinit") - if has("unix") && executable("ps") && !has("win32unix") - let s:haskdeinit= system("ps -e") =~ 'kdeinit' - if v:shell_error - let s:haskdeinit = 0 + " Detect if KDE is running (via `kdeinit*` process). + " This was previously used when `gnome-open` was used instead of `xdg-open` + " and is being kept as fallback (tnx Mikolaj Machowski). + fun! s:haskdeinit() + if !exists('s:_haskdeinit') + if has("unix") && executable("ps") && !has("win32unix") + let s:_haskdeinit = (system("ps -e") =~ '\<kdeinit') + if v:shell_error + let s:_haskdeinit = 0 + endif + else + let s:_haskdeinit= 0 endif - else - let s:haskdeinit= 0 +" call Decho("setting s:_haskdeinit=".s:_haskdeinit) endif -" call Decho("setting s:haskdeinit=".s:haskdeinit) + return s:_haskdeinit endif if a:remote == 1 @@ -4802,13 +4805,13 @@ fun! netrw#NetrwBrowseX(fname,remote) call inputsave()|call input("Press <cr> to continue")|call inputrestore() let ret= v:shell_error - elseif has("unix") && executable("xdg-open") && !s:haskdeinit + elseif has("unix") && executable("xdg-open") " call Decho("unix and xdg-open") " call Decho("exe sil !xdg-open ".shellescape(fname,1)." ".redir) exe "sil !xdg-open ".shellescape(fname,1).redir let ret= v:shell_error - elseif has("unix") && executable("kfmclient") && s:haskdeinit + elseif has("unix") && executable("kfmclient") && s:haskdeinit() " call Decho("unix and kfmclient") " call Decho("exe sil !kfmclient exec ".shellescape(fname,1)." ".redir) exe "sil !kfmclient exec ".shellescape(fname,1)." ".redir
