Permalink
Browse files

add doc

  • Loading branch information...
1 parent 6a62fac commit 7b41379642701fbe33f0a149ac0d7bdbcaea2093 @c9s c9s committed Dec 11, 2009
Showing with 23 additions and 4 deletions.
  1. +23 −4 gist.vim
View
@@ -396,21 +396,40 @@ function! s:GistDelete(user, token, gistid)
endif
endfunction
+" GistPost function:
+" Post new gist to github
+" if there is an embedded gist url or gist id, then just update it.
+"
+" embedded gist url format:
+"
+" Gist: http://gist.github.com/123123
+"
+" embedded gist id format:
+"
+" GistID: 123123
+"
function! s:GistPost(user, token, content, private)
" find GistID: in content , then we should just update
for l in split( a:content , "\n" )
- if l =~ 'GistID:'
+ if l =~ '\<GistID:'
let gistid = matchstr( l , '\(GistID:\s*\)\@<=[0-9]\+')
- if strlen(gistid) == 0
- let gistid = matchstr( l , '\(GistID:\s*http://gist.github.com/\)\@<=[0-9]\+')
- endif
if strlen(gistid) == 0
echohl WarningMsg | echo "GistID error" | echohl None
return
endif
+ echo "Found GistID: " . gistid
+ cal s:GistUpdate( a:user , a:token , a:content , gistid , '' )
+ return
+ elseif l =~ '\<Gist:'
+ let gistid = matchstr( l , '\(GistID:\s*http://gist.github.com/\)\@<=[0-9]\+')
+
+ if strlen(gistid) == 0
+ echohl WarningMsg | echo "GistID error" | echohl None
+ return
+ endif
echo "Found GistID: " . gistid
cal s:GistUpdate( a:user , a:token , a:content , gistid , '' )

0 comments on commit 7b41379

Please sign in to comment.