Created
November 8, 2012 20:12
-
-
Save gavinwahl/4041240 to your computer and use it in GitHub Desktop.
python super call snippet
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
snippet sup | |
super(`GetCurrentPythonClass()`, `GetFirstPythonArg()`).`GetCurrentPythonMethod()`(${1:`GetCurrentPythonArgs()`})${2} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function! GetCurrentPythonClass() | |
call search('^\s*class \ze\S\+\s*(', 'sbe') | |
let class = expand('<cword>') | |
normal '' | |
return class | |
endfunction | |
function! GetCurrentPythonMethod() | |
call search('^\s*def ', 'sbe') | |
let method = expand('<cword>') | |
normal '' | |
return method | |
endfunction | |
function! GetFirstPythonArg() | |
call search('^\s*def \S\+(', 'sbe') | |
let method = expand('<cword>') | |
normal '' | |
return method | |
endfunction | |
function! GetCurrentPythonArgs() | |
let line_number = search('^\s*def[^(]\+([^,]*,\?', 'sbe') | |
echo line_number | |
let args = matchstr(getline(line_number), '^\s*def[^(]\+([^,]\+,\s*\zs.*\ze):$') | |
let args = substitute(args, '\s*=[^,]\+', '', 'g') | |
normal '' | |
return args | |
endfunction |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment