winfileexplorer can't open files containing spaces in their filename

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

winfileexplorer can't open files containing spaces in their filename

Edward L. Fox
Hi VIMmers,

I'm using winmanager to navigate files in my system. The plugin can be found
at this address:

http://vim.sourceforge.net/scripts/script.php?script_id=95

But winmanager is not able to open the files which contain spaces in their
filenames. So I did a little adjustment. Here is the patch:

=================== filename: ~/.vim/plugin/winmanager.vim ===================
4c4
< " Last Change: Wed Apr 03 05:00 PM 2002 PST
---
> " Last Change: 2005-09-28 16:57:01
456c456
<                               exe 'silent! split '.bufcall
---
>                               exe 'silent! split '.escape(bufcall, " ")
458c458
<                               exe 'silent! e '.bufcall
---
>                               exe 'silent! e '.escape(bufcall, " ")
==================================== end =====================================

I added a little feature into winfileexplorer.vim: positioning your cursor on
a filename or a folder in the file list and press "S" will open the file with
the corresponding external program which is currently associated with the file
type. So now I can launch an xmms to play a piece of music without leaving my
(g)vim.

Here is the patch:

================ filename: ~/.vim/plugin/winfileexporer.vim ==================
4c4
< " Last Change: Sun Mar 31 11:00 PM 2002 PST
---
> " Last Change: 2005-09-28 17:09:38
438a439
>       nnoremap <buffer> S   :call <SID>ShellExecute()<cr>
651a653,675

>
> "---
> " Open file or directory with the corresponding application
> " associated by the shell
> "
> function! s:ShellExecute()
>   " Are we on a line with a file name?
>   let l = getline(".")
>   if l =~ '^"'
>     return
>   endif
>
>   " Copy window settings to script settings
>   let s:sortby=w:sortdirlabel . w:sorttype
>   let s:longhelp = w:longhelp
>   let s:longlist = w:longlist
>
>   " Get the file name
>   let fn=s:GetFullFileName()
>
>   exec "silent !start \'".fn."\'"
> endfunction
>
912a937
>                       \."\" S : open the file/folder with external program\n"
==================================== end =====================================

I'm using the utility "start" to launch the external program, the source code
is shown below:

=================================== start ====================================
#!/bin/sh
# For KDE only.

