talonhub / community

Voice command set for Talon, community-supported.
MIT License
623 stars 779 forks source link

override edit.selected_text (preserve/restore selection after copy) #1556

Open chdoc opened 1 month ago

chdoc commented 1 month ago

For quite a while, have been annoyed by homophone selection (specifically phones word) not working in emacs. I finally tracked this down to the following issue: the call to selected_text inside of user.homophones_show_selection actually clears the selection. As a consequence, "choose" appends the selected homophone to the original word, instead of replacing it.

Clearing the selection is the expected behavior when copying in emacs, but this changes selected_text to restore the selection after copying.

Note: This still requires enabling delete-selection-mode, but I would deem that acceptable when editing natural language text.

Context:

phones word:
    edit.select_word()
    user.homophones_show_selection()

choose <user.formatters> <number_small>:
    result = user.homophones_select(number_small)
    insert(user.formatted_text(result, formatters))
    user.homophones_hide()
chdoc commented 3 weeks ago

I just realized that this by itself will not solve the issue. In fact, the change that I proposed causes issues with dictation mode. I will have to investigate this further.