Handle prefixes from (git) diff
Closed this issue · 2 comments
blueyed commented
I've thought that we've talked about this before, but could not find it now.
I am using the following snippet to be able to open files from e.g. git-diff
, where the prefix is ignored.
It seems to be a good fit for this plugin?!
" Check if the new file (with git-diff prefix removed) is readable and
" edit that instead (copy'n'paste from shell).
" (for git diff: `[abiw]`).
au BufNewFile * nested let s:fn = expand('<afile>') |
\ echom filereadable(s:fn) |
\ if ! filereadable(s:fn) |
\ let s:fn = substitute(s:fn, '^\S/', '', '') |
\ if filereadable(s:fn) |
\ exec 'edit' s:fn |
\ bdelete # |
\ redraw |
\ echomsg 'Got unreadable file, editing' s:fn 'instead.' |
\ endif |
\ endif
kopischke commented
Yes we did, actually, in #6 (I had to look for it too, the topic of the issue is a bit generic). I am still not sure if interpreting paths is not best left to &includeexpr
and friends, but as I am currently reworking fetch to handle #9 and the refactoring needed for that has taken me 90 % of the way towards user configurable specs, I might go the last mile for the next release and open up the API.
kopischke commented
Closing as duplicate, but stay tuned for the next release.