changeset 681:9364d114ed8d v7.0204

updated for version 7.0204
author vimboss
date Wed, 22 Feb 2006 21:25:37 +0000
parents 5b101ff9d4c4
children f1b013312711
files runtime/doc/editing.txt runtime/doc/eval.txt runtime/doc/index.txt runtime/doc/insert.txt runtime/doc/options.txt runtime/doc/tabpage.txt runtime/doc/tags runtime/doc/todo.txt runtime/doc/usr_41.txt runtime/doc/version7.txt runtime/doc/windows.txt src/buffer.c src/diff.c src/edit.c src/eval.c src/ex_cmds.c src/ex_cmds2.c src/ex_docmd.c src/fileio.c src/fold.c src/globals.h src/gui.c src/gui_beval.c src/hardcopy.c src/main.c src/mbyte.c src/misc1.c src/misc2.c src/normal.c src/ops.c src/option.c src/option.h src/proto/buffer.pro src/proto/edit.pro src/proto/option.pro src/proto/window.pro src/quickfix.c src/screen.c src/search.c src/structs.h src/term.c src/version.h src/vim.h src/window.c
diffstat 44 files changed, 619 insertions(+), 190 deletions(-) [+]
line wrap: on
line diff
--- a/runtime/doc/editing.txt
+++ b/runtime/doc/editing.txt
@@ -334,6 +334,22 @@ CTRL-^			Edit the alternate file (equiva
 			(For {Visual} see |Visual-mode|.)
 			{not in VI}
 
+							*gF*
+[count]gF		Same as "gf", except if a number follows the file
+			name, then the cursor is positioned on that line in
+			the file. The file name and the number must be
+			separated by a non-filename (see 'isfname') and
+			non-numeric character. White space between the
+			filename, the separator and the number are ignored.
+			Examples: >
+				eval.c:10
+				eval.c @ 20
+				eval.c (30)
+				eval.c 40
+<
+							*v_gF*
+{Visual}[count]gF	Same as "v_gf".
+
 These commands are used to start editing a single file.  This means that the
 file is read into the buffer and the current file name is set.  The file that
 is opened depends on the current directory, see |:cd|.
--- 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 20
+*eval.txt*      For Vim version 7.0aa.  Last change: 2006 Feb 22
 
 
 		  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -6928,7 +6928,7 @@ This is not guaranteed 100% secure, but 
 
 							*sandbox-option*
 A few options contain an expression.  When this expression is evaluated it may
-have to be done in the sandbox to avoid trouble.  But the sandbox is
+have to be done in the sandbox to avoid a security risc.  But the sandbox is
 restrictive, thus this only happens when the option was set from an insecure
 location.  Insecure in this context are:
 - sourcing a .vimrc or .exrc in the current directlry
--- a/runtime/doc/index.txt
+++ b/runtime/doc/index.txt
@@ -541,6 +541,9 @@ tag		command		   action in Normal mode	~
 				   the cursor
 |CTRL-W_f|	CTRL-W f	   split window and edit file name under the
 				   cursor
+|CTRL-W_F|	CTRL-W F	   split window and edit file name under the
+				   cursor and jump to the line number
+				   following the file name.
 |CTRL-W_g_CTRL-]| CTRL-W g CTRL-]  split window and do |:tjump| to tag under
 				   cursor
 |CTRL-W_g]|	CTRL-W g ]	   split window and do |:tselect| for tag
@@ -719,6 +722,9 @@ tag		char	      note action in Normal mo
 				   word
 |gf|		gf		   start editing the file whose name is under
 				   the cursor
+|gF|		gF		   start editing the file whose name is under
+				   the cursor and jump to the line number
+				   following the filename.
 |gg|		gg		1  cursor to line N, default first line
 |gh|		gh		   start Select mode
 |gi|		gi		2  like "i", but first move to the |'^| mark
--- a/runtime/doc/insert.txt
+++ b/runtime/doc/insert.txt
@@ -1,4 +1,4 @@
-*insert.txt*    For Vim version 7.0aa.  Last change: 2006 Feb 14
+*insert.txt*    For Vim version 7.0aa.  Last change: 2006 Feb 22
 
 
 		  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -993,10 +993,12 @@ items:
 	menu		extra text for the popup menu
 	info		more information about the item
 	kind		single letter indicating the type of completion
+	icase		when not zero case is to be ignored; when omitted
+			the 'ignorecase' option is used
 
-All of these must be a string.  If an item does not meet these requirements
-then an error message is given and further items in the list are not used.
-You can mix string and Dictionary items in the returned list.
+All of these except 'icase' must be a string.  If an item does not meet these
+requirements then an error message is given and further items in the list are
+not used.  You can mix string and Dictionary items in the returned list.
 
 The "menu" item is used in the popup menu and may be truncated, thus it should
 be relatively short.  The "info" item can be longer, it may be displayed in a
--- 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 21
+*options.txt*	For Vim version 7.0aa.  Last change: 2006 Feb 22
 
 
 		  VIM REFERENCE MANUAL	  by Bram Moolenaar
@@ -1629,7 +1629,9 @@ A jump table for the options with a shor
 		    sufficient colors are available.  |ins-completion-menu|
 
 	   longest  Only insert the longest common text of the matches.  Use
-	            CTRL-L to add more characters.
+	            CTRL-L to add more characters.  Whether case is ignored
+		    depends on the kind of completion.  For buffer text the
+		    'ignorecase' option is used.
 
 
 				*'confirm'* *'cf'* *'noconfirm'* *'nocf'*
@@ -2904,7 +2906,7 @@ A jump table for the options with a shor
 	|v:count| the number of lines to be formatted.
 	When this option is empty 'formatprg' is used.
 	Example: >
-		:set formatexp=mylang#Format()
+		:set formatexpr=mylang#Format()
 <	This will invoke the mylang#Format() function in the
 	autoload/mylang.vim file in 'runtimepath'. |autoload|
 
@@ -6073,6 +6075,11 @@ A jump table for the options with a shor
 	( -   Start of item group.  Can be used for setting the width and
 	      alignment of a section.  Must be followed by %) somewhere.
 	) -   End of item group.  No width fields allowed.
+	T N   For 'tabline': start of tab page N label.  Use %T after the last
+	      label.  This information is used for mouse clicks.
+	X N   For 'tabline': start of close tab N label.  Use %X after the
+	      label, e.g.: %3Xclose%X.  Use %999X for a "close current tab"
+	      mark.  This information is used for mouse clicks.
 	< -   Where to truncate line if too long.  Default is at the start.
 	      No width fields allowed.
 	= -   Separation point between left and right aligned items.
@@ -6269,14 +6276,15 @@ A jump table for the options with a shor
 			feature}
 	When nonempty, this option determines the content of the tab pages
 	line at the top of the Vim window.  When empty Vim will use a default
-	tab pages line. |tab-page|
+	tab pages line.  See |setting-tabline| for more info.
 
 	The tab pages line only appears as specified with the 'showtabline'
 	option and only when there is no GUI implementation for tabs.
 
 	The value is evaluated like with 'statusline'.  You can use
 	|tabpagenr()|, |tabpagewinnr()| and |tabpagebuflist()| to figure out
-	the text to be displayed.  See |setting-tabline| for more info.
+	the text to be displayed.  Use "%1T" for the first label, "%2T" for
+	the second one, etc.  Use "%X" items for closing labels.
 
 	Keep in mind that only one of the tab pages is the current one, others
 	are invisible and you can't jump to their windows.
--- a/runtime/doc/tabpage.txt
+++ b/runtime/doc/tabpage.txt
@@ -1,4 +1,4 @@
-*tabpage.txt*   For Vim version 7.0aa.  Last change: 2006 Feb 21
+*tabpage.txt*   For Vim version 7.0aa.  Last change: 2006 Feb 22
 
 
 		  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -164,14 +164,28 @@ pages and define labels for them.  Then 
 	function MyTabLine()
 	  let s = ''
 	  for i in range(tabpagenr('$'))
+	    " select the highlighting
 	    if i + 1 == tabpagenr()
 	      let s .= '%#TabLineSel#'
 	    else
 	      let s .= '%#TabLine#'
 	    endif
+
+	    " set the tab page number (for mouse clicks)
+	    let s .= '%' . (i + 1) . 'T'
+
+	    " the label is made by MyTabLabel()
 	    let s .= ' %{MyTabLabel(' . (i + 1) . ')} '
 	  endfor
-	  let s .= '%#TabLineFill#'
+
+	  " after the last tab fill with TabLineFill and reset tab page nr
+	  let s .= '%#TabLineFill#%T'
+
+	  " right-align the label to close the current tab page
+	  if tabpagenr('$') > 1
+	    let s .= '%=%#TabLine#%999Xclose'
+	  endif
+
 	  return s
 	endfunction
 
@@ -187,7 +201,6 @@ This is just a simplistic example that r
 resembles the default, but without adding a + for a modified buffer or
 trunctating the names.  You will want to reduce the width of labels in a
 clever way when there is not enough room.  Check the 'columns' option for the
-space available, keeping in mind that the "X" at the right will take one more
-position.
+space available.
 
  vim:tw=78:ts=8:ft=help:norl:
