@@ -125,6 +125,7 @@ call s:NetrwInit("g:netrw_rsync_cmd", "rsync")
125125call s: NetrwInit (" g:netrw_scp_cmd" , " scp -q" )
126126call s: NetrwInit (" g:netrw_sftp_cmd" , " sftp" )
127127call s: NetrwInit (" g:netrw_ssh_cmd" , " ssh" )
128+ call s: NetrwInit (" g:netrw_dbx_cmd" , " dbx.py" )
128129
129130if (has (" win32" ) || has (" win95" ) || has (" win64" ) || has (" win16" ))
130131 \ && exists (" g:netrw_use_nt_rcp" )
@@ -954,6 +955,11 @@ fun! netrw#NetRead(mode,...)
954955 let result = s: NetrwGetFile (readcmd, tmpfile, b: netrw_method )
955956 let b: netrw_lastfile = choice
956957
958+ " NetRead: (Dropbox) NetRead Method #10 {{{3
959+ elseif b: netrw_method == 10
960+ exe s: netrw_silentxfer ." !" .g: netrw_dbx_cmd ." down " .shellescape (b: netrw_fname ,1 )." " .tmpfile
961+ let result = s: NetrwGetFile (readcmd, tmpfile, b: netrw_method )
962+ let b: netrw_lastfile = choice
957963 " .........................................
958964 " NetRead: Complain {{{3
959965 else
@@ -1320,6 +1326,10 @@ fun! netrw#NetWrite(...) range
13201326 exe filtbuf." bw!"
13211327 let b: netrw_lastfile = choice
13221328
1329+ " NetWrite: (Dropbox) NetWrite Method #10 {{{3
1330+ elseif b: netrw_method == 10
1331+ exe s: netrw_silentxfer ." !" .g: netrw_dbx_cmd ." up " .shellescape (b: netrw_fname ,1 )." " .tmpfile
1332+ let b: netrw_lastfile = choice
13231333 " .........................................
13241334 " NetWrite: Complain {{{3
13251335 else
@@ -1572,6 +1582,7 @@ fun! s:NetrwMethod(choice)
15721582 let rsyncurm = ' ^rsync://\([^/]\{-}\)/\(.*\)\=$'
15731583 let fetchurm = ' ^fetch://\(\([^/@]\{-}\)@\)\=\([^/#:]\{-}\)\(:http\)\=/\(.*\)$'
15741584 let sftpurm = ' ^sftp://\([^/]\{-}\)/\(.*\)\=$'
1585+ let dburm = ' ^dbx:///\(.*\)\=$'
15751586
15761587" call Decho("determine method:")
15771588 " Determine Method
@@ -1665,6 +1676,11 @@ fun! s:NetrwMethod(choice)
16651676 endif
16661677 endif
16671678
1679+ " Method#10: Get it from Dropbox
1680+ elseif match (a: choice , dburm) == 0
1681+ let b: netrw_method = 10
1682+ let b: netrw_fname = substitute (a: choice ,dburm,' \1' ," " )
1683+
16681684 " Method#8: fetch {{{3
16691685 elseif match (a: choice ,fetchurm) == 0
16701686" call Decho("fetch://...")
@@ -1718,7 +1734,6 @@ fun! s:NetrwMethod(choice)
17181734 if userid != " "
17191735 let g: netrw_uid= userid
17201736 endif
1721-
17221737 " Cannot Determine Method {{{3
17231738 else
17241739 if ! exists (" g:netrw_quiet" )
@@ -2510,7 +2525,7 @@ fun! s:NetrwBrowse(islocal,dirname)
25102525 " set b:netrw_curdir to the new directory name {{{3
25112526" call Decho("set b:netrw_curdir to the new directory name: (buf#".bufnr("%").")")
25122527 let b: netrw_curdir= dirname
2513- if b: netrw_curdir = ~ ' [/\\]$'
2528+ if b: netrw_curdir = ~ ' [/\\]$' && b: netrw_curdir !~ ' ^dbx:// '
25142529 let b: netrw_curdir= substitute (b: netrw_curdir ,' [/\\]$' ,' ' ,' e' )
25152530 endif
25162531 if b: netrw_curdir == ' '
@@ -2583,6 +2598,14 @@ fun! s:NetrwBrowse(islocal,dirname)
25832598 let dirname = substitute (dirname,' \\' ,' /' ,' g' )
25842599" call Decho("(normal) dirname<".dirname.">")
25852600 endif
2601+ " Check if the pattern matches a Dropbox URL.
2602+ let dbxpat = ' ^dbx:///\(.*\)\='
2603+ if dirname = ~ dbxpat
2604+ keepj call s: NetrwMaps (a: islocal )
2605+ keepj call s: PerformListing (a: islocal )
2606+ let s: locbrowseshellcmd= 1
2607+ return
2608+ endif
25862609
25872610 let dirpat = ' ^\(\w\{-}\)://\(\w\+@\)\=\([^/]\+\)/\(.*\)$'
25882611 if dirname !~ dirpat
@@ -3177,7 +3200,6 @@ fun! s:NetrwBrowseChgDir(islocal,newdir,...)
31773200 else
31783201 let dirpat= ' [\/]$'
31793202 endif
3180- " call Decho("dirname<".dirname."> dirpat<".dirpat.">")
31813203
31823204 if dirname !~ dirpat
31833205 " apparently vim is "recognizing" that it is in a directory and
@@ -6837,7 +6859,13 @@ fun! s:NetrwRemoteListing()
68376859 keepj call histdel (" /" ,-1 )
68386860 endif
68396861 endif
6840-
6862+ " Dropbox directory listing
6863+ elseif s: method == " dbx"
6864+ if s: path == ' '
6865+ exe " sil! keepalt r! " .g: netrw_dbx_cmd ." list /"
6866+ else
6867+ exe " sil! keepalt r! " .g: netrw_dbx_cmd ." list " .shellescape (s: path )
6868+ endif
68416869 else
68426870 " use ssh to get remote file listing {{{3
68436871" call Decho("use ssh to get remote file listing: s:path<".s:path.">")
@@ -8364,6 +8392,17 @@ endfun
83648392fun ! s: RemotePathAnalysis (dirname)
83658393" call Dfunc("s:RemotePathAnalysis(a:dirname<".a:dirname.">)")
83668394
8395+ let dbxpat = ' ^dbx:///\(.*\)\='
8396+ if a: dirname = ~ dbxpat
8397+ let s: method = ' dbx'
8398+ let s: user = ' '
8399+ let s: machine = ' '
8400+ let s: port = ' '
8401+ let s: path = substitute (a: dirname ,dbxpat,' \1' ,' ' )
8402+ let s: fname = ' '
8403+ return
8404+ endif
8405+
83678406 let dirpat = ' ^\(\w\{-}\)://\(\w\+@\)\=\([^/:#]\+\)\%([:#]\(\d\+\)\)\=/\(.*\)$'
83688407 let s: method = substitute (a: dirname ,dirpat,' \1' ,' ' )
83698408 let s: user = substitute (a: dirname ,dirpat,' \2' ,' ' )
0 commit comments