provide-module spell %~ define-command -override -hidden true nop define-command -override -hidden false fail declare-option -hidden bool autospell_enabled false define-command -docstring %{ Enable autospell. Autospell refreshes spellchecks and hides spelling in insert mode. } autospell-enable %{ set-option window autospell_enabled true try %{ spell hook -group auto-spell window ModeChange (push|pop):.*insert %{ try %{ spell-clear } } hook -group auto-spell window NormalIdle .* %{ try spell } } catch %{ fail "Couldn't enable autospell!" } } define-command -docstring %{ Disable autospell. Autospell refreshes spellchecks and hides spelling in insert mode. } autospell-disable %{ set-option window autospell_enabled false try spell-clear remove-hooks window auto-spell } define-command autospell-toggle %{ try %{ %opt{autospell_enabled} autospell-disable } catch %{ autospell-enable } } # keybindings declare-user-mode spell map -docstring 'autospell toggle' global spell t ': autospell-toggle' map -docstring 'show spell' global spell s ': spell' map -docstring 'spell next' global spell i ': spell-next' map -docstring 'spell prev' global spell m ': spell-prev' map -docstring 'spell clear' global spell c ': spell-clear' map -docstring 'spell add' global spell a ': spell-add' map -docstring 'spell replace' global spell r ': spell-replace' map -docstring 'spelling' global user s ': enter-user-mode spell' ~