Skip to content

Create RStudio addin for %<-% #54

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: zeallot
Type: Package
Title: Multiple, Unpacking, and Destructuring Assignment
Version: 0.1.0.9000
Version: 0.1.0.9001
Authors@R: c(
person("Nathan", "Teetor", email = "nathanteetor@gmail.com",
role = c("aut", "cre")),
Expand All @@ -22,6 +22,7 @@ VignetteBuilder: knitr
Depends:
R (>= 3.2)
Suggests:
rstudioapi,
testthat,
knitr,
rmarkdown,
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ S3method(destructure,summary.lm)
export("%->%")
export("%<-%")
export(destructure)
export(rs_addin_insert_multi_assign)
3 changes: 2 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# zeallot 0.1.0.9000
# zeallot 0.1.0.9001

## Minor Improvements

* Formally support R versions >= 3.2
* RStudio addin now supplied for `%<-%` (@dkahle)

# zeallot 0.1.0

Expand Down
14 changes: 14 additions & 0 deletions R/addins.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#' Insert multiple assignment operator
#'
#' Call this function as an addin to insert \code{ \%<-\% } at the
#' cursor position.
#'
#' @return \code{structure(list(), .Names = character(0))}
#' @author David Kahle \email{david@@kahle.io}
#' @export
rs_addin_insert_multi_assign <- function() {
rstudioapi::insertText(
rstudioapi::getActiveDocumentContext()$selection[[1]]$range,
" %<-% "
)
}
4 changes: 4 additions & 0 deletions inst/rstudio/addins.dcf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Name: Insert %<-%
Description: Inserts `%<-%` at the cursor position.
Binding: rs_addin_insert_multi_assign
Interactive: false
18 changes: 18 additions & 0 deletions man/rs_addin_insert_multi_assign.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.