Skip to content

Commit

Permalink
Use tlib#file#Edit(); require tlib 1.14; version
Browse files Browse the repository at this point in the history
  • Loading branch information
tomtom committed May 20, 2015
1 parent c691a82 commit 323688e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 64 deletions.
60 changes: 2 additions & 58 deletions autoload/tmru.vim
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim])
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
" @Created: 2011-04-10.
" @Last Change: 2014-12-10.
" @Last Change: 2015-05-20.
" @Revision: 330


Expand Down Expand Up @@ -68,29 +68,13 @@ if !exists('g:tmru_select_filter')
endif


if !exists('g:tmru#drop')
" If true, use |:drop| to edit loaded buffers (only available with GUI).
let g:tmru#drop = has('gui') "{{{2
endif


if !exists('g:tmru#auto_remove_unreadable')
" If true, automatically remove unreadable files from the mru list,
" when trying to edit them.
let g:tmru#auto_remove_unreadable = 1 "{{{2
endif


if !exists('g:tmru#use_tabs')
let g:tmru#use_tabs = 0 "{{{2
endif


if !exists('g:tmru#edit_cmds')
let g:tmru#edit_cmds = g:tmru#use_tabs ? {'buffer': 'tab split | buffer', 'edit': 'tabedit'} : {} "{{{2
endif


function! tmru#SelectMRU()
" TLogDBG "SelectMRU#1"
let tmruobj = TmruObj()
Expand Down Expand Up @@ -148,7 +132,7 @@ function! tmru#EditFiles(filenames, ...) "{{{3
let remove_files = []
for bf in a:filenames
" TLogVAR bf
if !tmru#Edit(bf)
if !tlib#file#Edit(bf)
call add(remove_files, bf)
endif
endfor
Expand All @@ -160,46 +144,6 @@ function! tmru#EditFiles(filenames, ...) "{{{3
endf


" Return 0 if the file isn't readable/doesn't exist.
" Otherwise return 1.
function! tmru#Edit(filename) "{{{3
let filename = fnamemodify(a:filename, ':p')
if filename == expand('%:p')
return 1
else
let bn = bufnr(filename)
" TLogVAR bn
if bn != -1 && buflisted(bn)
if g:tmru#drop
exec get(g:tmru#edit_cmds, 'drop', 'drop') fnameescape(filename)
else
exec get(g:tmru#edit_cmds, 'buffer', 'buffer') bn
endif
return 1
elseif filereadable(filename)
try
let file = tlib#arg#Ex(filename)
" TLogVAR file
exec get(g:tmru#edit_cmds, 'edit', 'edit') file
catch /E325/
" swap file exists, let the user handle it
catch
echohl error
echom v:exception
echohl NONE
endtry
return 1
else
echom "TMRU: File not readable: " . filename
if filename != a:filename
echom "TMRU: original filename: " . a:filename
endif
endif
endif
return 0
endf


function! s:RemoveItems(filenames, ...) "{{{3
" TLogVAR a:filenames
let modified_list = 0
Expand Down
11 changes: 5 additions & 6 deletions plugin/tmru.vim
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,18 @@
" @Author: Tom Link (micathom AT gmail com?subject=vim-tlib-mru)
" @Website: http://www.vim.org/account/profile.php?user_id=4037
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
" @Created: 2007-04-13.
" @Last Change: 2014-12-16.
" @Last Change: 2015-05-20.
" @Revision: 1043
" GetLatestVimScripts: 1864 1 tmru.vim

if &cp || exists("loaded_tmru")
finish
endif
if !exists('loaded_tlib') || loaded_tlib < 106
echoerr "tlib >= 1.06 is required"
if !exists('loaded_tlib') || loaded_tlib < 114
echoerr "tlib >= 1.14 is required"
finish
endif
let loaded_tmru = 103
let loaded_tmru = 104

let s:save_cpo = &cpo
set cpo&vim
Expand Down Expand Up @@ -369,7 +368,7 @@ function! s:BuildMenu(initial) "{{{3
for item in mru
let e = item[0]
let me = escape(e, '.\ ')
exec 'amenu '. g:tmruMenu . me .' :call tmru#Edit('. string(e) .')<cr>'
exec 'amenu '. g:tmruMenu . me .' :call tlib#file#Edit('. string(e) .')<cr>'
endfor
endif
endf
Expand Down

0 comments on commit 323688e

Please sign in to comment.