edit_text_file
This directory provides functionality for opening commonly edited files with a user's preferred text editor. It consists of a few key files that work together:
-
edit_text_file.talondefines a user commanduser.edit_text_filethat takes the name of a file as an argument, passes that to theuser.edit_text_fileaction defined inedit_text_file.py, waits 500ms, and then moves the cursor to the end of the file. This command is meant to be triggered using Talon voice commands. -
edit_text_file.pyimplements theuser.edit_text_fileaction, which opens the given file in the user's preferred text editor. It uses a platform-specific approach to open the file:- Windows: Uses
os.startfilewith the"edit"argument which attempts to open the file in the associated text editor, and if that fails, it uses"open"which opens a dialog to let the user choose an editor. - macOS: Uses
/usr/bin/open -twhich attempts to open the file in a text editor. - Linux: Uses
xdg-open, which may or may not open a text editor. Ifxdg-openisn't found, it will notify the user. It is important to note that this will fail if the user's$EDITORis set to a terminal editor such asnanoorvim.
The
edit_text_file.pyfile also defines theget_full_pathfunction. If the given file argument is not an absolute path, it will resolve it as being relative to the root of the repository. - Windows: Uses
-
edit_text_file_list.talon-listdefines theuser.edit_text_filelist. This list is used by Talon to provide a set of suggestions when using theuser.edit_text_filecommand. It contains a number of common talon files and other files that a user might want to quickly edit, including some that are outside the current directory. This is why theget_full_pathfunction is so important.