Patch 8.2.0953
Problem: Spell checking doesn't work for CamelCased words.
Solution: Add the "camel" value in the new option 'spelloptions'.
(closes #1235)
Files: runtime/doc/options.txt, runtime/doc/spell.txt, src/optiondefs.h,
src/option.h, src/option.c, src/buffer.c, src/optionstr.c,
src/testdir/gen_opt_test.vim, src/testdir/test_spell.vim
*** ../vim-8.2.0952/runtime/doc/options.txt 2020-06-07 22:21:35.220132507 +0200
--- runtime/doc/options.txt 2020-06-10 21:07:06.331864186 +0200
***************
*** 7106,7111 ****
--- 7105,7120 ----
up to the first character that is not an ASCII letter or number and
not a dash. Also see |set-spc-auto|.
+ *'spelloptions'* *'spo'*
+ 'spelloptions' 'spo' string (default "")
+ local to buffer
+ {not available when compiled without the |+syntax|
+ feature}
+ A comma separated list of options for spell checking:
+ camel When a word is CamelCased, assume "Cased" is a
+ separate word: every upper-case character in a word
+ that comes after a lower case character indicates the
+ start of a new word.
*'spellsuggest'* *'sps'*
'spellsuggest' 'sps' string (default "best")
*** ../vim-8.2.0952/runtime/doc/spell.txt 2019-12-12 12:49:06.000000000 +0100
--- runtime/doc/spell.txt 2020-06-10 21:08:57.055556930 +0200
***************
*** 215,220 ****
--- 215,223 ----
line may be postponed. Use |CTRL-L| when needed. Also see |set-spc-auto| for
how it can be set automatically when 'spelllang' is set.
+ The 'spelloptions' option has a few more flags that influence the way spell
+ checking works.
+
Vim counts the number of times a good word is encountered. This is used to
sort the suggestions: words that have been seen before get a small bonus,
words that have been seen often get a bigger bonus. The COMMON item in the
*** ../vim-8.2.0952/src/optiondefs.h 2020-05-31 23:11:02.082515688 +0200
--- src/optiondefs.h 2020-06-10 21:23:57.432906772 +0200
***************
*** 129,134 ****
--- 129,135 ----
# define PV_SPC OPT_BUF(BV_SPC)
# define PV_SPF OPT_BUF(BV_SPF)
# define PV_SPL OPT_BUF(BV_SPL)
+ # define PV_SPO OPT_BUF(BV_SPO)
#endif
#define PV_STS OPT_BUF(BV_STS)
#ifdef FEAT_SEARCHPATH
***************
*** 2396,2401 ****
--- 2397,2412 ----
#else
(char_u *)NULL, PV_NONE,
{(char_u *)0L, (char_u *)0L}
+ #endif
+ SCTX_INIT},
+ {"spelloptions", "spo", P_STRING|P_ALLOCED|P_VI_DEF
+ |P_ONECOMMA|P_NODUP|P_RBUF,
+ #ifdef FEAT_SPELL
+ (char_u *)&p_spo, PV_SPO,
+ {(char_u *)"", (char_u *)0L}
+ #else
+ (char_u *)NULL, PV_NONE,
+ {(char_u *)0L, (char_u *)0L}
#endif
SCTX_INIT},
{"spellsuggest", "sps", P_STRING|P_VI_DEF|P_EXPAND|P_SECURE|P_ONECOMMA,
*** ../vim-8.2.0952/src/option.h 2020-06-04 18:21:56.046395485 +0200
--- src/option.h 2020-06-10 21:18:38.369865493 +0200
***************
*** 913,918 ****
--- 913,919 ----
EXTERN char_u *p_spc; // 'spellcapcheck'
EXTERN char_u *p_spf; // 'spellfile'
EXTERN char_u *p_spl; // 'spelllang'
+ EXTERN char_u *p_spo; // 'spelloptions'
EXTERN char_u *p_sps; // 'spellsuggest'
#endif
EXTERN int p_spr; // 'splitright'
***************
*** 1185,1190 ****
--- 1186,1192 ----
, BV_SPC
, BV_SPF
, BV_SPL
+ , BV_SPO
#endif
, BV_STS
#ifdef FEAT_SEARCHPATH
*** ../vim-8.2.0952/src/option.c 2020-05-30 21:52:49.242816719 +0200
--- src/option.c 2020-06-10 21:10:51.627232404 +0200
***************
*** 5329,5334 ****
--- 5329,5335 ----
case PV_SPC: return (char_u *)&(curwin->w_s->b_p_spc);
case PV_SPF: return (char_u *)&(curwin->w_s->b_p_spf);
case PV_SPL: return (char_u *)&(curwin->w_s->b_p_spl);
+ case PV_SPO: return (char_u *)&(curwin->w_s->b_p_spo);
#endif
case PV_SW: return (char_u *)&(curbuf->b_p_sw);
case PV_TS: return (char_u *)&(curbuf->b_p_ts);
***************
*** 5838,5843 ****
--- 5839,5846 ----
COPY_OPT_SCTX(buf, BV_SPF);
buf->b_s.b_p_spl = vim_strsave(p_spl);
COPY_OPT_SCTX(buf, BV_SPL);
+ buf->b_s.b_p_spo = vim_strsave(p_spo);
+ COPY_OPT_SCTX(buf, BV_SPO);
#endif
#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
buf->b_p_inde = vim_strsave(p_inde);
*** ../vim-8.2.0952/src/buffer.c 2020-05-30 20:30:42.888816585 +0200
--- src/buffer.c 2020-06-10 21:11:32.639114815 +0200
***************
*** 2287,2292 ****
--- 2287,2293 ----
vim_regfree(buf->b_s.b_cap_prog);
buf->b_s.b_cap_prog = NULL;
clear_string_option(&buf->b_s.b_p_spl);
+ clear_string_option(&buf->b_s.b_p_spo);
#endif
#ifdef FEAT_SEARCHPATH
clear_string_option(&buf->b_p_sua);
*** ../vim-8.2.0952/src/optionstr.c 2020-06-08 18:54:44.957796367 +0200
--- src/optionstr.c 2020-06-10 21:21:06.441422152 +0200
***************
*** 248,253 ****
--- 248,254 ----
check_string_option(&buf->b_s.b_p_spc);
check_string_option(&buf->b_s.b_p_spf);
check_string_option(&buf->b_s.b_p_spl);
+ check_string_option(&buf->b_s.b_p_spo);
#endif
#ifdef FEAT_SEARCHPATH
check_string_option(&buf->b_p_sua);
***************
*** 1714,1719 ****
--- 1715,1726 ----
{
errmsg = compile_cap_prog(curwin->w_s);
}
+ // 'spelloptions'
+ else if (varp == &(curwin->w_s->b_p_spo))
+ {
+ if (**varp != NUL && STRCMP("camel", *varp) != 0)
+ errmsg = e_invarg;
+ }
// 'spellsuggest'
else if (varp == &p_sps)
{
*** ../vim-8.2.0952/src/testdir/gen_opt_test.vim 2020-04-17 19:41:16.100078313 +0200
--- src/testdir/gen_opt_test.vim 2020-06-10 21:44:34.576170474 +0200
***************
*** 132,137 ****
--- 132,138 ----
\ 'signcolumn': [['', 'auto', 'no'], ['xxx', 'no,yes']],
\ 'spellfile': [['', 'file.en.add'], ['xxx', '/tmp/file']],
\ 'spelllang': [['', 'xxx', 'sr@latin'], ['not&lang', "that\\\rthere"]],
+ \ 'spelloptions': [['', 'camel'], ['xxx']],
\ 'spellsuggest': [['', 'best', 'double,33'], ['xxx']],
\ 'switchbuf': [['', 'useopen', 'split,newtab'], ['xxx']],
\ 'tagcase': [['smart', 'match'], ['', 'xxx', 'smart,match']],
*** ../vim-8.2.0952/src/testdir/test_spell.vim 2020-06-10 16:39:27.359613652 +0200
--- src/testdir/test_spell.vim 2020-06-10 21:38:21.313550244 +0200
***************
*** 77,82 ****
--- 77,87 ----
call assert_equal(['bycycle', 'bad'], spellbadword('My bycycle.'))
call assert_equal(['another', 'caps'], 'A sentence. another sentence'->spellbadword())
+ call assert_equal(['TheCamelWord', 'bad'], 'TheCamelWord asdf'->spellbadword())
+ set spelloptions=camel
+ call assert_equal(['asdf', 'bad'], 'TheCamelWord asdf'->spellbadword())
+ set spelloptions=
+
set spelllang=en
call assert_equal(['', ''], spellbadword('centre'))
call assert_equal(['', ''], spellbadword('center'))
*** ../vim-8.2.0952/src/version.c 2020-06-10 20:56:55.025354576 +0200
--- src/version.c 2020-06-10 21:46:07.539841347 +0200
***************
*** 756,757 ****
--- 756,759 ----
{ /* Add new patch number below this line */
+ /**/
+ 953,
/**/
--
GUARD #1: What, ridden on a horse?
ARTHUR: Yes!
GUARD #1: You're using coconuts!
ARTHUR: What?
GUARD #1: You've got two empty halves of coconut and you're bangin' 'em
together.
The Quest for the Holy Grail (Monty Python)
/// Bram Moolenaar -- Br...@Moolenaar.net --
http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features --
http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language --
http://www.Zimbu.org ///
\\\ help me help AIDS victims --
http://ICCF-Holland.org ///