diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2019-06-01 18:09:09 +1200 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2019-06-01 18:09:09 +1200 |
commit | b34b8a2b3131c760599f4217a185ebd51d9e4e28 (patch) | |
tree | 3bed66f8921aadc1ccabae5a4e97f4ba50839627 /autoload | |
parent | Merge branch 'hotfix/v1.1.2' into develop (diff) | |
download | vim-write-mkpath-b34b8a2b3131c760599f4217a185ebd51d9e4e28.tar.gz vim-write-mkpath-b34b8a2b3131c760599f4217a185ebd51d9e4e28.zip |
Throw away the path absolution hooks
Too awkward, not worth it, especially the mess it makes of alternate
files.
Diffstat (limited to 'autoload')
-rw-r--r-- | autoload/write_mkpath.vim | 42 |
1 files changed, 1 insertions, 41 deletions
diff --git a/autoload/write_mkpath.vim b/autoload/write_mkpath.vim index 6c55e78..8a3ac9d 100644 --- a/autoload/write_mkpath.vim +++ b/autoload/write_mkpath.vim @@ -1,35 +1,6 @@ -" Handle a buffer created for a new file; anchor its filename to be absolute -" if it's relative and the directory path doesn't yet exist; this stops Vim -" trying to save in the wrong place if the user changes directory before -" writing the buffer -function! write_mkpath#New(path) abort - - " We don't have fnameescape(); this old Vim < v7.1.299 is likely too buggy - " to handle the buffer renaming for paths safely, so better not to mess with - " it and instead to stick with suboptimal but consistent behaviour - if !exists('*fnameescape') - return - endif - - " Path exists, or is absolute; we don't need to do anything - if isdirectory(fnamemodify(a:path, ':h')) - \ || s:Absolute(a:path) - return - endif - - " Set filename to absolute path using :file {name}; do it silently so that - " the nice name remains displayed to the user. Record the name of the - " alternate buffer first, so we can put it back after :file messes with it. - execute 'silent file '.fnameescape(getcwd().'/'.a:path) - - " Wipe the unlisted alternate buffer that :file leaves behind - bwipe # - -endfunction - " Handle a :write operation; prompt for directory creation if needed with " 'confirm', force it with :write! -function! write_mkpath#Write(path) abort +function! write_mkpath#(path) abort " Get all directory elements leading up to directory let dir = fnamemodify(a:path, ':h') @@ -56,14 +27,3 @@ function! write_mkpath#Write(path) abort endif endfunction - -" Clumsy and probably wrong helper function to check if a path is absolute -function! s:Absolute(path) abort - if has('unix') - return a:path =~# '^/' " Leading slash on Unix - elseif has('win32') || has('win64') - return a:path =~# '^\u:' " e.g. C: -- I'm not sure this is right - else - echoerr 'Unrecognised operating system' - endif -endfunction |