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

RStudio uses incorrect 'editor' option definition #3475

Closed
kevinushey opened this issue Sep 13, 2018 · 0 comments
Closed

RStudio uses incorrect 'editor' option definition #3475

kevinushey opened this issue Sep 13, 2018 · 0 comments

Comments

@kevinushey
Copy link
Contributor

Originally from tidyverse/reprex#204.

We define this function here:

options(editor = function(name, file, title) {

but utils::file.edit() calls the function as:

> utils::file.edit
function (..., title = file, editor = getOption("editor"), fileEncoding = "")
{
    file <- path.expand(c(...))
    title <- rep_len(as.character(title), length(file))
    if (nzchar(fileEncoding) && fileEncoding != "native.enc") {
        tfile <- file
        for (i in seq_along(file)) {
            tfile <- tempfile()
            con <- file(file[i], encoding = fileEncoding)
            writeLines(readLines(con), tfile)
            close(con)
            file[i] <- tfile
        }
    }
    if (is.function(editor))
        invisible(editor(file = file, title = title))
    else invisible(.External2(C_fileedit, file, title, editor))
}
<bytecode: 0x7f8e2caeac78>

That is, there is no argument 'name'. This implies that calls to e.g.

utils::file.edit(tempfile())

can fail. Surprisingly, it only fails on Windows; it does succeed on non-Windows.

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

1 participant