sort bookmarks when we add a new one

This commit is contained in:
Martin Grenfell 2008-06-30 09:36:50 +12:00
parent 02facac20a
commit 030cff2eda

View File

@ -166,6 +166,7 @@ function! s:oBookmark.AddBookmark(name, path) dict
endif
endfor
call add(s:oBookmark.Bookmarks(), s:oBookmark.New(a:name, a:path))
call s:oBookmark.Sort()
endfunction
" Function: oBookmark.Bookmarks() {{{3
" Class method to get all bookmarks. Lazily initializes the bookmarks global
@ -222,6 +223,11 @@ function! s:oBookmark.CacheBookmarks() dict
endif
endif
endfunction
" FUNCTION: oBookmark.CompareTo(otherbookmark) {{{3
" Compare these two bookmarks for sorting purposes
function! s:oBookmark.CompareTo(otherbookmark) dict
return a:otherbookmark.name < self.name
endfunction
" FUNCTION: oBookmark.ClearAll() {{{3
" Class method to delete all bookmarks.
function! s:oBookmark.ClearAll() dict
@ -280,6 +286,12 @@ function! s:oBookmark.New(name, path) dict
let newBookmark.path = a:path
return newBookmark
endfunction
" Function: oBookmark.Sort() {{{3
" Class method that sorts all bookmarks
function! s:oBookmark.Sort() dict
let CompareFunc = function("s:CompareBookmarks")
call sort(s:oBookmark.Bookmarks(), CompareFunc)
endfunction
" Function: oBookmark.Str() {{{3
" Get the string that should be rendered in the view for this bookmark
function! s:oBookmark.Str() dict
@ -1581,6 +1593,12 @@ function! s:BufInWindows(bnum)
return cnt
endfunction " >>>
"FUNCTION: CompareBookmarks(first, second) {{{2
"Compares two bookmarks
function! s:CompareBookmarks(first, second)
return a:first.CompareTo(a:second)
endfunction
" FUNCTION: s:CompleteBookmarks(A,L,P) {{{2
" completion function for the bookmark commands
function! s:CompleteBookmarks(A,L,P)