Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
lilyball opened this issue Jun 6, 2015 · 5 comments
Closed

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

lilyball opened this issue Jun 6, 2015 · 5 comments

Comments

@lilyball
Copy link
Contributor

lilyball commented Jun 6, 2015

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.

@mattn
Copy link
Owner

mattn commented Jun 7, 2015

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

@lilyball
Copy link
Contributor Author

lilyball commented Jun 8, 2015

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

@mattn
Copy link
Owner

mattn commented Jun 8, 2015

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

@mattn
Copy link
Owner

mattn commented Jun 8, 2015

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

@lilyball
Copy link
Contributor Author

lilyball commented Jun 8, 2015

PR submitted as #189.

@mattn mattn closed this as completed in #189 Jun 8, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants