feat: note deletion

This commit is contained in:
2026-02-28 15:16:47 +01:00
parent dfc15def2b
commit 1afd45b91a
2 changed files with 27 additions and 0 deletions

View File

@@ -144,3 +144,27 @@ function denote#notes#copy(origfile)
exe 'w'
endif
endfunction
" Delete notes from denote directory
function denote#notes#rm(line1, line2)
let l:items = getloclist(0, {'items': 1})['items']
if empty(l:items)
return
endif
for i in range(a:line1, a:line2)
let l:item = l:items[i-1]
let l:bufnr = l:item['bufnr']
let l:filename = bufname(l:bufnr)
let l:title = denote#meta#noteTitleFromFile(l:filename)
let l:answer = confirm('Are you sure you want to delete the note "' .. l:title .. '"?', "&Yes\n&No\n", 2, 'Question')
if l:answer != 1
continue
endif
" Wipe buffer, if it exists
if bufexists(l:filename)
exe 'silent bwipe ' .. fnameescape(l:filename)
endif
" Delete file
call delete(l:filename)
endfor
endfunction