diff --git a/README.md b/README.md index 6c074b2..becf250 100644 --- a/README.md +++ b/README.md @@ -48,15 +48,15 @@ After installation you can directly start using it. You can do this by either us | Action | Shortcut | Command | |-------------------------------------------------|-------------|------------------------------| -| Add/remove bookmark at current line | `mm` | `:ToggleBookmark` | -| Add/edit/remove annotation at current line | `mi` | `:Annotate ` | -| Jump to next bookmark in buffer | `mn` | `:NextBookmark` | -| Jump to previous bookmark in buffer | `mp` | `:PrevBookmark` | -| Show all bookmarks | `ma` | `:ShowAllBookmarks` | -| Clear bookmarks in current buffer only | `mc` | `:ClearBookmarks` | -| Clear bookmarks in all buffers | `mx` | `:ClearAllBookmarks` | -| Save all bookmarks to a file | | `:SaveBookmarks ` | -| Load bookmarks from a file | | `:LoadBookmarks ` | +| Add/remove bookmark at current line | `mm` | `:BookmarkToggle` | +| Add/edit/remove annotation at current line | `mi` | `:BookmarkAnnotate ` | +| Jump to next bookmark in buffer | `mn` | `:BookmarkNext` | +| Jump to previous bookmark in buffer | `mp` | `:BookmarkPrev` | +| Show all bookmarks | `ma` | `:BookmarkShowAll` | +| Clear bookmarks in current buffer only | `mc` | `:BookmarkClear` | +| Clear bookmarks in all buffers | `mx` | `:BookmarkClearAll` | +| Save all bookmarks to a file | | `:BookmarkSave ` | +| Load bookmarks from a file | | `:BookmarkLoad ` | You can change the shortcuts as you like, just read on... @@ -67,13 +67,13 @@ You can change the shortcuts as you like, just read on... You can overwrite any of the default mappings. Just put the following into your `~/.vimrc` and adjust as you like: ``` -nmap ToggleBookmark -nmap i Annotate -nmap a ShowAllBookmarks -nmap j NextBookmark -nmap k PrevBookmark -nmap c ClearBookmarks -nmap x ClearAllBookmarks +nmap BookmarkToggle +nmap i BookmarkAnnotate +nmap a BookmarkShowAll +nmap j BookmarkNext +nmap k BookmarkPrev +nmap c BookmarkClear +nmap x BookmarkClearAll ``` ### Colors @@ -104,7 +104,7 @@ Put any of the following options into your `~/.vimrc` in order to overwrite the ### Silent saving and loading -Call functions SaveBookmarks, LoadBookmarks and ClearAllBookmarks with the last argument set to 0 to perform these operations silently. You may use this to manage your bookmark list transparently from within your custom script. +Call functions BookmarkSave, BookmarkLoad and BookmarkClearAll with the last argument set to 0 to perform these operations silently. You may use this to manage your bookmark list transparently from within your custom script. ## FAQ diff --git a/doc/bookmarks.txt b/doc/bookmarks.txt index 10ed162..afb0384 100644 --- a/doc/bookmarks.txt +++ b/doc/bookmarks.txt @@ -60,32 +60,32 @@ You don't have to do anything: it just works. Commands for using Bookmarks - :ToggleBookmark *:ToggleBookmark* + :BookmarkToggle *:BookmarkToggle* Add or remove bookmark at current line - :Annotate *:Annotate* + :BookmarkAnnotate *:BookmarkAnnotate* Add/edit/remove annotation at current line - :NextBookmark *:NextBookmark* + :BookmarkNext *:BookmarkNext* Jump to the next bookmark downwards - :PrevBookmark *:PrevBookmark* + :BookmarkPrev *:BookmarkPrev* Jump to the next bookmark upwards - :ShowAllBookmarks *:ShowAllBookmarks* + :BookmarkShowAll *:BookmarkShowAll* Show bookmarks across all buffers in new window - :ClearBookmarks *:ClearBookmarks* + :BookmarkClear *:BookmarkClear* Removes bookmarks for current buffer - :ClearAllBookmarks *:ClearAllBookmarks* + :BookmarkClearAll *:BookmarkClearAll* Removes bookmarks for all buffer - :SaveBookmarks *:SaveBookmarks* + :BookmarkSave *:BookmarkSave* Saves all bookmarks to a file so you can load them back in later - :LoadBookmarks *:LoadBookmarks* - Loads bookmarks from a file (see :SaveBookmarks) + :BookmarkLoad *:BookmarkLoad* + Loads bookmarks from a file (see :BookmarkSave) =============================================================================== 5. CUSTOMISATION *BookmarksCustomisation* @@ -154,13 +154,13 @@ KEY MAPPINGS To change the default keys: > - nmap ToggleBookmark - nmap i Annotate - nmap a ShowAllBookmarks - nmap j NextBookmark - nmap k PrevBookmark - nmap c ClearBookmarks - nmap x ClearAllBookmarks + nmap BookmarkToggle + nmap i BookmarkAnnotate + nmap a BookmarkShowAll + nmap j BookmarkNext + nmap k BookmarkPrev + nmap c BookmarkClear + nmap x BookmarkClearAll < MORE OPTIONS @@ -206,9 +206,9 @@ Automatically close bookmarks split when jumping to a bookmark (default 0): 6. EXTENDING *BookmarksExtending* You can implement automatic switching of bookmarks file on your desired event. -To do so, use functions SaveBookmarks, LoadBookmarks and ClearAllBookmarks with +To do so, use functions BookmarkSave, BookmarkLoad and BookmarkClearAll with the last argument set to 1. This will suppress any messages and prompts these -functions normally issue. The LoadBookmarks function will return 1 to indicate +functions normally issue. The BookmarkLoad function will return 1 to indicate that file loading was successful, and 0 for failure. An example script using this feature is located in the 'examples/bm-autoload-example.vim' file. diff --git a/examples/bm-autoload-example.vim b/examples/bm-autoload-example.vim index 8df9f03..2c78e3f 100644 --- a/examples/bm-autoload-example.vim +++ b/examples/bm-autoload-example.vim @@ -23,7 +23,7 @@ function! AutoloadBookmarks(file_name) if (root_is_found && found_root != s:last_root) let s:last_file = found_root . '/.bookmarks' let s:last_root = found_root - call LoadBookmarks(s:last_file, 0, 1) + call BookmarkLoad(s:last_file, 0, 1) augroup AutoSaveBookmarks autocmd! @@ -40,7 +40,7 @@ augroup AutoLoadBookmarks augroup END function! s:remove_group() - call SaveBookmarks(s:last_file, 1) + call BookmarkSave(s:last_file, 1) augroup AutoSaveBookmarks autocmd! augroup END diff --git a/plugin/bookmark.vim b/plugin/bookmark.vim index 41ce567..9eef43a 100644 --- a/plugin/bookmark.vim +++ b/plugin/bookmark.vim @@ -35,7 +35,7 @@ augroup END " Commands {{{ -function! ToggleBookmark() +function! BookmarkToggle() call s:refresh_line_numbers() let file = expand("%:p") if file ==# "" @@ -50,9 +50,9 @@ function! ToggleBookmark() echo "Bookmark added" endif endfunction -command! ToggleBookmark call ToggleBookmark() - -function! Annotate(...) +command! ToggleBookmark call CallDeprecatedCommand('BookmarkToggle', []) +command! BookmarkToggle call BookmarkToggle() +function! BookmarkAnnotate(...) call s:refresh_line_numbers() let file = expand("%:p") if file ==# "" @@ -93,9 +93,10 @@ function! Annotate(...) echo "Bookmark added with annotation: ". new_annotation endif endfunction -command! -nargs=* Annotate call Annotate(, 0) +command! -nargs=* Annotate call CallDeprecatedCommand('BookmarkAnnotate', [, 0]) +command! -nargs=* BookmarkAnnotate call BookmarkAnnotate(, 0) -function! ClearBookmarks() +function! BookmarkClear() call s:refresh_line_numbers() let file = expand("%:p") let lines = bm#all_lines(file) @@ -104,9 +105,10 @@ function! ClearBookmarks() endfor echo "Bookmarks removed" endfunction -command! ClearBookmarks call ClearBookmarks() +command! ClearBookmarks call CallDeprecatedCommand('BookmarkClear', []) +command! BookmarkClear call BookmarkClear() -function! ClearAllBookmarks(silent) +function! BookmarkClearAll(silent) call s:refresh_line_numbers() let files = bm#all_files() let file_count = len(files) @@ -124,21 +126,24 @@ function! ClearAllBookmarks(silent) endif endif endfunction -command! ClearAllBookmarks call ClearAllBookmarks(0) +command! ClearAllBookmarks call CallDeprecatedCommand('BookmarkClearAll', [0]) +command! BookmarkClearAll call BookmarkClearAll(0) -function! NextBookmark() +function! BookmarkNext() call s:refresh_line_numbers() call s:jump_to_bookmark('next') endfunction -command! NextBookmark call NextBookmark() +command! NextBookmark call CallDeprecatedCommand('BookmarkNext') +command! BookmarkNext call BookmarkNext() -function! PrevBookmark() +function! BookmarkPrev() call s:refresh_line_numbers() call s:jump_to_bookmark('prev') endfunction -command! PrevBookmark call PrevBookmark() +command! PrevBookmark call CallDeprecatedCommand('BookmarkPrev') +command! BookmarkPrev call BookmarkPrev() -function! ShowAllBookmarks() +function! BookmarkShowAll() call s:refresh_line_numbers() let oldformat = &errorformat " backup original format let &errorformat = "%f:%l:%m" " custom format for bookmarks @@ -150,9 +155,10 @@ function! ShowAllBookmarks() augroup END let &errorformat = oldformat " re-apply original format endfunction -command! ShowAllBookmarks call ShowAllBookmarks() +command! ShowAllBookmarks call CallDeprecatedCommand('BookmarkShowAll') +command! BookmarkShowAll call BookmarkShowAll() -function! SaveBookmarks(target_file, silent) +function! BookmarkSave(target_file, silent) call s:refresh_line_numbers() let serialized_bookmarks = bm#serialize() call writefile(serialized_bookmarks, a:target_file) @@ -160,9 +166,10 @@ function! SaveBookmarks(target_file, silent) echo "All bookmarks saved" endif endfunction -command! -nargs=1 SaveBookmarks call SaveBookmarks(, 0) +command! -nargs=1 SaveBookmarks call CallDeprecatedCommand('BookmarkSave', [, 0]) +command! -nargs=1 BookmarkSave call BookmarkSave(, 0) -function! LoadBookmarks(target_file, startup, silent) +function! BookmarkLoad(target_file, startup, silent) let supports_confirm = has("dialog_con") || has("dialog_gui") let has_bookmarks = bm#total_count() ># 0 let confirmed = 1 @@ -191,7 +198,14 @@ function! LoadBookmarks(target_file, startup, silent) endtry endif endfunction -command! -nargs=1 LoadBookmarks call LoadBookmarks(, 0, 0) +command! -nargs=1 LoadBookmarks call CallDeprecatedCommand('BookmarkLoad', [, 0, 0]) +command! -nargs=1 BookmarkLoad call BookmarkLoad(, 0, 0) + +function! CallDeprecatedCommand(fun, args) + echo "Warning: Deprecated command, please use ':". a:fun ."' instead" + let Fn = function(a:fun) + return call(Fn, a:args) +endfunction " }}} @@ -265,7 +279,7 @@ function! s:remove_all_bookmarks() endfunction function! s:startup_load_bookmarks(file) - call LoadBookmarks(g:bookmark_auto_save_file, 1, 0) + call BookmarkLoad(g:bookmark_auto_save_file, 1, 0) call s:add_missing_signs(a:file) endfunction @@ -297,7 +311,7 @@ function! s:set_up_auto_save(file) call s:startup_load_bookmarks(a:file) augroup bm_auto_save autocmd! - autocmd VimLeave * call SaveBookmarks(g:bookmark_auto_save_file, 0) + autocmd VimLeave * call BookmarkSave(g:bookmark_auto_save_file, 0) autocmd BufWinEnter * call s:add_missing_signs(expand(':p')) augroup END endif @@ -315,12 +329,12 @@ function! s:register_mapping(command, shortcut) endif endfunction -call s:register_mapping('ShowAllBookmarks', 'ma') -call s:register_mapping('ToggleBookmark', 'mm') -call s:register_mapping('Annotate', 'mi') -call s:register_mapping('NextBookmark', 'mn') -call s:register_mapping('PrevBookmark', 'mp') -call s:register_mapping('ClearBookmarks', 'mc') -call s:register_mapping('ClearAllBookmarks', 'mx') +call s:register_mapping('BookmarkShowAll', 'ma') +call s:register_mapping('BookmarkToggle', 'mm') +call s:register_mapping('BookmarkAnnotate', 'mi') +call s:register_mapping('BookmarkNext', 'mn') +call s:register_mapping('BookmarkPrev', 'mp') +call s:register_mapping('BookmarkClear', 'mc') +call s:register_mapping('BookmarkClearAll', 'mx') " }}}