Skip to content

Commit

Permalink
Show deprecation warnings for deleted functions
Browse files Browse the repository at this point in the history
Given that most people use Command-T via a plug-in manages they end up
tracking `HEAD` of `master` and there is no nice way to warn about
upcoming breaking changes (ie. there are no "releases" for these people
and release notes are meaningless; furthermore, people may end up
upgrading without any conscious decision to do so).

So, add functions that show an error when a deprecated function is
called, and then call through to the new function.

Note that depending on the function being called, the screen may be
cleared which means that the user may not see the error. I might add a
prompt here to address this issue because many users may not be aware of
the `:messages` command which can be used to display previous error
messages if they scroll or otherwise move out of view.
  • Loading branch information
wincent committed Dec 26, 2015
1 parent 67c7704 commit afc9442
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions autoload/commandt.vim
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,55 @@ if exists('g:command_t_autoloaded') || &cp
endif
let g:command_t_autoloaded = 1

"
" Deprecated functions (to be removed in 3.0)
"
let s:deprecated = {
\ "commandt#CommandTFlush": "commandt#Flush",
\ "commandt#CommandTLoad": "commandt#Load",
\ "commandt#CommandTShowBufferFinder": "commandt#BufferFinder",
\ "commandt#CommandTShowFileFinder": "commandt#FileFinder",
\ "commandt#CommandTShowJumpFinder": "commandt#JumpFinder",
\ "commandt#CommandTShowMRUFinder": "commandt#MRUFinder",
\ "commandt#CommandTShowTagFinder": "commandt#TagFinder",
\ "CommandTAcceptSelection": "commandt#private#AcceptSelection",
\ "CommandTAcceptSelectionSplit": "commandt#private#AcceptSelectionSplit",
\ "CommandTAcceptSelectionTab": "commandt#private#AcceptSelectionTab",
\ "CommandTAcceptSelectionVSplit": "commandt#private#AcceptSelectionVSplit",
\ "CommandTBackspace": "commandt#private#Backspace",
\ "CommandTCancel": "commandt#private#Cancel",
\ "CommandTClear": "commandt#private#Clear",
\ "CommandTClearPrevWord": "commandt#private#ClearPrevWord",
\ "CommandTCursorEnd": "commandt#private#CursorEnd",
\ "CommandTCursorLeft": "commandt#private#CursorLeft",
\ "CommandTCursorRight": "commandt#private#CursorRight",
\ "CommandTCursorStart": "commandt#private#CursorStart",
\ "CommandTDelete": "commandt#private#Delete",
\ "CommandTHandleKey": "commandt#private#HandleKey",
\ "CommandTListMatches": "commandt#private#ListMatches",
\ "CommandTQuickfix": "commandt#private#Quickfix",
\ "CommandTRefresh": "commandt#private#Refresh",
\ "CommandTSelectNext": "commandt#private#SelectNext",
\ "CommandTSelectPrev": "commandt#private#SelectPrev",
\ "CommandTToggleFocus": "commandt#private#ToggleFocus",
\ }

for [old, new] in items(s:deprecated)
execute
\ "function! " . old . "(...) abort \n" .
\ " echoerr \"" . old . "() is deprecated: use " . new . "() instead\"\n" .
\ " if len(a:000) == 0\n" .
\ " call " . new . "()\n" .
\ " else\n" .
\ " call call(\"" . new . "\", a:000)\n" .
\ " endif\n" .
\ "endfunction"
endfor

"
" Functions
"

function! s:RubyWarning() abort
echohl WarningMsg
echo 'command-t.vim requires Vim to be compiled with Ruby support'
Expand Down

0 comments on commit afc9442

Please sign in to comment.