stata
The community/lang/stata
directory contains files that add Stata language support to Talon.
The file stata.py
defines the core logic for Stata code manipulation. This file sets the context for Stata code using ctx.matches = r""" code.language: stata """
which activates the defined actions and lists when the code language is detected as Stata. It defines lists for code parameters, common functions, and libraries which are used in code insertion, and defines many actions, including:
code_comment_line_prefix
: Inserts a comment prefix (*
) at the beginning of the line.code_private_function
andcode_default_function
: Creates a Stata program block with the user's input as the program's name.code_insert_named_argument
: Inserts a named argument with a trailing space.code_insert_function
: Inserts a Stata function name with a selected argument.- A variety of actions for inserting Stata control flow statements (if, else if, else, for, foreach, while), break and continue statements.
code_import
: Insertsssc install
for installing Stata packages.code_insert_library
: Insertsssc install
followed by a selected library name.- Actions for inserting operators (subscript, assignment, math, equality, and logical operators).
The file stata.talon
is the Talon script which activates the actions defined in stata.py
. It sets tags for imperative code, C-like comment blocks, regular comment blocks, comment lines, functions, common functions, libraries, array operators and assignment operators. It sets the user.code_private_function_formatter
setting to SNAKE_CASE
to apply snake case formatting to function names. Finally, it defines voice commands for:
* Inserting named arguments via arg {user.code_parameter_name}
* Inserting for loops via state for val
* Inserting ssc install
via s s c install
* Inserting ssc install
followed by a library name via s s c install <user.code_libraries>
* Toggling library/package inserts via toggle imports
or toggle packages