--- a/runtime/doc/tags
+++ b/runtime/doc/tags
@@ -3078,6 +3078,7 @@ CTRL-W_CTRL-Z	windows.txt	/*CTRL-W_CTRL-
 CTRL-W_CTRL-]	windows.txt	/*CTRL-W_CTRL-]*
 CTRL-W_CTRL-^	windows.txt	/*CTRL-W_CTRL-^*
 CTRL-W_CTRL-_	windows.txt	/*CTRL-W_CTRL-_*
+CTRL-W_F	windows.txt	/*CTRL-W_F*
 CTRL-W_H	windows.txt	/*CTRL-W_H*
 CTRL-W_J	windows.txt	/*CTRL-W_J*
 CTRL-W_K	windows.txt	/*CTRL-W_K*
@@ -5285,6 +5286,7 @@ g?g?	change.txt	/*g?g?*
 g@	map.txt	/*g@*
 gD	pattern.txt	/*gD*
 gE	motion.txt	/*gE*
+gF	editing.txt	/*gF*
 gH	visual.txt	/*gH*
 gI	insert.txt	/*gI*
 gJ	change.txt	/*gJ*
@@ -7283,6 +7285,7 @@ v_b_r_example	visual.txt	/*v_b_r_example
 v_c	change.txt	/*v_c*
 v_d	change.txt	/*v_d*
 v_g?	change.txt	/*v_g?*
+v_gF	editing.txt	/*v_gF*
 v_gJ	change.txt	/*v_gJ*
 v_gV	visual.txt	/*v_gV*
 v_g]	tagsrch.txt	/*v_g]*
--- 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 21
+*todo.txt*      For Vim version 7.0aa.  Last change: 2006 Feb 22
 
 
 		  VIM REFERENCE MANUAL	  by Bram Moolenaar
@@ -30,18 +30,6 @@ be worked on, but only if you sponsor Vi
 							*known-bugs*
 -------------------- Known bugs and current work -----------------------
 
-Remove resetting "bold" from screen_start_highlight()?
-
-Using 'tabline' breaks using mouse to select a tab.  How to do that?
-See suggestion from Tony Mechelynck.
-
-P_INSECURE should be remembered for local option values separately.
-
-Completion: <Up> and <Down> don't insert completion, <PageUp> and <PageDown>
-shouldn't either.
-
-Completion: case sensitiveness when typing BS: make it an option?
-
 Completion: When back at the original word behave like after BS.
 
 Completion: When to get out of the BS state when the user keeps on typing?
@@ -89,11 +77,16 @@ windows.  Let's call them "tab pages".
 
 Crash with X command server (Ciaran McCreesh).
 
+Make virtcol([lnum, col]) work?
+
 "dip" in end empty lines at end of file leaves one line. (Matt Mzyzik)
 
 Ctags still hasn't included the patch.  Darren is looking for someone to do
 maintanance.
 
+Script ID is only remembered for global options. Should remember it for every
+local option separately.
+
 "fsutil hardlink" can create a hard link on an NTFS file system. (Daniel
 Einspanjer)  What library function can detect that?
 
--- a/runtime/doc/usr_41.txt
+++ b/runtime/doc/usr_41.txt
@@ -1,4 +1,4 @@
-*usr_41.txt*	For Vim version 7.0aa.  Last change: 2005 Nov 30
+*usr_41.txt*	For Vim version 7.0aa.  Last change: 2006 Feb 22
 
 		     VIM USER MANUAL - by Bram Moolenaar
 
@@ -834,7 +834,7 @@ For people who like short functions, thi
 	:  return a:num2
 	:endfunction
 
-A user defined function is called in exactly the same way as a builtin
+A user defined function is called in exactly the same way as a built-in
 function.  Only the name is different.  The Min function can be used like
 this: >
 
@@ -2245,7 +2245,7 @@ organize your functions in library scrip
 where the part before the '#' matches the script name.  Otherwise Vim would
 not know what script to load.
 
-If you get really enthousiastic and write lots of library scripts, you may
+If you get really enthusiastic and write lots of library scripts, you may
 want to use subdirectories.  Example: >
 
 	call netlib#ftp#read('somefile')
--- 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 21
+*version7.txt*  For Vim version 7.0aa.  Last change: 2006 Feb 22
 
 
 		  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -388,6 +388,14 @@ CTRL-W <Enter>		In the quickfix window: 
 <A-RightMouse> ('mousemodel' "extend")
 			Make a blockwise selection. |<A-LeftMouse>|
 
+gF			Start editing the filename under the cursor and jump
+			to the line number following the file name.
+			(Yegappan Lakshmanan)
+
+CTRL-W F		Start editing the filename under the cursor in a new
+			window and jump to the line number following the file
+			name.  (Yegappan Lakshmanan)
+
 Insert mode commands: ~
 
 CTRL-\ CTRL-O		Execute a Normal mode command.  Like CTRL-O but
@@ -800,9 +808,6 @@ upper case.  Add color support to the bu
 For the '%' item in 'viminfo', allow a number to set a maximum for the number
 of buffers.
 
-The 'statusline' option can be local to the window, so that each window can
-have a different value.  (partly by Yegappan Lakshmanan)
-
 When a file looks like a shell script, check for an "exec" command that starts
 the tcl interpreter. (suggested by Alexios Zavras)
 
@@ -1018,12 +1023,20 @@ Insert mode completion for whole lines n
 The colortest.vim script can now be invoked directly with ":source" or
 ":runtime".
 
+The 'statusline' option can be local to the window, so that each window can
+have a different value.  (partly by Yegappan Lakshmanan)
+
 The 'statusline' option and other options that support the same format can now
 use these new features:
 - When it starts with "%!" the value is first evaluated as an expression
   before parsing the value.
 - "%#HLname#" can be used to start highlighting with HLname.
 
+When 'statusline' is set to something that causes an error message then it is
+made empty to avoid an endless redraw loop.  Also for other options, such at
+'tabline'.  ":verbose set statusline" will mention that it was set in an error
+handler.
+
 ==============================================================================
 COMPILE TIME CHANGES					*compile-changes-7*
 
@@ -1722,4 +1735,8 @@ When editing in an xterm with a differen
 screen would be cleared and redrawn, causing the message about the edited file
 to be cleared.  Now set "keep_msg" to redraw the last message.
 
+For a color terminal: When the Normal HL uses bold, possibly to make the color
+lighter, and another HL group specifies a color it might become light as well.
+Now reset bold if a HL group doesn't specify bold itself.
+
  vim:tw=78:ts=8:ft=help:norl:
--- a/runtime/doc/windows.txt
+++ b/runtime/doc/windows.txt
@@ -714,6 +714,11 @@ CTRL-W CTRL-F	Split current window in tw
 		{not available when the |+file_in_path| feature was disabled
 		at compile time}
 
+CTRL-W F						*CTRL-W_F*
+		Split current window in two.  Edit file name under cursor and
+		jump to the line number following the file name. See |gF| for
+		details on how the line number is obtained.
+
 Also see |CTRL-W_CTRL-I|: open window for an included file that includes
 the keyword under the cursor.
 
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -3018,12 +3018,12 @@ maketitle()
 	    int	    use_sandbox = FALSE;
 
 # ifdef FEAT_EVAL
-	    use_sandbox = was_set_insecurely((char_u *)"titlestring");
+	    use_sandbox = was_set_insecurely((char_u *)"titlestring", 0);
 # endif
 	    if (stl_syntax & STL_IN_TITLE)
 		build_stl_str_hl(curwin, t_str, sizeof(buf),
 					      p_titlestring, use_sandbox,
-					      0, maxlen, NULL);
+					      0, maxlen, NULL, NULL);
 	    else
 #endif
 		t_str = p_titlestring;
@@ -3115,12 +3115,12 @@ maketitle()
 	    int	    use_sandbox = FALSE;
 
 # ifdef FEAT_EVAL
-	    use_sandbox = was_set_insecurely((char_u *)"iconstring");
+	    use_sandbox = was_set_insecurely((char_u *)"iconstring", 0);
 # endif
 	    if (stl_syntax & STL_IN_ICON)
 		build_stl_str_hl(curwin, i_str, sizeof(buf),
 						    p_iconstring, use_sandbox,
-						    0, 0, NULL);
+						    0, 0, NULL, NULL);
 	    else
 #endif
 		i_str = p_iconstring;
@@ -3213,7 +3213,7 @@ free_titles()
  * or truncated if too long, fillchar is used for all whitespace.
  */
     int
-build_stl_str_hl(wp, out, outlen, fmt, use_sandbox, fillchar, maxwidth, hl)
+build_stl_str_hl(wp, out, outlen, fmt, use_sandbox, fillchar, maxwidth, hltab, tabtab)
     win_T	*wp;
     char_u	*out;		/* buffer to write into */
     size_t	outlen;		/* length of out[] */
