diff --git a/runtime/autoload/netrw.vim b/runtime/autoload/netrw.vim index a96364fb4b..d5e3a77dd4 100644 --- a/runtime/autoload/netrw.vim +++ b/runtime/autoload/netrw.vim @@ -4,8 +4,8 @@ " Date: May 03, 2023 " Version: 173a " Last Change: {{{1 -" 2023 Nov 21 by Vim Project: ignore wildignore when expanding $COMSPEC (v173a) -" 2023 Nov 22 by Vim Project: fix handling of very long filename on longlist style (v173a) +" 2023 Nov 21 by Vim Project: ignore wildignore when expanding $COMSPEC (v173a) +" 2023 Nov 22 by Vim Project: fix handling of very long filename on longlist style (v173a) " 2024 Feb 19 by Vim Project: (announce adoption) " 2024 Feb 29 by Vim Project: handle symlinks in tree mode correctly " 2024 Apr 03 by Vim Project: detect filetypes for remote edited files @@ -26,6 +26,7 @@ " 2024 Sep 15 by Vim Project: more strict confirmation dialog (#15680) " 2024 Sep 19 by Vim Project: mf-selection highlight uses wrong pattern (#15700) " 2024 Sep 21 by Vim Project: remove extraneous closing bracket (#15718) +" 2024 Oct 21 by Vim Project: remove netrwFileHandlers (#15895) " }}} " Former Maintainer: Charles E Campbell " GetLatestVimScripts: 1075 1 :AutoInstall: netrw.vim @@ -5398,11 +5399,7 @@ fun! netrw#BrowseX(fname,remote) " execute the file handler " call Decho("execute the file handler (if any)",'~'.expand("")) - if exists("g:netrw_browsex_viewer") && g:netrw_browsex_viewer == '-' -" call Decho("(netrw#BrowseX) g:netrw_browsex_viewer<".g:netrw_browsex_viewer.">",'~'.expand("")) - let ret= netrwFileHandlers#Invoke(exten,fname) - - elseif exists("g:netrw_browsex_viewer") && executable(viewer) + if exists("g:netrw_browsex_viewer") && executable(viewer) " call Decho("(netrw#BrowseX) g:netrw_browsex_viewer<".g:netrw_browsex_viewer.">",'~'.expand("")) call s:NetrwExe("sil !".viewer." ".viewopt.s:ShellEscape(fname,1).redir) let ret= v:shell_error @@ -5468,17 +5465,13 @@ fun! netrw#BrowseX(fname,remote) " call Decho("(netrw#BrowseX) macunix and open",'~'.expand("")) call s:NetrwExe("sil !open ".s:ShellEscape(fname,1)." ".redir) let ret= v:shell_error - else - " netrwFileHandlers#Invoke() always returns 0 -" call Decho("(netrw#BrowseX) use netrwFileHandlers",'~'.expand("")) - let ret= netrwFileHandlers#Invoke(exten,fname) + call netrw#ErrorMsg(s:ERROR, "Couldn't find a program to open '".a:fname."'", 0) + let ret=0 endif - " if unsuccessful, attempt netrwFileHandlers#Invoke() if ret -" call Decho("(netrw#BrowseX) ret=".ret," indicates unsuccessful thus far",'~'.expand("")) - let ret= netrwFileHandlers#Invoke(exten,fname) + call netrw#ErrorMsg(s:ERROR, "Failed to open '".a:fname."'", 0) endif " restoring redraw! after external file handlers diff --git a/runtime/autoload/netrwFileHandlers.vim b/runtime/autoload/netrwFileHandlers.vim index 2b6f8f7a0f..e69de29bb2 100644 --- a/runtime/autoload/netrwFileHandlers.vim +++ b/runtime/autoload/netrwFileHandlers.vim @@ -1,363 +0,0 @@ -" netrwFileHandlers: contains various extension-based file handlers for -" netrw's browsers' x command ("eXecute launcher") -" Maintainer: This runtime file is looking for a new maintainer. -" Original Author: Charles E. Campbell -" Date: Sep 18, 2020 -" Version: 11 -" Copyright: Copyright (C) 1999-2012 Charles E. Campbell {{{1 -" Permission is hereby granted to use and distribute this code, -" with or without modifications, provided that this copyright -" notice is copied with it. Like anything else that's free, -" netrwFileHandlers.vim is provided *as is* and comes with no -" warranty of any kind, either expressed or implied. In no -" event will the copyright holder be liable for any damages -" resulting from the use of this software. -" -" Rom 6:23 (WEB) For the wages of sin is death, but the free gift of God {{{1 -" is eternal life in Christ Jesus our Lord. - -" --------------------------------------------------------------------- -" Load Once: {{{1 -if exists("g:loaded_netrwFileHandlers") || &cp - finish -endif -let g:loaded_netrwFileHandlers= "v11" -if v:version < 702 - echohl WarningMsg - echo "***warning*** this version of netrwFileHandlers needs vim 7.2" - echohl Normal - finish -endif -let s:keepcpo= &cpo -set cpo&vim - -" --------------------------------------------------------------------- -" netrwFileHandlers#Invoke: {{{1 -fun! netrwFileHandlers#Invoke(exten,fname) -" call Dfunc("netrwFileHandlers#Invoke(exten<".a:exten."> fname<".a:fname.">)") - let exten= a:exten - " list of supported special characters. Consider rcs,v --- that can be - " supported with a NFH_rcsCOMMAv() handler - if exten =~ '[@:,$!=\-+%?;~]' - let specials= { -\ '@' : 'AT', -\ ':' : 'COLON', -\ ',' : 'COMMA', -\ '$' : 'DOLLAR', -\ '!' : 'EXCLAMATION', -\ '=' : 'EQUAL', -\ '-' : 'MINUS', -\ '+' : 'PLUS', -\ '%' : 'PERCENT', -\ '?' : 'QUESTION', -\ ';' : 'SEMICOLON', -\ '~' : 'TILDE'} - let exten= substitute(a:exten,'[@:,$!=\-+%?;~]','\=specials[submatch(0)]','ge') -" call Decho('fname<'.fname.'> done with dictionary') - endif - - if a:exten != "" && exists("*NFH_".exten) - " support user NFH_*() functions -" call Decho("let ret= netrwFileHandlers#NFH_".a:exten.'("'.fname.'")') - exe "let ret= NFH_".exten.'("'.a:fname.'")' - elseif a:exten != "" && exists("*s:NFH_".exten) - " use builtin-NFH_*() functions -" call Decho("let ret= netrwFileHandlers#NFH_".a:exten.'("'.fname.'")') - exe "let ret= s:NFH_".a:exten.'("'.a:fname.'")' - endif - -" call Dret("netrwFileHandlers#Invoke 0 : ret=".ret) - return 0 -endfun - -" --------------------------------------------------------------------- -" s:NFH_html: handles html when the user hits "x" when the {{{1 -" cursor is atop a *.html file -fun! s:NFH_html(pagefile) -" call Dfunc("s:NFH_html(".a:pagefile.")") - - let page= substitute(a:pagefile,'^','file://','') - - if executable("mozilla") -" call Decho("executing !mozilla ".page) - exe "!mozilla ".shellescape(page,1) - elseif executable("netscape") -" call Decho("executing !netscape ".page) - exe "!netscape ".shellescape(page,1) - else -" call Dret("s:NFH_html 0") - return 0 - endif - -" call Dret("s:NFH_html 1") - return 1 -endfun - -" --------------------------------------------------------------------- -" s:NFH_htm: handles html when the user hits "x" when the {{{1 -" cursor is atop a *.htm file -fun! s:NFH_htm(pagefile) -" call Dfunc("s:NFH_htm(".a:pagefile.")") - - let page= substitute(a:pagefile,'^','file://','') - - if executable("mozilla") -" call Decho("executing !mozilla ".page) - exe "!mozilla ".shellescape(page,1) - elseif executable("netscape") -" call Decho("executing !netscape ".page) - exe "!netscape ".shellescape(page,1) - else -" call Dret("s:NFH_htm 0") - return 0 - endif - -" call Dret("s:NFH_htm 1") - return 1 -endfun - -" --------------------------------------------------------------------- -" s:NFH_jpg: {{{1 -fun! s:NFH_jpg(jpgfile) -" call Dfunc("s:NFH_jpg(jpgfile<".a:jpgfile.">)") - - if executable("gimp") - exe "silent! !gimp -s ".shellescape(a:jpgfile,1) - elseif executable(expand("$SystemRoot")."/SYSTEM32/MSPAINT.EXE") -" call Decho("silent! !".expand("$SystemRoot")."/SYSTEM32/MSPAINT ".escape(a:jpgfile," []|'")) - exe "!".expand("$SystemRoot")."/SYSTEM32/MSPAINT ".shellescape(a:jpgfile,1) - else -" call Dret("s:NFH_jpg 0") - return 0 - endif - -" call Dret("s:NFH_jpg 1") - return 1 -endfun - -" --------------------------------------------------------------------- -" s:NFH_gif: {{{1 -fun! s:NFH_gif(giffile) -" call Dfunc("s:NFH_gif(giffile<".a:giffile.">)") - - if executable("gimp") - exe "silent! !gimp -s ".shellescape(a:giffile,1) - elseif executable(expand("$SystemRoot")."/SYSTEM32/MSPAINT.EXE") - exe "silent! !".expand("$SystemRoot")."/SYSTEM32/MSPAINT ".shellescape(a:giffile,1) - else -" call Dret("s:NFH_gif 0") - return 0 - endif - -" call Dret("s:NFH_gif 1") - return 1 -endfun - -" --------------------------------------------------------------------- -" s:NFH_png: {{{1 -fun! s:NFH_png(pngfile) -" call Dfunc("s:NFH_png(pngfile<".a:pngfile.">)") - - if executable("gimp") - exe "silent! !gimp -s ".shellescape(a:pngfile,1) - elseif executable(expand("$SystemRoot")."/SYSTEM32/MSPAINT.EXE") - exe "silent! !".expand("$SystemRoot")."/SYSTEM32/MSPAINT ".shellescape(a:pngfile,1) - else -" call Dret("s:NFH_png 0") - return 0 - endif - -" call Dret("s:NFH_png 1") - return 1 -endfun - -" --------------------------------------------------------------------- -" s:NFH_pnm: {{{1 -fun! s:NFH_pnm(pnmfile) -" call Dfunc("s:NFH_pnm(pnmfile<".a:pnmfile.">)") - - if executable("gimp") - exe "silent! !gimp -s ".shellescape(a:pnmfile,1) - elseif executable(expand("$SystemRoot")."/SYSTEM32/MSPAINT.EXE") - exe "silent! !".expand("$SystemRoot")."/SYSTEM32/MSPAINT ".shellescape(a:pnmfile,1) - else -" call Dret("s:NFH_pnm 0") - return 0 - endif - -" call Dret("s:NFH_pnm 1") - return 1 -endfun - -" --------------------------------------------------------------------- -" s:NFH_bmp: visualize bmp files {{{1 -fun! s:NFH_bmp(bmpfile) -" call Dfunc("s:NFH_bmp(bmpfile<".a:bmpfile.">)") - - if executable("gimp") - exe "silent! !gimp -s ".a:bmpfile - elseif executable(expand("$SystemRoot")."/SYSTEM32/MSPAINT.EXE") - exe "silent! !".expand("$SystemRoot")."/SYSTEM32/MSPAINT ".shellescape(a:bmpfile,1) - else -" call Dret("s:NFH_bmp 0") - return 0 - endif - -" call Dret("s:NFH_bmp 1") - return 1 -endfun - -" --------------------------------------------------------------------- -" s:NFH_pdf: visualize pdf files {{{1 -fun! s:NFH_pdf(pdf) -" call Dfunc("s:NFH_pdf(pdf<".a:pdf.">)") - if executable("gs") - exe 'silent! !gs '.shellescape(a:pdf,1) - elseif executable("pdftotext") - exe 'silent! pdftotext -nopgbrk '.shellescape(a:pdf,1) - else -" call Dret("s:NFH_pdf 0") - return 0 - endif - -" call Dret("s:NFH_pdf 1") - return 1 -endfun - -" --------------------------------------------------------------------- -" s:NFH_doc: visualize doc files {{{1 -fun! s:NFH_doc(doc) -" call Dfunc("s:NFH_doc(doc<".a:doc.">)") - - if executable("oowriter") - exe 'silent! !oowriter '.shellescape(a:doc,1) - redraw! - else -" call Dret("s:NFH_doc 0") - return 0 - endif - -" call Dret("s:NFH_doc 1") - return 1 -endfun - -" --------------------------------------------------------------------- -" s:NFH_sxw: visualize sxw files {{{1 -fun! s:NFH_sxw(sxw) -" call Dfunc("s:NFH_sxw(sxw<".a:sxw.">)") - - if executable("oowriter") - exe 'silent! !oowriter '.shellescape(a:sxw,1) - redraw! - else -" call Dret("s:NFH_sxw 0") - return 0 - endif - -" call Dret("s:NFH_sxw 1") - return 1 -endfun - -" --------------------------------------------------------------------- -" s:NFH_xls: visualize xls files {{{1 -fun! s:NFH_xls(xls) -" call Dfunc("s:NFH_xls(xls<".a:xls.">)") - - if executable("oocalc") - exe 'silent! !oocalc '.shellescape(a:xls,1) - redraw! - else -" call Dret("s:NFH_xls 0") - return 0 - endif - -" call Dret("s:NFH_xls 1") - return 1 -endfun - -" --------------------------------------------------------------------- -" s:NFH_ps: handles PostScript files {{{1 -fun! s:NFH_ps(ps) -" call Dfunc("s:NFH_ps(ps<".a:ps.">)") - if executable("gs") -" call Decho("exe silent! !gs ".a:ps) - exe "silent! !gs ".shellescape(a:ps,1) - redraw! - elseif executable("ghostscript") -" call Decho("exe silent! !ghostscript ".a:ps) - exe "silent! !ghostscript ".shellescape(a:ps,1) - redraw! - elseif executable("gswin32") -" call Decho("exe silent! !gswin32 ".shellescape(a:ps,1)) - exe "silent! !gswin32 ".shellescape(a:ps,1) - redraw! - else -" call Dret("s:NFH_ps 0") - return 0 - endif - -" call Dret("s:NFH_ps 1") - return 1 -endfun - -" --------------------------------------------------------------------- -" s:NFH_eps: handles encapsulated PostScript files {{{1 -fun! s:NFH_eps(eps) -" call Dfunc("s:NFH_eps()") - if executable("gs") - exe "silent! !gs ".shellescape(a:eps,1) - redraw! - elseif executable("ghostscript") - exe "silent! !ghostscript ".shellescape(a:eps,1) - redraw! - elseif executable("ghostscript") - exe "silent! !ghostscript ".shellescape(a:eps,1) - redraw! - elseif executable("gswin32") - exe "silent! !gswin32 ".shellescape(a:eps,1) - redraw! - else -" call Dret("s:NFH_eps 0") - return 0 - endif -" call Dret("s:NFH_eps 0") - return 1 -endfun - -" --------------------------------------------------------------------- -" s:NFH_fig: handles xfig files {{{1 -fun! s:NFH_fig(fig) -" call Dfunc("s:NFH_fig()") - if executable("xfig") - exe "silent! !xfig ".a:fig - redraw! - else -" call Dret("s:NFH_fig 0") - return 0 - endif - -" call Dret("s:NFH_fig 1") - return 1 -endfun - -" --------------------------------------------------------------------- -" s:NFH_obj: handles tgif's obj files {{{1 -fun! s:NFH_obj(obj) -" call Dfunc("s:NFH_obj()") - if has("unix") && executable("tgif") - exe "silent! !tgif ".a:obj - redraw! - else -" call Dret("s:NFH_obj 0") - return 0 - endif - -" call Dret("s:NFH_obj 1") - return 1 -endfun - -let &cpo= s:keepcpo -unlet s:keepcpo -" --------------------------------------------------------------------- -" Modelines: {{{1 -" vim: fdm=marker diff --git a/runtime/doc/pi_netrw.txt b/runtime/doc/pi_netrw.txt index 0652fb27e7..7fc7d4140a 100644 --- a/runtime/doc/pi_netrw.txt +++ b/runtime/doc/pi_netrw.txt @@ -1467,7 +1467,6 @@ permission to remove a file, it will issue an error message. *netrw-gx* CUSTOMIZING BROWSING WITH A SPECIAL HANDLER *netrw-x* *netrw-handler* {{{2 - (also see |netrw_filehandler|) Certain files, such as html, gif, jpeg, (word/office) doc, etc, files, are best seen with a special handler (ie. a tool provided with your computer's @@ -1486,21 +1485,12 @@ Netrw determines which special handler by the following method: < or > :let g:netrw_browsex_viewer= "xdg-open" < - If g:netrw_browsex_viewer == '-', then netrwFileHandlers#Invoke() will be - used instead (see |netrw_filehandler|). - If the viewer you wish to use does not support handling of a remote URL directory, set |g:netrw_browsex_support_remote| to 0. * for Windows 32 or 64, the URL and FileProtocolHandler dlls are used. * for Gnome (with gnome-open): gnome-open is used. * for KDE (with kfmclient) : kfmclient is used * for Mac OS X : open is used. - * otherwise the netrwFileHandler plugin is used. - -The file's suffix is used by these various approaches to determine an -appropriate application to use to "handle" these files. Such things as -OpenOffice (*.sfx), visualization (*.jpg, *.gif, etc), and PostScript (*.ps, -*.eps) can be handled. The gx mapping extends to all buffers; apply "gx" while atop a word and netrw will apply a special handler to it (like "x" works when in a netrw buffer). @@ -1517,46 +1507,6 @@ Associated setting variables: |g:netrw_nogx| prevent gx map while editing |g:netrw_suppress_gx_mesg| controls gx's suppression of browser messages - *netrw_filehandler* - -When |g:netrw_browsex_viewer| exists and is "-", then netrw will attempt to -handle the special file with a vim function. The "x" map applies a function -to a file, based on its extension. Of course, the handler function must exist -for it to be called! -> - Ex. mypgm.html x -> NFH_html("scp://user@host/some/path/mypgm.html") - -< Users may write their own netrw File Handler functions to - support more suffixes with special handling. See - for examples on how to make - file handler functions. As an example: > - - " NFH_suffix(filename) - fun! NFH_suffix(filename) - ..do something special with filename.. - endfun -< -These functions need to be defined in some file in your .vim/plugin -(vimfiles\plugin) directory. Vim's function names may not have punctuation -characters (except for the underscore) in them. To support suffices that -contain such characters, netrw will first convert the suffix using the -following table: > - - @ -> AT ! -> EXCLAMATION % -> PERCENT - : -> COLON = -> EQUAL ? -> QUESTION - , -> COMMA - -> MINUS ; -> SEMICOLON - $ -> DOLLAR + -> PLUS ~ -> TILDE -< -So, for example: > - - file.rcs,v -> NFH_rcsCOMMAv() -< -If more such translations are necessary, please send me email: > - NcampObell@SdrPchip.AorgM-NOSPAM -with a request. (remove the embedded NOSPAM first) - -Associated setting variable: |g:netrw_browsex_viewer| - *netrw-curdir* DELETING BOOKMARKS *netrw-mB* {{{2 @@ -2569,12 +2519,7 @@ your browsing preferences. (see also: |netrw-settings|) *g:netrw_browsex_viewer* specify user's preference for a viewer: > "kfmclient exec" "gnome-open" -< If > - "-" -< is used, then netrwFileHandler() will look for - a script/function to handle the given - extension. (see |netrw_filehandler|). - +< *g:netrw_browsex_support_remote* specify if the specified viewer supports a remote URL. (see |netrw-handler|).