Skip to content

emacs

The community/apps/emacs directory contains files that add support for using Talon with the Emacs text editor.

The core functionality is in emacs.py, which defines Talon actions for interacting with Emacs. It defines an emacs_meta setting which determines how the "meta" key is handled (defaults to "esc", but can be set to "alt" or "cmd"). It defines actions such as emacs_meta for pressing keys modified by the meta key, emacs_key for pressing keys with meta key translation, emacs_prefix for inputting a prefix argument, emacs for running emacs commands, and emacs_help for running help commands. It also defines many actions that override the standard Talon user, edit, app, code, and win actions for more seamless Emacs integration, such as cut_line, save, copy, find, tab_next, toggle_comment, and filename.

emacs.talon defines the voice commands that trigger the actions defined in emacs.py. It includes commands for common Emacs actions such as execute, prefix, cancel, switch, and shell command, along with commands for more complex actions like sort lines, fill paragraph, customize face, dired omit mode, profiler start, split solo, apropos, file open, and search back. There are also a number of commands for interacting with different modes such as python mode, smerge mode, and outline minor mode. Many commands take optional text or numbers as arguments, which are captured using Talon's <user.text>$ and <user.number_signed_small> tags.

emacs_commands.csv is a CSV file that lists Emacs commands, their key bindings, short forms, and spoken forms. This data is used by emacs_commands.py to provide keybindings, short forms, and spoken forms for Emacs commands in Talon. For example, the Command transpose-lines, has the Key binding ctrl-x ctrl-t, the Short form is empty, and the Spoken form is tr-lines.

emacs_commands.py is a Python file that reads emacs_commands.csv and provides actions for looking up the keybindings and short forms of Emacs commands. This file is used by emacs.py to implement the emacs_command_keybinding and emacs_command_short_form actions. The load_commands function parses the CSV, and uses the user.create_spoken_forms_from_list action to generate a list of commands that are recognized by Talon, using the Spoken form column where provided.

These files work together to create a comprehensive Emacs integration for Talon. emacs_commands.csv provides the data, emacs_commands.py loads it and makes it available to Talon actions, emacs.py implements the actions, and emacs.talon binds those actions to voice commands.