changeset 320:bb9041b0ad81

updated for version 7.0083
author vimboss
date Wed, 08 Jun 2005 22:05:14 +0000
parents 0ee579e01743
children 3ee6db0a746e
files runtime/doc/spell.txt src/option.c src/syntax.c
diffstat 3 files changed, 95 insertions(+), 27 deletions(-) [+]
line wrap: on
line diff
--- a/runtime/doc/spell.txt
+++ b/runtime/doc/spell.txt
@@ -1,4 +1,4 @@
-*spell.txt*	For Vim version 7.0aa.  Last change: 2005 Jun 07
+*spell.txt*	For Vim version 7.0aa.  Last change: 2005 Jun 08
 
 
 		  VIM REFERENCE MANUAL	  by Bram Moolenaar
@@ -69,17 +69,19 @@ zw			Add word under the cursor as a wron
 :spellw[rong] {word}	Add [word} as a wrong (bad) word to 'spellfile'.
 
 After adding a word to 'spellfile' its associated ".spl" file will
-automatically be updated.
+automatically be updated.  More details about the 'spellfile' format below
+|spell-wordlist-format|.
 
 
 PERFORMANCE
 
-Note that Vim does on-the-fly spellchecking.  To make this work fast the
+Note that Vim does on-the-fly spell checking.  To make this work fast the
 word list is loaded in memory.  Thus this uses a lot of memory (1 Mbyte or
-more).  There might also be a noticable delay when the word list is loaded,
-which happens when 'spelllang' is set.  Each word list is only loaded once,
-they are not deleted when 'spelllang' is made empty.  When 'encoding' is set
-the word lists are reloaded, thus you may notice a delay then too.
+more).  There might also be a noticeable delay when the word list is loaded,
+which happens when 'spelllang' or 'spell' is set.  Each word list is only
+loaded once, they are not deleted when 'spelllang' is made empty or 'spell' is
+reset.  When 'encoding' is set the word lists are reloaded, thus you may
+notice a delay then too.
 
 
 REGIONS
@@ -95,26 +97,59 @@ comes in (at least) these variants:
 	en_us		USA
 
 Words that are not used in one region but are used in another region are
-highlighted with SpellLocal.
+highlighted with |SpellLocal|.
 
 Always use lowercase letters for the language and region names.
 
+When adding a word with |zg| or another command it's always added for all
+regions.  You can change that by manually editing the 'spellfile'.  See
+|spell-wordlist-format|.
+
 
 SPELL FILES
 
 Vim searches for spell files in the "spell" subdirectory of the directories in
-'runtimepath'.  The name is: LL-XXX.EEE.spl, where:
+'runtimepath'.  The name is: LL.EEE.spl, where:
 	LL	the language name
-	-XXX	optional addition
 	EEE	the value of 'encoding'
 
+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.
+
 Exceptions:
 - Vim uses "latin1" when 'encoding' is "iso-8859-15".  The euro sign doesn't
   matter for spelling.
 - When no spell file for 'encoding' is found "ascii" is tried.  This only
   works for languages where nearly all words are ASCII, such as English.  It
   helps when 'encoding' is not "latin1", such as iso-8859-2, and English text
-  is being edited.
+  is being edited.  For the ".add" files the same name as the found main
+  spell file is used.
+
+For example, with these values:
+	'runtimepath' is "~/.vim,/usr/share/vim70,~/.vim/after"
+	'encoding'    is "iso-8859-2"
+	'spelllang'   is "pl"
+
+Vim will look for:
+1. ~/.vim/spell/pl.iso-8859-2.spl
+2. /usr/share/vim70/spell/pl.iso-8859-2.spl
+3. ~/.vim/spell/pl.iso-8859-2.add.spl
+4. /usr/share/vim70/spell/pl.iso-8859-2.add.spl
+5. ~/.vim/after/spell/pl.iso-8859-2.add.spl
+
+This assumes 1. is not found and 2. is found.
+
+If 'encoding' is "latin1" Vim will look for:
+1. ~/.vim/spell/pl.latin1.spl
+2. /usr/share/vim70/spell/pl.latin1.spl
+3. ~/.vim/after/spell/pl.latin1.spl
+4. ~/.vim/spell/pl.ascii.spl
+5. /usr/share/vim70/spell/pl.ascii.spl
+6. ~/.vim/after/spell/pl.ascii.spl
+
+This assumes none of them are found (Polish doesn't make sense when leaving
+out the non-ASCII characters).
 
 Spelling for EBCDIC is currently not supported.
 
@@ -135,7 +170,8 @@ Vim uses a fixed method to recognize a w
 include characters like '-' in 'iskeyword'.  The word characters do depend on
 'encoding'.
 
-A word that starts with a digit is always ignored.
+A word that starts with a digit is always ignored.  That includes hex numbers
+in the form 0xff and 0XFF.
 
 
 SYNTAX HIGHLIGHTING					*spell-syntax*
@@ -143,11 +179,13 @@ SYNTAX HIGHLIGHTING					*spell-syntax*
 Files that use syntax highlighting can specify where spell checking should be
 done:
 
-   everywhere			   default
-   in specific items		   use "contains=@Spell"
-   everywhere but specific items   use "contains=@NoSpell"
+1.  everywhere			   default
+2.  in specific items		   use "contains=@Spell"
+3.  everywhere but specific items  use "contains=@NoSpell"
 
