Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add doc

  • Loading branch information...
commit 7b41379642701fbe33f0a149ac0d7bdbcaea2093 1 parent 6a62fac
@c9s c9s authored
Showing with 23 additions and 4 deletions.
  1. +23 −4 gist.vim
View
27 gist.vim
@@ -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 , '' )
Please sign in to comment.
Something went wrong with that request. Please try again.