So, I’m trying to fix Add more key bindings to the `*spelling*` buffer · Issue #11 · dmerejkowsky/kak-spell · GitHub
Here’s what I’ve got so far:
First, the kak-spell
script generates a *spelling*
scratch buffer containing one selection per line, like this:
1.3,1.5 kak
3.1,3.9 PyEnchant
Then it calls the following commands:
hook buffer -group kak-spell NormalKey <ret> kak-spell-jump
hook buffer -group kak-spell NormalKey a 'kak-spell-add-from-spelling-buffer en_US'
The idea is that can you press ‘enter’ while in the *spelling*
buffer to jump to the error, and ‘a’ to add the word from the line into the personal dictionary.
The kak-spell-jump command works fine:
define-command kak-spell-jump -hidden %{
execute-keys '
<esc>
:edit -existing *spelling* <ret>
gi <a-E> <esc>
:set-option global kak_spell_current_error %val{selection} <ret>
ga
:select %opt{kak_spell_current_error} <ret>
'
}
But I did not manage to make kak-spell-add-from-spelling-buffer
work.
I tried this:
define-command -hidden kak-spell-add-from-spelling-buffer -params 1 %{
execute-keys '
<esc>
gi <a-w> l Gl
'
nop %sh{ kak-spell --lang $1 add $kak_selection }
But the problem is that the a
command still gets executed, and I end up with this:
1
.3,1.5 kak
3.1,3.9 PyEnchant
which breaks everything else because the buffer is no longer formatted properly.
I’ve tried using -draft
with -save-reg
but to no avail.
What am I doing wrong ?