r
This directory provides rich programming language support for R in Talon, enabling voice-driven R development. It implements standard programming syntax mappings, supports popular R libraries (such as the Tidyverse, ggplot2, and Shiny), and integrates R-specific operators and patterns like the pipe (%>%).
How It Works
Support is split across configuration files defining the vocabulary (.talon and .talon-list files) and a Python backend (.py) that handles context rules, list population, and custom code formatting.
The components collaborate to provide:
1. Context-Specific Activation: Language features are scoped to files where the active language is detected as R (code.language: r).
2. List-Based Vocabularies: Comprehensive lists of functions and libraries are loaded directly into Talon lists, reducing the need for manual spelling.
3. Custom Code Operators & Formatting: Implementation of snake_case formatting as the default for variables and functions, and mapping of operators like assignment (<-).
Core Files
r.py
This file sets up the Python backend context for R. It defines mappings and overrides action classes to implement:
* Libraries and Arguments: populates user.code_libraries with popular packages (such as ggplot2, dplyr, rmarkdown, brms, and shinyalert) and user.code_parameter_name with common R parameters (like na.rm, hjust, and vjust).
* Operators: overrides the standard programming operators, mapping the assignment operator to <- and setting up logical/mathematical operations like %in% or %%.
* R-Specific Actions: implements customized commands, such as code_private_function (which generates standard <- function() {} block constructs) and code_insert_library (which wraps selected text in an import statement).
r.talon
The main layout for R commands. It activates when R is detected and:
* Imports standard programming tags (e.g., user.code_imperative, user.code_comment_line, and user.code_operators_math).
* Configures formatting settings to default both functions and variables to SNAKE_CASE.
* Implements voice commands for R pipes (such as %>%, %<>%, %T>%, and %$%).
* Standardizes quick-insert commands like is N A and is not N A mapping to is.na() and !is.na().
* Handles library inclusion syntax: library <user.code_libraries> automatically inserts library(package) and starts a new line, while using <user.code_libraries> inserts package:: for quick namespace access.
code_common_function.talon-list
This list acts as a voice-mapping dictionary containing hundreds of common functions used in R. To prevent dictation struggles, it registers phonetic words to actual code signatures grouped by package:
* Base R: as factor $\rightarrow$ "as.factor", get working directory $\rightarrow$ "getwd", vector $\rightarrow$ "c".
* dplyr: mutate, filter, group by, inner join, case when.
* ggplot2: geom point $\rightarrow$ "geom_point", facet wrap $\rightarrow$ "facet_wrap", scale fill viridis.
* purrr: map, P map $\rightarrow$ "pmap".
* stringr: string detect $\rightarrow$ "str_detect".
* tidyr: pivot longer, pivot wider, drop NA.
* Shiny: render ui $\rightarrow$ "renderUI", observe event $\rightarrow$ "observeEvent".
code_keyword.talon-list
A smaller list file focusing specifically on the variations of the NA object in R. It allows you to quickly dictate the appropriate typed missing values:
* N A $\rightarrow$ NA
* N A character $\rightarrow$ NA_character_
* N A real $\rightarrow$ NA_real_
* N A complex $\rightarrow$ NA_complex_
* N A integer $\rightarrow$ NA_integer_