elixir
This directory provides voice-coding support for the Elixir programming language in Talon. It defines language-specific syntax, formatting conventions, standard operators, and custom vocabulary to enable efficient hands-free programming in Elixir.
The implementation consists of two primary files:
- elixir.py – Sets up the language context, defines Elixir operators and keywords, and overrides standard code-action behaviors.
- elixir.talon – Activates relevant language tags, configures formatting rules, and maps voice commands to Elixir constructs and symbols.
How It Works
The files work together under the code.language: elixir context to adapt Talon's generic programming commands to Elixir's syntax and idioms.
Language Configuration and Voice Commands
The elixir.talon file manages active tags, formatting styles, and voice mappings:
- Tags: Enables tags like
user.code_functionalanduser.code_concurrentto load generic functional programming and concurrency commands, alongside basic tags for comments, math operators, and functions. - Formatters: Forces both public and private functions and variables to use
SNAKE_CASEformatting, matching Elixir's style guidelines. - Voice Grammars: Defines commands for control flow structures (
state deffordef,state condforcond do,state endforend) and the Elixir pipe operator (op pipeinserts|>).
Backend Implementation and Actions
The elixir.py file implements the structural and contextual logic for the language:
- Keyword Mapping: Populates the
user.code_keywordlist with Elixir-specific keywords such asdefmodule,fn,receive,unless,alias, anduse. - Operator Translation: Instantiates the standard
Operatorsclass to map Talon's general mathematical and logical rules to Elixir symbols (e.g., lambda is mapped to->, weak equality to==, and strict equality to===). - Custom Code Actions: Overrides several action methods to output Elixir-specific syntax:
- Inserts
nilinstead of generic null keywords. - Defines functions (
defanddefp) with proper spacing, brackets, and formatter settings. - Handles module-level directives like
import,alias,require, anduse.
- Inserts