Commit Graph

22 Commits

Author SHA1 Message Date
Maxim Baz
0289131c24
spell.kak: ignore another undocumented control char 2021-07-01 21:52:59 +02:00
Frank LENORMAND
efb6fca068 rc spell: Remove :spell-replace default value
This commit removes the default prompt value from the `spell-replace`
command.

Currently, running the command after selecting a misspelled word
might not allow the editor to propose alternative spellings because
it completes upon whatever is inserted into the prompt. If the words
returned by `aspell` are too different from the currently misspelled
word, no candidates are shown.

For example, selecting “unanymously” and running `:spell-replace`
will not show any candidates under the current implementation (the
‘y’ probably trips the fuzzy-matcher).

The user develops a habit of clearing the prompt every time, because
that's the only way to make sure all suggestions from `aspell` are
visible, so the editor might as well not have any default value for
`:spell-replace`.
2021-01-19 16:38:23 +03:00
Patsakula Nikita
ff8d4d6567
[-] spell.kak: undocumented aspell buggy-behavior avoided. 2020-11-06 15:41:12 +03:00
Tim Allen
93e5a3b51f spell.kak: Replace "kak -f" with "sed" for efficiency. 2020-09-22 01:29:03 +10:00
Tim Allen
f75f484b84 spell.kak: Present spelling suggestions with :prompt
Previously, spelling suggestions were presented with the :menu command,
requiring the user to cycle through wild and fanciful alternatives to get to the
one they wanted. Now, we present suggestions with the :prompt command, which
allows the user to type to filter down the list, and also to customise the
replacement after they've chose it (perhaps to fix capitalisation or add
apostrophe-S).

We also use the mispelled word as the initial content of the prompt. That
filters out the wildest alternatives by default, and allows the user to edit the
original word instead of forcing them to choose from among the suggestions. To
get the full list of suggestions, it's easy enough to just backspace until the
word you want appears in the list.
2020-09-21 21:07:35 +10:00
Johannes Altmanninger
9a7d8df447 Avoid accidentally using environment variables in sh scopes
On the instances with altfile this was already the case, but this makes it more obvious.

Closes #3673
2020-08-24 19:01:05 +02:00
Maxime Coste
0b56c777c0 Merge remote-tracking branch 'lenormf/fix-spell-next' 2020-05-30 09:22:06 +10:00
Maxime Coste
08e0b663f7 Fix unintended interpretation of ranges length syntax
Ranges specified with a +<length> were inconsistent, with +0 meaning
an empty range, while +1 meant a two character long range (first character
+ the following one). Change that to mean a single character.

Fixes #3479
2020-05-29 12:25:57 +10:00
Frank LENORMAND
05db1e8697 rc spell: Make :spell-next wrap around the buffer 2020-05-15 18:37:03 +03:00
Frank LENORMAND
4eac927a01 rc spell: Rewrite :spell-next in Awk 2020-05-15 12:59:30 +03:00
Frank LENORMAND
e9e15e6a44 rc spell: Simplify selection-descriptions parsing
Remove everything after the first pipe sign. Pop the timestamp.
2020-05-15 12:21:02 +03:00
Frank LENORMAND
7db9062122 rc spell: Don't use expr to format-check
The regular pattern based on `printf`/`grep` is cleaner and less
error prone.
2020-05-15 12:19:29 +03:00
Frank LENORMAND
9bc6bddcac
rc spell: Fix off-by-one highlighting glitch 2020-05-07 10:40:25 +00:00
Jan-Jaap Korpershoek
063a702bf4 Add error handling
Rewrite line by line to make escaping easier
2020-04-27 12:28:29 +02:00
Jan-Jaap Korpershoek
246735520f Add spell-add command 2020-04-27 11:57:14 +02:00
codesoap
94cdd3f9e3 rc spell: Avoid C-style comments in awk 2020-03-22 08:13:30 +01:00
Frank LENORMAND
e83ad2a2a4 rc spell: Re-implement message processing in Awk
Plain shell takes too long on large files.

Fixes #3399
2020-03-09 14:22:34 +03:00
Frank LENORMAND
90ba4d0903 rc spell: Handle errors returned on the first line
The first line returned by `aspell` isn't always an identification
string, it can also be an error.

This commit prevents the first line from being ignored in any case,
and allows errors to be reported consistently.

Related to #3330
2020-02-01 16:04:58 +01:00
Frank LENORMAND
5b1f9255a1 rc: Use the standard fail command to report errors
Merely using `echo` with markup doesn't log errors in the debug
buffers, and is also less readable.
2019-11-14 08:32:55 +01:00
Frank LENORMAND
be8d0e6726 rc spell: Allow storing a language in an option
This commit adds a `spell_lang` option that will be used by the
`spell` command when no language is passed to it directly.

Setting a buffer/window local option allows using `:spell` seamlessly
across several buffers, written in different languages.
2019-11-08 12:44:55 +01:00
Aaron Bull Schaefer
3a401f0771 Trim whitespace from spell check word length variable
Due to ambiguity in the POSIX standard, GNU and BSD versions of the `wc`
utility use slightly different whitespace conventions when formatting
their output [1]. When limiting the output to just counting the number
of bytes (as is done by Kakoune when calculating the length of words
for spell check highlighting), the BSD version of `wc -c` has some
additional leading whitespace:

    gnu$ printf %s "test" | wc -c
    4
    bsd$ printf %s "test" | wc -c
           4

This leading whitespace needs to be removed before defining the "region"
to highlight, or `set-option` will not be able to parse the given
`spell_regions` and will complain that there are "not enough elements
in tuple." In other words, the region `1.21+8|Error` on Linux ends up
looking like `1.21+       8|Error` on macOS, which is invalid.

Removing the whitespace could be accomplished in a number of ways, but
using arithmetic expansion [2] is POSIX compliant and does not require
shelling out to another process.

[1]: https://unix.stackexchange.com/questions/205906/extra-space-with-counted-line-number
[2]: https://mywiki.wooledge.org/ArithmeticExpression
2019-06-02 20:23:42 -07:00
Alex Leferry 2
c0dccdd90d Add categories in rc/
Closes #2783
2019-03-21 01:06:16 +01:00