Skip to content

Commit 6d52a55

Browse files
committed
Mark deprecated commands obsolete
1 parent ee6fd5f commit 6d52a55

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

autoload/rails.vim

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -522,8 +522,7 @@ function! s:warn(str) abort
522522
endfunction
523523

524524
function! s:deprecate(old, new, ...) abort
525-
call s:warn(a:old . ' is deprecated in favor of ' . a:new)
526-
return a:0 ? a:1 : ''
525+
return 'echoerr ' . string(a:old . ' is obsolete. Use ' . a:new . ' instead.')
527526
endfunction
528527

529528
function! s:error(str) abort
@@ -1000,7 +999,7 @@ function! s:BufCommands()
1000999
call s:BufScriptWrappers()
10011000
command! -buffer -bar -nargs=* -bang Rabbrev :call s:Abbrev(<bang>0,<f-args>)
10021001
command! -buffer -bar -nargs=? -bang -count -complete=customlist,rails#complete_rake Rake :call s:Rake(<bang>0,!<count> && <line1> ? -1 : <count>,<q-args>)
1003-
command! -buffer -bar -nargs=? -bang -range -complete=customlist,s:Complete_preview Rpreview :exe s:deprecate(':Rpreview', ':Preview')|call s:Preview(<bang>0,<line1>,<q-args>)
1002+
command! -buffer -bar -nargs=? -bang -range -complete=customlist,s:Complete_preview Rpreview :exe s:deprecate(':Rpreview', ':Preview', ':Preview<bang> '.<q-args>))
10041003
command! -buffer -bar -nargs=? -bang -range -complete=customlist,s:Complete_preview Rbrowse :call s:Preview(<bang>0,<line1>,<q-args>)
10051004
command! -buffer -bar -nargs=? -bang -range -complete=customlist,s:Complete_preview Preview :call s:Preview(<bang>0,<line1>,<q-args>)
10061005
command! -buffer -bar -nargs=? -bang -complete=customlist,s:Complete_log Rlog exe s:deprecate(':Rlog', ':Clog', <bang>0 ? 'Clog<bang> '.<q-args> : s:Plog(0, <q-args>))
@@ -1014,15 +1013,15 @@ function! s:BufCommands()
10141013
let ext = expand("%:e")
10151014
if RailsFilePath() =~ '\<app/views/'
10161015
" TODO: complete controller names with trailing slashes here
1017-
command! -buffer -bar -bang -nargs=? -range -complete=customlist,s:controllerList Rextract :exe s:deprecate(':Rextract', ':Extract', '<line1>,<line2>Extract<bang> '.<q-args>)
10181016
command! -buffer -bar -bang -nargs=? -range -complete=customlist,s:controllerList Extract :<line1>,<line2>call s:Extract(<bang>0,'<mods>',<f-args>)
10191017
elseif rails#buffer().name() =~# '^app/helpers/.*\.rb$'
1020-
command! -buffer -bar -bang -nargs=1 -range Rextract :<line1>,<line2>call s:RubyExtract(<bang>0, '<mods>', 'app/helpers', [], s:sub(<f-args>, '_helper$|Helper$|$', '_helper'))
10211018
command! -buffer -bar -bang -nargs=1 -range Extract :<line1>,<line2>call s:RubyExtract(<bang>0, '<mods>', 'app/helpers', [], s:sub(<f-args>, '_helper$|Helper$|$', '_helper'))
10221019
elseif rails#buffer().name() =~# '^app/\w\+/.*\.rb$'
1023-
command! -buffer -bar -bang -nargs=1 -range Rextract :<line1>,<line2>call s:RubyExtract(<bang>0, '<mods>', matchstr(rails#buffer().name(), '^app/\w\+/').'concerns', [' extend ActiveSupport::Concern', ''], <f-args>)
10241020
command! -buffer -bar -bang -nargs=1 -range Extract :<line1>,<line2>call s:RubyExtract(<bang>0, '<mods>', matchstr(rails#buffer().name(), '^app/\w\+/').'concerns', [' extend ActiveSupport::Concern', ''], <f-args>)
10251021
endif
1022+
if exists(':Extract') == 2
1023+
command! -buffer -bar -bang -nargs=? -range -complete=customlist,s:controllerList Rextract :exe s:deprecate(':Rextract', ':Extract', '<line1>,<line2>Extract<bang> '.<q-args>)
1024+
endif
10261025
if RailsFilePath() =~ '\<db/migrate/.*\.rb$'
10271026
command! -buffer -bar Rinvert :call s:Invert(<bang>0)
10281027
endif
@@ -1677,13 +1676,13 @@ endfunction
16771676
function! s:BufScriptWrappers()
16781677
command! -buffer -bang -bar -nargs=? -complete=customlist,s:Complete_script Rscript :execute s:deprecate(':Rscript', ':Rails', 'Rails<bang>' . empty(<q-args>) ? 'console' : <q-args>)
16791678
command! -buffer -bang -bar -nargs=* -complete=customlist,s:Complete_environments Console :Rails<bang> console <args>
1680-
command! -buffer -bang -bar -nargs=* -complete=customlist,s:Complete_generate Rgenerate :execute s:deprecate(':Rgenerate', ':Generate', rails#app().generator_command(<bang>0,'<mods>','generate',<f-args>))
1679+
command! -buffer -bang -bar -nargs=* -complete=customlist,s:Complete_generate Rgenerate :execute s:deprecate(':Rgenerate', ':Generate', ':Generate<bang> '.<q-args>)
16811680
command! -buffer -bang -bar -nargs=* -complete=customlist,s:Complete_generate Generate :execute rails#app().generator_command(<bang>0,'<mods>','generate',<f-args>)
1682-
command! -buffer -bar -nargs=* -complete=customlist,s:Complete_destroy Rdestroy :execute s:deprecate(':Rdestroy', ':Destroy', rails#app().generator_command(1,'<mods>','destroy',<f-args>))
1681+
command! -buffer -bar -nargs=* -complete=customlist,s:Complete_destroy Rdestroy :execute s:deprecate(':Rdestroy', ':Destroy', ':Destroy<bang> '.<q-args>)
16831682
command! -buffer -bar -nargs=* -complete=customlist,s:Complete_destroy Destroy :execute rails#app().generator_command(1,'<mods>','destroy',<f-args>)
1684-
command! -buffer -bar -nargs=? -bang -complete=customlist,s:Complete_server Rserver :execute s:deprecate(':Rserver', ':Server', rails#app().server_command(<bang>0, 1, <q-args>))
1683+
command! -buffer -bar -nargs=? -bang -complete=customlist,s:Complete_server Rserver :execute s:deprecate(':Rserver', ':Server', ':Server<bang> '.<q-args>)
16851684
command! -buffer -bar -nargs=? -bang -complete=customlist,s:Complete_server Server :execute rails#app().server_command(0, <bang>0, <q-args>)
1686-
command! -buffer -bang -nargs=? -range=0 -complete=customlist,s:Complete_edit Rrunner :execute s:deprecate(':Rrunner', ':Runner', rails#buffer().runner_command(<bang>0, <count>?<line1>:0, <q-args>))
1685+
command! -buffer -bang -nargs=? -range=0 -complete=customlist,s:Complete_edit Rrunner :execute s:deprecate(':Rrunner', ':Runner', ':Runner<bang> '.<q-args>)
16871686
command! -buffer -bang -nargs=? -range=0 -complete=customlist,s:Complete_edit Runner :execute rails#buffer().runner_command(<bang>0, <count>?<line1>:0, <q-args>)
16881687
command! -buffer -nargs=1 -range=0 -complete=customlist,s:Complete_ruby Rp :execute rails#app().output_command(<count>==<line2>?<count>:-1, 'p begin '.<q-args>.' end')
16891688
command! -buffer -nargs=1 -range=0 -complete=customlist,s:Complete_ruby Rpp :execute rails#app().output_command(<count>==<line2>?<count>:-1, 'require %{pp}; pp begin '.<q-args>.' end')
@@ -3137,14 +3136,14 @@ function! s:projection_pairs(options)
31373136
return pairs
31383137
endfunction
31393138

3140-
function! s:r_warning(cmd) abort
3139+
function! s:r_error(cmd, impl) abort
31413140
let cmd = matchstr(a:cmd, '\w\+$')
31423141
if cmd =~# 'R\|^$'
31433142
let old = s:sub(cmd, '^$', 'R')
31443143
let instead = s:sub(s:sub(cmd, '^R', ''), '^$', 'E')
3145-
return '|echohl WarningMsg|echomsg ":'.old.' navigation commands are deprecated. Use :'.instead.' commands instead."|echohl None'
3144+
return 'echoerr ":'.old.' navigation commands are obsolete. Use :'.instead.' commands instead."'
31463145
endif
3147-
return ''
3146+
return a:impl
31483147
endfunction
31493148

31503149
function! s:readable_open_command(cmd, argument, name, projections) dict abort
@@ -3178,7 +3177,7 @@ function! s:readable_open_command(cmd, argument, name, projections) dict abort
31783177
endif
31793178
if !empty(file) && self.app().has_path(file)
31803179
let file = fnamemodify(self.app().path(file), ':.')
3181-
return cmd . ' ' . s:jumpargs(file, djump) . s:r_warning(a:cmd)
3180+
return s:r_error(a:cmd, cmd . ' ' . s:jumpargs(file, djump))
31823181
endif
31833182
endfor
31843183
if empty(argument)
@@ -3214,9 +3213,9 @@ function! s:readable_open_command(cmd, argument, name, projections) dict abort
32143213
call map(template, 's:expand_placeholders(v:val, ph)')
32153214
call map(template, 's:gsub(v:val, "\t", " ")')
32163215
let file = fnamemodify(simplify(file), ':.')
3217-
return cmd . ' ' . s:fnameescape(file) . '|call setline(1, '.string(template).')' . '|set nomod'.s:r_warning(a:cmd)
3216+
return s:r_error(a:cmd, cmd . ' ' . s:fnameescape(file) . '|call setline(1, '.string(template).')' . '|set nomod')
32183217
else
3219-
return cmd . ' +AD ' . s:fnameescape(file) . s:r_warning(a:cmd)
3218+
return s:r_error(a:cmd, cmd . ' +AD ' . s:fnameescape(file))
32203219
endif
32213220
endif
32223221
endfor

0 commit comments

Comments
 (0)