diff --git a/README.mkd b/README.mkd index 5c385cd..5d18bb0 100644 --- a/README.mkd +++ b/README.mkd @@ -142,6 +142,10 @@ If you want your gist to be private by default: let g:gist_post_private = 1 +If you want your gist to be anonymous by default: + + let g:gist_post_anonymous = 1 + If you want to manipulate multiple files in a gist: let g:gist_get_multiplefile = 1 @@ -240,3 +244,5 @@ list of ["Authorized applications" on GitHub's "Account Settings" page][uas]. [uas]: https://github.com/settings/applications + +**Note:** the username is optional if you only send anonymous gists. diff --git a/autoload/gist.vim b/autoload/gist.vim index eb2203f..299dcfe 100644 --- a/autoload/gist.vim +++ b/autoload/gist.vim @@ -660,10 +660,6 @@ endfunction function! gist#Gist(count, line1, line2, ...) abort redraw - if strlen(g:github_user) == 0 - echohl ErrorMsg | echomsg "You don't have github account. read ':help gist-vim-setup'." | echohl None - return - endif let bufname = bufname("%") " find GistID: in content , then we should just update let gistid = '' @@ -675,10 +671,14 @@ function! gist#Gist(count, line1, line2, ...) abort let clipboard = 0 let deletepost = 0 let editpost = 0 - let anonymous = 0 + let anonymous = get(g:, 'gist_post_anonymous', 0) let openbrowser = 0 let listmx = '^\%(-l\|--list\)\s*\([^\s]\+\)\?$' let bufnamemx = '^' . s:bufprefix .'\(\zs[0-9a-f]\+\ze\|\zs[0-9a-f]\+\ze[/\\].*\)$' + if strlen(g:github_user) == 0 && anonymous == 0 + echohl ErrorMsg | echomsg "You don't have github account. read ':help gist-vim-setup'." | echohl None + return + endif if bufname =~ bufnamemx let gistidbuf = matchstr(bufname, bufnamemx) elseif exists('b:gist') && has_key(b:gist, 'id') diff --git a/doc/gist-vim.txt b/doc/gist-vim.txt index a02f0d9..9b1504e 100644 --- a/doc/gist-vim.txt +++ b/doc/gist-vim.txt @@ -150,7 +150,10 @@ If you want to show your private gists with ":Gist -l": > If you want your gist to be private by default: > let g:gist_post_private = 1 +< +If you want your gist to be anonymous by default: > + let g:gist_post_anonymous = 1 < If you want to edit all files for gists containing more than one: > @@ -270,6 +273,8 @@ Then, add following into your ~/.vimrc < This is not secure at all, so strongly discouraged. +NOTE: the username is optional if you only send anonymous gists. + ============================================================================== FAQ *gist-vim-faq*