code: cleaned up
This commit is contained in:
@@ -10,35 +10,35 @@ function denote#meta#fileFromNoteId(noteId)
|
||||
" (A) First, we get all files that contain the note id as substring.
|
||||
" (B) Then we ensure that the note id is followed by another field or by the
|
||||
" file extension.
|
||||
let files = glob(g:denote_directory .. "/*" .. a:noteId .. "*", 0, v:true)
|
||||
let l:files = glob(g:denote_directory .. '/*' .. a:noteId .. '*', 0, v:true)
|
||||
\ ->filter('v:val->split("/")[-1] =~ "' .. a:noteId .. '\\(==\\|--\\|__\\|\\.\\)"')
|
||||
\ ->filter('v:val->split("/")[-1] =~ "^' .. a:noteId .. '\\|@@' .. a:noteId .. '"')
|
||||
return empty(files) ? v:false : files[0]
|
||||
return empty(l:files) ? v:false : l:files[0]
|
||||
endfunction
|
||||
|
||||
" Return the note id from the filename. On failure, v:false is returned.
|
||||
function denote#meta#noteIdFromFile(file)
|
||||
return a:file->fnamemodify(':t')->matchstr("@@\\zs.\\{-\\}\\ze\\(==\\|--\\|__\\|\\..\\)")
|
||||
\ ?? a:file->fnamemodify(':t')->matchstr("^.\\{-\\}\\ze\\(==\\|--\\|__\\|\\..\\)")
|
||||
return a:file->fnamemodify(':t')->matchstr('@@\zs.\{-\}\ze\(==\|--\|__\|\..\)')
|
||||
\ ?? a:file->fnamemodify(':t')->matchstr('^.\{-\}\ze\(==\|--\|__\|\..\)')
|
||||
\ ?? v:false
|
||||
endfunction
|
||||
|
||||
" Return the note title from the filename.
|
||||
function denote#meta#noteTitleFromFile(file)
|
||||
return a:file->fnamemodify(':t')->matchstr("--\\zs.\\{-\\}\\ze\\(==\\|@@\\|__\\|\\..\\)")->substitute("-", " ", "g")
|
||||
return a:file->fnamemodify(':t')->matchstr('--\zs.\{-\}\ze\(==\|@@\|__\|\..\)')->substitute('-', ' ', 'g')
|
||||
endfunction
|
||||
|
||||
" Return the note tags from the filename as a list.
|
||||
function denote#meta#noteTagsFromFile(file)
|
||||
return a:file->fnamemodify(':t')->matchstr("__\\zs.\\{-\\}\\ze\\(==\\|@@\\|--\\|\\..\\)")->split("_")
|
||||
return a:file->fnamemodify(':t')->matchstr('__\zs.\{-\}\ze\(==\|@@\|--\|\..\)')->split('_')
|
||||
endfunction
|
||||
|
||||
" Identifier creation
|
||||
function denote#meta#identifier_generate()
|
||||
if g:denote_identifier_fun
|
||||
return execute "call " .. g:denote_identifier_fun .. "()"
|
||||
return execute 'call ' .. g:denote_identifier_fun .. '()'
|
||||
endif
|
||||
return exists("*strftime")
|
||||
\ ? strftime("%Y%m%dT%H%M%S")
|
||||
return exists('*strftime')
|
||||
\ ? strftime('%Y%m%dT%H%M%S')
|
||||
\ : rand()
|
||||
endfunction
|
||||
|
||||
Reference in New Issue
Block a user