@@ -3221,7 +3221,8 @@ build_stl_str_hl(wp, out, outlen, fmt, u
     int		use_sandbox;	/* "fmt" was set insecurely, use sandbox */
     int		fillchar;
     int		maxwidth;
-    struct stl_hlrec *hl;
+    struct stl_hlrec *hltab;	/* return: HL attributes (can be NULL) */
+    struct stl_hlrec *tabtab;	/* return: tab page nrs (can be NULL) */
 {
     char_u	*p;
     char_u	*s;
@@ -3258,6 +3259,7 @@ build_stl_str_hl(wp, out, outlen, fmt, u
 	    Group,
 	    Middle,
 	    Highlight,
+	    TabPage,
 	    Trunc
 	}		type;
     }		item[STL_MAX_ITEM];
@@ -3269,6 +3271,7 @@ build_stl_str_hl(wp, out, outlen, fmt, u
 #define TMPLEN 70
     char_u	tmp[TMPLEN];
     char_u	*usefmt = fmt;
+    struct stl_hlrec *sp;
 
 #ifdef FEAT_EVAL
     /*
@@ -3452,6 +3455,32 @@ build_stl_str_hl(wp, out, outlen, fmt, u
 	    curitem++;
 	    continue;
 	}
+	if (*s == STL_TABPAGENR || *s == STL_TABCLOSENR)
+	{
+	    if (*s == STL_TABCLOSENR)
+	    {
+		if (minwid == 0)
+		{
+		    /* %X ends the close label, go back to the previously
+		     * define tab label nr. */
+		    for (n = curitem - 1; n >= 0; --n)
+			if (item[n].type == TabPage && item[n].minwid >= 0)
+			{
+			    minwid = item[n].minwid;
+			    break;
+			}
+		}
+		else
+		    /* close nrs are stored as negative values */
+		    minwid = - minwid;
+	    }
+	    item[curitem].type = TabPage;
+	    item[curitem].start = p;
+	    item[curitem].minwid = minwid;
+	    s++;
+	    curitem++;
+	    continue;
+	}
 	if (*s == '.')
 	{
 	    s++;
@@ -3953,19 +3982,38 @@ build_stl_str_hl(wp, out, outlen, fmt, u
 	}
     }
 
-    if (hl != NULL)
+    /* Store the info about highlighting. */
+    if (hltab != NULL)
     {
+	sp = hltab;
 	for (l = 0; l < itemcnt; l++)
 	{
 	    if (item[l].type == Highlight)
 	    {
-		hl->start = item[l].start;
-		hl->userhl = item[l].minwid;
-		hl++;
+		sp->start = item[l].start;
+		sp->userhl = item[l].minwid;
+		sp++;
 	    }
 	}
-	hl->start = NULL;
-	hl->userhl = 0;
+	sp->start = NULL;
+	sp->userhl = 0;
+    }
+
+    /* Store the info about tab pages labels. */
+    if (tabtab != NULL)
+    {
+	sp = tabtab;
+	for (l = 0; l < itemcnt; l++)
+	{
+	    if (item[l].type == TabPage)
+	    {
+		sp->start = item[l].start;
+		sp->userhl = item[l].minwid;
+		sp++;
+	    }
+	}
+	sp->start = NULL;
+	sp->userhl = 0;
     }
 
     return width;
--- a/src/diff.c
+++ b/src/diff.c
@@ -1078,6 +1078,9 @@ diff_win_options(wp, addbuf)
 	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
 	curwin = old_curwin;
 	curbuf = curwin->w_buffer;
 	wp->w_p_fdc = 2;
@@ -1125,6 +1128,9 @@ ex_diffoff(eap)
 	    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
 	    curwin = old_curwin;
 	    curbuf = curwin->w_buffer;
 	    wp->w_p_fdc = 0;
--- a/src/edit.c
+++ b/src/edit.c
@@ -62,12 +62,13 @@ static char_u e_hitend[] = N_("Hit end o
 /*
  * Structure used to store one match for insert completion.
  */
-typedef struct Completion compl_T;
-struct Completion
+typedef struct compl_S compl_T;
+struct compl_S
 {
     compl_T	*cp_next;
     compl_T	*cp_prev;
     char_u	*cp_str;	/* matched text */
+    char	cp_icase;	/* TRUE or FALSE: ignore case */
     char_u	*cp_extra;	/* extra menu text (allocated, can be NULL) */
     char_u	*cp_info;	/* verbose info (can be NULL) */
     char_u	cp_kind;	/* kind of match, single letter, or NUL */
@@ -121,8 +122,9 @@ static expand_T	  compl_xp;
 
 static void ins_ctrl_x __ARGS((void));
 static int  has_compl_option __ARGS((int dict_opt));
+static int  ins_compl_equal __ARGS((compl_T *match, char_u *str, int len));
 static void ins_compl_longest_match __ARGS((compl_T *match));
-static void ins_compl_add_matches __ARGS((int num_matches, char_u **matches));
+static void ins_compl_add_matches __ARGS((int num_matches, char_u **matches, int icase));
 static int  ins_compl_make_cyclic __ARGS((void));
 static void ins_compl_upd_pum __ARGS((void));
 static void ins_compl_del_pum __ARGS((void));
@@ -144,6 +146,7 @@ static int  ins_compl_next __ARGS((int a
 static int  ins_compl_key2dir __ARGS((int c));
 static int  ins_compl_pum_key __ARGS((int c));
 static int  ins_compl_key2count __ARGS((int c));
+static int  ins_compl_use_match __ARGS((int c));
 static int  ins_complete __ARGS((int c));
 static int  quote_meta __ARGS((char_u *dest, char_u *str, int len));
 #endif /* FEAT_INS_EXPAND */
@@ -1982,9 +1985,10 @@ vim_is_ctrl_x_key(c)
  * TODO: make this work for multi-byte characters.
  */
     int
-ins_compl_add_infercase(str, len, fname, dir, flags)
+ins_compl_add_infercase(str, len, icase, fname, dir, flags)
     char_u	*str;
     int		len;
+    int		icase;
     char_u	*fname;
     int		dir;
     int		flags;
@@ -2038,26 +2042,22 @@ ins_compl_add_infercase(str, len, fname,
 	/* Copy the original case of the part we typed */
 	STRNCPY(IObuff, compl_orig_text, compl_length);
 
-	return ins_compl_add(IObuff, len, fname, NULL, dir, flags);
-    }
-    return ins_compl_add(str, len, fname, NULL, dir, flags);
+	return ins_compl_add(IObuff, len, icase, fname, NULL, dir, flags);
+    }
+    return ins_compl_add(str, len, icase, fname, NULL, dir, flags);
 }
 
 /*
  * Add a match to the list of matches.
  * If the given string is already in the list of completions, then return
- * FAIL, otherwise add it to the list and return OK.  If there is an error,
- * maybe because alloc() returns NULL, then RET_ERROR is returned -- webb.
- *
- * New:
- * If the given string is already in the list of completions, then return
  * NOTDONE, otherwise add it to the list and return OK.  If there is an error,
- * maybe because alloc() returns NULL, then FAIL is returned -- webb.
+ * maybe because alloc() returns NULL, then FAIL is returned.
  */
     int
-ins_compl_add(str, len, fname, extra, cdir, flags)
+ins_compl_add(str, len, icase, fname, extra, cdir, flags)
     char_u	*str;
     int		len;
+    int		icase;
     char_u	*fname;
     char_u	*extra;	    /* extra text for popup menu or NULL */
     int		cdir;
@@ -2081,7 +2081,7 @@ ins_compl_add(str, len, fname, extra, cd
 	do
 	{
 	    if (    !(match->cp_flags & ORIGINAL_TEXT)
-		    && STRNCMP(match->cp_str, str, (size_t)len) == 0
+		    && ins_compl_equal(match, str, len)
 		    && match->cp_str[len] == NUL)
 		return NOTDONE;
 	    match = match->cp_next;
@@ -2109,6 +2109,7 @@ ins_compl_add(str, len, fname, extra, cd
 	vim_free(match);
 	return FAIL;
     }
+    match->cp_icase = icase;
 
     /* match-fname is:
      * - compl_curr_match->cp_fname if it is a string equal to fname.
@@ -2163,6 +2164,21 @@ ins_compl_add(str, len, fname, extra, cd
 }
 
 /*
+ * Return TRUE if "str[len]" matches with match->cp_str, considering
+ * match->cp_icase.
+ */
+    static int
+ins_compl_equal(match, str, len)
+    compl_T	*match;
+    char_u	*str;
+    int		len;
+{
+    if (match->cp_icase)
+	return STRNICMP(match->cp_str, str, (size_t)len) == 0;
+    return STRNCMP(match->cp_str, str, (size_t)len) == 0;
+}
+
+/*
  * Reduce the longest common string for match "match".
  */
     static void
@@ -2170,7 +2186,7 @@ ins_compl_longest_match(match)
     compl_T	*match;
 {
     char_u	*p, *s;
-    int		l;
+    int		c1, c2;
     int		had_match;
 
     if (compl_leader == NULL)
@@ -2179,21 +2195,36 @@ ins_compl_longest_match(match)
     else
     {
 	/* Reduce the text if this match differs from compl_leader. */
-	for (p = compl_leader, s = match->cp_str; *p != NUL; p += l, s += l)
+	p = compl_leader;
+	s = match->cp_str;
+	while (*p != NUL)
 	{
 #ifdef FEAT_MBYTE
 	    if (has_mbyte)
 	    {
-		l = mb_ptr2len(p);
-		if (STRNICMP(p, s, l) != 0)
-			break;
+		c1 = mb_ptr2char(p);
+		c2 = mb_ptr2char(s);
 	    }
 	    else
 #endif
 	    {
-		if (MB_TOLOWER(*p) != MB_TOLOWER(*s))
-		    break;
-		l = 1;
+		c1 = *p;
+		c2 = *s;
+	    }
+	    if (match->cp_icase ? (MB_TOLOWER(c1) != MB_TOLOWER(c2))
+								 : (c1 != c2))
+		break;
+#ifdef FEAT_MBYTE
+	    if (has_mbyte)
+	    {
+		mb_ptr_adv(p);
+		mb_ptr_adv(s);
+	    }
+	    else
+#endif
+	    {
+		++p;
+		++s;
 	    }
 	}
 
@@ -2221,16 +2252,18 @@ ins_compl_longest_match(match)
  * Frees matches[].
  */
     static void
-ins_compl_add_matches(num_matches, matches)
+ins_compl_add_matches(num_matches, matches, icase)
     int		num_matches;
     char_u	**matches;
+    int		icase;
 {
     int		i;
     int		add_r = OK;
     int		dir = compl_direction;
 
     for (i = 0; i < num_matches && add_r != FAIL; i++)
-	if ((add_r = ins_compl_add(matches[i], -1, NULL, NULL, dir, 0)) == OK)
+	if ((add_r = ins_compl_add(matches[i], -1, icase,
+						   NULL, NULL, dir, 0)) == OK)
 	    /* if dir was BACKWARD then honor it just once */
 	    dir = FORWARD;
     FreeWild(num_matches, matches);
@@ -2376,7 +2409,7 @@ ins_compl_show_pum()
 	{
 	    if ((compl->cp_flags & ORIGINAL_TEXT) == 0
 		    && (compl_leader == NULL
-			|| STRNCMP(compl->cp_str, compl_leader, lead_len) == 0))
+			|| ins_compl_equal(compl, compl_leader, lead_len)))
 		++compl_match_arraysize;
 	    compl = compl->cp_next;
 	} while (compl != NULL && compl != compl_first_match);
@@ -2393,8 +2426,7 @@ ins_compl_show_pum()
 	    {
 		if ((compl->cp_flags & ORIGINAL_TEXT) == 0
 			&& (compl_leader == NULL
-			    || STRNCMP(compl->cp_str, compl_leader,
-							      lead_len) == 0))
+			    || ins_compl_equal(compl, compl_leader, lead_len)))
 		{
 		    if (!shown_match_ok)
 		    {
@@ -2560,7 +2592,7 @@ ins_compl_dictionaries(dict, pat, flags,
 			    ptr = find_word_end(ptr);
 			add_r = ins_compl_add_infercase(regmatch.startp[0],
 					      (int)(ptr - regmatch.startp[0]),
-							    files[i], dir, 0);
+					      p_ic, files[i], dir, 0);
 			if (thesaurus)
 			{
 			    char_u *wstart;
@@ -2595,7 +2627,8 @@ ins_compl_dictionaries(dict, pat, flags,
 #endif
 				    ptr = find_word_end(ptr);
 				add_r = ins_compl_add_infercase(wstart,
-					(int)(ptr - wstart), files[i], dir, 0);
+					(int)(ptr - wstart),
+					p_ic, files[i], dir, 0);
 			    }
 			}
 			if (add_r == OK)
@@ -3170,6 +3203,7 @@ expand_by_function(type, base)
     pos_T	pos;
     int		dir = compl_direction;
     char_u	*x;
+    int		icase;
 
     funcname = (type == CTRL_X_FUNCTION) ? curbuf->b_p_cfu : curbuf->b_p_ofu;
     if (*funcname == NUL)
@@ -3192,6 +3226,12 @@ expand_by_function(type, base)
 	{
 	    p = get_dict_string(li->li_tv.vval.v_dict, (char_u *)"word", FALSE);
 	    x = get_dict_string(li->li_tv.vval.v_dict, (char_u *)"menu", FALSE);
+	    if (get_dict_string(li->li_tv.vval.v_dict, (char_u *)"icase",
+							       FALSE) == NULL)
+		icase = p_ic;
+	    else
+		icase = get_dict_number(li->li_tv.vval.v_dict,
+							   (char_u *)"icase");
 	}
 	else
 	{
@@ -3200,7 +3240,7 @@ expand_by_function(type, base)
 	}
 	if (p != NULL && *p != NUL)
 	{
-	    if (ins_compl_add(p, -1, NULL, x, dir, 0) == OK)
+	    if (ins_compl_add(p, -1, icase, NULL, x, dir, 0) == OK)
 		/* if dir was BACKWARD then honor it just once */
 		dir = FORWARD;
 	}
@@ -3399,7 +3439,7 @@ ins_compl_get_exp(ini)
 		    TAG_INS_COMP | (ctrl_x_mode ? TAG_VERBOSE : 0),
 		    TAG_MANY, curbuf->b_ffname) == OK && num_matches > 0)
 	    {
-		ins_compl_add_matches(num_matches, matches);
+		ins_compl_add_matches(num_matches, matches, p_ic);
 	    }
 	    p_ic = save_p_ic;
 	    break;
@@ -3411,7 +3451,13 @@ ins_compl_get_exp(ini)
 
 		/* May change home directory back to "~". */
 		tilde_replace(compl_pattern, num_matches, matches);
-		ins_compl_add_matches(num_matches, matches);
+		ins_compl_add_matches(num_matches, matches,
+#ifdef CASE_INSENSITIVE_FILENAME
+			TRUE
+#else
+			FALSE
+#endif
+			);
 	    }
 	    break;
 
@@ -3419,7 +3465,7 @@ ins_compl_get_exp(ini)
 	    if (expand_cmdline(&compl_xp, compl_pattern,
 			(int)STRLEN(compl_pattern),
 					 &num_matches, &matches) == EXPAND_OK)
-		ins_compl_add_matches(num_matches, matches);
+		ins_compl_add_matches(num_matches, matches, FALSE);
 	    break;
 
 #ifdef FEAT_COMPL_FUNC
@@ -3434,7 +3480,7 @@ ins_compl_get_exp(ini)
 	    num_matches = expand_spelling(first_match_pos.lnum,
 				 first_match_pos.col, compl_pattern, &matches);
 	    if (num_matches > 0)
-		ins_compl_add_matches(num_matches, matches);
+		ins_compl_add_matches(num_matches, matches, FALSE);
 #endif
 	    break;
 
@@ -3568,7 +3614,7 @@ ins_compl_get_exp(ini)
 			    continue;
 		    }
 		}
