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

Make an RStudio add in #28

Closed
hadley opened this issue Jan 19, 2016 · 7 comments
Closed

Make an RStudio add in #28

hadley opened this issue Jan 19, 2016 · 7 comments

Comments

@hadley
Copy link
Member

hadley commented Jan 19, 2016

http://rstudio.github.io/rstudioaddins/

I think the nicest implementation would replace the currently selected code with the reprexed version. To make it work if called multiple times, you could first strip any lines that start with #' (maybe reprex already does this?)

@jennybc
Copy link
Member

jennybc commented Jan 20, 2016

By "strip any lines that start with #'", do you mean what I mean in #27? I.e. be able to cycle between just the code and the reprexed version of it? I think I also have to strip off any enclosing backtick lines and, in the case of SO, the <!-- language: lang-r --> line, yes?

Are you saying to do this instead of or in addition to putting the reprexed version on the clipboard?

@hadley
Copy link
Member Author

hadley commented Jan 20, 2016

I was thinking of replacing the currently selected code instead of putting it on the clipboard, so it wouldn't have the backticks.

jennybc pushed a commit that referenced this issue Dec 29, 2016
* init addin

* paneViewer() --> dialogViewer()

* something that sort of works

* Better description

* Something much simpler that basically works
@jennybc
Copy link
Member

jennybc commented Dec 29, 2016

If you have occasion to use reprex, you could re-install and try the draft addin.

I am still NOT replacing the reprex source with the output, although I experimented with that and could still do it. I now have the ability to do round trips (code --> rendered reprex --> code), which would come up.

Overwriting or augmenting the source with the reprexed result caused me more grief than joy, but I think we must use this thing differently? I like seeing the html preview and having the GitHub-flavored markdown on the clipboard.

I think what you want ("strip lines that start with #'", no backticks, etc.) might be related to #32, which is about going from .R to .R but with commented-out output?

@MilesMcBain
Copy link

MilesMcBain commented Jan 5, 2017

Another reason to go with Hadley's suggestion is that reprex would work nicely on RStudio server.

It currently gives an error from clipr: "Error: Clipboard on X11 requires that the DISPLAY envvar be configured."

I think this means that if I exported DISPLAY in my .profile and use clipr::write_clip() I might be able to then build the reprex and then obtain the result using clipr::read_clip(). A bit convoluted though.

@jennybc
Copy link
Member

jennybc commented Jan 5, 2017

Thanks @MilesMcBain this is a helpful use case, when it would be nice for the rendered reprex to be inserted into or on top of the current file.

As for DISPLAY, yes, that must be configured for clipboard to work (see .travis.yml).

... and use clipr::write_clip() I might be able to then build the reprex and then obtain the result using clipr::read_clip(). A bit convoluted though.

Once you get the clipboard working at all, reprex takes care of all this for you, i.e. you would never need to explicitly call clipr.

@jennybc
Copy link
Member

jennybc commented Jan 10, 2017

From @hadley:

confirmation dialog ("reprex ready on clipboard") is a bit too assertive

I should either remove this or figure out how to make the message simply disappear after some suitable interval.

@jennybc
Copy link
Member

jennybc commented Jan 16, 2017

Thx @hadley and @daattali, I think current addin now counts as "existing"!

@MilesMcBain The more I think about this, you should never get that error. reprex should detect the lack of clipboard and give you a better message about where to find the output. Are you sure you were using a very recent version? If so, will you open that as a separate issue about RStudio Server?

@jennybc jennybc closed this as completed Jan 16, 2017
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

3 participants