Skip to content

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_functional and user.code_concurrent to 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_CASE formatting, matching Elixir's style guidelines.
  • Voice Grammars: Defines commands for control flow structures (state def for def, state cond for cond do, state end for end) and the Elixir pipe operator (op pipe inserts |>).

Backend Implementation and Actions

The elixir.py file implements the structural and contextual logic for the language:

  • Keyword Mapping: Populates the user.code_keyword list with Elixir-specific keywords such as defmodule, fn, receive, unless, alias, and use.
  • Operator Translation: Instantiates the standard Operators class 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 nil instead of generic null keywords.
    • Defines functions (def and defp) with proper spacing, brackets, and formatter settings.
    • Handles module-level directives like import, alias, require, and use.