Просмотр исходного кода

Add abort keyword to the functions

Yegappan Lakshmanan 5 лет назад
Родитель
Сommit
7fccc52c49
2 измененных файлов с 31 добавлено и 31 удалено
  1. 1 1
      doc/mru.txt
  2. 30 30
      plugin/mru.vim

+ 1 - 1
doc/mru.txt

@@ -81,7 +81,7 @@ using the following steps.
    recently used files.
    recently used files.
 
 
 To uninstall the MRU plugin, either use the uninstall command provided by the
 To uninstall the MRU plugin, either use the uninstall command provided by the
-plugin manager or manually remove the plugin/mru.vim, and doc/greplace.txt
+plugin manager or manually remove the plugin/mru.vim, and doc/mru.txt
 files from either the $HOME/.vim or $HOME/vimfiles directory.
 files from either the $HOME/.vim or $HOME/vimfiles directory.
 
 
 ==============================================================================
 ==============================================================================

+ 30 - 30
plugin/mru.vim

@@ -129,7 +129,7 @@ let s:mru_list_locked = 0
 
 
 " MRU_LoadList                          {{{1
 " MRU_LoadList                          {{{1
 " Loads the latest list of file names from the MRU file
 " Loads the latest list of file names from the MRU file
-function! s:MRU_LoadList()
+func! s:MRU_LoadList() abort
     " If the MRU file is present, then load the list of filenames. Otherwise
     " If the MRU file is present, then load the list of filenames. Otherwise
     " start with an empty list.
     " start with an empty list.
     if filereadable(g:MRU_File)
     if filereadable(g:MRU_File)
@@ -151,21 +151,21 @@ function! s:MRU_LoadList()
 
 
     " Refresh the MRU menu with the latest list of filenames
     " Refresh the MRU menu with the latest list of filenames
     call s:MRU_Refresh_Menu()
     call s:MRU_Refresh_Menu()
-endfunction
+endfunc
 
 
 " MRU_SaveList                          {{{1
 " MRU_SaveList                          {{{1
 " Saves the MRU file names to the MRU file
 " Saves the MRU file names to the MRU file
-function! s:MRU_SaveList()
+func! s:MRU_SaveList() abort
     let l = []
     let l = []
     call add(l, '# Most recently edited files in Vim (version 3.0)')
     call add(l, '# Most recently edited files in Vim (version 3.0)')
     call extend(l, s:MRU_files)
     call extend(l, s:MRU_files)
     call writefile(l, g:MRU_File)
     call writefile(l, g:MRU_File)
-endfunction
+endfunc
 
 
 " MRU_AddFile                           {{{1
 " MRU_AddFile                           {{{1
 " Adds a file to the MRU file list
 " Adds a file to the MRU file list
 "   acmd_bufnr - Buffer number of the file to add
 "   acmd_bufnr - Buffer number of the file to add
-function! s:MRU_AddFile(acmd_bufnr)
+func! s:MRU_AddFile(acmd_bufnr) abort
     if s:mru_list_locked
     if s:mru_list_locked
         " MRU list is currently locked
         " MRU list is currently locked
         return
         return
@@ -239,26 +239,26 @@ function! s:MRU_AddFile(acmd_bufnr)
             exe cur_winnr . 'wincmd w'
             exe cur_winnr . 'wincmd w'
         endif
         endif
     endif
     endif
-endfunction
+endfunc
 
 
 " MRU_escape_filename                   {{{1
 " MRU_escape_filename                   {{{1
 " Escape special characters in a filename. Special characters in file names
 " Escape special characters in a filename. Special characters in file names
 " that should be escaped (for security reasons)
 " that should be escaped (for security reasons)
 let s:esc_filename_chars = ' *?[{`$%#"|!<>();&' . "'\t\n"
 let s:esc_filename_chars = ' *?[{`$%#"|!<>();&' . "'\t\n"
-function! s:MRU_escape_filename(fname)
+func! s:MRU_escape_filename(fname) abort
     if exists("*fnameescape")
     if exists("*fnameescape")
         return fnameescape(a:fname)
         return fnameescape(a:fname)
     else
     else
         return escape(a:fname, s:esc_filename_chars)
         return escape(a:fname, s:esc_filename_chars)
     endif
     endif
-endfunction
+endfunc
 
 
 " MRU_Edit_File                         {{{1
 " MRU_Edit_File                         {{{1
 " Edit the specified file
 " Edit the specified file
 "   filename - Name of the file to edit
 "   filename - Name of the file to edit
 "   sanitized - Specifies whether the filename is already escaped for special
 "   sanitized - Specifies whether the filename is already escaped for special
 "   characters or not.
 "   characters or not.
-function! s:MRU_Edit_File(filename, sanitized)
+func! s:MRU_Edit_File(filename, sanitized) abort
     if !a:sanitized
     if !a:sanitized
 	let esc_fname = s:MRU_escape_filename(a:filename)
 	let esc_fname = s:MRU_escape_filename(a:filename)
     else
     else