-		if (ins_compl_add_infercase(ptr, len,
+		if (ins_compl_add_infercase(ptr, len, p_ic,
 				 ins_buf == curbuf ? NULL : ins_buf->b_sfname,
 					   0, flags) != NOTDONE)
 		{
@@ -3687,8 +3733,8 @@ ins_compl_next(allow_get_expansion, coun
     {
 	/* Set "compl_shown_match" to the actually shown match, it may differ
 	 * when "compl_leader" is used to omit some of the matches. */
-	while (STRNCMP(compl_shown_match->cp_str,
-				     compl_leader, STRLEN(compl_leader)) != 0
+	while (!ins_compl_equal(compl_shown_match,
+					   compl_leader, STRLEN(compl_leader))
 		&& compl_shown_match->cp_next != NULL
 		&& compl_shown_match->cp_next != compl_first_match)
 	    compl_shown_match = compl_shown_match->cp_next;
@@ -3732,8 +3778,8 @@ ins_compl_next(allow_get_expansion, coun
 	}
 	if ((compl_shown_match->cp_flags & ORIGINAL_TEXT) == 0
 		&& compl_leader != NULL
-		&& STRNCMP(compl_shown_match->cp_str,
-				     compl_leader, STRLEN(compl_leader)) != 0)
+		&& !ins_compl_equal(compl_shown_match,
+					  compl_leader, STRLEN(compl_leader)))
 	    ++todo;
 	else
 	    /* Remember a matching item. */
@@ -3891,6 +3937,29 @@ ins_compl_key2count(c)
 }
 
 /*
+ * Return TRUE if completion with "c" should insert the match, FALSE if only
+ * to change the currently selected completion.
+ */
+    static int
+ins_compl_use_match(c)
+    int		c;
+{
+    switch (c)
+    {
+	case K_UP:
+	case K_DOWN:
+	case K_PAGEDOWN:
+	case K_KPAGEDOWN:
+	case K_S_DOWN:
+	case K_PAGEUP:
+	case K_KPAGEUP:
+	case K_S_UP:
+	    return FALSE;
+    }
+    return TRUE;
+}
+
+/*
  * Do Insert mode completion.
  * Called when character "c" was typed, which has a meaning for completion.
  * Returns OK if completion was done, FAIL if something failed (out of mem).
@@ -4252,7 +4321,7 @@ ins_complete(c)
 	 * when the list of matches is freed. */
 	compl_orig_text = vim_strnsave(line + compl_col, compl_length);
 	if (compl_orig_text == NULL || ins_compl_add(compl_orig_text,
-				      -1, NULL, NULL, 0, ORIGINAL_TEXT) != OK)
+			       -1, FALSE, NULL, NULL, 0, ORIGINAL_TEXT) != OK)
 	{
 	    vim_free(compl_pattern);
 	    compl_pattern = NULL;
@@ -4278,7 +4347,7 @@ ins_complete(c)
     /*
      * Find next match (and following matches).
      */
-    n = ins_compl_next(TRUE, ins_compl_key2count(c), c != K_UP && c != K_DOWN);
+    n = ins_compl_next(TRUE, ins_compl_key2count(c), ins_compl_use_match(c));
 
     /* may undisplay the popup menu */
     ins_compl_upd_pum();
--- a/src/eval.c
+++ b/src/eval.c
@@ -1580,7 +1580,8 @@ eval_foldexpr(arg, cp)
     typval_T	tv;
     int		retval;
     char_u	*s;
-    int		use_sandbox = was_set_insecurely((char_u *)"foldexpr");
+    int		use_sandbox = was_set_insecurely((char_u *)"foldexpr",
+								   OPT_LOCAL);
 
     ++emsg_off;
     if (use_sandbox)
@@ -8036,6 +8037,7 @@ f_complete_add(argvars, rettv)
 {
     char_u	*word;
     char_u	*extra = NULL;
+    int		icase = FALSE;
 
     if (argvars[0].v_type == VAR_DICT && argvars[0].vval.v_dict != NULL)
     {
@@ -8043,11 +8045,13 @@ f_complete_add(argvars, rettv)
 						     (char_u *)"word", FALSE);
 	extra = get_dict_string(argvars[0].vval.v_dict,
 						     (char_u *)"menu", FALSE);
+	icase = get_dict_number(argvars[0].vval.v_dict, (char_u *)"icase");
     }
     else
 	word = get_tv_string_chk(&argvars[0]);
     if (word != NULL)
-	rettv->vval.v_number = ins_compl_add(word, -1, NULL, extra, 0, 0);
+	rettv->vval.v_number = ins_compl_add(word, -1, icase,
+							   NULL, extra, 0, 0);
 }
 
 /*
--- a/src/ex_cmds.c
+++ b/src/ex_cmds.c
@@ -3266,6 +3266,9 @@ do_ecmd(fnum, ffname, sfname, eap, newln
 #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
 #endif
 
 	/*
@@ -3285,6 +3288,9 @@ do_ecmd(fnum, ffname, sfname, eap, newln
 	{
 	    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
 	    check_buf_options(curbuf);
 	    (void)buf_init_chartab(curbuf, FALSE);
 	}
--- a/src/ex_cmds2.c
+++ b/src/ex_cmds2.c
@@ -3077,13 +3077,15 @@ get_scriptname(id)
     scid_T	id;
 {
     if (id == SID_MODELINE)
-	return (char_u *)"modeline";
+	return (char_u *)_("modeline");
     if (id == SID_CMDARG)
-	return (char_u *)"--cmd argument";
+	return (char_u *)_("--cmd argument");
     if (id == SID_CARG)
-	return (char_u *)"-c argument";
+	return (char_u *)_("-c argument");
     if (id == SID_ENV)
-	return (char_u *)"environment variable";
+	return (char_u *)_("environment variable");
+    if (id == SID_ERROR)
+	return (char_u *)_("error handler");
     return SCRIPT_ITEM(id).sn_name;
 }
 
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -9225,7 +9225,7 @@ eval_vars(src, usedlen, lnump, errormsg,
 
 #ifdef FEAT_SEARCHPATH
 	case SPEC_CFILE:	/* file name under cursor */
-		result = file_name_at_cursor(FNAME_MESS|FNAME_HYP, 1L);
+		result = file_name_at_cursor(FNAME_MESS|FNAME_HYP, 1L, NULL);
 		if (result == NULL)
 		{
 		    *errormsg = (char_u *)"";
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -583,8 +583,13 @@ 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
+			}
 			vim_free(fenc);
 		    }
 #endif
@@ -2108,8 +2113,13 @@ 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
+    }
     if (fenc_alloced)
 	vim_free(fenc);
 # ifdef USE_ICONV
