annotate runtime/plugin/netrwPlugin.vim @ 553:249173daa651

updated for version 7.0157
author vimboss
date Wed, 12 Oct 2005 20:52:20 +0000
parents c6296b0ad9ea
children 862863033fdd
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
534
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
1 " netrwPlugin.vim: Handles file transfer and remote directory listing across a network
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
2 " PLUGIN PORTION
553
249173daa651 updated for version 7.0157
vimboss
parents: 534
diff changeset
3 " Date: Oct 12, 2005
534
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
4 " Maintainer: Charles E Campbell, Jr <drchipNOSPAM at campbellfamily dot biz>
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
5 " GetLatestVimScripts: 1075 1 :AutoInstall: netrw.vim
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
6 " Copyright: Copyright (C) 1999-2005 Charles E. Campbell, Jr. {{{1
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
7 " Permission is hereby granted to use and distribute this code,
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
8 " with or without modifications, provided that this copyright
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
9 " notice is copied with it. Like anything else that's free,
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
10 " netrw.vim, netrwPlugin.vim, and netrwSettings.vim are provided
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
11 " *as is* and comes with no warranty of any kind, either
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
12 " expressed or implied. By using this plugin, you agree that
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
13 " in no event will the copyright holder be liable for any damages
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
14 " resulting from the use of this software.
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
15 "
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
16 " But be doers of the Word, and not only hearers, deluding your own selves {{{1
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
17 " (James 1:22 RSV)
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
18 " =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
19
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
20 " ---------------------------------------------------------------------
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
21 " Load Once: {{{1
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
22 if exists("g:loaded_netrw")
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
23 finish
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
24 endif
553
249173daa651 updated for version 7.0157
vimboss
parents: 534
diff changeset
25 if v:version < 700
249173daa651 updated for version 7.0157
vimboss
parents: 534
diff changeset
26 echohl WarningMsg | echo "***netrw*** you need vim version 7.0 for this version of netrw" | echohl None
249173daa651 updated for version 7.0157
vimboss
parents: 534
diff changeset
27 finish
249173daa651 updated for version 7.0157
vimboss
parents: 534
diff changeset
28 endif
534
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
29 let s:keepcpo= &cpo
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
30 set cpo&vim
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
31
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
32 " ---------------------------------------------------------------------
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
33 " Public Interface: {{{1
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
34
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
35 " Local Browsing: {{{2
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
36 augroup FileExplorer
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
37 au!
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
38 au BufEnter * call s:LocalBrowse(expand("<amatch>"))
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
39 augroup END
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
40
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
41 " Network Browsing Reading Writing: {{{2
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
42 augroup Network
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
43 au!
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
44 if has("win32") || has("win95") || has("win64") || has("win16")
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
45 au BufReadCmd file://* exe "silent doau BufReadPre ".expand("<amatch>")|exe 'e '.substitute(expand("<amatch>"),"file:/*","","")|exe "silent doau BufReadPost ".expand("<amatch>")
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
46 else
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
47 au BufReadCmd file:///* exe "silent doau BufReadPre ".expand("<amatch>")|exe 'e /'.substitute(expand("<amatch>"),"file:/*","","")|exe "silent doau BufReadPost ".expand("<amatch>")
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
48 au BufReadCmd file://localhost/* exe "silent doau BufReadPre ".expand("<amatch>")|exe 'e /'.substitute(expand("<amatch>"),"file:/*","","")|exe "silent doau BufReadPost ".expand("<amatch>")
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
49 endif
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
50 au BufReadCmd ftp://*,rcp://*,scp://*,http://*,dav://*,rsync://*,sftp://* exe "silent doau BufReadPre ".expand("<amatch>")|exe "Nread 0r ".expand("<amatch>")|exe "silent doau BufReadPost ".expand("<amatch>")
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
51 au FileReadCmd ftp://*,rcp://*,scp://*,http://*,dav://*,rsync://*,sftp://* exe "silent doau BufReadPre ".expand("<amatch>")|exe "Nread " .expand("<amatch>")|exe "silent doau FileReadPost ".expand("<amatch>")
553
249173daa651 updated for version 7.0157
vimboss
parents: 534
diff changeset
52 au BufWriteCmd ftp://*,rcp://*,scp://*,dav://*,rsync://*,sftp://* exe "silent doau BufWritePre ".expand("<amatch>")|exe "Nwrite " .expand("<amatch>")|exe "silent doau BufWritePost ".expand("<amatch>")
249173daa651 updated for version 7.0157
vimboss
parents: 534
diff changeset
53 au FileWriteCmd ftp://*,rcp://*,scp://*,dav://*,rsync://*,sftp://* exe "silent doau BufWritePre ".expand("<amatch>")|exe "'[,']Nwrite " .expand("<amatch>")|exe "silent doau FileWritePost ".expand("<amatch>")
534
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
54 augroup END
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
55
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
56 " Commands: :Nread, :Nwrite, :NetUserPass {{{2
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
57 com! -nargs=* Nread call netrw#NetSavePosn()<bar>call netrw#NetRead(<f-args>)<bar>call netrw#NetRestorePosn()
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
58 com! -range=% -nargs=* Nwrite call netrw#NetSavePosn()<bar><line1>,<line2>call netrw#NetWrite(<f-args>)<bar>call netrw#NetRestorePosn()
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
59 com! -nargs=* NetUserPass call NetUserPass(<f-args>)
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
60
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
61 " Commands: :Explore, :Sexplore, Hexplore, Vexplore {{{2
553
249173daa651 updated for version 7.0157
vimboss
parents: 534
diff changeset
62 com! -nargs=? -bar -bang -count=0 Explore call netrw#Explore(<count>,0,0+<bang>0,<q-args>)
249173daa651 updated for version 7.0157
vimboss
parents: 534
diff changeset
63 com! -nargs=? -bar -bang -count=0 Sexplore call netrw#Explore(<count>,1,0+<bang>0,<q-args>)
249173daa651 updated for version 7.0157
vimboss
parents: 534
diff changeset
64 com! -nargs=? -bar -bang -count=0 Hexplore call netrw#Explore(<count>,1,2+<bang>0,<q-args>)
249173daa651 updated for version 7.0157
vimboss
parents: 534
diff changeset
65 com! -nargs=? -bar -bang -count=0 Vexplore call netrw#Explore(<count>,1,4+<bang>0,<q-args>)
249173daa651 updated for version 7.0157
vimboss
parents: 534
diff changeset
66 com! -nargs=? -bar -bang Nexplore call netrw#Explore(-1,0,0,<q-args>)
249173daa651 updated for version 7.0157
vimboss
parents: 534
diff changeset
67 com! -nargs=? -bar -bang Pexplore call netrw#Explore(-2,0,0,<q-args>)
534
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
68
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
69 " Commands: NetrwSettings {{{2
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
70 com! -nargs=0 NetrwSettings :call netrwSettings#NetrwSettings()
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
71
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
72 " ---------------------------------------------------------------------
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
73 " LocalBrowse: {{{2
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
74 fun! s:LocalBrowse(dirname)
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
75 " unfortunate interaction -- debugging calls can't be used here;
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
76 " the BufEnter event causes triggering when attempts to write to
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
77 " the DBG buffer are made.
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
78 if isdirectory(a:dirname)
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
79 call netrw#DirBrowse(a:dirname)
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
80 endif
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
81 " not a directory, ignore it
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
82 endfun
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
83
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
84 " ---------------------------------------------------------------------
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
85 " NetrwStatusLine: {{{1
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
86 fun! NetrwStatusLine()
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
87 " let g:stlmsg= "Xbufnr=".w:netrw_explore_bufnr." bufnr=".bufnr(".")." Xline#".w:netrw_explore_line." line#".line(".")
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
88 if !exists("w:netrw_explore_bufnr") || w:netrw_explore_bufnr != bufnr(".") || !exists("w:netrw_explore_line") || w:netrw_explore_line != line(".") || !exists("w:netrw_explore_list")
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
89 let &stl= s:netrw_explore_stl
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
90 if exists("w:netrw_explore_bufnr")|unlet w:netrw_explore_bufnr|endif
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
91 if exists("w:netrw_explore_line")|unlet w:netrw_explore_line|endif
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
92 return ""
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
93 else
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
94 return "Match ".w:netrw_explore_mtchcnt." of ".w:netrw_explore_listlen
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
95 endif
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
96 endfun
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
97
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
98 " ------------------------------------------------------------------------
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
99 " NetUserPass: set username and password for subsequent ftp transfer {{{1
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
100 " Usage: :call NetUserPass() -- will prompt for userid and password
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
101 " :call NetUserPass("uid") -- will prompt for password
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
102 " :call NetUserPass("uid","password") -- sets global userid and password
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
103 fun! NetUserPass(...)
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
104
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
105 " get/set userid
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
106 if a:0 == 0
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
107 " call Dfunc("NetUserPass(a:0<".a:0.">)")
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
108 if !exists("g:netrw_uid") || g:netrw_uid == ""
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
109 " via prompt
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
110 let g:netrw_uid= input('Enter username: ')
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
111 endif
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
112 else " from command line
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
113 " call Dfunc("NetUserPass(a:1<".a:1.">) {")
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
114 let g:netrw_uid= a:1
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
115 endif
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
116
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
117 " get password
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
118 if a:0 <= 1 " via prompt
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
119 " call Decho("a:0=".a:0." case <=1:")
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
120 let g:netrw_passwd= inputsecret("Enter Password: ")
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
121 else " from command line
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
122 " call Decho("a:0=".a:0." case >1: a:2<".a:2.">")
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
123 let g:netrw_passwd=a:2
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
124 endif
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
125 " call Dret("NetUserPass")
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
126 endfun
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
127
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
128 " ------------------------------------------------------------------------
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
129 " NetReadFixup: this sort of function is typically written by the user {{{1
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
130 " to handle extra junk that their system's ftp dumps
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
131 " into the transfer. This function is provided as an
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
132 " example and as a fix for a Windows 95 problem: in my
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
133 " experience, win95's ftp always dumped four blank lines
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
134 " at the end of the transfer.
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
135 if has("win95") && exists("g:netrw_win95ftp") && g:netrw_win95ftp
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
136 fun! NetReadFixup(method, line1, line2)
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
137 " call Dfunc("NetReadFixup(method<".a:method."> line1=".a:line1." line2=".a:line2.")")
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
138 if method == 3 " ftp (no <.netrc>)
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
139 let fourblanklines= line2 - 3
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
140 silent fourblanklines.",".line2."g/^\s*/d"
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
141 endif
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
142 " call Dret("NetReadFixup")
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
143 endfun
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
144 endif
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
145
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
146 " ------------------------------------------------------------------------
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
147 " Modelines And Restoration: {{{1
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
148 let &cpo= s:keepcpo
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
149 unlet s:keepcpo
c6296b0ad9ea updated for version 7.0151
vimboss
parents:
diff changeset
150 " vim:ts=8 fdm=marker