@@ -290,14 +290,14 @@ function! s:MRU_Edit_File(filename, sanitized)
             exe 'edit ' . esc_fname
             exe 'edit ' . esc_fname
         endif
         endif
     endif
     endif
-endfunction
+endfunc
 
 
 " MRU_Open_File_In_Tab
 " MRU_Open_File_In_Tab
 " Open a file in a tab. If the file is already opened in a tab, jump to the
 " Open a file in a tab. If the file is already opened in a tab, jump to the
 " tab. Otherwise, create a new tab and open the file.
 " tab. Otherwise, create a new tab and open the file.
 "   fname     : Name of the file to open
 "   fname     : Name of the file to open
 "   esc_fname : File name with special characters escaped
 "   esc_fname : File name with special characters escaped
-function! s:MRU_Open_File_In_Tab(fname, esc_fname)
+func! s:MRU_Open_File_In_Tab(fname, esc_fname) abort
     " If the selected file is already open in the current tab or in
     " If the selected file is already open in the current tab or in
     " another tab, jump to it. Otherwise open it in a new tab
     " another tab, jump to it. Otherwise open it in a new tab
     if bufwinnr('^' . a:fname . '$') == -1
     if bufwinnr('^' . a:fname . '$') == -1
@@ -327,7 +327,7 @@ function! s:MRU_Open_File_In_Tab(fname, esc_fname)
     if winnum != winnr()
     if winnum != winnr()
 	exe winnum . 'wincmd w'
 	exe winnum . 'wincmd w'
     endif
     endif
-endfunction
+endfunc
 
 
 " MRU_Window_Edit_File                  {{{1
 " MRU_Window_Edit_File                  {{{1
 "   fname     : Name of the file to edit. May specify single or multiple
 "   fname     : Name of the file to edit. May specify single or multiple
@@ -346,7 +346,7 @@ endfunction
 "               newtab  - Open the file in a new tab. If the file is already
 "               newtab  - Open the file in a new tab. If the file is already
 "                         opened in a tab, then jump to that tab.
 "                         opened in a tab, then jump to that tab.
 "               preview - Open the file in the preview window
 "               preview - Open the file in the preview window
-function! s:MRU_Window_Edit_File(fname, multi, edit_type, open_type)
+func! s:MRU_Window_Edit_File(fname, multi, edit_type, open_type) abort
     let esc_fname = s:MRU_escape_filename(a:fname)
     let esc_fname = s:MRU_escape_filename(a:fname)
 
 
     if a:open_type ==# 'newwin_horiz'
     if a:open_type ==# 'newwin_horiz'
@@ -423,7 +423,7 @@ function! s:MRU_Window_Edit_File(fname, multi, edit_type, open_type)
             endif
             endif
         endif
         endif
     endif
     endif
-endfunction
+endfunc
 
 
 " MRU_Select_File_Cmd                   {{{1
 " MRU_Select_File_Cmd                   {{{1
 " Open a file selected from the MRU window
 " Open a file selected from the MRU window
@@ -437,7 +437,7 @@ endfunction
 "     'newtab' to open the file in a new tab.
 "     'newtab' to open the file in a new tab.
 " If multiple file names are selected using visual mode, then open multiple
 " If multiple file names are selected using visual mode, then open multiple
 " files (either in split windows or tabs)
 " files (either in split windows or tabs)
-function! s:MRU_Select_File_Cmd(opt) range
+func! s:MRU_Select_File_Cmd(opt) range abort
     let [edit_type, open_type] = split(a:opt, ',')
     let [edit_type, open_type] = split(a:opt, ',')
 
 
     let fnames = getline(a:firstline, a:lastline)
     let fnames = getline(a:firstline, a:lastline)
@@ -465,21 +465,21 @@ function! s:MRU_Select_File_Cmd(opt) range
             let multi = 1
             let multi = 1
         endif
         endif
     endfor
     endfor
-endfunction
+endfunc
 
 
 " MRU_Warn_Msg                          {{{1
 " MRU_Warn_Msg                          {{{1
 " Display a warning message
 " Display a warning message
-function! s:MRU_Warn_Msg(msg)
+func! s:MRU_Warn_Msg(msg) abort
     echohl WarningMsg
     echohl WarningMsg
     echo a:msg
     echo a:msg
     echohl None
     echohl None
-endfunction
+endfunc
 
 
 " MRU_Open_Window                       {{{1
 " MRU_Open_Window                       {{{1
 " Display the Most Recently Used file list in a temporary window.
 " Display the Most Recently Used file list in a temporary window.
 " If the optional argument is supplied, then it specifies the pattern of files
 " If the optional argument is supplied, then it specifies the pattern of files
 " to selectively display in the MRU window.
 " to selectively display in the MRU window.
-function! s:MRU_Open_Window(...)
+func! s:MRU_Open_Window(...) abort
 
 
     " Load the latest MRU file list
     " Load the latest MRU file list
     call s:MRU_LoadList()
     call s:MRU_LoadList()
@@ -650,11 +650,11 @@ function! s:MRU_Open_Window(...)
     endif
     endif
 
 
     setlocal nomodifiable
     setlocal nomodifiable
