copy files to denote directory
This commit is contained in:
@@ -122,3 +122,25 @@ function denote#notes#tagmod(line1, line2, tag, add)
|
||||
endif
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
" Add file to denote directory
|
||||
function denote#notes#copy(origfile)
|
||||
if !filereadable(a:origfile)
|
||||
echohl WarningMsg
|
||||
echom 'Cannot copy specified file to denote directory.'
|
||||
return
|
||||
endif
|
||||
" Derive title from origfile
|
||||
let l:title = fnamemodify(a:origfile, ':t:r')
|
||||
let l:ext = fnamemodify(a:origfile, ':e')
|
||||
let l:identifier = g:Denote_identifier_fun()
|
||||
let l:filename = denote#meta#filename(l:ext, l:identifier, l:title)
|
||||
call system('cp ' .. shellescape(a:origfile) .. ' ' .. shellescape(l:filename))
|
||||
" Write front matter, if this is supported
|
||||
if index(g:denote_note_file_extensions, l:ext) >= 0
|
||||
call denote#loclist#jumptowindow()
|
||||
exe 'edit ' .. l:filename
|
||||
call denote#frontmatter#prepend(l:filename, l:identifier, l:title)
|
||||
exe 'w'
|
||||
endif
|
||||
endfunction
|
||||
|
||||
Reference in New Issue
Block a user