Browse Source

Refer to the MRU_File global variable only when loading the plugin. Use a script local varaiable after that.

Yegappan Lakshmanan 4 years ago
parent
commit
49934eacb5
1 changed files with 9 additions and 9 deletions
  1. 9 9
      plugin/mru.vim

+ 9 - 9
plugin/mru.vim

@@ -55,20 +55,20 @@ if !exists('MRU_Auto_Close')
   let MRU_Auto_Close = 1
 endif
 
-if !exists('MRU_File')
+if !exists('g:MRU_File')
   if has('unix') || has('macunix')
-    let MRU_File = $HOME . '/.vim_mru_files'
+    let s:MRU_File = $HOME . '/.vim_mru_files'
   else
-    let MRU_File = $VIM . '/_vim_mru_files'
+    let s:MRU_File = $VIM . '/_vim_mru_files'
     if has('win32')
       " MS-Windows
       if $USERPROFILE != ''
-	let MRU_File = $USERPROFILE . '\_vim_mru_files'
+	let s:MRU_File = $USERPROFILE . '\_vim_mru_files'
       endif
     endif
   endif
 else
-  let MRU_File=expand(MRU_File)
+  let s:MRU_File = expand(g:MRU_File)
 endif
 
 " Option for enabling or disabling the MRU menu
@@ -143,8 +143,8 @@ let s:mru_list_locked = 0
 func! s:MRU_LoadList() abort
   " If the MRU file is present, then load the list of filenames. Otherwise
   " start with an empty list.
-  if filereadable(g:MRU_File)
-    let s:MRU_files = readfile(g:MRU_File)
+  if filereadable(s:MRU_File)
+    let s:MRU_files = readfile(s:MRU_File)
     if s:MRU_files[0] =~# '^\s*" Most recently edited files in Vim'
       " Generated by the previous version of the MRU plugin.
       " Discard the list.
@@ -170,7 +170,7 @@ func! s:MRU_SaveList() abort
   let l = []
   call add(l, '# Most recently edited files in Vim (version 3.0)')
   call extend(l, s:MRU_files)
-  call writefile(l, g:MRU_File)
+  call writefile(l, s:MRU_File)
 endfunc
 
 " MRU_AddFile                           {{{1
@@ -895,7 +895,7 @@ func! s:MRU_Refresh_Menu() abort
   anoremenu <silent> &File.&Recent\ Files.Refresh\ list
 	\ :call <SID>MRU_LoadList()<CR>
   exe 'tmenu File.&Recent\ Files.Refresh\ list Reload the MRU file list from '
-	\ . s:MRU_escape_filename(g:MRU_File)
+	\ . s:MRU_escape_filename(s:MRU_File)
   anoremenu File.&Recent\ Files.-SEP1-           :
 
   " Add the filenames in the MRU list to the menu