endwise で実装されている正規表現パターンを参考に、smartinput のルールを書き起こした。とりあえず Ruby のみ。
" module, class, def, if, unless, case, while, until, for, begin に対応する end を補完
call smartinput#define_rule({
\ 'at': '^\%(.*=\)\?\s*\zs\%(module\|class\|def\|if\|unless\|case\|while\|until\|for\|begin\)\>\%(.*[^.:@$]\<end\>\)\@!.*\%#$',
\ 'char': '<CR>',
\ 'input': '<CR>end<Esc>O',
\ 'filetype': ['ruby'],
\ 'syntax': ['rubyBlock']
\ })
" do に対応する end を補完
call smartinput#define_rule({
\ 'at': '\<do\ze\%(\s*|.*|\)\=\s*\%#$',
\ 'char': '<CR>',
\ 'input': '<CR>end<Esc>O',
\ 'filetype': ['ruby'],
\ 'syntax': ['rubyDoBlock']
\ })