summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2020-09-22 21:26:22 +1000
committerMaxime Coste <mawww@kakoune.org>2020-09-22 21:26:22 +1000
commitc6bfce0350dbc3b641fd71ea65e691af62c8073b (patch)
treea6e30d0f2df01f1bf8849328c9465bcf317e292b
parent3dcdd6617f52b9fb57d8282d7b4c230bb1d271bc (diff)
parent93e5a3b51f81febeadaeb474dd97fd4bb881b787 (diff)
Merge remote-tracking branch 'Screwtapello/spell-replace-prompt' into master
-rw-r--r--rc/tools/spell.kak33
1 files changed, 20 insertions, 13 deletions
diff --git a/rc/tools/spell.kak b/rc/tools/spell.kak
index 135b53df..b9fe5903 100644
--- a/rc/tools/spell.kak
+++ b/rc/tools/spell.kak
@@ -142,20 +142,27 @@ define-command spell-next %{ evaluate-commands %sh{
define-command \
-docstring "Suggest replacement words for the current selection, against the last language used by the spell-check command" \
- spell-replace %{ evaluate-commands %sh{
- options=""
- if [ -n "$kak_opt_spell_last_lang" ]; then
- options="-l '$kak_opt_spell_last_lang'"
- fi
- suggestions=$(printf %s "$kak_selection" | eval "aspell -a $options" | grep '^&' | cut -d: -f2)
- menu=$(printf %s "${suggestions#?}" | awk -F', ' '
- {
- for (i=1; i<=NF; i++)
- printf "%s", "%{"$i"}" "%{execute-keys -itersel %{c"$i"<esc>be}}"
+ spell-replace %{
+ prompt \
+ -init %val{selection} \
+ -shell-script-candidates %{
+ options=""
+ if [ -n "$kak_opt_spell_last_lang" ]; then
+ options="-l '$kak_opt_spell_last_lang'"
+ fi
+ printf %s "$kak_selection" |
+ eval "aspell -a $options" |
+ sed -n -e '/^&/ { s/^[^:]*: //; s/, /\n/g; p }'
+ } \
+ "Replace with: " \
+ %{
+ evaluate-commands -save-regs a %{
+ set-register a %val{text}
+ execute-keys c <c-r>a <esc>
+ }
}
- ')
- printf 'try %%{ menu -auto-single %s }' "${menu}"
-} }
+}
+
define-command -params 0.. \
-docstring "Add the current selection to the dictionary" \