" Put all notes of the given tag to the location list. The search argument may be " empty. For improving search, white spaces are replaced by the * |wildcard|. function denote#notes#list(search) let l:s = substitute(' ' .. a:search .. ' ', ' ', '*', 'g') let l:files = glob(g:denote_directory .. '/' .. l:s, 0, v:true) let l:title = 'Denote notes search:' .. a:search let l:Gfun = function('denote#notes#list', [a:search]) call denote#loclist#fill(l:title, l:files, l:Gfun) endfunction " Put all notes of the given tag to the location list. The tag argument is " mandatory. function denote#notes#bytag(tag) let l:files = glob(g:denote_directory .. '/*_' .. a:tag .. '*', 0, v:true)->filter('v:val->split("/")[-1] =~ "_' .. a:tag .. '\\(==\\|@@\\|__\\|_\\|\\.\\)"') let l:title = 'Denote notes: ' .. a:tag let l:Gfun = function('denote#notes#bytag', [a:tag]) call denote#loclist#fill(l:title, l:files, l:Gfun) endfunction " Search in denote notes function denote#notes#grep(re) let l:title = 'Grep results for: ' .. a:re let l:fpat=map(copy(g:denote_note_file_extensions), {_, e -> g:denote_directory .. '/*.' .. e})->join() execute 'silent! lvimgrep ' .. a:re .. ' ' .. l:fpat let l:Gfun = function('denote#notes#grep', [a:re]) call denote#loclist#setgrep(l:title, l:Gfun) endfunction " This creates a new denote entry with the given title and of the given " filetype. The title may be empty. function denote#notes#new(title, ft=g:denote_new_ft) let l:identifier = g:Denote_identifier_fun() let l:fn = denote#meta#filename(a:ft, l:identifier, a:title) " Jump to window this location list belongs to call denote#loclist#jumptowindow() " Open file and write front matter execute 'edit ' l:fn call setline(1, denote#frontmatter#new(a:ft, l:identifier, a:title)) endfunction " Function to set the title of the selected entry function denote#notes#settitle(linenr, title) " Get file first! let l:items = getloclist(0, {'items': 1})['items'] if empty(l:items) return endif let l:item = l:items[a:linenr-1] let l:bufnr = l:item['bufnr'] let l:filename = bufname(l:bufnr) let l:noteid = denote#meta#noteIdFromFile(l:filename) let l:notetags = denote#meta#noteTagsFromFile(l:filename) let l:notesignature = denote#meta#noteSignatureFromFile(l:filename) let l:oldtitle = denote#meta#noteTitleFromFile (l:filename) let l:ext = fnamemodify(l:filename, ':e') let l:newfilename = denote#meta#filename(l:ext, l:noteid, a:title, l:notetags, l:notesignature) " If this note has a front matter, we rewrite the front matter and rename the " file. Otherwise, we rename the file only. if index(g:denote_note_file_extensions, l:ext) >= 0 " Handle front matter call denote#frontmatter#setTitle(l:filename, a:title) call denote#loclist#jumptowindow() exe l:bufnr .. 'buf' exe 'silent file ' .. l:newfilename exe 'silent w' exe 'lopen' call delete(l:filename) else if fnamemodify(l:filename, ':t') == fnamemodify(l:newfilename, ':t') return endif call rename(l:filename, l:newfilename) endif endfunction