--- a/src/fold.c
+++ b/src/fold.c
@@ -1939,7 +1939,7 @@ get_foldtext(wp, lnum, lnume, foldinfo, 
 
 	++emsg_off;
 	text = eval_to_string_safe(wp->w_p_fdt, NULL,
-				    was_set_insecurely((char_u *)"foldtext"));
+			 was_set_insecurely((char_u *)"foldtext", OPT_LOCAL));
 	--emsg_off;
 
 	curwin = save_curwin;
--- a/src/globals.h
+++ b/src/globals.h
@@ -62,7 +62,14 @@ EXTERN schar_T	*ScreenLines2 INIT(= NULL
 #endif
 
 #ifdef FEAT_WINDOWS
-EXTERN char_u	*TabPageIdxs INIT(= NULL);	/* indexes for tab page line */
+/*
+ * Indexes for tab page line:
+ *	N > 0 for label of tab page N
+ *	N == 0 for no label
+ *	N < 0 for closing tab page -N
+ *	N == -999 for closing current tab page
+ */
+EXTERN short	*TabPageIdxs INIT(= NULL);
 #endif
 
 EXTERN int	screen_Rows INIT(= 0);	    /* actual size of ScreenLines[] */
--- a/src/gui.c
+++ b/src/gui.c
@@ -786,6 +786,9 @@ set_guifontwide(name)
 			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
 		    }
 		}
 		break;
--- a/src/gui_beval.c
+++ b/src/gui_beval.c
@@ -55,7 +55,7 @@ general_beval_cb(beval, state)
 	set_vim_var_string(VV_BEVAL_TEXT, text, -1);
 	vim_free(text);
 
-	use_sandbox = was_set_insecurely((char_u *)"balloonexpr");
+	use_sandbox = was_set_insecurely((char_u *)"balloonexpr", 0);
 	if (use_sandbox)
 	    ++sandbox;
 	++textlock;
--- a/src/hardcopy.c
+++ b/src/hardcopy.c
@@ -492,11 +492,11 @@ prt_header(psettings, pagenum, lnum)
 	printer_page_num = pagenum;
 
 # ifdef FEAT_EVAL
-	use_sandbox = was_set_insecurely((char_u *)"printheader");
+	use_sandbox = was_set_insecurely((char_u *)"printheader", 0);
 # endif
 	build_stl_str_hl(curwin, tbuf, (size_t)(width + IOSIZE),
 						  p_header, use_sandbox,
-						  ' ', width, NULL);
+						  ' ', width, NULL, NULL);
 
 	/* Reset line numbers */
 	curwin->w_cursor.lnum = tmp_lnum;
--- a/src/main.c
+++ b/src/main.c
@@ -635,8 +635,13 @@ 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
+	}
 	if (qf_init(NULL, p_ef, p_efm, TRUE) < 0)
 	{
 	    out_char('\n');
--- a/src/mbyte.c
+++ b/src/mbyte.c
@@ -731,8 +731,13 @@ 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
+    }
 #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
@@ -7677,7 +7677,8 @@ get_expr_indent()
     int		indent;
     pos_T	pos;
     int		save_State;
-    int		use_sandbox = was_set_insecurely((char_u *)"indentexpr");
+    int		use_sandbox = was_set_insecurely((char_u *)"indentexpr",
+								   OPT_LOCAL);
 
     pos = curwin->w_cursor;
     set_vim_var_nr(VV_LNUM, curwin->w_cursor.lnum);
--- a/src/misc2.c
+++ b/src/misc2.c
@@ -2793,8 +2793,13 @@ 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
+    }
 #ifdef FEAT_WINDOWS
     /* This may cause the buffer to become (un)modified. */
     check_status(curbuf);
--- a/src/normal.c
+++ b/src/normal.c
@@ -2427,28 +2427,43 @@ do_mouse(oap, c, dir, count, fixindent)
     {
 	got_click = FALSE;	/* ignore mouse-up and drag events */
 
-	/* click in last column closes the current tab page. */
-	if (mouse_col == Columns - 1 && first_tabpage->tp_next != NULL)
-	{
-	    tabpage_close(FALSE);
-	    return TRUE;
-	}
-
 	/* click in a tab selects that tab page */
 	if (is_click
 # ifdef FEAT_CMDWIN
 		&& cmdwin_type == 0
 # endif
-		&& mouse_col < Columns && TabPageIdxs[mouse_col] != 0xff)
-	{
-	    goto_tabpage(TabPageIdxs[mouse_col]);
-
-	    /* It's like clicking on the status line of a window. */
-	    if (curwin != old_curwin)
-		end_visual_mode();
-	    return TRUE;
-	}
-	return FALSE;
+		&& mouse_col < Columns)
+	{
+	    c1 = TabPageIdxs[mouse_col];
+	    if (c1 >= 0)
+	    {
+		/* Go to specified tab page, or next one if not clicking on a
+		 * label. */
+		goto_tabpage(c1);
+
+		/* It's like clicking on the status line of a window. */
+		if (curwin != old_curwin)
+		    end_visual_mode();
+	    }
+	    else if (c1 < 0)
+	    {
+		tabpage_T	*tp;
+
+		/* Close the current or specified tab page. */
+		if (c1 == -999)
+		    tp = curtab;
+		else
+		    tp = find_tabpage(-c1);
+		if (tp == curtab)
+		{
+		    if (first_tabpage->tp_next != NULL)
+			tabpage_close(FALSE);
+		}
+		else if (tp != NULL)
+		    tabpage_close_other(tp, FALSE);
+	    }
+	}
+	return TRUE;
     }
 #endif
 
@@ -5785,6 +5800,7 @@ nv_gotofile(cap)
     cmdarg_T	*cap;
 {
     char_u	*ptr;
+    linenr_T	lnum = -1;
 
     if (text_locked())
     {
@@ -5793,7 +5809,7 @@ nv_gotofile(cap)
 	return;
     }
 
-    ptr = grab_file_name(cap->count1);
+    ptr = grab_file_name(cap->count1, &lnum);
 
     if (ptr != NULL)
     {
@@ -5803,6 +5819,12 @@ nv_gotofile(cap)
 	setpcmark();
 	(void)do_ecmd(0, ptr, NULL, NULL, ECMD_LAST,
 					       P_HID(curbuf) ? ECMD_HIDE : 0);
+	if (cap->nchar == 'F' && lnum >= 0)
+	{
+	    curwin->w_cursor.lnum = lnum;
+	    check_cursor_lnum();
+	    beginline(BL_SOL | BL_FIX);
+	}
 	vim_free(ptr);
     }
     else
@@ -7720,6 +7742,7 @@ nv_g_cmd(cap)
      * "]f" and "[f": can also be used.
      */
     case 'f':
+    case 'F':
 	nv_gotofile(cap);
 	break;
 #endif
--- a/src/ops.c
+++ b/src/ops.c
@@ -1439,7 +1439,7 @@ get_spec_reg(regname, argp, allocated, e
 	    if (!errmsg)
 		return FALSE;
 	    *argp = file_name_at_cursor(FNAME_MESS | FNAME_HYP
-				| (regname == Ctrl_P ? FNAME_EXP : 0), 1L);
+			    | (regname == Ctrl_P ? FNAME_EXP : 0), 1L, NULL);
 	    *allocated = TRUE;
 	    return TRUE;
 #endif
@@ -4334,7 +4334,8 @@ fex_format(lnum, count)
     linenr_T	lnum;
     long	count;
 {
-    int		use_sandbox = was_set_insecurely((char_u *)"formatexpr");
+    int		use_sandbox = was_set_insecurely((char_u *)"formatexpr",
+								   OPT_LOCAL);
     int		r;
 
     /*
--- a/src/option.c
+++ b/src/option.c
@@ -2673,6 +2673,11 @@ static void did_set_title __ARGS((int ic
 static char_u *option_expand __ARGS((int opt_idx, char_u *val));
 static void didset_options __ARGS((void));
 static void check_string_option __ARGS((char_u **pp));
+#if defined(FEAT_EVAL) || defined(PROTO)
+static long_u *insecure_flag __ARGS((int opt_idx, int opt_flags));
+#else
+# define insecure_flag(opt_idx, opt_flags) (&options[opt_idx].flags)
+#endif
 static void set_string_option_global __ARGS((int opt_idx, char_u **varp));
 static void set_string_option __ARGS((int opt_idx, char_u *value, int opt_flags));
 static char_u *did_set_string_option __ARGS((int opt_idx, char_u **varp, int new_value_alloced, char_u *oldval, char_u *errbuf, int opt_flags));
@@ -3143,6 +3148,7 @@ set_option_default(opt_idx, opt_flags, c
     char_u	*varp;		/* pointer to variable for current option */
     int		dvi;		/* index in def_val[] */
     long_u	flags;
+    long_u	*flagsp;
     int		both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0;
 
     varp = get_varp_scope(&(options[opt_idx]), both ? OPT_LOCAL : opt_flags);
@@ -3188,10 +3194,9 @@ set_option_default(opt_idx, opt_flags, c
 								*(int *)varp;
 	}
 
-	/* The default value is not insecure.  But if there are local values
-	 * we can't be sure. */
-	if (options[opt_idx].indir == PV_NONE)
-	    options[opt_idx].flags &= ~P_INSECURE;
+	/* The default value is not insecure. */
+	flagsp = insecure_flag(opt_idx, opt_flags);
+	*flagsp = *flagsp & ~P_INSECURE;
     }
 
 #ifdef FEAT_EVAL
@@ -4467,19 +4472,22 @@ did_set_option(opt_idx, opt_flags, new_v
     int	    opt_flags;	    /* possibly with OPT_MODELINE */
     int	    new_value;	    /* value was replaced completely */
 {
+    long_u	*p;
+
     options[opt_idx].flags |= P_WAS_SET;
 
     /* When an option is set in the sandbox, from a modeline or in secure mode
      * set the P_INSECURE flag.  Otherwise, if a new value is stored reset the
-     * flag.  But not when there are local values. */
+     * flag. */
+    p = insecure_flag(opt_idx, opt_flags);
     if (secure
 #ifdef HAVE_SANDBOX
 	    || sandbox != 0
 #endif
 	    || (opt_flags & OPT_MODELINE))
-	options[opt_idx].flags |= P_INSECURE;
-    else if (new_value && options[opt_idx].indir == PV_NONE)
-	options[opt_idx].flags &= ~P_INSECURE;
+	*p = *p | P_INSECURE;
+    else if (new_value)
+	*p = *p & ~P_INSECURE;
 }
 
     static char_u *
@@ -4924,16 +4932,55 @@ set_term_option_alloced(p)
  * Return -1 for an unknown option.
  */
     int
-was_set_insecurely(opt)
-    char_u *opt;
+was_set_insecurely(opt, opt_flags)
+    char_u  *opt;
+    int	    opt_flags;
 {
     int	    idx = findoption(opt);
+    long_u  *flagp;
 
     if (idx >= 0)
-	return (options[idx].flags & P_INSECURE) != 0;
+    {
+	flagp = insecure_flag(idx, opt_flags);
+	return (*flagp & P_INSECURE) != 0;
+    }
     EMSG2(_(e_intern2), "was_set_insecurely()");
     return -1;
 }
+
+/*
+ * Get a pointer to the flags used for the P_INSECURE flag of option
+ * "opt_idx".  For some local options a local flags field is used.
+ */
+    static long_u *
+insecure_flag(opt_idx, opt_flags)
+    int		opt_idx;
+    int		opt_flags;
+{
+    if (opt_flags & OPT_LOCAL)
+	switch ((int)options[opt_idx].indir)
+	{
+#ifdef FEAT_STL_OPT
+	    case OPT_BOTH(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;
+#endif
+#if defined(FEAT_EVAL)
+# if defined(FEAT_CINDENT)
+	    case PV_INDE:	    return &curbuf->b_p_inde_flags;
+# endif
+	    case PV_FEX:	    return &curbuf->b_p_fex_flags;
+# ifdef FEAT_FIND_ID
+	    case PV_INEX:	    return &curbuf->b_p_inex_flags;
+# endif
+#endif
+	}
+
+    /* Nothing special, return global flags field. */
+    return &options[opt_idx].flags;
+}
 #endif
 
 /*
@@ -6657,6 +6704,24 @@ compile_cap_prog(buf)
 }
 #endif
 
+#if defined(FEAT_EVAL) || defined(PROTO)
+/*
+ * Set the script ID of option "name" to "id".
+ */
+    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
+	options[opt_idx].scriptID = id;
+}
+#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.
@@ -6766,6 +6831,9 @@ 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
 	}
 	/* remove 's' from p_shm */
 	else if (!p_terse && p != NULL)
@@ -6851,6 +6919,9 @@ set_bool_option(opt_idx, varp, value, op
 	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
     }
 
     /*
--- a/src/option.h
+++ b/src/option.h
@@ -288,6 +288,8 @@
 #define STL_TRUNCMARK	'<'		/* truncation mark if line is too long*/
 #define STL_USER_HL	'*'		/* highlight from (User)1..9 or 0 */
 #define STL_HIGHLIGHT	'#'		/* highlight name */
+#define STL_TABPAGENR	'T'		/* tab page label nr */
+#define STL_TABCLOSENR	'X'		/* tab page close nr */
 #define STL_ALL		((char_u *) "fFtcvVlLknoObBrRhHmYyWwMpPaN{#")
 
 /* flags used for parsed 'wildmode' */
--- a/src/proto/buffer.pro
+++ b/src/proto/buffer.pro
@@ -40,7 +40,7 @@ void col_print __ARGS((char_u *buf, int 
 void maketitle __ARGS((void));
 void resettitle __ARGS((void));
 void free_titles __ARGS((void));
-int build_stl_str_hl __ARGS((win_T *wp, char_u *out, size_t outlen, char_u *fmt, int insecure, int fillchar, int maxwidth, struct stl_hlrec *hl));
+int build_stl_str_hl __ARGS((win_T *wp, char_u *out, size_t outlen, char_u *fmt, int use_sandbox, int fillchar, int maxwidth, struct stl_hlrec *hltab, struct stl_hlrec *tabtab));
 void get_rel_pos __ARGS((win_T *wp, char_u *str));
 int append_arg_number __ARGS((win_T *wp, char_u *buf, int add_file, int maxlen));
 char_u *fix_fname __ARGS((char_u *fname));
--- a/src/proto/edit.pro
+++ b/src/proto/edit.pro
@@ -7,8 +7,8 @@ void change_indent __ARGS((int type, int
 void truncate_spaces __ARGS((char_u *line));
 void backspace_until_column __ARGS((int col));
 int vim_is_ctrl_x_key __ARGS((int c));
-int ins_compl_add_infercase __ARGS((char_u *str, int len, char_u *fname, int dir, int flags));
-int ins_compl_add __ARGS((char_u *str, int len, char_u *fname, char_u *extra, int cdir, int flags));
+int ins_compl_add_infercase __ARGS((char_u *str, int len, int icase, char_u *fname, int dir, int flags));
+int ins_compl_add __ARGS((char_u *str, int len, int icase, char_u *fname, char_u *extra, int cdir, int flags));
 void ins_compl_show_pum __ARGS((void));
 char_u *find_word_start __ARGS((char_u *ptr));
 char_u *find_word_end __ARGS((char_u *ptr));
--- a/src/proto/option.pro
+++ b/src/proto/option.pro
@@ -17,9 +17,10 @@ void check_buf_options __ARGS((buf_T *bu
 void free_string_option __ARGS((char_u *p));
 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 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));
 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));
 void set_option_value __ARGS((char_u *name, long number, char_u *string, int opt_flags));
 char_u *get_term_code __ARGS((char_u *tname));
--- a/src/proto/window.pro
+++ b/src/proto/window.pro
@@ -41,9 +41,9 @@ void win_comp_scroll __ARGS((win_T *wp))
 void command_height __ARGS((long old_p_ch));
 void last_status __ARGS((int morewin));
 int tabpageline_height __ARGS((void));
-char_u *grab_file_name __ARGS((long count));
-char_u *file_name_at_cursor __ARGS((int options, long count));
-char_u *file_name_in_line __ARGS((char_u *line, int col, int options, long count, char_u *rel_fname));
+char_u *grab_file_name __ARGS((long count, linenr_T *file_lnum));
+char_u *file_name_at_cursor __ARGS((int options, long count, linenr_T *file_lnum));
+char_u *file_name_in_line __ARGS((char_u *line, int col, int options, long count, char_u *rel_fname, linenr_T *file_lnum));
 char_u *find_file_name_in_path __ARGS((char_u *ptr, int len, int options, long count, char_u *rel_fname));
 int path_with_url __ARGS((char_u *fname));
 int vim_isAbsName __ARGS((char_u *name));
--- a/src/quickfix.c
+++ b/src/quickfix.c
@@ -2839,7 +2839,12 @@ 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
+    }
 
     /*
      * This function is used by the :cfile, :cgetfile and :caddfile
--- a/src/screen.c
+++ b/src/screen.c
@@ -5474,9 +5474,14 @@ 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
+    }
     called_emsg |= save_called_emsg;
 }
 #endif
@@ -5586,7 +5591,8 @@ win_redr_custom(wp, draw_ruler)
     int		fillchar;
     char_u	buf[MAXPATHL];
     char_u	*p;
-    struct	stl_hlrec hl[STL_MAX_ITEM];
+    struct	stl_hlrec hltab[STL_MAX_ITEM];
+    struct	stl_hlrec tabtab[STL_MAX_ITEM];
     int		use_sandbox = FALSE;
 
     /* setup environment for the task at hand */
@@ -5599,7 +5605,7 @@ win_redr_custom(wp, draw_ruler)
 	attr = hl_attr(HLF_TPF);
 	maxwidth = Columns;
 # ifdef FEAT_EVAL
-	use_sandbox = was_set_insecurely((char_u *)"tabline");
+	use_sandbox = was_set_insecurely((char_u *)"tabline", 0);
 # endif
     }
     else
@@ -5643,7 +5649,7 @@ win_redr_custom(wp, draw_ruler)
 	    }
 
 # ifdef FEAT_EVAL
-	    use_sandbox = was_set_insecurely((char_u *)"rulerformat");
+	    use_sandbox = was_set_insecurely((char_u *)"rulerformat", 0);
 # endif
 	}
 	else
@@ -5653,7 +5659,8 @@ win_redr_custom(wp, draw_ruler)
 	    else
 		p = p_stl;
 # ifdef FEAT_EVAL
-	    use_sandbox = was_set_insecurely((char_u *)"statusline");
+	    use_sandbox = was_set_insecurely((char_u *)"statusline",
+					 *wp->w_p_stl == NUL ? 0 : OPT_LOCAL);
 # endif
 	}
 
@@ -5668,7 +5675,7 @@ win_redr_custom(wp, draw_ruler)
     width = build_stl_str_hl(wp == NULL ? curwin : wp,
 				buf, sizeof(buf),
 				p, use_sandbox,
-				fillchar, maxwidth, hl);
+				fillchar, maxwidth, hltab, tabtab);
     len = STRLEN(buf);
 
     while (width < maxwidth && len < sizeof(buf) - 1)
@@ -5682,27 +5689,49 @@ win_redr_custom(wp, draw_ruler)
     }
     buf[len] = NUL;
 
+    /*
+     * Draw each snippet with the specified highlighting.
+     */
     curattr = attr;
     p = buf;
-    for (n = 0; hl[n].start != NULL; n++)
-    {
-	len = (int)(hl[n].start - p);
+    for (n = 0; hltab[n].start != NULL; n++)
+    {
+	len = (int)(hltab[n].start - p);
 	screen_puts_len(p, len, row, col, curattr);
 	col += vim_strnsize(p, len);
-	p = hl[n].start;
-
-	if (hl[n].userhl == 0)
+	p = hltab[n].start;
+
+	if (hltab[n].userhl == 0)
 	    curattr = attr;
-	else if (hl[n].userhl < 0)
-	    curattr = syn_id2attr(-hl[n].userhl);
+	else if (hltab[n].userhl < 0)
+	    curattr = syn_id2attr(-hltab[n].userhl);
 #ifdef FEAT_WINDOWS
 	else if (wp != NULL && wp != curwin && wp->w_status_height != 0)
-	    curattr = highlight_stlnc[hl[n].userhl - 1];
+	    curattr = highlight_stlnc[hltab[n].userhl - 1];
 #endif
 	else
-	    curattr = highlight_user[hl[n].userhl - 1];
+	    curattr = highlight_user[hltab[n].userhl - 1];
     }
     screen_puts(p, row, col, curattr);
+
+    if (wp == NULL)
+    {
+	/* Fill the TabPageIdxs[] array for clicking in the tab pagesline. */
+	col = 0;
+	len = 0;
+	p = buf;
+	fillchar = 0;
+	for (n = 0; tabtab[n].start != NULL; n++)
+	{
+	    len += vim_strnsize(p, (int)(tabtab[n].start - p));
+	    while (col < len)
+		TabPageIdxs[col++] = fillchar;
+	    p = tabtab[n].start;
+	    fillchar = tabtab[n].userhl;
+	}
+	while (col < Columns)
+	    TabPageIdxs[col++] = fillchar;
+    }
 }
 
 #endif /* FEAT_STL_OPT */
@@ -6198,7 +6227,8 @@ screen_start_highlight(attr)
 	{
 	    char	buf[20];
 
-	    sprintf(buf, IF_EB("\033|%dh", ESC_STR "|%dh"), attr);		/* internal GUI code */
+	    /* The GUI handles this internally. */
+	    sprintf(buf, IF_EB("\033|%dh", ESC_STR "|%dh"), attr);
 	    OUT_STR(buf);
 	}
 	else
@@ -6207,14 +6237,7 @@ screen_start_highlight(attr)
 	    if (attr > HL_ALL)				/* special HL attr. */
 	    {
 		if (t_colors > 1)
-		{
 		    aep = syn_cterm_attr2entry(attr);
-		    /* If the Normal FG color has BOLD attribute and the new
-		     * HL has a FG color defined, clear BOLD. */
-		    if (aep != NULL && aep->ae_u.cterm.fg_color
-						      && cterm_normal_fg_bold)
-			out_str(T_ME);
-		}
 		else
 		    aep = syn_term_attr2entry(attr);
 		if (aep == NULL)	    /* did ":syntax clear" */
@@ -6224,6 +6247,11 @@ screen_start_highlight(attr)
 	    }
 	    if ((attr & HL_BOLD) && T_MD != NULL)	/* bold */
 		out_str(T_MD);
+	    else if (aep != NULL && t_colors > 1 && aep->ae_u.cterm.fg_color
+						      && cterm_normal_fg_bold)
+		/* If the Normal FG color has BOLD attribute and the new HL
+		 * has a FG color defined, clear BOLD. */
+		out_str(T_ME);
 	    if ((attr & HL_STANDOUT) && T_SO != NULL)	/* standout */
 		out_str(T_SO);
 	    if ((attr & (HL_UNDERLINE | HL_UNDERCURL)) && T_US != NULL)
@@ -6808,7 +6836,7 @@ screenalloc(clear)
     unsigned	    *new_LineOffset;
     char_u	    *new_LineWraps;
 #ifdef FEAT_WINDOWS
-    char_u	    *new_TabPageIdxs;
+    short	    *new_TabPageIdxs;
     tabpage_T	    *tp;
 #endif
     static int	    entered = FALSE;		/* avoid recursiveness */
@@ -6885,7 +6913,7 @@ screenalloc(clear)
 					 Rows * sizeof(unsigned)), FALSE);
     new_LineWraps = (char_u *)lalloc((long_u)(Rows * sizeof(char_u)), FALSE);
 #ifdef FEAT_WINDOWS
-    new_TabPageIdxs = (char_u *)lalloc((long_u)(Columns * sizeof(char_u)), FALSE);
+    new_TabPageIdxs = (short *)lalloc((long_u)(Columns * sizeof(short)), FALSE);
 #endif
 
     FOR_ALL_TAB_WINDOWS(tp, wp)
@@ -8553,6 +8581,11 @@ draw_tabline()
 	return;
 
 #if defined(FEAT_STL_OPT)
+
+    /* Init TabPageIdxs[] to zero: Clicking outside of tabs has no effect. */
+    for (scol = 0; scol < Columns; ++scol)
+	TabPageIdxs[scol] = 0;
+
     /* Use the 'tabline' option if it's set. */
     if (*p_tal != NUL)
     {
@@ -8563,8 +8596,13 @@ 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
+	}
 	called_emsg |= save_called_emsg;
     }
     else
@@ -8579,6 +8617,7 @@ draw_tabline()
 
 	attr = attr_nosel;
 	tabcount = 0;
+	scol = 0;
 	for (tp = first_tabpage; tp != NULL && col < Columns; tp = tp->tp_next)
 	{
 	    scol = col;
@@ -8671,15 +8710,14 @@ draw_tabline()
 	else
 	    c = ' ';
 	screen_fill(0, 1, col, (int)Columns, c, c, attr_fill);
-    }
-
-    /* Put an "X" for closing the current tab if there are several. */
-    if (first_tabpage->tp_next != NULL)
-	screen_putchar('X', 0, (int)Columns - 1, attr_nosel);
-
-    /* Clicking outside of tabs has no effect. */
-    while (scol < Columns)
-	TabPageIdxs[scol++] = 0xff;
+
+	/* Put an "X" for closing the current tab if there are several. */
+	if (first_tabpage->tp_next != NULL)
+	{
+	    screen_putchar('X', 0, (int)Columns - 1, attr_nosel);
+	    TabPageIdxs[Columns - 1] = -999;
+	}
+    }
 }
 #endif
 
@@ -8852,8 +8890,13 @@ 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
+	}
 	called_emsg |= save_called_emsg;
 	return;
     }
--- a/src/search.c
+++ b/src/search.c
@@ -4499,7 +4499,7 @@ find_pattern_in_path(ptr, dir, len, whol
 	    else
 		/* Use text after match with 'include'. */
 		new_fname = file_name_in_line(incl_regmatch.endp[0], 0,
-				 FNAME_EXP|FNAME_INCL|FNAME_REL, 1L, p_fname);
+			     FNAME_EXP|FNAME_INCL|FNAME_REL, 1L, p_fname, NULL);
 	    already_searched = FALSE;
 	    if (new_fname != NULL)
 	    {
@@ -4829,7 +4829,7 @@ search_line:
 			goto exit_matched;
 		}
 
-		add_r = ins_compl_add_infercase(aux, i,
+		add_r = ins_compl_add_infercase(aux, i, p_ic,
 			curr_fname == curbuf->b_fname ? NULL : curr_fname,
 			dir, reuse);
 		if (add_r == OK)
--- a/src/structs.h
+++ b/src/structs.h
@@ -1324,14 +1324,17 @@ struct file_buffer
     char_u	*b_p_inc;	/* 'include' */
 # ifdef FEAT_EVAL
     char_u	*b_p_inex;	/* 'includeexpr' */
+    long_u	b_p_inex_flags;	/* flags for 'includeexpr' */
 # endif
 #endif
 #if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
     char_u	*b_p_inde;	/* 'indentexpr' */
+    long_u	b_p_inde_flags;	/* flags for 'indentexpr' */
     char_u	*b_p_indk;	/* 'indentkeys' */
 #endif
 #if defined(FEAT_EVAL)
     char_u	*b_p_fex;	/* 'formatexpr' */
+    long_u	b_p_fex_flags;	/* flags for 'formatexpr' */
 #endif
 #ifdef FEAT_CRYPT
     char_u	*b_p_key;	/* 'key' */
@@ -1826,6 +1829,15 @@ struct window_S
     winopt_T	w_onebuf_opt;
     winopt_T	w_allbuf_opt;
 
+    /* A few options have local flags for P_INSECURE. */
+#ifdef FEAT_STL_OPT
+    long_u	w_p_stl_flags;	    /* flags for 'statusline' */
+#endif
+#ifdef FEAT_EVAL
+    long_u	w_p_fde_flags;	    /* flags for 'foldexpr' */
+    long_u	w_p_fdt_flags;	    /* flags for 'foldtext' */
+#endif
+
     /* transform a pointer to a "onebuf" option into a "allbuf" option */
 #define GLOBAL_WO(p)	((char *)p + sizeof(winopt_T))
 
--- a/src/term.c
+++ b/src/term.c
@@ -1562,6 +1562,9 @@ set_color_count(nr)
     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
 }
 #endif
 
@@ -2501,6 +2504,9 @@ termcapinit(name)
     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 the default terminal name. */
     set_string_default("term", term);
--- 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 21)"
-#define VIM_VERSION_LONG_DATE	"VIM - Vi IMproved 7.0aa ALPHA (2006 Feb 21, compiled "
+#define VIM_VERSION_LONG	"VIM - Vi IMproved 7.0aa ALPHA (2006 Feb 22)"
+#define VIM_VERSION_LONG_DATE	"VIM - Vi IMproved 7.0aa ALPHA (2006 Feb 22, compiled "
--- a/src/vim.h
+++ b/src/vim.h
@@ -1035,6 +1035,7 @@ extern char *(*dyn_libintl_textdomain)(c
 #define SID_CMDARG	-2	/* for "--cmd" argument */
 #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 */
 
 /*
  * Events for autocommands.
--- a/src/window.c
+++ b/src/window.c
@@ -105,6 +105,7 @@ do_window(nchar, Prenum, xchar)
     win_T	*wp;
 #if defined(FEAT_SEARCHPATH) || defined(FEAT_FIND_ID)
     char_u	*ptr;
+    linenr_T    lnum = -1;
 #endif
 #ifdef FEAT_FIND_ID
     int		type = FIND_DEFINE;
@@ -478,10 +479,11 @@ newwindow:
 #ifdef FEAT_SEARCHPATH
 /* edit file name under cursor in a new window */
     case 'f':
+    case 'F':
     case Ctrl_F:
 		CHECK_CMDWIN
 
-		ptr = grab_file_name(Prenum1);
+		ptr = grab_file_name(Prenum1, &lnum);
 		if (ptr != NULL)
 		{
 #ifdef FEAT_GUI
@@ -493,8 +495,13 @@ newwindow:
 # ifdef FEAT_SCROLLBIND
 			curwin->w_p_scb = FALSE;
 # endif
-			(void)do_ecmd(0, ptr, NULL, NULL, ECMD_LASTL,
-								   ECMD_HIDE);
+			(void)do_ecmd(0, ptr, NULL, NULL, ECMD_LASTL, ECMD_HIDE);
+			if (nchar == 'F' && lnum >= 0)
+			{
+			    curwin->w_cursor.lnum = lnum;
+			    check_cursor_lnum();
+			    beginline(BL_SOL | BL_FIX);
+			}
 		    }
 		    vim_free(ptr);
 		}
@@ -5081,8 +5088,9 @@ tabpageline_height()
  * Returns the name in allocated memory, NULL for failure.
  */
     char_u *
-grab_file_name(count)
-    long count;
+grab_file_name(count, file_lnum)
+    long	count;
+    linenr_T	*file_lnum;
 {
 # ifdef FEAT_VISUAL
     if (VIsual_active)
@@ -5096,7 +5104,9 @@ grab_file_name(count)
 		     FNAME_MESS|FNAME_EXP|FNAME_REL, count, curbuf->b_ffname);
     }
 # endif
-    return file_name_at_cursor(FNAME_MESS|FNAME_HYP|FNAME_EXP|FNAME_REL, count);
+    return file_name_at_cursor(FNAME_MESS|FNAME_HYP|FNAME_EXP|FNAME_REL, count,
+			       file_lnum);
+
 }
 
 /*
@@ -5113,12 +5123,14 @@ grab_file_name(count)
  * FNAME_INCL	    apply "includeexpr"
  */
     char_u *
-file_name_at_cursor(options, count)
-    int	    options;
-    long    count;
+file_name_at_cursor(options, count, file_lnum)
+    int		options;
+    long	count;
+    linenr_T	*file_lnum;
 {
     return file_name_in_line(ml_get_curline(),
-		      curwin->w_cursor.col, options, count, curbuf->b_ffname);
+		      curwin->w_cursor.col, options, count, curbuf->b_ffname,
+		      file_lnum);
 }
 
 /*
@@ -5126,12 +5138,13 @@ file_name_at_cursor(options, count)
  * Otherwise like file_name_at_cursor().
  */
     char_u *
-file_name_in_line(line, col, options, count, rel_fname)
+file_name_in_line(line, col, options, count, rel_fname, file_lnum)
     char_u	*line;
     int		col;
     int		options;
     long	count;
     char_u	*rel_fname;	/* file we are searching relative to */
+    linenr_T	*file_lnum;	/* line number after the file name */
 {
     char_u	*ptr;
     int		len;
@@ -5189,6 +5202,23 @@ file_name_in_line(line, col, options, co
 						       && ptr[len - 2] != '.')
 	--len;
 
+    if (file_lnum != NULL)
+    {
+	char_u *p;
+
+	/* Get the number after the file name and a separator character */
+	p = ptr + len;
+	p = skipwhite(p);
+	if (*p != NUL)
+	{
+	    if (!isdigit(*p))
+		++p;		    /* skip the separator */
+	    p = skipwhite(p);
+	    if (isdigit(*p))
+		*file_lnum = (int)getdigits(&p);
+	}
+    }
+
     return find_file_name_in_path(ptr, len, options, count, rel_fname);
 }
 
@@ -5204,7 +5234,7 @@ eval_includeexpr(ptr, len)
 
     set_vim_var_string(VV_FNAME, ptr, len);
     res = eval_to_string_safe(curbuf->b_p_inex, NULL,
-				 was_set_insecurely((char_u *)"includeexpr"));
+		      was_set_insecurely((char_u *)"includeexpr", OPT_LOCAL));
     set_vim_var_string(VV_FNAME, NULL, 0);
     return res;
 }