-Note that mixing @Spell and @NoSpell doesn't make sense.
+For the second method adding the @NoSpell cluster will disable spell checking
+again.  This can be used, for example, to add @Spell to the comments of a
+program, and add @NoSpell for items that shouldn't be checked.
 
 ==============================================================================
 2. Generating a spell file				*spell-mkspell*
@@ -234,7 +272,7 @@ requires two files, one with .aff and on
 format is a list of words.
 
 
-FORMAT OF WORD LIST
+FORMAT OF WORD LIST				*spell-wordlist-format*
 
 The words must appear one per line.  That is all that is required.
 Additionally the following items are recognized:
@@ -243,13 +281,30 @@ Additionally the following items are rec
 - A line starting with "/encoding=", before any word, specifies the encoding
   of the file.  After the second '=' comes an encoding name.  This tells Vim
   to setup conversion from the specified encoding to 'encoding'.
+- A line starting with "/regions=" specifies the region names that are
+  supported.  Each region name must be two ASCII letters.  The first one is
+  region 1.  Thus "/regions=usca" has region 1 "us" and region 2 "ca".
+  In an addition word list the list should be equal to the main word list!
 - A line starting with "/?" specifies a word that should be marked as rare.
 - A line starting with "/!" specifies a word that should be marked as bad.
 - A line starting with "/=" specifies a word where case must match exactly.
   A "?" or "!" may be following: "/=?" and "/=!".
+- Digits after "/" indicate the regions in which the word is valid.  If no
+  regions are specified the word is valid in all regions.
 - Other lines starting with '/' are reserved for future use.  The ones that
   are not recognized are ignored (but you do get a warning message).
 
+Example:
+
+	# This is an example word list		comment
+	/encoding=latin1			encoding of the file
+	/regions=uscagb				regions "us", "ca" and "gb"
+	example					word for all regions
+	/1blah					word for region 1 "us"
+	/!Vim					bad word
+	/?3Campbell				rare word in region 3 "gb"
+	/='s mornings				keep-case word
+
 
 FORMAT WITH AFFIX COMPRESSION
 
@@ -277,7 +332,7 @@ them before the Vim word list is made.  
 "src/spell" directory.
 
 
-WORD LIST FORMAT					*spell-wordlist-format*
+WORD LIST FORMAT				*spell-dic-format*
 
 A very short example, with line numbers:
 
--- a/src/option.c
+++ b/src/option.c
@@ -3048,7 +3048,7 @@ set_option_default(opt_idx, opt_flags, c
 
     varp = get_varp_scope(&(options[opt_idx]), both ? OPT_LOCAL : opt_flags);
     flags = options[opt_idx].flags;
-    if (varp != NULL)	    /* nothing to do for hidden option */
+    if (varp != NULL)	    /* skip hidden option, nothing to do for it */
     {
 	dvi = ((flags & P_VI_DEF) || compatible) ? VI_DEFAULT : VIM_DEFAULT;
 	if (flags & P_STRING)
@@ -6678,6 +6678,7 @@ set_bool_option(opt_idx, varp, value, op
 	if (curwin->w_p_spell)
 	{
 	    char_u	*errmsg = did_set_spelllang(curbuf);
+
 	    if (errmsg != NULL)
 		EMSG(_(errmsg));
 	}
--- a/src/syntax.c
+++ b/src/syntax.c
@@ -2202,10 +2202,10 @@ syn_current_attr(syncing, displaying, ca
 	     * done in the current item.
 	     */
 
-	    /* If there is no @Spell cluster: Do spelling for items without
-	     * @NoSpell.  Otherwise only in items with @Spell */
 	    if (syn_buf->b_spell_cluster_id == 0)
 	    {
+		/* There is no @Spell cluster: Do spelling for items without
+		 * @NoSpell cluster. */
 		if (syn_buf->b_nospell_cluster_id == 0 || current_trans_id == 0)
 		    *can_spell = TRUE;
 		else
@@ -2216,14 +2216,26 @@ syn_current_attr(syncing, displaying, ca
 		    *can_spell = !in_id_list(sip, sip->si_cont_list, &sps, 0);
 		}
 	    }
-	    else if (current_trans_id == 0)
-		*can_spell = FALSE;
 	    else
 	    {
-		sps.inc_tag = 0;
-		sps.id = syn_buf->b_spell_cluster_id;
-		sps.cont_in_list = NULL;
-		*can_spell = in_id_list(sip, sip->si_cont_list, &sps, 0);
+		/* The @Spell cluster is defined: Do spelling in items with
+		 * the @Spell cluster.  But not when @NoSpell is also there. */
+		if (current_trans_id == 0)
+		    *can_spell = FALSE;
+		else
+		{
+		    sps.inc_tag = 0;
+		    sps.id = syn_buf->b_spell_cluster_id;
+		    sps.cont_in_list = NULL;
+		    *can_spell = in_id_list(sip, sip->si_cont_list, &sps, 0);
+
+		    if (syn_buf->b_nospell_cluster_id != 0)
+		    {
+			sps.id = syn_buf->b_nospell_cluster_id;
+			if (in_id_list(sip, sip->si_cont_list, &sps, 0))
+			    *can_spell = FALSE;
+		    }
+		}
 	    }
 	}