changeset 694:07d199fe02ed v7.0209

updated for version 7.0209
author vimboss
date Mon, 27 Feb 2006 23:58:35 +0000
parents 05dc93b9c61f
children 653eeb31bad6
files runtime/doc/Makefile runtime/doc/autocmd.txt runtime/doc/eval.txt runtime/doc/gui.txt runtime/doc/help.txt runtime/doc/makehtml.awk runtime/doc/options.txt runtime/doc/pi_paren.txt runtime/doc/tags runtime/doc/todo.txt runtime/doc/version7.txt runtime/filetype.vim runtime/plugin/matchparen.vim src/diff.c src/edit.c src/eval.c src/ex_cmds.c src/ex_docmd.c src/fileio.c src/globals.h src/gui.c src/main.c src/mbyte.c src/misc1.c src/misc2.c src/option.c src/option.h src/os_riscos.c src/os_vms.c src/proto/option.pro src/quickfix.c src/screen.c src/structs.h src/syntax.c src/term.c src/testdir/test51.ok src/version.h src/vim.h
diffstat 38 files changed, 882 insertions(+), 397 deletions(-) [+]
line wrap: on
line diff
--- a/runtime/doc/Makefile
+++ b/runtime/doc/Makefile
@@ -71,6 +71,7 @@ DOCS = \
 	pattern.txt \
 	pi_gzip.txt \
 	pi_netrw.txt \
+	pi_paren.txt \
 	pi_spec.txt \
 	pi_tar.txt \
 	pi_zip.txt \
@@ -196,6 +197,7 @@ HTMLS = \
 	pattern.html \
 	pi_gzip.html \
 	pi_netrw.html \
+	pi_paren.html \
 	pi_spec.html \
 	print.html \
 	quickfix.html \
--- a/runtime/doc/autocmd.txt
+++ b/runtime/doc/autocmd.txt
@@ -1,4 +1,4 @@
-*autocmd.txt*   For Vim version 7.0aa.  Last change: 2006 Feb 20
+*autocmd.txt*   For Vim version 7.0aa.  Last change: 2006 Feb 27
 
 
 		  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -471,6 +471,8 @@ CursorHoldI			Just like CursorHold, but 
 
 							*CursorMoved*
 CursorMoved			After the cursor was moved in Normal mode.
+				Also when the text of the cursor line has been
+				changed, e.g., with "x", "rx" or "p".
 				Not triggered when there is typeahead or when
 				an operator is pending.
 				For an example see |match-parens|.
