Skip to content

Instantly share code, notes, and snippets.

@mmisono
Created September 18, 2010 17:59
Show Gist options
  • Save mmisono/585897 to your computer and use it in GitHub Desktop.
Save mmisono/585897 to your computer and use it in GitHub Desktop.
function! s:aojproblem(id,lang)
let base_url = "http://rose.u-aizu.ac.jp/onlinejudge/ProblemSet/description.jsp?id="
let url = '"' . base_url.printf("%04d",a:id) . "&lang=" . a:lang . '"'
let winnum = bufwinnr(bufnr('AOJ:Problem'))
if winnum != -1
if winnum != bufwinnr('%')
exe "normal \<c-w>".winnum."w"
endif
setl modifiable
setl noreadonly
normal ggdG
else
exec 'silent top split AOJ:Problem'
endif
exec "silent! r! w3m -dump " . url
normal gg
call search("\\[submitIcon]")
normal jdgg
silent! g/Submit : Statistics/d
silent! %s/\n\n\n//g
silent! nohl
setl nomodified
setl nomodifiable
setl readonly
setl bufhidden=delete
endfunction
command! -nargs=1 AOJProblem call s:aojproblem(<args>,"en")
command! -nargs=1 AOJProblemJa call s:aojproblem(<args>,"jp")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment