Created
March 1, 2012 17:40
-
-
Save oxyc/1951604 to your computer and use it in GitHub Desktop.
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! DrupalImplementsComment () | |
| let filename = bufname("%") | |
| let dot = stridx(filename, ".") | |
| let module = strpart(filename, 0, dot) | |
| let current_line = getline(".") | |
| let hook_idx = matchend(current_line, "function " . module . "_") | |
| if !empty(module) && hook_idx != -1 | |
| let hook_length = match(current_line, "(") - hook_idx | |
| let hook_name = strpart(current_line, hook_idx, hook_length) | |
| call DoxygenComment ("Implements hook_" . hook_name . "().") | |
| else | |
| call DoxygenComment () | |
| endif | |
| endfunction | |
| function! DoxygenComment (...) | |
| set paste | |
| let message = (a:0 > 0) ? a:1 : '' | |
| exe "normal! O/**\<CR>" | |
| \ . " * " . message . "\<CR>" | |
| \ . " */\<Esc>" | |
| if empty(message) | |
| -1 | startinsert! | |
| else | |
| +1 | |
| endif | |
| set nopaste | |
| endfunction | |
| noremap <leader>d :call DoxygenComment ()<CR> | |
| noremap <leader>c :call DrupalImplementsComment ()<CR> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment