summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2005-07-02 23:19:16 +0000
committerBram Moolenaar <Bram@vim.org>2005-07-02 23:19:16 +0000
commit0d9c26dd8333aae4b20015f13fe2e8e1f07037bd (patch)
treebb7411a26272fdb19424741790f1d3b4a2c61f20
parentf9184a1d3151b5b727fec86c2ac0946c9c68df4d (diff)
downloadvim-0d9c26dd8333aae4b20015f13fe2e8e1f07037bd.zip
updated for version 7.0100
-rw-r--r--runtime/doc/options.txt26
-rw-r--r--runtime/doc/spell.txt52
-rw-r--r--runtime/doc/tags4
-rw-r--r--src/option.c58
-rw-r--r--src/proto/spell.pro4
-rw-r--r--src/screen.c43
-rw-r--r--src/structs.h2
-rw-r--r--src/syntax.c2
-rw-r--r--src/version.h4
9 files changed, 170 insertions, 25 deletions
diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt
index 678d63e6f..300ddb750 100644
--- a/runtime/doc/options.txt
+++ b/runtime/doc/options.txt
@@ -1,4 +1,4 @@
-*options.txt* For Vim version 7.0aa. Last change: 2005 Jun 30
+*options.txt* For Vim version 7.0aa. Last change: 2005 Jul 02
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -3318,7 +3318,8 @@ A jump table for the options with a short description can be found at |Q_op|.
t:Title,v:Visual,w:WarningMsg,W:WildMenu,
f:Folded,F:FoldColumn,A:DiffAdd,
C:DiffChange,D:DiffDelete,T:DiffText,
- >:SignColumn")
+ >:SignColumn,B:SpellBad,P:SpellCap,
+ R:SpellRare,L:SpellLocal")
global
{not in Vi}
This option can be used to set highlighting mode for various
@@ -3350,8 +3351,13 @@ A jump table for the options with a short description can be found at |Q_op|.
|hl-WildMenu| W wildcard matches displayed for 'wildmenu'
|hl-Folded| f line used for closed folds
|hl-FoldColumn| F 'foldcolumn'
+ |hl-DiffAdd| A added line in diff mode
+ |hl-DiffChange| C changed line in diff mode
+ |hl-DiffDelete| D deleted line in diff mode
+ |hl-DiffText| T inserted text in diff mode
|hl-SignColumn| > column used for |signs|
|hl-SpellBad| B misspelled word |spell|
+ |hl-SpellCap| P word that should start with capital|spell|
|hl-SpellRare| R rare word |spell|
|hl-SpellLocal| L word from other region |spell|
@@ -5635,6 +5641,18 @@ A jump table for the options with a short description can be found at |Q_op|.
When on spell checking will be done. See |spell|.
The languages are specified with 'spelllang'.
+ *'spellcapcheck'* *'spc'*
+'spellcapcheck' 'spc' string (default "[.?!][])'" \t\n]\+")
+ local to buffer
+ {not in Vi}
+ {not available when compiled without the |+syntax|
+ feature}
+ Pattern to locate the end of a sentence. The following word will be
+ checked to start with a capital letter. If not then it is highlighted
+ with SpellCap |hl-SpellCap|.
+ When this check is not wanted make this option empty.
+ Only used when 'spell' is set.
+
*'spellfile'* *'spf'*
'spellfile' 'spf' string (default empty)
local to buffer
@@ -5643,6 +5661,10 @@ A jump table for the options with a short description can be found at |Q_op|.
feature}
Name of the word list file where words are added for the |zg| and |zw|
commands. It must end in ".{encoding}.add".
+ *E765*
+ It may also be a comma separated list of names. A count before the
+ |zg| and |zw| commands can be used to access each. This allows using
+ a personal word list file and a project word list file.
When a word is added while this option is empty Vim will set it for
you: Using the first "spell" directory in 'runtimepath' that is
writable and the first language name that appears in 'spelllang',
diff --git a/runtime/doc/spell.txt b/runtime/doc/spell.txt
index 0ca0e0b15..9ccfbefb8 100644
--- a/runtime/doc/spell.txt
+++ b/runtime/doc/spell.txt
@@ -1,4 +1,4 @@
-*spell.txt* For Vim version 7.0aa. Last change: 2005 Jul 01
+*spell.txt* For Vim version 7.0aa. Last change: 2005 Jul 02
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -27,6 +27,7 @@ This switches on the 'spell' option and specifies to check for US English.
The words that are not recognized are highlighted with one of these:
SpellBad word not recognized |hl-SpellBad|
+ SpellCap word not capatilized |hl-SpellCap|
SpellRare rare word |hl-SpellRare|
SpellLocal wrong spelling for selected region |hl-SpellLocal|
@@ -42,7 +43,8 @@ To search for the next misspelled word:
[s Like "]s" but search backwards, find the misspelled
word before the cursor. Doesn't recognize words
split over two lines, thus may stop at words that are
- not highlighted as bad.
+ not highlighted as bad. Does not stop at word with
+ missing capital at the start of a line.
*]S*
]S Like "]s" but only stop at bad words, not at rare
@@ -55,28 +57,40 @@ To search for the next misspelled word:
To add words to your own word list: *E764*
*zg*
-zg Add word under the cursor as a good word to
- 'spellfile'. In Visual mode the selected characters
- are added as a word (including white space!).
+zg Add word under the cursor as a good word to the first
+ name in 'spellfile'. In Visual mode the selected
+ characters are added as a word (including white
+ space!). If the word is explicitly marked as bad word
+ in another spell file the result is unpredictable.
+ A count may precede the command to indicate the entry
+ in 'spellfile' to be used. A count of two uses the
+ second entry.
*zG*
-zG Like "zg" but add the word to the internal word list.
+zG Like "zg" but add the word to the internal word list
+ |internal-wordlist|.
*zw*
-zw Add word under the cursor as a wrong (bad) word to
- 'spellfile'. In Visual mode the selected characters
- are added as a word (including white space!).
+zw Like "zg" but mark the word as a wrong (bad) word.
*zW*
-zW Like "zw" but add the word to the internal word list.
+zW Like "zw" but add the word to the internal word list
+ |internal-wordlist|.
*:spe* *:spellgood*
-:spe[llgood] {word} Add [word} as a good word to 'spellfile'.
+:[count]spe[llgood] {word}
+ Add [word} as a good word to 'spellfile', like with
+ "zg". Without count the first name is used, with a
+ count of two the second entry, etc.
-:spe[llgood]! {word} Add [word} as a good word to the internal word list.
+:spe[llgood]! {word} Add [word} as a good word to the internal word list,
+ like with "zG".
*:spellw* *:spellwrong*
-:spellw[rong] {word} Add [word} as a wrong (bad) word to 'spellfile'.
+:[count]spellw[rong] {word}
+ Add [word} as a wrong (bad) word to 'spellfile', as
+ with "zw". Without count the first name is used, with
+ a count of two the second entry, etc.
:spellw[rong]! {word} Add [word} as a wrong (bad) word to the internal word
list.
@@ -85,12 +99,13 @@ After adding a word to 'spellfile' with the above commands its associated
".spl" file will automatically be updated and reloaded. If you change
'spellfile' manually you need to use the |:mkspell| command. This sequence of
commands mostly works well: >
- :exe 'e ' . &spellfile
+ :edit <file in 'spellfile'>
< (make changes to the spell file) >
:mkspell! %
More details about the 'spellfile' format below |spell-wordlist-format|.
+ *internal-wordlist*
The internal word list is used for all buffers where 'spell' is set. It is
not stored, it is lost when you exit Vim. It is also cleared when 'encoding'
is set.
@@ -128,6 +143,11 @@ z? For the word under/after the cursor suggest correctly
The 'spellsuggest' option influences how the list of suggestions is generated
and sorted. See |'spellsuggest'|.
+The 'spellcapcheck' option is used to check the first word of a sentence
+starts with a capital. This doesn't work for the first word in the file.
+When there is a line break right after a sentence the highlighting of the next
+line may be postponed. Use |CTRL-L| when needed.
+
==============================================================================
2. Remarks on spell checking *spell-remarks*
@@ -182,8 +202,8 @@ Only the first file is loaded, the one that is first in 'runtimepath'. If
this succeeds then additionally files with the name LL.EEE.add.spl are loaded.
All the ones that are found are used.
-Additionally, the file related to 'spellfile' is loaded. This is the file
-that |zg| and |zw| add good and wrong words to.
+Additionally, the files related to the names in 'spellfile' are loaded. These
+are the files that |zg| and |zw| add good and wrong words to.
Exceptions:
- Vim uses "latin1" when 'encoding' is "iso-8859-15". The euro sign doesn't
diff --git a/runtime/doc/tags b/runtime/doc/tags
index 4b315ed60..2b19ebcb4 100644
--- a/runtime/doc/tags
+++ b/runtime/doc/tags
@@ -728,7 +728,9 @@ $VIMRUNTIME starting.txt /*$VIMRUNTIME*
'sol' options.txt /*'sol'*
'sourceany' vi_diff.txt /*'sourceany'*
'sp' options.txt /*'sp'*
+'spc' options.txt /*'spc'*
'spell' options.txt /*'spell'*
+'spellcapcheck' options.txt /*'spellcapcheck'*
'spellfile' options.txt /*'spellfile'*
'spelllang' options.txt /*'spelllang'*
'spellsuggest' options.txt /*'spellsuggest'*
@@ -3724,6 +3726,7 @@ E761 spell.txt /*E761*
E762 spell.txt /*E762*
E763 spell.txt /*E763*
E764 spell.txt /*E764*
+E765 options.txt /*E765*
E77 message.txt /*E77*
E78 motion.txt /*E78*
E79 message.txt /*E79*
@@ -5412,6 +5415,7 @@ intel-itanium syntax.txt /*intel-itanium*
intellimouse-wheel-problems gui_w32.txt /*intellimouse-wheel-problems*
interfaces-5.2 version5.txt /*interfaces-5.2*
internal-variables eval.txt /*internal-variables*
+internal-wordlist spell.txt /*internal-wordlist*
internet intro.txt /*internet*
intro intro.txt /*intro*
intro.txt intro.txt /*intro.txt*
diff --git a/src/option.c b/src/option.c
index eef61292b..57d2951d9 100644
--- a/src/option.c
+++ b/src/option.c
@@ -121,6 +121,7 @@ typedef enum
, PV_SI
, PV_SN
, PV_SPELL
+ , PV_SPC
, PV_SPF
, PV_SPL
, PV_STL
@@ -235,6 +236,7 @@ static long p_sw;
static int p_swf;
#ifdef FEAT_SYN_HL
static char_u *p_syn;
+static char_u *p_spc;
static char_u *p_spf;
static char_u *p_spl;
#endif
@@ -1113,7 +1115,7 @@ static struct vimoption
{(char_u *)FALSE, (char_u *)0L}},
{"highlight", "hl", P_STRING|P_VI_DEF|P_RCLR|P_COMMA|P_NODUP,
(char_u *)&p_hl, PV_NONE,
- {(char_u *)"8:SpecialKey,@:NonText,d:Directory,e:ErrorMsg,i:IncSearch,l:Search,m:MoreMsg,M:ModeMsg,n:LineNr,r:Question,s:StatusLine,S:StatusLineNC,c:VertSplit,t:Title,v:Visual,V:VisualNOS,w:WarningMsg,W:WildMenu,f:Folded,F:FoldColumn,A:DiffAdd,C:DiffChange,D:DiffDelete,T:DiffText,>:SignColumn,B:SpellBad,R:SpellRare,L:SpellLocal",
+ {(char_u *)"8:SpecialKey,@:NonText,d:Directory,e:ErrorMsg,i:IncSearch,l:Search,m:MoreMsg,M:ModeMsg,n:LineNr,r:Question,s:StatusLine,S:StatusLineNC,c:VertSplit,t:Title,v:Visual,V:VisualNOS,w:WarningMsg,W:WildMenu,f:Folded,F:FoldColumn,A:DiffAdd,C:DiffChange,D:DiffDelete,T:DiffText,>:SignColumn,B:SpellBad,P:SpellCap,R:SpellRare,L:SpellLocal",
(char_u *)0L}},
{"history", "hi", P_NUM|P_VIM,
(char_u *)&p_hi, PV_NONE,
@@ -2031,7 +2033,16 @@ static struct vimoption
(char_u *)NULL, PV_NONE,
#endif
{(char_u *)FALSE, (char_u *)0L}},
- {"spellfile", "spf", P_STRING|P_EXPAND|P_ALLOCED|P_VI_DEF|P_SECURE,
+ {"spellcapcheck", "spc", P_STRING|P_ALLOCED|P_VI_DEF|P_SECURE|P_RBUF,
+#ifdef FEAT_SYN_HL
+ (char_u *)&p_spc, PV_SPC,
+ {(char_u *)"[.?!][])'\" \\t\\n]\\+", (char_u *)0L}
+#else
+ (char_u *)NULL, PV_NONE,
+ {(char_u *)0L, (char_u *)0L}
+#endif
+ },
+ {"spellfile", "spf", P_STRING|P_EXPAND|P_ALLOCED|P_VI_DEF|P_SECURE|P_COMMA,
#ifdef FEAT_SYN_HL
(char_u *)&p_spf, PV_SPF,
{(char_u *)"", (char_u *)0L}
@@ -2593,6 +2604,9 @@ static char_u *set_chars_option __ARGS((char_u **varp));
#ifdef FEAT_CLIPBOARD
static char_u *check_clipboard_option __ARGS((void));
#endif
+#ifdef FEAT_SYN_HL
+static char_u *compile_cap_prog __ARGS((void));
+#endif
static char_u *set_bool_option __ARGS((int opt_idx, char_u *varp, int value, int opt_flags));
static char_u *set_num_option __ARGS((int opt_idx, char_u *varp, long value, char_u *errbuf, size_t errbuflen, int opt_flags));
static void check_redraw __ARGS((long_u flags));
@@ -4596,6 +4610,7 @@ didset_options()
#endif
#ifdef FEAT_SYN_HL
(void)spell_check_sps();
+ (void)compile_cap_prog();
#endif
#if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32)
(void)opt_strings_flags(p_toolbar, p_toolbar_values, &toolbar_flags, TRUE);
@@ -4668,6 +4683,7 @@ check_buf_options(buf)
#endif
#ifdef FEAT_SYN_HL
check_string_option(&buf->b_p_syn);
+ check_string_option(&buf->b_p_spc);
check_string_option(&buf->b_p_spf);
check_string_option(&buf->b_p_spl);
#endif
@@ -5755,6 +5771,11 @@ did_set_string_option(opt_idx, varp, new_value_alloced, oldval, errbuf,
}
}
}
+ /* When 'spellcapcheck' is set compile the regexp program. */
+ else if (varp == &(curbuf->b_p_spc))
+ {
+ errmsg = compile_cap_prog();
+ }
/* 'spellsuggest' */
else if (varp == &p_sps)
{
@@ -6410,6 +6431,37 @@ check_clipboard_option()
}
#endif
+#ifdef FEAT_SYN_HL
+/*
+ * Set curbuf->b_cap_prog to the regexp program for 'spellcapcheck'.
+ * Return error message when failed, NULL when OK.
+ */
+ static char_u *
+compile_cap_prog()
+{
+ regprog_T *rp = curbuf->b_cap_prog;
+
+ if (*curbuf->b_p_spc == NUL)
+ {
+ curbuf->b_cap_prog = NULL;
+ vim_free(rp);
+ return NULL;
+ }
+
+ /* Prepend a ^ so that we only match at one column */
+ vim_snprintf((char *)IObuff, IOSIZE, "^%s", curbuf->b_p_spc);
+ curbuf->b_cap_prog = vim_regcomp(IObuff, RE_MAGIC);
+ if (curbuf->b_cap_prog == NULL)
+ {
+ curbuf->b_cap_prog = rp;
+ return e_invarg;
+ }
+
+ vim_free(rp);
+ return NULL;
+}
+#endif
+
/*
* Set the value of a boolean option, and take care of side effects.
* Returns NULL for success, or an error message for an error.
@@ -8393,6 +8445,7 @@ get_varp(p)
case PV_SWF: return (char_u *)&(curbuf->b_p_swf);
#ifdef FEAT_SYN_HL
case PV_SYN: return (char_u *)&(curbuf->b_p_syn);
+ case PV_SPC: return (char_u *)&(curbuf->b_p_spc);
case PV_SPF: return (char_u *)&(curbuf->b_p_spf);
case PV_SPL: return (char_u *)&(curbuf->b_p_spl);
#endif
@@ -8704,6 +8757,7 @@ buf_copy_options(buf, flags)
#ifdef FEAT_SYN_HL
/* Don't copy 'syntax', it must be set */
buf->b_p_syn = empty_option;
+ buf->b_p_spc = vim_strsave(p_spc);
buf->b_p_spf = vim_strsave(p_spf);
buf->b_p_spl = vim_strsave(p_spl);
#endif
diff --git a/src/proto/spell.pro b/src/proto/spell.pro
index 91fcf7293..1b47b313a 100644
--- a/src/proto/spell.pro
+++ b/src/proto/spell.pro
@@ -1,5 +1,5 @@
/* spell.c */
-int spell_check __ARGS((win_T *wp, char_u *ptr, int *attrp));
+int spell_check __ARGS((win_T *wp, char_u *ptr, int *attrp, int *capcol));
int spell_move_to __ARGS((int dir, int allwords, int curline));
void spell_cat_line __ARGS((char_u *buf, char_u *line, int maxlen));
char_u *did_set_spelllang __ARGS((buf_T *buf));
@@ -8,7 +8,7 @@ void spell_reload __ARGS((void));
void put_bytes __ARGS((FILE *fd, long_u nr, int len));
void ex_mkspell __ARGS((exarg_T *eap));
void ex_spell __ARGS((exarg_T *eap));
-void spell_add_word __ARGS((char_u *word, int len, int bad, int temp));
+void spell_add_word __ARGS((char_u *word, int len, int bad, int index));
void init_spell_chartab __ARGS((void));
int spell_check_sps __ARGS((void));
void spell_suggest __ARGS((void));
diff --git a/src/screen.c b/src/screen.c
index f1a7c7ad0..3e11c532e 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -2512,6 +2512,8 @@ win_line(wp, lnum, startrow, endrow)
static linenr_T checked_lnum = 0; /* line number for "checked_col" */
static int checked_col = 0; /* column in "checked_lnum" up to which
* there are no spell errors */
+ static int cap_col = -1; /* column to check for Cap word */
+ static linenr_T capcol_lnum = 0; /* line number where "cap_col" used */
int cur_checked_col = 0; /* checked column for current line */
#endif
int extra_check; /* has syntax or linebreak */
@@ -2634,6 +2636,15 @@ win_line(wp, lnum, startrow, endrow)
if (lnum == checked_lnum)
cur_checked_col = checked_col;
checked_lnum = 0;
+
+ /* When there was a sentence end in the previous line may require a
+ * word starting with capital in this line. In line 1 always check
+ * the first word. */
+ if (lnum != capcol_lnum)
+ cap_col = -1;
+ if (lnum == 1)
+ cap_col = 0;
+ capcol_lnum = 0;
}
#endif
@@ -2802,6 +2813,10 @@ win_line(wp, lnum, startrow, endrow)
#ifdef FEAT_SYN_HL
if (has_spell)
{
+ /* For checking first word with a capital skip white space. */
+ if (cap_col == 0)
+ cap_col = skipwhite(line) - line;
+
/* To be able to spell-check over line boundaries copy the end of the
* current line into nextline[]. Above the start of the next line was
* copied to nextline[SPWORDLEN]. */
@@ -3673,7 +3688,8 @@ win_line(wp, lnum, startrow, endrow)
p = nextline + (prev_ptr - line) - nextlinecol;
else
p = prev_ptr;
- len = spell_check(wp, p, &spell_attr);
+ cap_col -= (prev_ptr - line);
+ len = spell_check(wp, p, &spell_attr, &cap_col);
word_end = v + len;
/* In Insert mode only highlight a word that
@@ -3697,6 +3713,22 @@ win_line(wp, lnum, startrow, endrow)
checked_lnum = lnum + 1;
checked_col = (p - nextline) + len - nextline_idx;
}
+
+ if (cap_col > 0)
+ {
+ if (p != prev_ptr
+ && (p - nextline) + cap_col >= nextline_idx)
+ {
+ /* Remember that the word in the next line
+ * must start with a capital. */
+ capcol_lnum = lnum + 1;
+ cap_col = (p - nextline) + cap_col
+ - nextline_idx;
+ }
+ else
+ /* Compute the actual column. */
+ cap_col += (prev_ptr - line);
+ }
}
}
if (spell_attr != 0)
@@ -4367,6 +4399,15 @@ win_line(wp, lnum, startrow, endrow)
} /* for every character in the line */
+#ifdef FEAT_SYN_HL
+ /* After an empty line check first word for capital. */
+ if (*skipwhite(line) == NUL)
+ {
+ capcol_lnum = lnum + 1;
+ cap_col = 0;
+ }
+#endif
+
return row;
}
diff --git a/src/structs.h b/src/structs.h
index bc2b1bbd5..7e144447d 100644
--- a/src/structs.h
+++ b/src/structs.h
@@ -1345,6 +1345,8 @@ struct file_buffer
int b_p_swf; /* 'swapfile' */
#ifdef FEAT_SYN_HL
char_u *b_p_syn; /* 'syntax' */
+ char_u *b_p_spc; /* 'spellcapcheck' */
+ regprog_T *b_cap_prog; /* program for 'spellcapcheck' */
char_u *b_p_spf; /* 'spellfile' */
char_u *b_p_spl; /* 'spelllang' */
#endif
diff --git a/src/syntax.c b/src/syntax.c
index 7a94df71c..6639df0b8 100644
--- a/src/syntax.c
+++ b/src/syntax.c
@@ -6031,6 +6031,7 @@ static char *(highlight_init_light[]) =
"Question term=standout ctermfg=DarkGreen gui=bold guifg=SeaGreen",
"Search term=reverse ctermbg=Yellow ctermfg=NONE guibg=Yellow guifg=NONE",
"SpellBad term=reverse ctermbg=LightRed guisp=Red gui=undercurl",
+ "SpellCap term=reverse ctermbg=LightBlue guisp=Blue gui=undercurl",
"SpellRare term=reverse ctermbg=LightMagenta guisp=Magenta gui=undercurl",
"SpellLocal term=underline ctermbg=Cyan guisp=DarkCyan gui=undercurl",
"SpecialKey term=bold ctermfg=DarkBlue guifg=Blue",
@@ -6057,6 +6058,7 @@ static char *(highlight_init_dark[]) =
"Search term=reverse ctermbg=Yellow ctermfg=Black guibg=Yellow guifg=Black",
"SpecialKey term=bold ctermfg=LightBlue guifg=Cyan",
"SpellBad term=reverse ctermbg=Red guisp=Red gui=undercurl",
+ "SpellCap term=reverse ctermbg=Blue guisp=Blue gui=undercurl",
"SpellRare term=reverse ctermbg=Magenta guisp=Magenta gui=undercurl",
"SpellLocal term=underline ctermbg=Cyan guisp=Cyan gui=undercurl",
"Title term=bold ctermfg=LightMagenta gui=bold guifg=Magenta",
diff --git a/src/version.h b/src/version.h
index 7655ee182..7728e9ade 100644
--- a/src/version.h
+++ b/src/version.h
@@ -36,5 +36,5 @@
#define VIM_VERSION_NODOT "vim70aa"
#define VIM_VERSION_SHORT "7.0aa"
#define VIM_VERSION_MEDIUM "7.0aa ALPHA"
-#define VIM_VERSION_LONG "VIM - Vi IMproved 7.0aa ALPHA (2005 Jul 1)"
-#define VIM_VERSION_LONG_DATE "VIM - Vi IMproved 7.0aa ALPHA (2005 Jul 1, compiled "
+#define VIM_VERSION_LONG "VIM - Vi IMproved 7.0aa ALPHA (2005 Jul 2)"
+#define VIM_VERSION_LONG_DATE "VIM - Vi IMproved 7.0aa ALPHA (2005 Jul 2, compiled "