hadley / emo

Easily insert emoji into R and RMarkdown
416 stars 53 forks source link

emoji completion #27

Closed romainfrancois closed 7 years ago

romainfrancois commented 7 years ago

I've already added the emo::ji_completion function:

> emo::ji_completion("cat")
😺 😸 😹 😻 😼 😽 πŸ™€ 😿 😾 🐱 🐈 🈸 βœ–οΈ

given part of the alias , e.g. pull( emo::jis, aliases) or names( emo::ji_name ) it sends back the emojis to complete it.

Now we need to figure out how to call ji_completion from rstudio. I've been playing with this on my fork: https://github.com/romainfrancois/rstudio/tree/emoji_completion


.original.rs.getCompletionsFile <- .rs.getCompletionsFile

assign( ".rs.getCompletionsFile", function (token, path = getwd(), quote = FALSE, directoriesOnly = FALSE) {
  if( grepl( ".*[:]", token ) ){
    tok   <- sub( ".*[:]", "", token)
    start <- sub( "[:].*", "", token)
    .rs.makeCompletions(
      token = token , results = paste0( start, emo::ji_completion(tok) ) ,
      excludeOtherCompletions = TRUE, type= .rs.acCompletionTypes$STRING,
      quote = FALSE
    )
  } else {
    .original.rs.getCompletionsFile( token, path, quote, directoriesOnly )
  }
}, as.environment("tools:rstudio") )

Thing is, rstudio is huge, and I don't get everything in the code base 😱

places where we might like completions:

This is not really an emo issue, but that's easier to track this here.

romainfrancois commented 7 years ago

romainfrancois commented 7 years ago

PR sent to rstudio. https://github.com/rstudio/rstudio/pull/1462