mattn/vim-gist

:Gist should copy posted URL to "+, not ""

lilyball opened this issue · 5 comments

When I run :Gist, it seems to yank the pasted URL into "". For reference, I have not defined g:gist_clip_command. From reading the code, it appears to yank into "" if has('unix') && !has('xterm_clipboard'). This is a bad condition. I'm running MacVim, which maps "+ (and "*) to the system clipboard, similar to xterm, but MacVim does not define the +xterm_clipboard feature (possibly because it does not automatically copy selections to "*, because OS X does not have a selection clipboard).

I'd recommend changing this to just being has('clipboard'), which is the condition you use in s:GistGet to determine if you should yank to "+. This should be sufficient to determine if there is a "+ register, and if there is, then you should be yanking to it.

do you mean following?

        if exists('g:gist_clip_command')
          call system(g:gist_clip_command, url)
        elseif (has('unix') && !has('xterm_clipboard')) || !has("clipboard")
          let @* = url
        else
          let @+ = url
        endif

Yanking to @+ is perfectly fine under these circumstances. In MacVim, @+ and @* are the exact same register, made available under both names. And in fact I think the code you pasted there is wrong if !has('clipboard'), because the @* register shouldn't exist at all in that case (the /usr/bin/vim that OS X ships with does not have the clipboard feature and does not have a @* (or @+) register at all).

In s:GistGet() you have

        if exists('g:gist_clip_command')
          exec 'silent w !'.g:gist_clip_command
        elseif has('clipboard')
          silent! %yank +
        else
          %yank
        endif

I think that's the right logic there. You should just update gist#Gist() to say

        if exists('g:gist_clip_command')
          call system(g:gist_clip_command, url)
        elseif has('clipboard')
          let @+ = url
        else
          let @" = url
        endif

Ah, do you mean that gist.vim should copy URL instead of contents?

If you can, could you please send me a pull-request?

PR submitted as #189.