-endfunction
+endfunc
 
 
 " MRU_Complete                          {{{1
 " MRU_Complete                          {{{1
 " Command-line completion function used by :MRU command
 " Command-line completion function used by :MRU command
-function! s:MRU_Complete(ArgLead, CmdLine, CursorPos)
+func! s:MRU_Complete(ArgLead, CmdLine, CursorPos) abort
     if a:ArgLead == ''
     if a:ArgLead == ''
         " Return the complete list of MRU files
         " Return the complete list of MRU files
         return s:MRU_files
         return s:MRU_files
@@ -662,12 +662,12 @@ function! s:MRU_Complete(ArgLead, CmdLine, CursorPos)
         " Return only the files matching the specified pattern
         " Return only the files matching the specified pattern
         return filter(copy(s:MRU_files), 'v:val =~? a:ArgLead')
         return filter(copy(s:MRU_files), 'v:val =~? a:ArgLead')
     endif
     endif
-endfunction
+endfunc
 
 
 " MRU_Cmd                               {{{1
 " MRU_Cmd                               {{{1
 " Function to handle the MRU command
 " Function to handle the MRU command
 "   pat - File name pattern passed to the MRU command
 "   pat - File name pattern passed to the MRU command
-function! s:MRU_Cmd(pat)
+func! s:MRU_Cmd(pat) abort
     if a:pat == ''
     if a:pat == ''
         " No arguments specified. Open the MRU window
         " No arguments specified. Open the MRU window
         call s:MRU_Open_Window()
         call s:MRU_Open_Window()
@@ -730,13 +730,13 @@ function! s:MRU_Cmd(pat)
     endif
     endif
 
 
     call s:MRU_Open_Window(a:pat)
     call s:MRU_Open_Window(a:pat)
-endfunction
+endfunc
 
 
 " MRU_add_files_to_menu                 {{{1
 " MRU_add_files_to_menu                 {{{1
 " Adds a list of files to the "Recent Files" sub menu under the "File" menu.
 " Adds a list of files to the "Recent Files" sub menu under the "File" menu.
 "   prefix - Prefix to use for each of the menu entries
 "   prefix - Prefix to use for each of the menu entries
 "   file_list - List of file names to add to the menu
 "   file_list - List of file names to add to the menu
-function! s:MRU_add_files_to_menu(prefix, file_list)
+func! s:MRU_add_files_to_menu(prefix, file_list) abort
     for fname in a:file_list
     for fname in a:file_list
         " Escape special characters in the filename
         " Escape special characters in the filename
         let esc_fname = escape(fnamemodify(fname, ':t'), ".\\" .
         let esc_fname = escape(fnamemodify(fname, ':t'), ".\\" .
@@ -774,11 +774,11 @@ function! s:MRU_add_files_to_menu(prefix, file_list)
                     \ " :call <SID>MRU_Edit_File('" . esc_mfname . "', 1)<CR>"
                     \ " :call <SID>MRU_Edit_File('" . esc_mfname . "', 1)<CR>"
 	exe 'tmenu ' . menu_path . ' Edit file ' . esc_mfname
 	exe 'tmenu ' . menu_path . ' Edit file ' . esc_mfname
     endfor
     endfor
-endfunction
+endfunc
 
 
 " MRU_Refresh_Menu                      {{{1
 " MRU_Refresh_Menu                      {{{1
 " Refresh the MRU menu
 " Refresh the MRU menu
-function! s:MRU_Refresh_Menu()
+func! s:MRU_Refresh_Menu() abort
     if !has('menu') || !g:MRU_Add_Menu
     if !has('menu') || !g:MRU_Add_Menu
         " No support for menus
         " No support for menus
         return
         return
@@ -833,7 +833,7 @@ function! s:MRU_Refresh_Menu()
 
 
     " Restore the previous cpoptions settings
     " Restore the previous cpoptions settings
     let &cpoptions = old_cpoptions
     let &cpoptions = old_cpoptions
-endfunction
+endfunc
 
 
 " Load the MRU list on plugin startup
 " Load the MRU list on plugin startup
 call s:MRU_LoadList()
 call s:MRU_LoadList()
@@ -857,11 +857,11 @@ command! -nargs=? -complete=customlist,s:MRU_Complete Mru
             \ call s:MRU_Cmd(<q-args>)
             \ call s:MRU_Cmd(<q-args>)
 
 
 " FZF (fuzzy finder) integration
 " FZF (fuzzy finder) integration
-func s:MRU_FZF_EditFile(fname)
+func s:MRU_FZF_EditFile(fname) abort
     call s:MRU_Window_Edit_File(a:fname, 0, 'edit', 'useopen')
     call s:MRU_Window_Edit_File(a:fname, 0, 'edit', 'useopen')
 endfunc
 endfunc
 
 
-func s:MRU_FZF_Run()
+func s:MRU_FZF_Run() abort
     if !exists('*fzf#run')
     if !exists('*fzf#run')
 	call s:MRU_Warn_Msg('FZF plugin is not present')
 	call s:MRU_Warn_Msg('FZF plugin is not present')
 	return
 	return