Permalink
Browse files

add bm#is_bookmark_has_annotation_by_line() to check whether a bookma…

…rk has an annotation

add g:bookmark_show_toggle_warning to show warning in toggle a annotated bookmark
confirm to remove a bookmark with annotation when g:bookmark_show_toggle_warning = 1
  • Loading branch information...
1 parent 20403b5 commit 36be95ea682323398a36dd62f93dfad9e5de84b0 @yuan- yuan- committed Sep 15, 2015
Showing with 12 additions and 0 deletions.
  1. +4 −0 autoload/bm.vim
  2. +8 −0 plugin/bookmark.vim
View
@@ -23,6 +23,10 @@ function! bm#get_bookmark_by_line(file, line_nr)
return g:line_map[a:file][a:line_nr]
endfunction
+function! bm#is_bookmark_has_annotation_by_line(file, line_nr)
+ return g:line_map[a:file][a:line_nr]['annotation'] !=# ""
+endfunction
+
function! bm#get_bookmark_by_sign(file, sign_idx)
let line_nr = g:sign_map[a:file][a:sign_idx]
return bm#get_bookmark_by_line(a:file, line_nr)
View
@@ -23,6 +23,7 @@ call s:set('g:bookmark_highlight_lines', 0 )
call s:set('g:bookmark_sign', '')
call s:set('g:bookmark_annotation_sign', '')
call s:set('g:bookmark_show_warning', 1 )
+call s:set('g:bookmark_show_toggle_warning', 1 )
call s:set('g:bookmark_save_per_working_dir', 0 )
call s:set('g:bookmark_auto_save', 1 )
call s:set('g:bookmark_manage_per_buffer', 0 )
@@ -57,6 +58,13 @@ function! BookmarkToggle()
endif
let current_line = line('.')
if bm#has_bookmark_at_line(file, current_line)
+ if g:bookmark_show_toggle_warning ==# 1 && bm#is_bookmark_has_annotation_by_line(file, current_line)
+ let delete = confirm("Delete Annotated bookmarks?", "&Yes\n&No", 2)
+ if (delete !=# 1)
+ echo "Ignore!"
+ return
+ endif
+ endif
call s:bookmark_remove(file, current_line)
echo "Bookmark removed"
else

0 comments on commit 36be95e

Please sign in to comment.