note deletion with bang
This commit is contained in:
@@ -45,7 +45,7 @@ function denote#ft#qf()
|
|||||||
command! -nargs=1 -range -buffer DenoteSetTitle :call denote#notes#settitle(<line1>, <q-args>)
|
command! -nargs=1 -range -buffer DenoteSetTitle :call denote#notes#settitle(<line1>, <q-args>)
|
||||||
command! -nargs=1 -range -buffer -complete=custom,denote#completion#tags DenoteTagAdd :call denote#notes#tagmod(<line1>, <line2>, <q-args>, v:true)
|
command! -nargs=1 -range -buffer -complete=custom,denote#completion#tags DenoteTagAdd :call denote#notes#tagmod(<line1>, <line2>, <q-args>, v:true)
|
||||||
command! -nargs=1 -range -buffer -complete=custom,denote#completion#tags DenoteTagRm :call denote#notes#tagmod(<line1>, <line2>, <q-args>, v:false)
|
command! -nargs=1 -range -buffer -complete=custom,denote#completion#tags DenoteTagRm :call denote#notes#tagmod(<line1>, <line2>, <q-args>, v:false)
|
||||||
command! -range -buffer DenoteDelete :call denote#notes#rm(<line1>, <line2>)
|
command! -range -buffer -bang DenoteDelete :call denote#notes#rm(<line1>, <line2>, <bang>0)
|
||||||
nnoremap <buffer> C :DenoteSetTitle
|
nnoremap <buffer> C :DenoteSetTitle
|
||||||
nnoremap <buffer> + :DenoteTagAdd
|
nnoremap <buffer> + :DenoteTagAdd
|
||||||
nnoremap <buffer> - :DenoteTagRm
|
nnoremap <buffer> - :DenoteTagRm
|
||||||
|
|||||||
@@ -146,7 +146,8 @@ function denote#notes#copy(origfile)
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" Delete notes from denote directory
|
" Delete notes from denote directory
|
||||||
function denote#notes#rm(line1, line2)
|
function denote#notes#rm(line1, line2, bang)
|
||||||
|
echom "bang set to:"..a:bang
|
||||||
let l:items = getloclist(0, {'items': 1})['items']
|
let l:items = getloclist(0, {'items': 1})['items']
|
||||||
if empty(l:items)
|
if empty(l:items)
|
||||||
return
|
return
|
||||||
@@ -156,10 +157,12 @@ function denote#notes#rm(line1, line2)
|
|||||||
let l:bufnr = l:item['bufnr']
|
let l:bufnr = l:item['bufnr']
|
||||||
let l:filename = bufname(l:bufnr)
|
let l:filename = bufname(l:bufnr)
|
||||||
let l:title = denote#meta#noteTitleFromFile(l:filename)
|
let l:title = denote#meta#noteTitleFromFile(l:filename)
|
||||||
|
if a:bang == v:false
|
||||||
let l:answer = confirm('Are you sure you want to delete the note "' .. l:title .. '"?', "&Yes\n&No\n", 2, 'Question')
|
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
|
if l:answer != 1
|
||||||
continue
|
continue
|
||||||
endif
|
endif
|
||||||
|
endif
|
||||||
" Wipe buffer, if it exists
|
" Wipe buffer, if it exists
|
||||||
if bufexists(l:filename)
|
if bufexists(l:filename)
|
||||||
exe 'silent bwipe ' .. fnameescape(l:filename)
|
exe 'silent bwipe ' .. fnameescape(l:filename)
|
||||||
|
|||||||
Reference in New Issue
Block a user