if (test $# = 0) then
    echo Usage: start filename
else
    while (test $# -gt 0)
    do
        kfmclient exec "$1"
        shift
    done
fi
==================================== end =====================================

Can anybody provide me an implementation for GNOME? Thanks very much!


Regards,

Edward L. Fox
Reply | Threaded
Open this post in threaded view
|

Re: winfileexplorer can't open files containing spaces in their filename

Charles E Campbell Jr
Edward L. Fox wrote:

>Hi VIMmers,
>
>I'm using winmanager to navigate files in my system. The plugin can be found
>at this address:
>
>http://vim.sourceforge.net/scripts/script.php?script_id=95
>
>But winmanager is not able to open the files which contain spaces in their
>filenames. So I did a little adjustment. Here is the patch:
>  
>

Did you send this message to the script's author/maintainer?  As taken
from winmanager.vim, that
would be:  Srinath Avadhanula ([hidden email])

Regards,
Chip Campbell

Reply | Threaded
Open this post in threaded view
|

Re: winfileexplorer can't open files containing spaces in their filename

Edward L. Fox
Thanks, Campbell!

I'll forward my first message to him.

2005/9/28, Charles E. Campbell, Jr. <[hidden email]>:

> Edward L. Fox wrote:
>
> >Hi VIMmers,
> >
> >I'm using winmanager to navigate files in my system. The plugin can be found
> >at this address:
> >
> >http://vim.sourceforge.net/scripts/script.php?script_id=95
> >
> >But winmanager is not able to open the files which contain spaces in their
> >filenames. So I did a little adjustment. Here is the patch:
> >
> >
>
> Did you send this message to the script's author/maintainer?  As taken
> from winmanager.vim, that
> would be:  Srinath Avadhanula ([hidden email])
>
> Regards,
> Chip Campbell
>
>
Reply | Threaded
Open this post in threaded view
|

Re: winfileexplorer can't open files containing spaces in their filename

Edward L. Fox
In reply to this post by Edward L. Fox
Hi VIMmers,

The patch I made to winfileexplorer to support opening selected file with
associated external program doesn't work properly under M$ Windoze. Here is
the patch:

============= filename: $VIM/vimfiles/plugin/winfileexplorer.vim =============
4c4
< " Last Change: 2005-09-28 17:09:38
---
> " Last Change: 2005-09-29 12:11:48
673c673,677
<   exec "silent !start \'".fn."\'"
---
>   if (has("win32"))
>     exec "silent ! start \"\" \"".substitute(fn, "/", "\\", "g")."\""
>   else
>     exec "silent !start \'".fn."\'"
>   endif
==================================== end =====================================

I'm not using Windoze so I didn't recognize such problem yesterday. Sorry for
my carelessness, and many thanks to my friend who lent me the laptop with
Windoze for debugging the script.

The hacking that Mr. Moolenaar made to "!start" under M$ Windoze really
puzzled me so much when I was debugging the script. See ":help !start" for
more details.

   To avoid this special treatment, use ":! start".

                                                             -- Bram Moolenaar


Regards,

Edward L. Fox


在 05-9-28,Edward L. Fox<[hidden email]> 写道:

> ---------- Forwarded message ----------
> From: Edward L. Fox <[hidden email]>
> Date: 2005-9-28 下午5:31
> Subject: winfileexplorer can't open files containing spaces in their filename
> To: [hidden email]
>
>
> Hi VIMmers,
>
> I'm using winmanager to navigate files in my system. The plugin can be found
> at this address:
>
> http://vim.sourceforge.net/scripts/script.php?script_id=95
>
> But winmanager is not able to open the files which contain spaces in their
> filenames. So I did a little adjustment. Here is the patch:
>
> =================== filename: ~/.vim/plugin/winmanager.vim ===================
> 4c4
> < " Last Change: Wed Apr 03 05:00 PM 2002 PST
> ---
> > " Last Change: 2005-09-28 16:57:01
> 456c456
> <                               exe 'silent! split '.bufcall
> ---
> >                               exe 'silent! split '.escape(bufcall, " ")
> 458c458
> <                               exe 'silent! e '.bufcall
> ---
> >                               exe 'silent! e '.escape(bufcall, " ")
> ==================================== end =====================================
>
> I added a little feature into winfileexplorer.vim: positioning your cursor on
> a filename or a folder in the file list and press "S" will open the file with
> the corresponding external program which is currently associated with the file
> type. So now I can launch an xmms to play a piece of music without leaving my
> (g)vim.
>
> Here is the patch:
>
> ================ filename: ~/.vim/plugin/winfileexporer.vim ==================
> 4c4
> < " Last Change: Sun Mar 31 11:00 PM 2002 PST
> ---
> > " Last Change: 2005-09-28 17:09:38
> 438a439
> >       nnoremap <buffer> S   :call <SID>ShellExecute()<cr>
> 651a653,675
> >
> > "---
> > " Open file or directory with the corresponding application
> > " associated by the shell
> > "
> > function! s:ShellExecute()
> >   " Are we on a line with a file name?
> >   let l = getline(".")
> >   if l =~ '^"'
> >     return
> >   endif
> >
> >   " Copy window settings to script settings
> >   let s:sortby=w:sortdirlabel . w:sorttype
> >   let s:longhelp = w:longhelp
> >   let s:longlist = w:longlist
> >
> >   " Get the file name
> >   let fn=s:GetFullFileName()
> >
> >   exec "silent !start \'".fn."\'"
> > endfunction
> >
> 912a937
> >                       \."\" S : open the file/folder with external program\n"
> ==================================== end =====================================
>
> I'm using the utility "start" to launch the external program, the source code
> is shown below:
>
> =================================== start ====================================
> #!/bin/sh
> # For KDE only.
>
> if (test $# = 0) then
>     echo Usage: start filename
> else
>     while (test $# -gt 0)
>     do
>         kfmclient exec "$1"
>         shift
>     done
> fi
> ==================================== end =====================================
>
> Can anybody provide me an implementation for GNOME? Thanks very much!
>
>
> Regards,
>
> Edward L. Fox
>