--- a/runtime/doc/eval.txt
+++ b/runtime/doc/eval.txt
@@ -1,4 +1,4 @@
-*eval.txt*      For Vim version 7.0aa.  Last change: 2006 Feb 26
+*eval.txt*      For Vim version 7.0aa.  Last change: 2006 Feb 27
 
 
 		  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -3361,12 +3361,6 @@ match({expr}, {pat}[, {start}[, {count}]
 		"\c" to the pattern to ignore case: >
 			:let idx = match(haystack, '\cneedle')
 <
-		When {count} is given use the {count}'th match.  When a match
-		is found in a String the search for the next one starts on
-		character further.  Thus this example results in 1: >
-			echo match("testing", "..", 0, 2)
-<		In a |List| the search continues in the next item.
-
 		If {start} is given, the search starts from byte index
 		{start} in a String or item {start} in a |List|.
 		The result, however, is still the index counted from the
@@ -3377,11 +3371,19 @@ match({expr}, {pat}[, {start}[, {count}]
 <		result is again "4". >
 			:echo match("testing", "t", 2)
 <		result is "3".
+		For a String, if {start} > 0 then it is like the string starts
+		{start} bytes later, thus "^" will match there.
 		For a String, if {start} < 0, it will be set to 0.  For a list
 		the index is counted from the end.
 		If {start} is out of range (> strlen({expr} for a String or
 		> len({expr} for a |List|) -1 is returned.
 
+		When {count} is given use the {count}'th match.  When a match
+		is found in a String the search for the next one starts on
+		character further.  Thus this example results in 1: >
+			echo match("testing", "..", 0, 2)
+<		In a |List| the search continues in the next item.
+
 		See |pattern| for the patterns that are accepted.
 		The 'ignorecase' option is used to set the ignore-caseness of
 		the pattern.  'smartcase' is NOT used.  The matching is always
--- a/runtime/doc/gui.txt
+++ b/runtime/doc/gui.txt
@@ -1,4 +1,4 @@
-*gui.txt*       For Vim version 7.0aa.  Last change: 2006 Feb 21
+*gui.txt*       For Vim version 7.0aa.  Last change: 2006 Feb 27
 
 
 		  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -24,9 +24,9 @@ Other GUI documentation:
 1. Starting the GUI				*gui-start* *E229* *E233*
 
 First you must make sure you actually have a version of Vim with the GUI code
-included.  You can check this with the ":version" command, it should include
-"+GUI_Athena", "+GUI_GTK", "+GUI_KDE", "+GUI_Motif" or "MS-Windows ... bit
-GUI version".
+included.  You can check this with the ":version" command, it says "with xxx
+GUI", where "xxx" is X11-Motif, X11-Athena, Photon, GTK, GTK2, etc., or
+"MS-Windows 32 bit GUI version".
 
 How to start the GUI depends on the system used.  Mostly you can run the
 GUI version of Vim with:
--- a/runtime/doc/help.txt
+++ b/runtime/doc/help.txt
@@ -1,4 +1,4 @@
-*help.txt*	For Vim version 7.0aa.  Last change: 2006 Feb 18
+*help.txt*	For Vim version 7.0aa.  Last change: 2006 Feb 27
 
 			VIM - main help file
 									 k
@@ -187,9 +187,11 @@ Remarks about specific systems ~
 |os_win32.txt|	MS-Windows 95/98/NT
 						*standard-plugin-list*
 Standard plugins ~
+|pi_gzip.txt|	Reading and writing compressed files
 |pi_netrw.txt|	Reading and writing files over a network
-|pi_gzip.txt|	Reading and writing compressed files
-|pi_expl.txt|	File explorer
+|pi_paren.txt|	Highlight matching parens
+|pi_tar.txt|	Tar file explorer
+|pi_zip.txt|	Zip archive explorer
 
 LOCAL ADDITIONS:				*local-additions*
 
--- a/runtime/doc/makehtml.awk
+++ b/runtime/doc/makehtml.awk
@@ -581,7 +581,7 @@ function find_tag2() {
 	ntags=split(atag,blata,"[ 	]");
 	if ( ntags > 1 ) { return; }
 	if 	( ( allow_one_char == "no" ) && \
-		  ( index("!#$%\&'()+,-./0:;=?@ACINX\\[\\]^_`at\\{\\}~",atag) !=0 ) ) {
+		  ( index("!#$%&'()+,-./0:;=?@ACINX\\[\\]^_`at\\{\\}~",atag) !=0 ) ) {
 		return;
 	}
 	if ( skip_word[atag] == "yes" ) { return; }
@@ -610,7 +610,7 @@ function find_tag3() {
 	ntags=split(btag,blata,"[ 	]");
 	if ( ntags > 1 ) { return; }
 	if 	( ( allow_one_char == "no" ) && \
-		  ( index("!#$%\&'()+,-./0:;=?@ACINX\\[\\]^_`at\\{\\}~",btag) !=0 ) ) {
+		  ( index("!#$%&'()+,-./0:;=?@ACINX\\[\\]^_`at\\{\\}~",btag) !=0 ) ) {
 	  	return;
 	}
 	if ( skip_word[btag] == "yes" ) { return; }
--- a/runtime/doc/options.txt
+++ b/runtime/doc/options.txt
@@ -1,4 +1,4 @@
-*options.txt*	For Vim version 7.0aa.  Last change: 2006 Feb 26
+*options.txt*	For Vim version 7.0aa.  Last change: 2006 Feb 27
 
 
 		  VIM REFERENCE MANUAL	  by Bram Moolenaar
@@ -4639,7 +4639,7 @@ A jump table for the options with a shor
 			{only available when compiled with the |+linebreak|
 			feature}
 	Minimal number of columns to use for the line number.  Only relevant
-	when the 'number' option is set or printint lines with a line number.
+	when the 'number' option is set or printing lines with a line number.
 	Since one space is always between the number and the text, there is
 	one less character for the number itself.
 	The value is the minimum width.  A bigger width is used when needed to
new file mode 100644
--- /dev/null
+++ b/runtime/doc/pi_paren.txt
@@ -0,0 +1,42 @@
+*pi_paren.txt*   For Vim version 7.0aa.  Last change: 2006 Feb 27
+
+
+		  VIM REFERENCE MANUAL    by Bram Moolenaar
+
+
+Highlighting matching parens			*matchparen*
+
+The functionality mentioned here is a |standard-plugin|.
+This plugin is only available if 'compatible' is not set.
+
+You can avoid loading this plugin by setting the "loaded_matchparen" variable: >
+	:let loaded_matchparen = 1
+
+The plugin installs CursorMoved autocommands to redefine the match
+highlighting.
+
+To disable the plugin after it was loaded use this command: >
+
+	:NoMatchParen
+
+And to enable it again: >
+
+	:DoMatchParen
+
+The highlighting used is ParenMatch.  You can specify different colors with
+the ":highlight" command.  Example: >
+
+	:hi ParenMatch ctermbg=blue guibg=lightblue
+
+The characters to be matched come from the 'matchpairs' option.  You can
+change the value to highlight different matches.  Note that not everything is
+possible.  For example, you can't highlight single or double quotes, because
+the start and end are equal.
+
+The syntax highlighting attributes are used.  When the cursor currently is not
+in a string or comment syntax item, then matches inside string and comment
+syntax items are ignored.  Any syntax items with "string" or "comment"
+somewhere in their name are considered string or comment items.
+
+==============================================================================
+ vim:tw=78:ts=8:ft=help:norl:
--- a/runtime/doc/tags
+++ b/runtime/doc/tags
@@ -5920,6 +5920,7 @@ match-parens	tips.txt	/*match-parens*
 matchend()	eval.txt	/*matchend()*
 matchit-install	usr_05.txt	/*matchit-install*
 matchlist()	eval.txt	/*matchlist()*
+matchparen	pi_paren.txt	/*matchparen*
 matchstr()	eval.txt	/*matchstr()*
 max()	eval.txt	/*max()*
 mbyte-IME	mbyte.txt	/*mbyte-IME*
@@ -6180,6 +6181,7 @@ new-items-7	version7.txt	/*new-items-7*
 new-line-continuation	version5.txt	/*new-line-continuation*
 new-location-list	version7.txt	/*new-location-list*
 new-manpage-trans	version7.txt	/*new-manpage-trans*
+new-matchparen	version7.txt	/*new-matchparen*
 new-multi-byte	version5.txt	/*new-multi-byte*
 new-multi-lang	version6.txt	/*new-multi-lang*
 new-netrw-explore	version7.txt	/*new-netrw-explore*
@@ -6318,6 +6320,7 @@ php3.vim	syntax.txt	/*php3.vim*
 phtml.vim	syntax.txt	/*phtml.vim*
 pi_gzip.txt	pi_gzip.txt	/*pi_gzip.txt*
 pi_netrw.txt	pi_netrw.txt	/*pi_netrw.txt*
+pi_paren.txt	pi_paren.txt	/*pi_paren.txt*
 pi_spec.txt	pi_spec.txt	/*pi_spec.txt*
 plugin	usr_05.txt	/*plugin*
 plugin-details	filetype.txt	/*plugin-details*
--- a/runtime/doc/todo.txt
+++ b/runtime/doc/todo.txt
@@ -1,4 +1,4 @@
-*todo.txt*      For Vim version 7.0aa.  Last change: 2006 Feb 26
+*todo.txt*      For Vim version 7.0aa.  Last change: 2006 Feb 27
 
 
 		  VIM REFERENCE MANUAL	  by Bram Moolenaar
@@ -30,11 +30,8 @@ be worked on, but only if you sponsor Vi
 							*known-bugs*
 -------------------- Known bugs and current work -----------------------
 
-Script ID is only remembered for global options. Should remember it for every
-local option separately.
-    Change PV_XXX values in separate ranges for buffer and window.
-    Move the enums to option.h so that the size is known in structs.h
-    use array for each window and buffer with scriptID values.
+test 49 fails because of the function line numbering now taking care of
+continuation lines.
 
 Crash with X command server (Ciaran McCreesh).
 
@@ -43,7 +40,6 @@ maintanance.
 
 "fsutil hardlink" can create a hard link on an NTFS file system. (Daniel
 Einspanjer)  What library function can detect that?
-
 Win32: use GetFileInformationByHandle() to detect hard links on NTFS?
 (George Reilly)
 
@@ -90,9 +86,6 @@ 8   Alternate Dutch word list at www.ned
   adding a bad word like "zw" would.  Use "zuw" to undo "zw"?  (Antonio
   Colombo)
 
-An error in a function uses a line number that doesn't take line continuation
-into account. (Mikolaj Machowski)  Store line count in an extra array?
-
 Is it possible to keep the command-line window open?  Would actually work like
 closing it, executing the command and re-opening it (at the same position).
 
@@ -1603,7 +1596,7 @@ 8   Add specific syntax item to match wi
     "%" match.  :syntax nomatch cMatchError (,{,[,),},] [contained]
 8   Highlight the text between two matching parens (e.g., with a grey
     background) when on one of the parens or in between them.
-    Or highlight the matching paren when the cursor is on one.
+    Option for the matchparen plugin?
 8   Add a command to jump to the next character highlighted with "Error".
 8   When using a cterm, and no ctermfg or ctermbg are defined, use start/stop
     sequences.	Add remark in docs that :if 'term' == "term-name" should be
@@ -1796,17 +1789,16 @@ 8   argc() returns 0 when using "vim -t 
     specified in any way?  To be able to jump to the last edited file.
 8   Pass the executable name to the Vim scripts in some way.  As v:argv0?
 8   Add command arguments with three dashes, passed on to Vim scripts.
-8   When starting to source a vim script, delete all functions that it has
-    previously defined?  Avoids using ":fun!" all the time.
 7   Add optional arguments to user functions:
 	:func myFunc(arg1, arg2, arg3 = "blah", arg4 = 17)
 6   User functions: Functions local to buffer "b:func()"?
-8   Add ":let var[{expr}] = {expr}".  When past the end of "var" just ignore.
+8   For Strings add ":let var[{expr}] = {expr}".  When past the end of "var"
+    just ignore.
 8   The "= register should be writable, if followed by the name of a variable,
     option or environment variable.
 8   ":let &option" should list the value of the option.
-7   Add synIDlist(), making the whole list of syntax items on the
-    stack available (separated with '\n').
+7   Add synIDlist(), making the whole list of syntax items on the syntax stack
+    available as a List.
 8   Add autocommand-event for when a variable is changed:
 	:au VarChanged {varname} {commands}
 8   Add "has("gui_capable")", to check if the GUI can be started.
--- a/runtime/doc/version7.txt
+++ b/runtime/doc/version7.txt
@@ -1,4 +1,4 @@
-*version7.txt*  For Vim version 7.0aa.  Last change: 2006 Feb 26
+*version7.txt*  For Vim version 7.0aa.  Last change: 2006 Feb 27
 
 
 		  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -23,6 +23,7 @@ Spell checking				|new-spell|
 Omni completion				|new-omni-completion|
 MzScheme interface			|new-MzScheme|
 Printing multi-byte text		|new-print-multi-byte|
+Highlighting matching parens		|new-matchparen|
 Translated manual pages			|new-manpage-trans|
 Internal grep				|new-vimgrep|
 Scroll back in messages			|new-scroll-back|
@@ -227,6 +228,16 @@ The 'printmbcharset' and 'printmbfont' o
 Also see |postscript-cjk-printing|.  (Mike Williams)
 
 
+Highlighting matching parens				*new-matchparen*
+----------------------------
+
+When moving the cursor through the text and it is on a paren, then the
+matching paren can be highlighted.  This uses the new |CursorMoved|
+autocommand event.
+
+See |pi_paren.txt| for more information.
+
+
 Translated manual pages					*new-manpage-trans*
 -----------------------
 
@@ -1767,4 +1778,17 @@ the end of every line only up to the len
 
 "dip" in trailing empty lines left one empty line behind.
 
+The script ID was only remembered globally for each option. When a buffer- or
+window-local option was set the same "last set" location was changed for all
+buffers and windows.  Now remember the script ID for each local option
+separately.
+
+GUI: The "Replace All" button didn't handle backslashes in the replacement in
+the same way as "Replace".  Escape backslashes so that they are taken
+literally.
+
+An error in a function reported a line number that doesn't take line
+continuation into account.  Now store a NULL for continuation lines, so that
+the index is equal to the line number in the sourced file.
+
  vim:tw=78:ts=8:ft=help:norl:
--- a/runtime/filetype.vim
+++ b/runtime/filetype.vim
@@ -1,7 +1,7 @@
 " Vim support file to detect file types
 "
 " Maintainer:	Bram Moolenaar <Bram@vim.org>
-" Last Change:	2006 Feb 25
+" Last Change:	2006 Feb 27
 
 " Listen very carefully, I will say this only once
 if exists("did_load_filetypes")
@@ -1658,19 +1658,29 @@ au BufNewFile,BufRead *.latex,*.sty,*.dt
 au BufNewFile,BufRead *.tex			call s:FTtex()
 
 fun! s:FTtex()
-  let n = 1
-  while n < 10 && n < line("$")
-    let line = getline(n)
-    if line =~ '^\s*\\\%(documentclass\>\|usepackage\>\|begin{\)'
-      setf tex
-      return
-    elseif line =~ '^\s*\\\%(start\l\+\|setup\l\+\|usemodule\|enablemode\>\|enableregime\>\|setvariables\>\|useencoding\>\|usesymbols\>\|stel\l\+\|verwende\l\+\|stel\l\+\|gebruik\l\+\|usa\l\+\|imposta\l\+\|regle\l\+\|utilisemodule\>\)\>'
-      setf context
-      return
+  let lnum = 1
+  let checked = 0
+  while checked < 25 && lnum < line("$")
+    let line = getline(lnum)
+    if line !~ '^\s*%'
+      if line =~ '^\s*\\\%(documentclass\>\|usepackage\>\|begin{\|newcommand\>\|renewcommand\>\)'
+	setf tex
+	return
+      elseif line =~ '^\s*\\\%(start\a\+\|setup\a\+\|usemodule\|enablemode\|enableregime\|setvariables\|useencoding\|usesymbols\|stelle\a\+\|verwende\a\+\|stel\a\+\|gebruik\a\+\|usa\a\+\|imposta\a\+\|regle\a\+\|utilisemodule\)\>'
+	setf context
+	return
+      endif
+      let checked = checked + 1
     endif
-    let n = n + 1
+    let lnum = lnum + 1
   endwhile
-  setf tex
+
+  " Didn't recognize anything, guess.
+  if exists("g:tex_flavour") && g:tex_flavour == "context"
+    setf context
+  else
+    setf tex
+  endif
 endfun
 
 " Context
new file mode 100644
--- /dev/null
+++ b/runtime/plugin/matchparen.vim
@@ -0,0 +1,106 @@
+" Vim plugin for showing matching parens
+" Maintainer:  Bram Moolenaar <Bram@vim.org>
+" Last Change: 2006 Feb 27
+
+" Exit quickly when:
+" - this plugin was already loaded (or disabled)
+" - when 'compatible' is set
+" - the "CursorMoved" autocmd event is not availble.
+if exists("g:loaded_matchparen") || &cp || !exists("##CursorMoved")
+  finish
+endif
+let g:loaded_matchparen = 1
+
+augroup matchparen
+  " Replace all matchparen autocommands
+  autocmd! CursorMoved,CursorMovedI * call s:Highlight_Matching_Pair()
+augroup END
+
+let s:paren_hl_on = 0
+
+" Skip the rest if it was already done.
+if exists("*s:Highlight_Matching_Pair")
+  finish
+endif
+
+" The function that is invoked (very often) to define a ":match" highlighting
+" for any matching paren.
+function! s:Highlight_Matching_Pair()
+  " Remove any previous match.
+  if s:paren_hl_on
+    match none
+    let s:paren_hl_on = 0
+  endif
+
+  " Get the character under the cursor and check if it's in 'matchpairs'.
+  let c_lnum = line('.')
+  let c_col = col('.')
+  let before = 0
+
+  let c = getline(c_lnum)[c_col - 1]
+  let plist = split(&matchpairs, ':\|,')
+  let i = index(plist, c)
+  if i < 0
+    " not found, in Insert mode try character before the cursor
+    if c_col > 1 && (mode() == 'i' || mode() == 'R')
+      let before = 1
+      let c = getline(c_lnum)[c_col - 2]
+      let i = index(plist, c)
+    endif
+    if i < 0
+      " not found, nothing to do
+      return
+    endif
+  endif
+
+  " Figure out the arguments for searchpairpos().
+  " Restrict the search to visible lines with "stopline".
+  if i % 2 == 0
+    let s_flags = 'nW'
+    let c2 = plist[i + 1]
+    let stopline = line('w$')
+  else
+    let s_flags = 'nbW'
+    let c2 = c
+    let c = plist[i - 1]
+    let stopline = line('w0')
+  endif
+  if c == '['
+    let c = '\['
+    let c2 = '\]'
+  endif
+
+  " When not in a string or comment ignore matches inside them.
+  let s_skip ='synIDattr(synID(c_lnum, c_col - before, 0), "name") ' .
+	\ '=~?  "string\\|comment"'
+  execute 'if' s_skip '| let s_skip = 0 | endif'
+
+  " Find the match.  When it was just before the cursor move it there for a
+  " moment.  To restore the cursor position use "N|" and when 'virtualedit'
+  " is set, cursor() otherwise.
+  if before > 0
+    if &ve != ''
+      let vcol = virtcol('.')
+    endif
+    call cursor(c_lnum, c_col - before)
+  endif
+  let [m_lnum, m_col] = searchpairpos(c, '', c2, s_flags, s_skip, stopline)
+  if before > 0
+    if &ve != ''
+      exe 'normal ' . vcol . '|'
+    else
+      call cursor(0, c_col)
+    endif
+  endif
+
+  " If a match is found setup match highlighting.
+  if m_lnum > 0 && m_lnum >= line('w0') && m_lnum <= line('w$')
+    exe 'match MatchParen /\(\%' . c_lnum . 'l\%' . (c_col - before) .
+	  \ 'c\)\|\(\%' . m_lnum . 'l\%' . m_col . 'c\)/'
+    let s:paren_hl_on = 1
+  endif
+endfunction
+
+" Define commands that will disable and enable the plugin.
+command! NoMatchParen match none | unlet! g:loaded_matchparen | au! matchparen
+command! DoMatchParen runtime plugin/matchparen.vim | doau CursorMoved
--- a/src/diff.c
+++ b/src/diff.c
@@ -1083,10 +1083,7 @@ diff_win_options(wp, addbuf)
 	curwin = wp;
 	curbuf = curwin->w_buffer;
 	set_string_option_direct((char_u *)"fdm", -1, (char_u *)"diff",
-							  OPT_LOCAL|OPT_FREE);
-# ifdef FEAT_EVAL
-	set_option_scriptID((char_u *)"fdm", current_SID);
-# endif
+						       OPT_LOCAL|OPT_FREE, 0);
 	curwin = old_curwin;
 	curbuf = curwin->w_buffer;
 	wp->w_p_fdc = 2;
@@ -1133,10 +1130,7 @@ ex_diffoff(eap)
 	    curwin = wp;
 	    curbuf = curwin->w_buffer;
 	    set_string_option_direct((char_u *)"fdm", -1,
-				      (char_u *)"manual", OPT_LOCAL|OPT_FREE);
-# ifdef FEAT_EVAL
-	    set_option_scriptID((char_u *)"fdm", current_SID);
-# endif
+				   (char_u *)"manual", OPT_LOCAL|OPT_FREE, 0);
 	    curwin = old_curwin;
 	    curbuf = curwin->w_buffer;
 	    wp->w_p_fdc = 0;
--- a/src/edit.c
+++ b/src/edit.c
@@ -136,6 +136,7 @@ static void ins_compl_free __ARGS((void)
 static void ins_compl_clear __ARGS((void));
 static int  ins_compl_bs __ARGS((void));
 static void ins_compl_addleader __ARGS((int c));
+static void ins_compl_set_original_text __ARGS((char_u *str));
 static void ins_compl_addfrommatch __ARGS((void));
 static int  ins_compl_prep __ARGS((int c));
 static buf_T *ins_compl_next_buf __ARGS((buf_T *buf, int flag));
@@ -1387,7 +1388,7 @@ ins_redraw(ready)
     if (!char_avail())
     {
 #ifdef FEAT_AUTOCMD
-	    /* Trigger CursorMoved if the cursor moved. */
+	/* Trigger CursorMoved if the cursor moved. */
 	if (ready && has_cursormovedI()
 			     && !equalpos(last_cursormoved, curwin->w_cursor))
 	{
@@ -2109,11 +2110,8 @@ ins_compl_add(str, len, icase, fname, ex
 	return FAIL;
     match->cp_number = -1;
     if (flags & ORIGINAL_TEXT)
-    {
 	match->cp_number = 0;
-	match->cp_str = compl_orig_text;
-    }
-    else if ((match->cp_str = vim_strnsave(str, len)) == NULL)
+    if ((match->cp_str = vim_strnsave(str, len)) == NULL)
     {
 	vim_free(match);
 	return FAIL;
@@ -2818,7 +2816,9 @@ ins_compl_bs()
 	ins_compl_delete();
 	ins_bytes(compl_leader + curwin->w_cursor.col - compl_col);
 
-	if (!compl_started)
+	if (compl_started)
+	    ins_compl_set_original_text(compl_leader);
+	else
 	{
 	    /* Matches were cleared, need to search for them now. */
 	    if (ins_complete(Ctrl_N) == FAIL)
@@ -2872,6 +2872,28 @@ ins_compl_addleader(c)
 	ins_compl_del_pum();
 	ins_compl_show_pum();
 	compl_used_match = FALSE;
+	ins_compl_set_original_text(compl_leader);
+    }
+}
+
+/*
+ * Set the first match, the original text.
+ */
+    static void
+ins_compl_set_original_text(str)
+    char_u	*str;
+{
+    char_u	*p;
+
+    /* Replace the original text entry. */
+    if (compl_first_match->cp_flags & ORIGINAL_TEXT)	/* safety check */
+    {
+	p = vim_strsave(str);
+	if (p != NULL)
+	{
+	    vim_free(compl_first_match->cp_str);
+	    compl_first_match->cp_str = p;
+	}
     }
 }
 
@@ -4328,9 +4350,8 @@ ins_complete(c)
 	else
 	    edit_submode = (char_u *)_(CTRL_X_MSG(ctrl_x_mode));
 
-	/* Always add completion for the original text.  Note that
-	 * "compl_orig_text" itself (not a copy) is added, it will be freed
-	 * when the list of matches is freed. */
+	/* Always add completion for the original text. */
+	vim_free(compl_orig_text);
 	compl_orig_text = vim_strnsave(line + compl_col, compl_length);
 	if (compl_orig_text == NULL || ins_compl_add(compl_orig_text,
 			       -1, FALSE, NULL, NULL, 0, ORIGINAL_TEXT) != OK)
@@ -5779,6 +5800,8 @@ free_last_insert()
 {
     vim_free(last_insert);
     last_insert = NULL;
+    vim_free(compl_orig_text);
+    compl_orig_text = NULL;
 }
 #endif
 
--- a/src/eval.c
+++ b/src/eval.c
@@ -11731,6 +11731,7 @@ find_some_match(argvars, rettv, type)
     char_u	*save_cpo;
     long	start = 0;
     long	nth = 1;
+    colnr_T	startcol = 0;
     int		match = 0;
     list_T	*l = NULL;
     listitem_T	*li = NULL;
@@ -11811,12 +11812,12 @@ find_some_match(argvars, rettv, type)
 		    break;
 		}
 		vim_free(tofree);
-		str = echo_string(&li->li_tv, &tofree, strbuf,0);
+		str = echo_string(&li->li_tv, &tofree, strbuf, 0);
 		if (str == NULL)
 		    break;
 	    }
 
-	    match = vim_regexec_nl(&regmatch, str, (colnr_T)0);
+	    match = vim_regexec_nl(&regmatch, str, (colnr_T)startcol);
 
 	    if (match && --nth <= 0)
 		break;
@@ -11832,9 +11833,10 @@ find_some_match(argvars, rettv, type)
 	    else
 	    {
 #ifdef FEAT_MBYTE
-		str = regmatch.startp[0] + (*mb_ptr2len)(regmatch.startp[0]);
+		startcol = regmatch.startp[0]
+				    + (*mb_ptr2len)(regmatch.startp[0]) - str;
 #else
-		str = regmatch.startp[0] + 1;
+		startcol = regmatch.startp[0] + 1 - str;
 #endif
 	    }
 	}
@@ -17400,6 +17402,7 @@ ex_function(eap)
     hashtab_T	*ht;
     int		todo;
     hashitem_T	*hi;
+    int		sourcing_lnum_off;
 
     /*
      * ":function" without argument: list functions.
@@ -17522,6 +17525,8 @@ ex_function(eap)
 		list_func_head(fp, TRUE);
 		for (j = 0; j < fp->uf_lines.ga_len && !got_int; ++j)
 		{
+		    if (FUNCLINE(fp, j) == NULL)
+			continue;
 		    msg_putchar('\n');
 		    msg_outnum((long)(j + 1));
 		    if (j < 9)
@@ -17693,6 +17698,8 @@ ex_function(eap)
     {
 	msg_scroll = TRUE;
 	need_wait_return = FALSE;
+	sourcing_lnum_off = sourcing_lnum;
+
 	if (line_arg != NULL)
 	{
 	    /* Use eap->arg, split up in parts by line breaks. */
@@ -17718,6 +17725,12 @@ ex_function(eap)
 	    goto erret;
 	}
 
+	/* Detect line continuation: sourcing_lnum increased more than one. */
+	if (sourcing_lnum > sourcing_lnum_off + 1)
+	    sourcing_lnum_off = sourcing_lnum - sourcing_lnum_off - 1;
+	else
+	    sourcing_lnum_off = 0;
+
 	if (skip_until != NULL)
 	{
 	    /* between ":append" and "." and between ":python <<EOF" and "EOF"
@@ -17802,7 +17815,7 @@ ex_function(eap)
 	}
 
 	/* Add the line to the function. */
-	if (ga_grow(&newlines, 1) == FAIL)
+	if (ga_grow(&newlines, 1 + sourcing_lnum_off) == FAIL)
 	{
 	    if (line_arg == NULL)
 		vim_free(theline);
@@ -17820,8 +17833,12 @@ ex_function(eap)
 	    theline = p;
 	}
 
-	((char_u **)(newlines.ga_data))[newlines.ga_len] = theline;
-	newlines.ga_len++;
+	((char_u **)(newlines.ga_data))[newlines.ga_len++] = theline;
+
+	/* Add NULL lines for continuation lines, so that the line count is
+	 * equal to the index in the growarray.   */
+	while (sourcing_lnum_off-- > 0)
+	    ((char_u **)(newlines.ga_data))[newlines.ga_len++] = NULL;
 
 	/* Check for end of eap->arg. */
 	if (line_arg != NULL && *line_arg == NUL)
@@ -18362,6 +18379,8 @@ func_dump_profile(fd)
 
 		for (i = 0; i < fp->uf_lines.ga_len; ++i)
 		{
+		    if (FUNCLINE(fp, i) == NULL)
+			continue;
 		    prof_func_line(fd, fp->uf_tml_count[i],
 			     &fp->uf_tml_total[i], &fp->uf_tml_self[i], TRUE);
 		    fprintf(fd, "%s\n", FUNCLINE(fp, i));
@@ -19270,18 +19289,26 @@ get_func_line(c, cookie, indent)
 #endif
 
     gap = &fp->uf_lines;
-    if ((fp->uf_flags & FC_ABORT) && did_emsg && !aborted_in_try())
-	retval = NULL;
-    else if (fcp->returned || fcp->linenr >= gap->ga_len)
+    if (((fp->uf_flags & FC_ABORT) && did_emsg && !aborted_in_try())
+	    || fcp->returned)
 	retval = NULL;
     else
     {
-	retval = vim_strsave(((char_u **)(gap->ga_data))[fcp->linenr++]);
-	sourcing_lnum = fcp->linenr;
+	/* Skip NULL lines (continuation lines). */
+	while (fcp->linenr < gap->ga_len
+			  && ((char_u **)(gap->ga_data))[fcp->linenr] == NULL)
+	    ++fcp->linenr;
+	if (fcp->linenr >= gap->ga_len)
+	    retval = NULL;
+	else
+	{
+	    retval = vim_strsave(((char_u **)(gap->ga_data))[fcp->linenr++]);
+	    sourcing_lnum = fcp->linenr;
 #ifdef FEAT_PROFILE
-	if (do_profiling)
-	    func_line_start(cookie);
-#endif
+	    if (do_profiling)
+		func_line_start(cookie);
+#endif
+	}
     }
 
     /* Did we encounter a breakpoint? */
@@ -19315,6 +19342,9 @@ func_line_start(cookie)
 				      && sourcing_lnum <= fp->uf_lines.ga_len)
     {
 	fp->uf_tml_idx = sourcing_lnum - 1;
+	/* Skip continuation lines. */
+	while (fp->uf_tml_idx > 0 && FUNCLINE(fp, fp->uf_tml_idx) == NULL)
+	    --fp->uf_tml_idx;
 	fp->uf_tml_execed = FALSE;
 	profile_start(&fp->uf_tml_start);
 	profile_zero(&fp->uf_tml_children);
--- a/src/ex_cmds.c
+++ b/src/ex_cmds.c
@@ -3265,10 +3265,7 @@ do_ecmd(fnum, ffname, sfname, eap, newln
 	curbuf->b_help = TRUE;
 #ifdef FEAT_QUICKFIX
 	set_string_option_direct((char_u *)"buftype", -1,
-				       (char_u *)"help", OPT_FREE|OPT_LOCAL);
-# ifdef FEAT_EVAL
-	set_option_scriptID((char_u *)"buftype", current_SID);
-# endif
+				     (char_u *)"help", OPT_FREE|OPT_LOCAL, 0);
 #endif
 
 	/*
@@ -3287,10 +3284,7 @@ do_ecmd(fnum, ffname, sfname, eap, newln
 	if (STRCMP(curbuf->b_p_isk, p) != 0)
 	{
 	    set_string_option_direct((char_u *)"isk", -1, p,
-							  OPT_FREE|OPT_LOCAL);
-# ifdef FEAT_EVAL
-	    set_option_scriptID((char_u *)"isk", current_SID);
-# endif
+						       OPT_FREE|OPT_LOCAL, 0);
 	    check_buf_options(curbuf);
 	    (void)buf_init_chartab(curbuf, FALSE);
 	}
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -1825,7 +1825,7 @@ do_one_cmd(cmdlinep, sourcing,
 			     * existing option value, we restore it later. */
 			    cmdmod.save_ei = vim_strsave(p_ei);
 			    set_string_option_direct((char_u *)"ei", -1,
-						   (char_u *)"all", OPT_FREE);
+					 (char_u *)"all", OPT_FREE, SID_NONE);
 			}
 #endif
 			continue;
@@ -2649,7 +2649,8 @@ doend:
     if (cmdmod.save_ei != NULL)
     {
 	/* Restore 'eventignore' to the value before ":noautocmd". */
-	set_string_option_direct((char_u *)"ei", -1, cmdmod.save_ei, OPT_FREE);
+	set_string_option_direct((char_u *)"ei", -1, cmdmod.save_ei,
+							  OPT_FREE, SID_NONE);
 	free_string_option(cmdmod.save_ei);
     }
 #endif
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -583,13 +583,8 @@ readfile(fname, sfname, from, lines_to_s
 			/* set forced 'fileencoding' */
 			fenc = enc_canonize(eap->cmd + eap->force_enc);
 			if (fenc != NULL)
-			{
 			    set_string_option_direct((char_u *)"fenc", -1,
-						    fenc, OPT_FREE|OPT_LOCAL);
-# ifdef FEAT_EVAL
-			    set_option_scriptID((char_u *)"fenc", current_SID);
-# endif
-			}
+						 fenc, OPT_FREE|OPT_LOCAL, 0);
 			vim_free(fenc);
 		    }
 #endif
@@ -2113,13 +2108,8 @@ failed:
 #ifdef FEAT_MBYTE
     /* If editing a new file: set 'fenc' for the current buffer. */
     if (newfile)
-    {
 	set_string_option_direct((char_u *)"fenc", -1, fenc,
-							  OPT_FREE|OPT_LOCAL);
-# ifdef FEAT_EVAL
-	set_option_scriptID((char_u *)"fenc", current_SID);
-# endif
-    }
+						       OPT_FREE|OPT_LOCAL, 0);
     if (fenc_alloced)
 	vim_free(fenc);
 # ifdef USE_ICONV
@@ -7503,7 +7493,8 @@ au_event_disable(what)
 	if (new_ei != NULL)
 	{
 	    STRCAT(new_ei, what);
-	    set_string_option_direct((char_u *)"ei", -1, new_ei, OPT_FREE);
+	    set_string_option_direct((char_u *)"ei", -1, new_ei,
+							  OPT_FREE, SID_NONE);
 	    vim_free(new_ei);
 	}
     }
@@ -7516,7 +7507,8 @@ au_event_restore(old_ei)
 {
     if (old_ei != NULL)
     {
-	set_string_option_direct((char_u *)"ei", -1, old_ei, OPT_FREE);
+	set_string_option_direct((char_u *)"ei", -1, old_ei,
+							  OPT_FREE, SID_NONE);
 	vim_free(old_ei);
     }
 }
--- a/src/globals.h
+++ b/src/globals.h
@@ -1472,10 +1472,7 @@ EXTERN char_u e_invexprmsg[]	INIT(= N_("
 EXTERN char_u e_guarded[]	INIT(= N_("E463: Region is guarded, cannot modify"));
 EXTERN char_u e_nbreadonly[]	INIT(= N_("E744: NetBeans does not allow changes in read-only files"));
 #endif
-#if defined(FEAT_INS_EXPAND) || defined(FEAT_EVAL) || defined(FEAT_SYN_HL) \
-	|| defined(FEAT_WINDOWS)
 EXTERN char_u e_intern2[]	INIT(= N_("E685: Internal error: %s"));
-#endif
 EXTERN char_u e_maxmempat[]	INIT(= N_("E363: pattern uses more memory than 'maxmempattern'"));
 EXTERN char_u e_emptybuf[]	INIT(= N_("E749: empty buffer"));
 
--- a/src/gui.c
+++ b/src/gui.c
@@ -346,7 +346,7 @@ gui_init()
 	 */
 	if (!option_was_set((char_u *)"mouse"))
 	    set_string_option_direct((char_u *)"mouse", -1,
-						     (char_u *)"a", OPT_FREE);
+					   (char_u *)"a", OPT_FREE, SID_NONE);
 
 	/*
 	 * If -U option given, use only the initializations from that file and
@@ -788,10 +788,7 @@ set_guifontwide(name)
 			gui_mch_free_font(gui.wide_font);
 			gui.wide_font = font;
 			set_string_option_direct((char_u *)"gfw", -1,
-							 wide_name, OPT_FREE);
-# ifdef FEAT_EVAL
-			set_option_scriptID((char_u *)"gfw", current_SID);
-# endif
+						      wide_name, OPT_FREE, 0);
 		    }
 		}
 		break;
@@ -3387,13 +3384,8 @@ get_tabline_label(tp)
 	STRCPY(NameBuff, res);
 
 	if (called_emsg)
-	{
 	    set_string_option_direct((char_u *)"guitablabel", -1,
-						      (char_u *)"", OPT_FREE);
-# ifdef FEAT_EVAL
-	    set_option_scriptID((char_u *)"guitablabel", SID_ERROR);
-# endif
-	}
+					   (char_u *)"", OPT_FREE, SID_ERROR);
 	called_emsg |= save_called_emsg;
     }
     else
@@ -4809,7 +4801,11 @@ gui_do_findrepl(flags, find_text, repl_t
     if (type == FRD_REPLACEALL)
     {
 	ga_concat(&ga, (char_u *)"/");
-	concat_esc(&ga, repl_text, '/');	/* escape slashes */
+						/* escape / and \ */
+	p = vim_strsave_escaped(repl_text, (char_u *)"/\\");
+	if (p != NULL)
+	    ga_concat(&ga, p);
+	vim_free(p);
 	ga_concat(&ga, (char_u *)"/g");
     }
     ga_append(&ga, NUL);
--- a/src/main.c
+++ b/src/main.c
@@ -635,13 +635,8 @@ main
     if (params.edit_type == EDIT_QF)
     {
 	if (params.use_ef != NULL)
-	{
 	    set_string_option_direct((char_u *)"ef", -1,
-						     params.use_ef, OPT_FREE);
-# ifdef FEAT_EVAL
-	    set_option_scriptID((char_u *)"ef", SID_CARG);
-# endif
-	}
+					   params.use_ef, OPT_FREE, SID_CARG);
 	if (qf_init(NULL, p_ef, p_efm, TRUE) < 0)
 	{
 	    out_char('\n');
@@ -1010,7 +1005,6 @@ main_loop(cmdwin, noexmode)
 	    /* Trigger CursorMoved if the cursor moved. */
 	    if (!finish_op && has_cursormoved()
 			     && !equalpos(last_cursormoved, curwin->w_cursor))
-
 	    {
 		apply_autocmds(EVENT_CURSORMOVED, NULL, NULL, FALSE, curbuf);
 		last_cursormoved = curwin->w_cursor;
--- a/src/mbyte.c
+++ b/src/mbyte.c
@@ -731,13 +731,9 @@ codepage_invalid:
 
     /* When using Unicode, set default for 'fileencodings'. */
     if (enc_utf8 && !option_was_set((char_u *)"fencs"))
-    {
 	set_string_option_direct((char_u *)"fencs", -1,
-			  (char_u *)"ucs-bom,utf-8,default,latin1", OPT_FREE);
-# ifdef FEAT_EVAL
-	set_option_scriptID((char_u *)"fencs", current_SID);
-# endif
-    }
+		       (char_u *)"ucs-bom,utf-8,default,latin1", OPT_FREE, 0);
+
 #if defined(HAVE_BIND_TEXTDOMAIN_CODESET) && defined(FEAT_GETTEXT)
     /* GNU gettext 0.10.37 supports this feature: set the codeset used for
      * translated messages independently from the current locale. */
--- a/src/misc1.c
+++ b/src/misc1.c
@@ -2833,6 +2833,12 @@ changed_common(lnum, col, lnume, xtra)
      * since it notices b_mod_set and then uses b_mod_*. */
     if (must_redraw < VALID)
 	must_redraw = VALID;
+
+#ifdef FEAT_AUTOCMD
+    /* when the cursor line is changed always trigger CursorMoved */
+    if (lnum <= curwin->w_cursor.lnum && lnume > curwin->w_cursor.lnum)
+	last_cursormoved.lnum = 0;
+#endif
 }
 
 /*
--- a/src/misc2.c
+++ b/src/misc2.c
@@ -2793,13 +2793,9 @@ set_fileformat(t, opt_flags)
 	break;
     }
     if (p != NULL)
-    {
 	set_string_option_direct((char_u *)"ff", -1, (char_u *)p,
-							OPT_FREE | opt_flags);
-# ifdef FEAT_EVAL
-	set_option_scriptID((char_u *)"ff", current_SID);
-# endif
-    }
+						     OPT_FREE | opt_flags, 0);
+
 #ifdef FEAT_WINDOWS
     /* This may cause the buffer to become (un)modified. */
     check_status(curbuf);
--- a/src/option.c
+++ b/src/option.c
@@ -45,142 +45,193 @@
 #define PV_BOTH 0x1000
 #define PV_WIN  0x2000
 #define PV_BUF  0x4000
+#define PV_MASK 0x0fff
 #define OPT_WIN(x)  (idopt_T)(PV_WIN + (int)(x))
 #define OPT_BUF(x)  (idopt_T)(PV_BUF + (int)(x))
 #define OPT_BOTH(x) (idopt_T)(PV_BOTH + (int)(x))
 
 /*
- * "indir" values for buffer-local opions
+ * Definition of the PV_ values for buffer-local options.
+ * The BV_ values are defined in option.h.
  */
-enum
-{
-    BV_AI = 0
-    , BV_AR
-#if defined(FEAT_QUICKFIX)
-    , BV_BH
-#endif
-    , BV_BIN
-    , BV_BL
-    , BV_COUNT	    /* must be the last one */
-};
-
 #define PV_AI		OPT_BUF(BV_AI)
 #define PV_AR		OPT_BOTH(OPT_BUF(BV_AR))
-#if defined(FEAT_QUICKFIX)
+#ifdef FEAT_QUICKFIX
 # define PV_BH		OPT_BUF(BV_BH)
+# define PV_BT		OPT_BUF(BV_BT)
+# define PV_EFM		OPT_BOTH(OPT_BUF(BV_EFM))
+# define PV_GP		OPT_BOTH(OPT_BUF(BV_GP))
+# define PV_MP		OPT_BOTH(OPT_BUF(BV_MP))
 #endif
 #define PV_BIN		OPT_BUF(BV_BIN)
 #define PV_BL		OPT_BUF(BV_BL)
+#ifdef FEAT_MBYTE
+# define PV_BOMB	OPT_BUF(BV_BOMB)
+#endif
+#define PV_CI		OPT_BUF(BV_CI)
+#ifdef FEAT_CINDENT
+# define PV_CIN		OPT_BUF(BV_CIN)
+# define PV_CINK	OPT_BUF(BV_CINK)
+# define PV_CINO	OPT_BUF(BV_CINO)
+#endif
+#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
+# define PV_CINW	OPT_BUF(BV_CINW)
+#endif
+#ifdef FEAT_FOLDING
+# define PV_CMS		OPT_BUF(BV_CMS)
+#endif
+#ifdef FEAT_COMMENTS
+# define PV_COM		OPT_BUF(BV_COM)
+#endif
+#ifdef FEAT_INS_EXPAND
+# define PV_CPT		OPT_BUF(BV_CPT)
+# define PV_DICT	OPT_BOTH(OPT_BUF(BV_DICT))
+# define PV_TSR		OPT_BOTH(OPT_BUF(BV_TSR))
+#endif
+#ifdef FEAT_COMPL_FUNC
+# define PV_CFU		OPT_BUF(BV_CFU)
+#endif
+#ifdef FEAT_FIND_ID
+# define PV_DEF		OPT_BOTH(OPT_BUF(BV_DEF))
+# define PV_INC		OPT_BOTH(OPT_BUF(BV_INC))
+#endif
+#define PV_EOL		OPT_BUF(BV_EOL)
+#define PV_EP		OPT_BOTH(OPT_BUF(BV_EP))
+#define PV_ET		OPT_BUF(BV_ET)
+#ifdef FEAT_MBYTE
+# define PV_FENC	OPT_BUF(BV_FENC)
+#endif
+#ifdef FEAT_EVAL
+# define PV_FEX		OPT_BUF(BV_FEX)
+#endif
+#define PV_FF		OPT_BUF(BV_FF)
+#define PV_FLP		OPT_BUF(BV_FLP)
+#define PV_FO		OPT_BUF(BV_FO)
+#ifdef FEAT_AUTOCMD
+# define PV_FT		OPT_BUF(BV_FT)
+#endif
+#define PV_IMI		OPT_BUF(BV_IMI)
+#define PV_IMS		OPT_BUF(BV_IMS)
+#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
+# define PV_INDE	OPT_BUF(BV_INDE)
+# define PV_INDK	OPT_BUF(BV_INDK)
+#endif
+#if defined(FEAT_FIND_ID) && defined(FEAT_EVAL)
+# define PV_INEX	OPT_BUF(BV_INEX)
+#endif
+#define PV_INF		OPT_BUF(BV_INF)
+#define PV_ISK		OPT_BUF(BV_ISK)
+#ifdef FEAT_CRYPT
+# define PV_KEY		OPT_BUF(BV_KEY)
+#endif
+#ifdef FEAT_KEYMAP
+# define PV_KMAP	OPT_BUF(BV_KMAP)
+#endif
+#define PV_KP		OPT_BOTH(OPT_BUF(BV_KP))
+#ifdef FEAT_LISP
+# define PV_LISP	OPT_BUF(BV_LISP)
+#endif
+#define PV_MA		OPT_BUF(BV_MA)
+#define PV_ML		OPT_BUF(BV_ML)
+#define PV_MOD		OPT_BUF(BV_MOD)
+#define PV_MPS		OPT_BUF(BV_MPS)
+#define PV_NF		OPT_BUF(BV_NF)
+#ifdef FEAT_OSFILETYPE
+# define PV_OFT		OPT_BUF(BV_OFT)
+#endif
+#ifdef FEAT_COMPL_FUNC
+# define PV_OFU		OPT_BUF(BV_OFU)
+#endif
+#define PV_PATH		OPT_BOTH(OPT_BUF(BV_PATH))
+#define PV_PI		OPT_BUF(BV_PI)
+#ifdef FEAT_TEXTOBJ
+# define PV_QE		OPT_BUF(BV_QE)
+#endif
+#define PV_RO		OPT_BUF(BV_RO)
+#ifdef FEAT_SMARTINDENT
+# define PV_SI		OPT_BUF(BV_SI)
+#endif
+#ifndef SHORT_FNAME
+# define PV_SN		OPT_BUF(BV_SN)
+#endif
+#ifdef FEAT_SYN_HL
+# define PV_SMC		OPT_BUF(BV_SMC)
+# define PV_SPC		OPT_BUF(BV_SPC)
+# define PV_SPF		OPT_BUF(BV_SPF)
+# define PV_SPL		OPT_BUF(BV_SPL)
+# define PV_SYN		OPT_BUF(BV_SYN)
+#endif
+#define PV_STS		OPT_BUF(BV_STS)
+#ifdef FEAT_SEARCHPATH
+# define PV_SUA		OPT_BUF(BV_SUA)
+#endif
+#define PV_SW		OPT_BUF(BV_SW)
+#define PV_SWF		OPT_BUF(BV_SWF)
+#define PV_TAGS		OPT_BOTH(OPT_BUF(BV_TAGS))
+#define PV_TS		OPT_BUF(BV_TS)
+#define PV_TW		OPT_BUF(BV_TW)
+#define PV_TX		OPT_BUF(BV_TX)
+#define PV_WM		OPT_BUF(BV_WM)
 
 /*
- * "indir" values for window-local options
+ * Definition of the PV_ values for window-local options.
+ * The WV_ values are defined in option.h.
  */
-enum
-{
-    WV_LIST = 0
-#ifdef FEAT_ARABIC
-	, WV_ARAB
-#endif
-    , WV_COUNT	    /* must be the last one */
-};
-
 #define PV_LIST		OPT_WIN(WV_LIST)
 #ifdef FEAT_ARABIC
 # define PV_ARAB	OPT_WIN(WV_ARAB)
 #endif
-
-/* TODO: "indir" values for the rest */
+#ifdef FEAT_DIFF
+# define PV_DIFF	OPT_WIN(WV_DIFF)
+#endif
+#ifdef FEAT_FOLDING
+# define PV_FDC		OPT_WIN(WV_FDC)
+# define PV_FEN		OPT_WIN(WV_FEN)
+# define PV_FDI		OPT_WIN(WV_FDI)
+# define PV_FDL		OPT_WIN(WV_FDL)
+# define PV_FDM		OPT_WIN(WV_FDM)
+# define PV_FML		OPT_WIN(WV_FML)
+# define PV_FDN		OPT_WIN(WV_FDN)
+# ifdef FEAT_EVAL
+#  define PV_FDE	OPT_WIN(WV_FDE)
+#  define PV_FDT	OPT_WIN(WV_FDT)
+# endif
+# define PV_FMR		OPT_WIN(WV_FMR)
+#endif
+#ifdef FEAT_LINEBREAK
+# define PV_LBR		OPT_WIN(WV_LBR)
+#endif
+#define PV_NU		OPT_WIN(WV_NU)
+#ifdef FEAT_LINEBREAK
+# define PV_NUW		OPT_WIN(WV_NUW)
+#endif
+#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
+# define PV_PVW		OPT_WIN(WV_PVW)
+#endif
+#ifdef FEAT_RIGHTLEFT
+# define PV_RL		OPT_WIN(WV_RL)
+# define PV_RLC		OPT_WIN(WV_RLC)
+#endif
+#ifdef FEAT_SCROLLBIND
+# define PV_SCBIND	OPT_WIN(WV_SCBIND)
+#endif
+#define PV_SCROLL	OPT_WIN(WV_SCROLL)
+#ifdef FEAT_SYN_HL
+# define PV_SPELL	OPT_WIN(WV_SPELL)
+#endif
+#ifdef FEAT_STL_OPT
+# define PV_STL		OPT_BOTH(OPT_WIN(WV_STL))
+#endif
+#ifdef FEAT_WINDOWS
+# define PV_WFH		OPT_WIN(WV_WFH)
+#endif
+#define PV_WRAP		OPT_WIN(WV_WRAP)
+
+
+/* WV_ and BV_ values get typecasted to this for the "indir" field */
 typedef enum
 {
     PV_NONE = 0
-    , PV_BOMB
-    , PV_BT
-    , PV_CI
-    , PV_CIN
-    , PV_CINK
-    , PV_CINO
-    , PV_CINW
-    , PV_CMS
-    , PV_COM
-    , PV_CPT
-    , PV_CFU
-    , PV_DEF
-    , PV_DICT
-    , PV_DIFF
-    , PV_EFM
-    , PV_EOL
-    , PV_EP
-    , PV_ET
-    , PV_FDC
-    , PV_FDE
-    , PV_FDI
-    , PV_FDL
-    , PV_FDM
-    , PV_FDN
-    , PV_FDT
-    , PV_FEN
-    , PV_FENC
-    , PV_FEX
-    , PV_FF
-    , PV_FML
-    , PV_FMR
-    , PV_FLP
-    , PV_FO
-    , PV_FT
-    , PV_GP
-    , PV_IMI
-    , PV_IMS
-    , PV_INC
-    , PV_INDE
-    , PV_INDK
-    , PV_INEX
-    , PV_INF
-    , PV_ISK
-    , PV_KEY
-    , PV_KMAP
-    , PV_KP
-    , PV_LBR
-    , PV_LISP
-    , PV_MA
-    , PV_ML
-    , PV_MOD
-    , PV_MP
-    , PV_MPS
-    , PV_NF
-    , PV_NU
-    , PV_NUW
-    , PV_OFT
-    , PV_OFU
-    , PV_PATH
-    , PV_PI
-    , PV_PVW
-    , PV_QE
-    , PV_RL
-    , PV_RLC
-    , PV_RO
-    , PV_SCBIND
-    , PV_SCROLL
-    , PV_SI
-    , PV_SN
-    , PV_SPELL
-    , PV_SPC
-    , PV_SPF
-    , PV_SPL
-    , PV_STL
-    , PV_STS
-    , PV_SUA
-    , PV_SW
-    , PV_SWF
-    , PV_SMC
-    , PV_SYN
-    , PV_TAGS
-    , PV_TS
-    , PV_TSR
-    , PV_TW
-    , PV_TX
-    , PV_WFH
-    , PV_WM
-    , PV_WRAP
 } idopt_T;
 
 /*
@@ -784,7 +835,7 @@ static struct vimoption
 			    {(char_u *)"", (char_u *)0L}},
     {"define",	    "def",  P_STRING|P_ALLOCED|P_VI_DEF,
 #ifdef FEAT_FIND_ID
-			    (char_u *)&p_def, OPT_BOTH(PV_DEF),
+			    (char_u *)&p_def, PV_DEF,
 			    {(char_u *)"^\\s*#\\s*define", (char_u *)0L}
 #else
 			    (char_u *)NULL, PV_NONE,
@@ -801,7 +852,7 @@ static struct vimoption
 			    },
     {"dictionary",  "dict", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP,
 #ifdef FEAT_INS_EXPAND
-			    (char_u *)&p_dict, OPT_BOTH(PV_DICT),
+			    (char_u *)&p_dict, PV_DICT,
 #else
 			    (char_u *)NULL, PV_NONE,
 #endif
@@ -872,7 +923,7 @@ static struct vimoption
 			    (char_u *)&p_ea, PV_NONE,
 			    {(char_u *)TRUE, (char_u *)0L}},
     {"equalprg",    "ep",   P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
-			    (char_u *)&p_ep, OPT_BOTH(PV_EP),
+			    (char_u *)&p_ep, PV_EP,
 			    {(char_u *)"", (char_u *)0L}},
     {"errorbells",  "eb",   P_BOOL|P_VI_DEF,
 			    (char_u *)&p_eb, PV_NONE,
@@ -888,7 +939,7 @@ static struct vimoption
 			    },
     {"errorformat", "efm",  P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
 #ifdef FEAT_QUICKFIX
-			    (char_u *)&p_efm, OPT_BOTH(PV_EFM),
+			    (char_u *)&p_efm, PV_EFM,
 			    {(char_u *)DFLT_EFM, (char_u *)0L},
 #else
 			    (char_u *)NULL, PV_NONE,
@@ -1019,7 +1070,7 @@ static struct vimoption
 			    },
 #endif
     {"formatexpr", "fex",   P_STRING|P_ALLOCED|P_VI_DEF|P_VIM,
-#if defined(FEAT_EVAL)
+#ifdef FEAT_EVAL
 			    (char_u *)&p_fex, PV_FEX,
 			    {(char_u *)"", (char_u *)0L}
 #else
@@ -1062,7 +1113,7 @@ static struct vimoption
 			    },
     {"grepprg",	    "gp",   P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
 #ifdef FEAT_QUICKFIX
-			    (char_u *)&p_gp, OPT_BOTH(PV_GP),
+			    (char_u *)&p_gp, PV_GP,
 			    {
 # ifdef WIN3264
 			    /* may be changed to "grep -n" in os_win32.c */
@@ -1274,7 +1325,7 @@ static struct vimoption
 			    },
     {"include",	    "inc",  P_STRING|P_ALLOCED|P_VI_DEF,
 #ifdef FEAT_FIND_ID
-			    (char_u *)&p_inc, OPT_BOTH(PV_INC),
+			    (char_u *)&p_inc, PV_INC,
 			    {(char_u *)"^\\s*#\\s*include", (char_u *)0L}
 #else
 			    (char_u *)NULL, PV_NONE,
@@ -1421,7 +1472,7 @@ static struct vimoption
 #endif
 			    {(char_u *)"", (char_u *)0L}},
     {"keywordprg",  "kp",   P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
-			    (char_u *)&p_kp, OPT_BOTH(PV_KP),
+			    (char_u *)&p_kp, PV_KP,
 			    {
 #if defined(MSDOS) || defined(MSWIN)
 			    (char_u *)":help",
@@ -1534,7 +1585,7 @@ static struct vimoption
 			    },
     {"makeprg",	    "mp",   P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
 #ifdef FEAT_QUICKFIX
-			    (char_u *)&p_mp, OPT_BOTH(PV_MP),
+			    (char_u *)&p_mp, PV_MP,
 # ifdef VMS
 			    {(char_u *)"MMS", (char_u *)0L}
 # else
@@ -1724,7 +1775,7 @@ static struct vimoption
 			    (char_u *)&p_pm, PV_NONE,
 			    {(char_u *)"", (char_u *)0L}},
     {"path",	    "pa",   P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP,
-			    (char_u *)&p_path, OPT_BOTH(PV_PATH),
+			    (char_u *)&p_path, PV_PATH,
 			    {
 #if defined AMIGA || defined MSDOS || defined MSWIN
 			    (char_u *)".,,",
@@ -2192,7 +2243,7 @@ static struct vimoption
 			    {(char_u *)TRUE, (char_u *)0L}},
     {"statusline"  ,"stl",  P_STRING|P_VI_DEF|P_ALLOCED|P_RSTAT,
 #ifdef FEAT_STL_OPT
-			    (char_u *)&p_stl, OPT_BOTH(PV_STL),
+			    (char_u *)&p_stl, PV_STL,
 #else
 			    (char_u *)NULL, PV_NONE,
 #endif
@@ -2202,7 +2253,7 @@ static struct vimoption
 			    {(char_u *)".bak,~,.o,.h,.info,.swp,.obj",
 				(char_u *)0L}},
     {"suffixesadd", "sua",  P_STRING|P_VI_DEF|P_ALLOCED|P_COMMA|P_NODUP,
-#if defined(FEAT_SEARCHPATH)
+#ifdef FEAT_SEARCHPATH
 			    (char_u *)&p_sua, PV_SUA,
 			    {(char_u *)"", (char_u *)0L}
 #else
@@ -2262,7 +2313,7 @@ static struct vimoption
 			    (char_u *)&p_tr, PV_NONE,
 			    {(char_u *)FALSE, (char_u *)TRUE}},
     {"tags",	    "tag",  P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP,
-			    (char_u *)&p_tags, OPT_BOTH(PV_TAGS),
+			    (char_u *)&p_tags, PV_TAGS,
 			    {
 #if defined(FEAT_EMACS_TAGS) && !defined(CASE_INSENSITIVE_FILENAME)
 			    (char_u *)"./tags,./TAGS,tags,TAGS",
@@ -2312,7 +2363,7 @@ static struct vimoption
 			    {(char_u *)0L, (char_u *)0L}},
     {"thesaurus",   "tsr",  P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP,
 #ifdef FEAT_INS_EXPAND
-			    (char_u *)&p_tsr, OPT_BOTH(PV_TSR),
+			    (char_u *)&p_tsr, PV_TSR,
 #else
 			    (char_u *)NULL, PV_NONE,
 #endif
@@ -2531,7 +2582,7 @@ static struct vimoption
 #endif
 			    {(char_u *)1L, (char_u *)0L}},
     {"winfixheight", "wfh", P_BOOL|P_VI_DEF|P_RSTAT,
-#if defined(FEAT_WINDOWS)
+#ifdef FEAT_WINDOWS
 			    (char_u *)VAR_WIN, PV_WFH,
 #else
 			    (char_u *)NULL, PV_NONE,
@@ -2737,6 +2788,9 @@ static char_u *check_clipboard_option __
 #ifdef FEAT_SYN_HL
 static char_u *compile_cap_prog __ARGS((buf_T *buf));
 #endif
+#ifdef FEAT_EVAL
+static void set_option_scriptID_idx __ARGS((int opt_idx, int opt_flags, int id));
+#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));
@@ -3139,7 +3193,7 @@ set_init_1()
 	    {
 		/* Adjust the default for 'isprint' to match latin1. */
 		set_string_option_direct((char_u *)"isp", -1,
-					     (char_u *)"@,161-255", OPT_FREE);
+				   (char_u *)"@,161-255", OPT_FREE, SID_NONE);
 		(void)init_chartab();
 	    }
 #endif
@@ -3211,7 +3265,7 @@ set_option_default(opt_idx, opt_flags, c
 	     * freeing and allocating the value. */
 	    if (options[opt_idx].indir != PV_NONE)
 		set_string_option_direct(NULL, opt_idx,
-				    options[opt_idx].def_val[dvi], opt_flags);
+				 options[opt_idx].def_val[dvi], opt_flags, 0);
 	    else
 	    {
 		if ((opt_flags & OPT_FREE) && (flags & P_ALLOCED))
@@ -3249,8 +3303,7 @@ set_option_default(opt_idx, opt_flags, c
     }
 
 #ifdef FEAT_EVAL
-    /* Remember where the option was set. */
-    options[opt_idx].scriptID = current_SID;
+    set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
 #endif
 }
 
@@ -3381,7 +3434,7 @@ set_init_2()
     idx = findoption((char_u *)"bg");
     if (!(options[idx].flags & P_WAS_SET) && *term_bg_default() == 'd')
     {
-	set_string_option_direct(NULL, idx, (char_u *)"dark", OPT_FREE);
+	set_string_option_direct(NULL, idx, (char_u *)"dark", OPT_FREE, 0);
 	/* don't mark it as set, when starting the GUI it may be
 	 * changed again */
 	options[idx].flags &= ~P_WAS_SET;
@@ -3966,7 +4019,17 @@ do_set(arg, opt_flags)
 		    showoneopt(&options[opt_idx], opt_flags);
 #ifdef FEAT_EVAL
 		    if (p_verbose > 0)
-			last_set_msg(options[opt_idx].scriptID);
+		    {
+			/* Mention where the option was last set. */
+			if (varp == options[opt_idx].var)
+			    last_set_msg(options[opt_idx].scriptID);
+			else if ((int)options[opt_idx].indir & PV_WIN)
+			    last_set_msg(curwin->w_p_scriptID[
+				      (int)options[opt_idx].indir & PV_MASK]);
+			else if ((int)options[opt_idx].indir & PV_BUF)
+			    last_set_msg(curbuf->b_p_scriptID[
+				      (int)options[opt_idx].indir & PV_MASK]);
+		    }
 #endif
 		}
 		else
@@ -5010,19 +5073,19 @@ insecure_flag(opt_idx, opt_flags)
 	switch ((int)options[opt_idx].indir)
 	{
 #ifdef FEAT_STL_OPT
-	    case OPT_BOTH(PV_STL):  return &curwin->w_p_stl_flags;
+	    case PV_STL:	return &curwin->w_p_stl_flags;
 #endif
 #ifdef FEAT_EVAL
-	    case PV_FDE:	    return &curwin->w_p_fde_flags;
-	    case PV_FDT:	    return &curwin->w_p_fdt_flags;
+	    case PV_FDE:	return &curwin->w_p_fde_flags;
+	    case PV_FDT:	return &curwin->w_p_fdt_flags;
 #endif
 #if defined(FEAT_EVAL)
 # if defined(FEAT_CINDENT)
-	    case PV_INDE:	    return &curbuf->b_p_inde_flags;
+	    case PV_INDE:	return &curbuf->b_p_inde_flags;
 # endif
-	    case PV_FEX:	    return &curbuf->b_p_fex_flags;
+	    case PV_FEX:	return &curbuf->b_p_fex_flags;
 # ifdef FEAT_FIND_ID
-	    case PV_INEX:	    return &curbuf->b_p_inex_flags;
+	    case PV_INEX:	return &curbuf->b_p_inex_flags;
 # endif
 #endif
 	}
@@ -5036,13 +5099,17 @@ insecure_flag(opt_idx, opt_flags)
  * Set a string option to a new value (without checking the effect).
  * The string is copied into allocated memory.
  * if ("opt_idx" == -1) "name" is used, otherwise "opt_idx" is used.
+ * When "set_sid" is zero set the scriptID to current_SID.  When "set_sid" is
+ * SID_NONE don't set the scriptID.  Otherwose set the scriptID to "set_sid".
  */
+/*ARGSUSED*/
     void
-set_string_option_direct(name, opt_idx, val, opt_flags)
+set_string_option_direct(name, opt_idx, val, opt_flags, set_sid)
     char_u	*name;
     int		opt_idx;
     char_u	*val;
     int		opt_flags;	/* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */
+    int		set_sid;
 {
     char_u	*s;
     char_u	**varp;
@@ -5052,7 +5119,10 @@ set_string_option_direct(name, opt_idx, 
     {
 	opt_idx = findoption(name);
 	if (opt_idx == -1)	/* not found (should not happen) */
+	{
+	    EMSG2(_(e_intern2), "set_string_option_direct()");
 	    return;
+	}
     }
 
     if (options[opt_idx].var == NULL)	/* can't set hidden option */
@@ -5080,6 +5150,11 @@ set_string_option_direct(name, opt_idx, 
 	    free_string_option(*varp);
 	    *varp = empty_option;
 	}
+# ifdef FEAT_EVAL
+	if (set_sid != SID_NONE)
+	    set_option_scriptID_idx(opt_idx, opt_flags,
+					set_sid == 0 ? current_SID : set_sid);
+# endif
     }
 }
 
@@ -6376,7 +6451,7 @@ did_set_string_option(opt_idx, varp, new
     {
 #ifdef FEAT_EVAL
 	/* Remember where the option was set. */
-	options[opt_idx].scriptID = current_SID;
+	set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
 #endif
 	/*
 	 * Free string options that are in allocated memory.
@@ -6761,19 +6836,29 @@ compile_cap_prog(buf)
 
 #if defined(FEAT_EVAL) || defined(PROTO)
 /*
- * Set the script ID of option "name" to "id".
+ * Set the scriptID for an option, taking care of setting the buffer- or
+ * window-local value.
  */
-    void
-set_option_scriptID(name, id)
-    char_u	*name;
-    int		id;
-{
-    int opt_idx = findoption(name);
-
-    if (opt_idx == -1)	/* not found (should not happen) */
-	EMSG2(_(e_intern2), "set_option_scriptID()");
-    else
+    static void
+set_option_scriptID_idx(opt_idx, opt_flags, id)
+    int	    opt_idx;
+    int	    opt_flags;
+    int	    id;
+{
+    int		both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0;
+    int		indir = (int)options[opt_idx].indir;
+
+    /* Remember where the option was set.  For local options need to do that
+     * in the buffer or window structure. */
+    if (both || (opt_flags & OPT_GLOBAL) || (indir & (PV_BUF|PV_WIN)) == 0)
 	options[opt_idx].scriptID = id;
+    if (both || (opt_flags & OPT_LOCAL))
+    {
+	if (indir & PV_BUF)
+	    curbuf->b_p_scriptID[indir & PV_MASK] = id;
+	else if (indir & PV_WIN)
+	    curwin->w_p_scriptID[indir & PV_MASK] = id;
+    }
 }
 #endif
 
@@ -6801,7 +6886,7 @@ set_bool_option(opt_idx, varp, value, op
     *(int *)varp = value;	    /* set the new value */
 #ifdef FEAT_EVAL
     /* Remember where the option was set. */
-    options[opt_idx].scriptID = current_SID;
+    set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
 #endif
 
 #ifdef FEAT_GUI
@@ -6885,10 +6970,7 @@ set_bool_option(opt_idx, varp, value, op
 	{
 	    STRCPY(IObuff, p_shm);
 	    STRCAT(IObuff, "s");
-	    set_string_option_direct((char_u *)"shm", -1, IObuff, OPT_FREE);
-# ifdef FEAT_EVAL
-	    set_option_scriptID((char_u *)"shm", current_SID);
-# endif
+	    set_string_option_direct((char_u *)"shm", -1, IObuff, OPT_FREE, 0);
 	}
 	/* remove 's' from p_shm */
 	else if (!p_terse && p != NULL)
@@ -6970,14 +7052,9 @@ set_bool_option(opt_idx, varp, value, op
 
     /* when 'textauto' is set or reset also change 'fileformats' */
     else if ((int *)varp == &p_ta)
-    {
 	set_string_option_direct((char_u *)"ffs", -1,
 				 p_ta ? (char_u *)DFLT_FFS_VIM : (char_u *)"",
-							OPT_FREE | opt_flags);
-# ifdef FEAT_EVAL
-	set_option_scriptID((char_u *)"ffs", current_SID);
-# endif
-    }
+						     OPT_FREE | opt_flags, 0);
 
     /*
      * When 'lisp' option changes include/exclude '-' in
@@ -7313,7 +7390,7 @@ set_num_option(opt_idx, varp, value, err
     *pp = value;
 #ifdef FEAT_EVAL
     /* Remember where the option was set. */
-    options[opt_idx].scriptID = current_SID;
+    set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
 #endif
 #ifdef FEAT_GUI
     need_mouse_correct = TRUE;
@@ -8297,23 +8374,39 @@ makeset(fd, opt_flags, local_only)
 		}
 		else    /* P_STRING */
 		{
+#if defined(FEAT_SYN_HL) || defined(FEAT_AUTOCMD)
+		    int		do_endif = FALSE;
+
 		    /* Don't set 'syntax' and 'filetype' again if the value is
 		     * already right, avoids reloading the syntax file. */
-		    if (p->indir == PV_SYN || p->indir == PV_FT)
+		    if (
+# if defined(FEAT_SYN_HL)
+			    p->indir == PV_SYN
+#  if defined(FEAT_AUTOCMD)
+			    ||
+#  endif
+# endif
+# if defined(FEAT_AUTOCMD)
+			    p->indir == PV_FT)
+# endif
 		    {
 			if (fprintf(fd, "if &%s != '%s'", p->fullname,
 						       *(char_u **)(varp)) < 0
 				|| put_eol(fd) < 0)
 			    return FAIL;
+			do_endif = TRUE;
 		    }
+#endif
 		    if (put_setstring(fd, cmd, p->fullname, (char_u **)varp,
 					  (p->flags & P_EXPAND) != 0) == FAIL)
 			return FAIL;
-		    if (p->indir == PV_SYN || p->indir == PV_FT)
+#if defined(FEAT_SYN_HL) || defined(FEAT_AUTOCMD)
+		    if (do_endif)
 		    {
 			if (put_line(fd, "endif") == FAIL)
 			    return FAIL;
 		    }
+#endif
 		}
 	    }
 	}
@@ -8583,25 +8676,25 @@ get_varp_scope(p, opt_flags)
 	switch ((int)p->indir)
 	{
 #ifdef FEAT_QUICKFIX
-	    case OPT_BOTH(PV_GP):   return (char_u *)&(curbuf->b_p_gp);
-	    case OPT_BOTH(PV_MP):   return (char_u *)&(curbuf->b_p_mp);
-	    case OPT_BOTH(PV_EFM):  return (char_u *)&(curbuf->b_p_efm);
-#endif
-	    case OPT_BOTH(PV_EP):   return (char_u *)&(curbuf->b_p_ep);
-	    case OPT_BOTH(PV_KP):   return (char_u *)&(curbuf->b_p_kp);
-	    case OPT_BOTH(PV_PATH): return (char_u *)&(curbuf->b_p_path);
+	    case PV_EFM:  return (char_u *)&(curbuf->b_p_efm);
+	    case PV_GP:   return (char_u *)&(curbuf->b_p_gp);
+	    case PV_MP:   return (char_u *)&(curbuf->b_p_mp);
+#endif
+	    case PV_EP:   return (char_u *)&(curbuf->b_p_ep);
+	    case PV_KP:   return (char_u *)&(curbuf->b_p_kp);
+	    case PV_PATH: return (char_u *)&(curbuf->b_p_path);
 	    case PV_AR:   return (char_u *)&(curbuf->b_p_ar);
-	    case OPT_BOTH(PV_TAGS): return (char_u *)&(curbuf->b_p_tags);
+	    case PV_TAGS: return (char_u *)&(curbuf->b_p_tags);
 #ifdef FEAT_FIND_ID
-	    case OPT_BOTH(PV_DEF):  return (char_u *)&(curbuf->b_p_def);
-	    case OPT_BOTH(PV_INC):  return (char_u *)&(curbuf->b_p_inc);
+	    case PV_DEF:  return (char_u *)&(curbuf->b_p_def);
+	    case PV_INC:  return (char_u *)&(curbuf->b_p_inc);
 #endif
 #ifdef FEAT_INS_EXPAND
-	    case OPT_BOTH(PV_DICT): return (char_u *)&(curbuf->b_p_dict);
-	    case OPT_BOTH(PV_TSR):  return (char_u *)&(curbuf->b_p_tsr);
+	    case PV_DICT: return (char_u *)&(curbuf->b_p_dict);
+	    case PV_TSR:  return (char_u *)&(curbuf->b_p_tsr);
 #endif
 #ifdef FEAT_STL_OPT
-	    case OPT_BOTH(PV_STL):  return (char_u *)&(curwin->w_p_stl);
+	    case PV_STL:  return (char_u *)&(curwin->w_p_stl);
 #endif
 	}
 	return NULL; /* "cannot happen" */
@@ -8625,38 +8718,38 @@ get_varp(p)
 	case PV_NONE:	return p->var;
 
 	/* global option with local value: use local value if it's been set */
-	case OPT_BOTH(PV_EP):	return *curbuf->b_p_ep != NUL
+	case PV_EP:	return *curbuf->b_p_ep != NUL
 				    ? (char_u *)&curbuf->b_p_ep : p->var;
-	case OPT_BOTH(PV_KP):	return *curbuf->b_p_kp != NUL
+	case PV_KP:	return *curbuf->b_p_kp != NUL
 				    ? (char_u *)&curbuf->b_p_kp : p->var;
-	case OPT_BOTH(PV_PATH):	return *curbuf->b_p_path != NUL
+	case PV_PATH:	return *curbuf->b_p_path != NUL
 				    ? (char_u *)&(curbuf->b_p_path) : p->var;
 	case PV_AR:	return curbuf->b_p_ar >= 0
 				    ? (char_u *)&(curbuf->b_p_ar) : p->var;
-	case OPT_BOTH(PV_TAGS):	return *curbuf->b_p_tags != NUL
+	case PV_TAGS:	return *curbuf->b_p_tags != NUL
 				    ? (char_u *)&(curbuf->b_p_tags) : p->var;
 #ifdef FEAT_FIND_ID
-	case OPT_BOTH(PV_DEF):	return *curbuf->b_p_def != NUL
+	case PV_DEF:	return *curbuf->b_p_def != NUL
 				    ? (char_u *)&(curbuf->b_p_def) : p->var;
-	case OPT_BOTH(PV_INC):	return *curbuf->b_p_inc != NUL
+	case PV_INC:	return *curbuf->b_p_inc != NUL
 				    ? (char_u *)&(curbuf->b_p_inc) : p->var;
 #endif
 #ifdef FEAT_INS_EXPAND
-	case OPT_BOTH(PV_DICT):	return *curbuf->b_p_dict != NUL
+	case PV_DICT:	return *curbuf->b_p_dict != NUL
 				    ? (char_u *)&(curbuf->b_p_dict) : p->var;
-	case OPT_BOTH(PV_TSR):	return *curbuf->b_p_tsr != NUL
+	case PV_TSR:	return *curbuf->b_p_tsr != NUL
 				    ? (char_u *)&(curbuf->b_p_tsr) : p->var;
 #endif
 #ifdef FEAT_QUICKFIX
-	case OPT_BOTH(PV_GP):	return *curbuf->b_p_gp != NUL
+	case PV_EFM:	return *curbuf->b_p_efm != NUL
+				    ? (char_u *)&(curbuf->b_p_efm) : p->var;
+	case PV_GP:	return *curbuf->b_p_gp != NUL
 				    ? (char_u *)&(curbuf->b_p_gp) : p->var;
-	case OPT_BOTH(PV_MP):	return *curbuf->b_p_mp != NUL
+	case PV_MP:	return *curbuf->b_p_mp != NUL
 				    ? (char_u *)&(curbuf->b_p_mp) : p->var;
-	case OPT_BOTH(PV_EFM):	return *curbuf->b_p_efm != NUL
-				    ? (char_u *)&(curbuf->b_p_efm) : p->var;
 #endif
 #ifdef FEAT_STL_OPT
-	case OPT_BOTH(PV_STL):  return *curwin->w_p_stl != NUL
+	case PV_STL:	return *curwin->w_p_stl != NUL
 				    ? (char_u *)&(curwin->w_p_stl) : p->var;
 #endif
 
@@ -8688,7 +8781,7 @@ get_varp(p)
 #ifdef FEAT_LINEBREAK
 	case PV_NUW:	return (char_u *)&(curwin->w_p_nuw);
 #endif
-#if defined(FEAT_WINDOWS)
+#ifdef FEAT_WINDOWS
 	case PV_WFH:	return (char_u *)&(curwin->w_p_wfh);
 #endif
 #if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
@@ -8763,7 +8856,7 @@ get_varp(p)
 	case PV_INDE:	return (char_u *)&(curbuf->b_p_inde);
 	case PV_INDK:	return (char_u *)&(curbuf->b_p_indk);
 #endif
-#if defined(FEAT_EVAL)
+#ifdef FEAT_EVAL
 	case PV_FEX:	return (char_u *)&(curbuf->b_p_fex);
 #endif
 #ifdef FEAT_CRYPT
@@ -8798,10 +8891,10 @@ get_varp(p)
 	case PV_SWF:	return (char_u *)&(curbuf->b_p_swf);
 #ifdef FEAT_SYN_HL
 	case PV_SMC:	return (char_u *)&(curbuf->b_p_smc);
-	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);
+	case PV_SYN:	return (char_u *)&(curbuf->b_p_syn);
 #endif
 	case PV_SW:	return (char_u *)&(curbuf->b_p_sw);
 	case PV_TS:	return (char_u *)&(curbuf->b_p_ts);
--- a/src/option.h
+++ b/src/option.h
@@ -850,3 +850,190 @@ EXTERN int	p_write;	/* 'write' */
 EXTERN int	p_wa;		/* 'writeany' */
 EXTERN int	p_wb;		/* 'writebackup' */
 EXTERN long	p_wd;		/* 'writedelay' */
+
+/*
+ * "indir" values for buffer-local opions.
+ * These need to be defined globally, so that the BV_COUNT can be used with
+ * b_p_scriptID[].
+ */
+enum
+{
+    BV_AI = 0
+    , BV_AR
+#ifdef FEAT_QUICKFIX
+    , BV_BH
+    , BV_BT
+    , BV_EFM
+    , BV_GP
+    , BV_MP
+#endif
+    , BV_BIN
+    , BV_BL
+#ifdef FEAT_MBYTE
+    , BV_BOMB
+#endif
+    , BV_CI
+#ifdef FEAT_CINDENT
+    , BV_CIN
+    , BV_CINK
+    , BV_CINO
+#endif
+#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
+    , BV_CINW
+#endif
+#ifdef FEAT_FOLDING
+    , BV_CMS
+#endif
+#ifdef FEAT_COMMENTS
+    , BV_COM
+#endif
+#ifdef FEAT_INS_EXPAND
+    , BV_CPT
+    , BV_DICT
+    , BV_TSR
+#endif
+#ifdef FEAT_COMPL_FUNC
+    , BV_CFU
+#endif
+#ifdef FEAT_FIND_ID
+    , BV_DEF
+    , BV_INC
+#endif
+    , BV_EOL
+    , BV_EP
+    , BV_ET
+    , BV_FENC
+#ifdef FEAT_EVAL
+    , BV_FEX
+#endif
+    , BV_FF
+    , BV_FLP
+    , BV_FO
+#ifdef FEAT_AUTOCMD
+    , BV_FT
+#endif
+    , BV_IMI
+    , BV_IMS
+#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
+    , BV_INDE
+    , BV_INDK
+#endif
+#if defined(FEAT_FIND_ID) && defined(FEAT_EVAL)
+    , BV_INEX
+#endif
+    , BV_INF
+    , BV_ISK
+#ifdef FEAT_CRYPT
+    , BV_KEY
+#endif
+#ifdef FEAT_KEYMAP
+    , BV_KMAP
+#endif
+    , BV_KP
+#ifdef FEAT_LISP
+    , BV_LISP
+#endif
+    , BV_MA
+    , BV_ML
+    , BV_MOD
+    , BV_MPS
+    , BV_NF
+#ifdef FEAT_OSFILETYPE
+    , BV_OFT
+#endif
+#ifdef FEAT_COMPL_FUNC
+    , BV_OFU
+#endif
+    , BV_PATH
+    , BV_PI
+#ifdef FEAT_TEXTOBJ
+    , BV_QE
+#endif
+    , BV_RO
+#ifdef FEAT_SMARTINDENT
+    , BV_SI
+#endif
+#ifndef SHORT_FNAME
+    , BV_SN
+#endif
+#ifdef FEAT_SYN_HL
+    , BV_SMC
+    , BV_SPC
+    , BV_SPF
+    , BV_SPL
+    , BV_SYN
+#endif
+    , BV_STS
+#ifdef FEAT_SEARCHPATH
+    , BV_SUA
+#endif
+    , BV_SW
+    , BV_SWF
+    , BV_TAGS
+    , BV_TS
+    , BV_TW
+    , BV_TX
+    , BV_WM
+    , BV_COUNT	    /* must be the last one */
+};
+
+/*
+ * "indir" values for window-local options.
+ * These need to be defined globally, so that the WV_COUNT can be used in the
+ * window structure.
+ */
+enum
+{
+    WV_LIST = 0
+#ifdef FEAT_ARABIC
+    , WV_ARAB
+#endif
+#ifdef FEAT_DIFF
+    , WV_DIFF
+#endif
+#ifdef FEAT_FOLDING
+    , WV_FDC
+    , WV_FEN
+    , WV_FDI
+    , WV_FDL
+    , WV_FDM
+    , WV_FML
+    , WV_FDN
+# ifdef FEAT_EVAL
+    , WV_FDE
+    , WV_FDT
+# endif
+    , WV_FMR
+#endif
+#ifdef FEAT_LINEBREAK
+    , WV_LBR
+#endif
+    , WV_NU
+#ifdef FEAT_LINEBREAK
+    , WV_NUW
+#endif
+#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
+    , WV_PVW
+#endif
+#ifdef FEAT_RIGHTLEFT
+    , WV_RL
+    , WV_RLC
+#endif
+#ifdef FEAT_SCROLLBIND
+    , WV_SCBIND
+#endif
+    , WV_SCROLL
+#ifdef FEAT_SYN_HL
+    , WV_SPELL
+    , WV_SPC
+    , WV_SYN
+#endif
+#ifdef FEAT_STL_OPT
+    , WV_STL
+#endif
+#ifdef FEAT_WINDOWS
+    , WV_WFH
+#endif
+    , WV_WRAP
+    , WV_COUNT	    /* must be the last one */
+};
--- a/src/os_riscos.c
+++ b/src/os_riscos.c
@@ -1245,7 +1245,7 @@ mch_read_filetype(file)
 	;
     type_string[i] = 0;
 
-    set_string_option_direct("osfiletype", -1, type_string, OPT_FREE);
+    set_string_option_direct("osfiletype", -1, type_string, OPT_FREE, 0);
     return;
 }
 
--- a/src/os_vms.c
+++ b/src/os_vms.c
@@ -298,33 +298,38 @@ vms_sys_status(int status)
     int
 vms_read(char *inbuf, size_t nbytes)
 {
-    int		status, function, len;
-    TT_MODE	tt_mode;
-    ITEM	itmlst[3];
+    int         status, function, len;
+    TT_MODE     tt_mode;
+    ITEM        itmlst[2];     /* terminates on everything */
     static long trm_mask[8] = {-1, -1, -1, -1, -1, -1, -1, -1};
 
     /* whatever happened earlier we need an iochan here */
     if (!iochan)
-	tt_mode = get_tty();
+        tt_mode = get_tty();
 
-    vul_item(&itmlst[0], 0, TRM$_MODIFIERS,
-	     (char *)( TRM$M_TM_ESCAPE	| TRM$M_TM_TIMED    | TRM$M_TM_NOECHO |
-		       TRM$M_TM_NOEDIT	| TRM$M_TM_NOFILTR  |
-		       TRM$M_TM_NORECALL| TRM$M_TM_TRMNOECHO), 0);
-    vul_item(&itmlst[1], 0, TRM$_TIMEOUT, (char *) 1, 0 );
-    vul_item(&itmlst[2], sizeof(trm_mask), TRM$_TERM, (char *)&trm_mask, 0);
-
-    function = (IO$_READLBLK | IO$M_EXTEND);
+    /* important: clean the inbuf */
     memset(inbuf, 0, nbytes);
 
-    for (;;)
-    {
-	status = sys$qiow(0, iochan, function, &iosb, 0, 0, inbuf, nbytes - 1,
-					       0, 0, &itmlst, sizeof(itmlst));
-	len = strlen(inbuf);
-	if (len > 0)
-	    break;
-    }
+    /* set up the itemlist for the first read */
+    vul_item(&itmlst[0], 0, TRM$_MODIFIERS,
+         (char *)( TRM$M_TM_NOECHO  | TRM$M_TM_NOEDIT    |
+                   TRM$M_TM_NOFILTR | TRM$M_TM_TRMNOECHO |
+                   TRM$M_TM_NORECALL) , 0);
+    vul_item(&itmlst[1], sizeof(trm_mask), TRM$_TERM, (char *)&trm_mask, 0);
+
+    /* wait forever for a char */
+    function = (IO$_READLBLK | IO$M_EXTEND);
+    status = sys$qiow(0, iochan, function, &iosb, 0, 0,
+                         inbuf, nbytes-1, 0, 0, &itmlst, sizeof(itmlst));
+    len = strlen(inbuf); /* how many chars we got? */
+
+    /* read immedatelly the rest in the IO queue   */
+    function = (IO$_READLBLK | IO$M_TIMED | IO$M_ESCAPE | IO$M_NOECHO | IO$M_NOFILTR);
+    status = sys$qiow(0, iochan, function, &iosb, 0, 0,
+                         inbuf+len, nbytes-1-len, 0, 0, 0, 0);
+
+    len = strlen(inbuf); /* return the total length */
+
     return len;
 }
 
@@ -510,7 +515,7 @@ vms_unix_mixed_filespec(char *in, char *
 
     /* start of directory portion */
     ch = *in;
-    if ((ch == '[') || (ch == '/') || (ch == '<') ) {	/* start of directory(s) ? */
+    if ((ch == '[') || (ch == '/') || (ch == '<')) {	/* start of directory(s) ? */
 	ch = '[';
 	SKIP_FOLLOWING_SLASHES(in);
     } else if (EQN(in, "../", 3)) { /* Unix parent directory? */
--- a/src/proto/option.pro
+++ b/src/proto/option.pro
@@ -18,7 +18,7 @@ void free_string_option __ARGS((char_u *
 void clear_string_option __ARGS((char_u **pp));
 void set_term_option_alloced __ARGS((char_u **p));
 int was_set_insecurely __ARGS((char_u *opt, int opt_flags));
-void set_string_option_direct __ARGS((char_u *name, int opt_idx, char_u *val, int opt_flags));
+void set_string_option_direct __ARGS((char_u *name, int opt_idx, char_u *val, int opt_flags, int set_sid));
 char_u *check_stl_option __ARGS((char_u *s));
 void set_option_scriptID __ARGS((char_u *name, int id));
 int get_option_value __ARGS((char_u *name, long *numval, char_u **stringval, int opt_flags));
--- a/src/quickfix.c
+++ b/src/quickfix.c
@@ -2846,12 +2846,7 @@ ex_cfile(eap)
 	wp = curwin;
 
     if (*eap->arg != NUL)
-    {
-	set_string_option_direct((char_u *)"ef", -1, eap->arg, OPT_FREE);
-# ifdef FEAT_EVAL
-	set_option_scriptID((char_u *)"ef", current_SID);
-# endif
-    }
+	set_string_option_direct((char_u *)"ef", -1, eap->arg, OPT_FREE, 0);
 
     /*
      * This function is used by the :cfile, :cgetfile and :caddfile
--- a/src/screen.c
+++ b/src/screen.c
@@ -5469,14 +5469,9 @@ redraw_custum_statusline(wp)
     called_emsg = FALSE;
     win_redr_custom(wp, FALSE);
     if (called_emsg)
-    {
 	set_string_option_direct((char_u *)"statusline", -1,
 		(char_u *)"", OPT_FREE | (*wp->w_p_stl != NUL
-						   ? OPT_LOCAL : OPT_GLOBAL));
-# ifdef FEAT_EVAL
-	set_option_scriptID((char_u *)"statusline", SID_ERROR);
-# endif
-    }
+					? OPT_LOCAL : OPT_GLOBAL), SID_ERROR);
     called_emsg |= save_called_emsg;
 }
 #endif
@@ -8610,13 +8605,8 @@ draw_tabline()
 	called_emsg = FALSE;
 	win_redr_custom(NULL, FALSE);
 	if (called_emsg)
-	{
 	    set_string_option_direct((char_u *)"tabline", -1,
-						      (char_u *)"", OPT_FREE);
-# ifdef FEAT_EVAL
-	    set_option_scriptID((char_u *)"tabline", SID_ERROR);
-# endif
-	}
+					   (char_u *)"", OPT_FREE, SID_ERROR);
 	called_emsg |= save_called_emsg;
     }
     else
@@ -8915,13 +8905,8 @@ win_redr_ruler(wp, always)
 	called_emsg = FALSE;
 	win_redr_custom(wp, TRUE);
 	if (called_emsg)
-	{
 	    set_string_option_direct((char_u *)"rulerformat", -1,
-						      (char_u *)"", OPT_FREE);
-# ifdef FEAT_EVAL
-	    set_option_scriptID((char_u *)"rulerformat", SID_ERROR);
-# endif
-	}
+					   (char_u *)"", OPT_FREE, SID_ERROR);
 	called_emsg |= save_called_emsg;
 	return;
     }
--- a/src/structs.h
+++ b/src/structs.h
@@ -203,6 +203,11 @@ typedef struct
 #endif
     int		wo_wrap;
 #define w_p_wrap w_onebuf_opt.wo_wrap	/* 'wrap' */
+
+#ifdef FEAT_EVAL
+    int		wo_scriptID[WV_COUNT];	/* SIDs for window-local options */
+# define w_p_scriptID w_onebuf_opt.wo_scriptID
+#endif
 } winopt_T;
 
 /*
@@ -1283,6 +1288,10 @@ struct file_buffer
      */
     int		b_p_initialized;	/* set when options initialized */
 
+#ifdef FEAT_EVAL
+    int		b_p_scriptID[BV_COUNT];	/* SIDs for buffer-local options */
+#endif
+
     int		b_p_ai;		/* 'autoindent' */
     int		b_p_ai_nopaste;	/* b_p_ai saved for paste mode */
     int		b_p_ci;		/* 'copyindent' */
--- a/src/syntax.c
+++ b/src/syntax.c
@@ -6081,6 +6081,7 @@ static char *(highlight_init_both[]) =
 	"PmenuSbar ctermbg=Grey guibg=Grey",
 	"TabLineSel term=bold cterm=bold gui=bold",
 	"TabLineFill term=reverse cterm=reverse gui=reverse",
+	"MatchParen term=reverse ctermbg=Cyan guibg=Cyan",
 	NULL
     };
 
@@ -7925,8 +7926,10 @@ highlight_list_one(id)
 	msg_outtrans(HL_TABLE()[HL_TABLE()[id - 1].sg_link - 1].sg_name);
     }
 
+    if (!didh)
+	highlight_list_arg(id, didh, LIST_STRING, 0, (char_u *)"cleared", "");
 #ifdef FEAT_EVAL
-    if (didh && p_verbose > 0)
+    if (p_verbose > 0)
 	last_set_msg(sgp->sg_scriptID);
 #endif
 }
@@ -7973,8 +7976,11 @@ highlight_list_arg(id, didh, type, iarg,
 	didh = TRUE;
 	if (!got_int)
 	{
-	    MSG_PUTS_ATTR(name, hl_attr(HLF_D));
-	    MSG_PUTS_ATTR("=", hl_attr(HLF_D));
+	    if (*name != NUL)
+	    {
+		MSG_PUTS_ATTR(name, hl_attr(HLF_D));
+		MSG_PUTS_ATTR("=", hl_attr(HLF_D));
+	    }
 	    msg_outtrans(ts);
 	}
     }
--- a/src/term.c
+++ b/src/term.c
@@ -1561,10 +1561,7 @@ set_color_count(nr)
 	sprintf((char *)nr_colors, "%d", t_colors);
     else
 	*nr_colors = NUL;
-    set_string_option_direct((char_u *)"t_Co", -1, nr_colors, OPT_FREE);
-# ifdef FEAT_EVAL
-    set_option_scriptID((char_u *)"t_Co", current_SID);
-# endif
+    set_string_option_direct((char_u *)"t_Co", -1, nr_colors, OPT_FREE, 0);
 }
 #endif
 
@@ -1825,7 +1822,8 @@ set_termname(term)
 		    out_flush();
 		    ui_delay(2000L, TRUE);
 		}
-		set_string_option_direct((char_u *)"term", -1, term, OPT_FREE);
+		set_string_option_direct((char_u *)"term", -1, term,
+								 OPT_FREE, 0);
 		display_errors();
 	    }
 	    out_flush();
@@ -2503,10 +2501,7 @@ termcapinit(name)
 #endif
     if (term == NULL || *term == NUL)
 	term = DEFAULT_TERM;
-    set_string_option_direct((char_u *)"term", -1, term, OPT_FREE);
-# ifdef FEAT_EVAL
-    set_option_scriptID((char_u *)"term", current_SID);
-# endif
+    set_string_option_direct((char_u *)"term", -1, term, OPT_FREE, 0);
 
     /* Set the default terminal name. */
     set_string_default("term", term);
--- a/src/testdir/test51.ok
+++ b/src/testdir/test51.ok
@@ -2,14 +2,19 @@
 
 NewGroup       xxx term=bold cterm=italic ctermfg=2 ctermbg=3
 
+Group2         xxx cleared
 
 Group3         xxx term=underline cterm=bold
 
 
+NewGroup       xxx cleared
 
-
+Group2         xxx cleared
 
 
+Group2         xxx cleared
 
 
+Group3         xxx cleared
+
 E475: term='asdf
--- 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 (2006 Feb 26)"
-#define VIM_VERSION_LONG_DATE	"VIM - Vi IMproved 7.0aa ALPHA (2006 Feb 26, compiled "
+#define VIM_VERSION_LONG	"VIM - Vi IMproved 7.0aa ALPHA (2006 Feb 27)"
+#define VIM_VERSION_LONG_DATE	"VIM - Vi IMproved 7.0aa ALPHA (2006 Feb 27, compiled "
--- a/src/vim.h
+++ b/src/vim.h
@@ -1036,6 +1036,7 @@ extern char *(*dyn_libintl_textdomain)(c
 #define SID_CARG	-3	/* for "-c" argument */
 #define SID_ENV		-4	/* for sourcing environment variable */
 #define SID_ERROR	-5	/* option was reset because of an error */
+#define SID_NONE	-6	/* don't set scriptID */
 
 /*
  * Events for autocommands.