updated for version 7.0183
diff --git a/src/buffer.c b/src/buffer.c
index 677215d..83c9690 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -1806,9 +1806,9 @@
     if (buf == curbuf)
 	return OK;
 
-    if (editing_cmdline())
+    if (text_locked())
     {
-	editing_cmdline_msg();
+	text_locked_msg();
 	return FAIL;
     }
 
@@ -3506,7 +3506,8 @@
 	    curwin = wp;
 	    curbuf = wp->w_buffer;
 
-	    str = eval_to_string_safe(p, &t);
+	    str = eval_to_string_safe(p, &t,
+				  was_set_insecurely((char_u *)"statusline"));
 
 	    curwin = o_curwin;
 	    curbuf = o_curbuf;
diff --git a/src/ex_docmd.c b/src/ex_docmd.c
index fe9cd6b..4e430c7 100644
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -2137,7 +2137,7 @@
 	    goto doend;
 	}
 
-	if (editing_cmdline() && !(ea.argt & CMDWIN)
+	if (text_locked() && !(ea.argt & CMDWIN)
 # ifdef FEAT_USR_CMDS
 		&& !USER_CMDIDX(ea.cmdidx)
 # endif
@@ -6034,9 +6034,9 @@
     }
 #endif
     /* Don't quit while editing the command line. */
-    if (editing_cmdline())
+    if (text_locked())
     {
-	editing_cmdline_msg();
+	text_locked_msg();
 	return;
     }
 
@@ -6103,9 +6103,9 @@
 # endif
 
     /* Don't quit while editing the command line. */
-    if (editing_cmdline())
+    if (text_locked())
     {
-	editing_cmdline_msg();
+	text_locked_msg();
 	return;
     }
 
@@ -6128,7 +6128,7 @@
 	cmdwin_result = K_IGNORE;
     else
 # endif
-	if (!editing_cmdline())
+	if (!text_locked())
 	    ex_win_close(eap, curwin);
 }
 
@@ -6289,9 +6289,9 @@
     }
 #endif
     /* Don't quit while editing the command line. */
-    if (editing_cmdline())
+    if (text_locked())
     {
-	editing_cmdline_msg();
+	text_locked_msg();
 	return;
     }
 
@@ -6407,7 +6407,7 @@
     int		save_msg_scroll = msg_scroll;
 
     /* Postpone this while editing the command line. */
-    if (editing_cmdline())
+    if (text_locked())
 	return;
 
     /* Check whether the current buffer is changed. If so, we will need
diff --git a/src/fileio.c b/src/fileio.c
index 2236bbc..ce3e2a0 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -59,6 +59,7 @@
 #ifdef UNIX
 static void set_file_time __ARGS((char_u *fname, time_t atime, time_t mtime));
 #endif
+static int set_rw_fname __ARGS((char_u *fname, char_u *sfname));
 static int msg_add_fileformat __ARGS((int eol_type));
 static void msg_add_eol __ARGS((void));
 static int check_mtime __ARGS((buf_T *buf, struct stat *s));
@@ -301,8 +302,8 @@
 	    && vim_strchr(p_cpo, CPO_FNAMER) != NULL
 	    && !(flags & READ_DUMMY))
     {
-	if (setfname(curbuf, fname, sfname, FALSE) == OK)
-	    curbuf->b_flags |= BF_NOTEDITED;
+	if (set_rw_fname(fname, sfname) == FAIL)
+	    return FAIL;
     }
 
     /* After reading a file the cursor line changes but we don't want to
@@ -2801,35 +2802,20 @@
      * Don't do this when appending.
      * Only do this when 'cpoptions' contains the 'F' flag.
      */
-    if (reset_changed
+    if (buf->b_ffname == NULL
+	    && reset_changed
 	    && whole
 	    && buf == curbuf
 #ifdef FEAT_QUICKFIX
 	    && !bt_nofile(buf)
 #endif
-	    && buf->b_ffname == NULL
 	    && !filtering
 	    && (!append || vim_strchr(p_cpo, CPO_FNAMEAPP) != NULL)
 	    && vim_strchr(p_cpo, CPO_FNAMEW) != NULL)
     {
-#ifdef FEAT_AUTOCMD
-	/* It's like the unnamed buffer is deleted.... */
-	if (curbuf->b_p_bl)
-	    apply_autocmds(EVENT_BUFDELETE, NULL, NULL, FALSE, curbuf);
-	apply_autocmds(EVENT_BUFWIPEOUT, NULL, NULL, FALSE, curbuf);
-#ifdef FEAT_EVAL
-	if (aborting())	    /* autocmds may abort script processing */
+	if (set_rw_fname(fname, sfname) == FAIL)
 	    return FAIL;
-#endif
-#endif
-	if (setfname(curbuf, fname, sfname, FALSE) == OK)
-	    curbuf->b_flags |= BF_NOTEDITED;
-#ifdef FEAT_AUTOCMD
-	/* ....and a new named one is created */
-	apply_autocmds(EVENT_BUFNEW, NULL, NULL, FALSE, curbuf);
-	if (curbuf->b_p_bl)
-	    apply_autocmds(EVENT_BUFADD, NULL, NULL, FALSE, curbuf);
-#endif
+	buf = curbuf;	    /* just in case autocmds made "buf" invalid */
     }
 
     if (sfname == NULL)
@@ -4601,6 +4587,50 @@
 }
 
 /*
+ * Set the name of the current buffer.  Use when the buffer doesn't have a
+ * name and a ":r" or ":w" command with a file name is used.
+ */
+    static int
+set_rw_fname(fname, sfname)
+    char_u	*fname;
+    char_u	*sfname;
+{
+#ifdef FEAT_AUTOCMD
+    /* It's like the unnamed buffer is deleted.... */
+    if (curbuf->b_p_bl)
+	apply_autocmds(EVENT_BUFDELETE, NULL, NULL, FALSE, curbuf);
+    apply_autocmds(EVENT_BUFWIPEOUT, NULL, NULL, FALSE, curbuf);
+# ifdef FEAT_EVAL
+    if (aborting())	    /* autocmds may abort script processing */
+	return FAIL;
+# endif
+#endif
+
+    if (setfname(curbuf, fname, sfname, FALSE) == OK)
+	curbuf->b_flags |= BF_NOTEDITED;
+
+#ifdef FEAT_AUTOCMD
+    /* ....and a new named one is created */
+    apply_autocmds(EVENT_BUFNEW, NULL, NULL, FALSE, curbuf);
+    if (curbuf->b_p_bl)
+	apply_autocmds(EVENT_BUFADD, NULL, NULL, FALSE, curbuf);
+# ifdef FEAT_EVAL
+    if (aborting())	    /* autocmds may abort script processing */
+	return FAIL;
+# endif
+
+    /* Do filetype detection now if 'filetype' is empty. */
+    if (*curbuf->b_p_ft == NUL)
+    {
+	(void)do_doautocmd((char_u *)"filetypedetect BufRead", TRUE);
+	do_modelines(FALSE);
+    }
+#endif
+
+    return OK;
+}
+
+/*
  * Put file name into IObuff with quotes.
  */
     void
diff --git a/src/normal.c b/src/normal.c
index 12ede73..e866250 100644
--- a/src/normal.c
+++ b/src/normal.c
@@ -789,11 +789,11 @@
 	goto normal_end;
     }
 
-    if (editing_cmdline() && (nv_cmds[idx].cmd_flags & NV_NCW))
+    if (text_locked() && (nv_cmds[idx].cmd_flags & NV_NCW))
     {
 	/* This command is not allowed wile editing a ccmdline: beep. */
 	clearopbeep(oap);
-	editing_cmdline_msg();
+	text_locked_msg();
 	goto normal_end;
     }
 
@@ -5741,10 +5741,10 @@
 {
     char_u	*ptr;
 
-    if (editing_cmdline())
+    if (text_locked())
     {
 	clearopbeep(cap->oap);
-	editing_cmdline_msg();
+	text_locked_msg();
 	return;
     }
 
@@ -7801,10 +7801,10 @@
 
     /* "gQ": improved Ex mode */
     case 'Q':
-	if (editing_cmdline())
+	if (text_locked())
 	{
 	    clearopbeep(cap->oap);
-	    editing_cmdline_msg();
+	    text_locked_msg();
 	    break;
 	}
 
diff --git a/src/proto/ex_getln.pro b/src/proto/ex_getln.pro
index 3b11a38..6b4fa4f 100644
--- a/src/proto/ex_getln.pro
+++ b/src/proto/ex_getln.pro
@@ -1,8 +1,8 @@
 /* ex_getln.c */
 char_u *getcmdline __ARGS((int firstc, long count, int indent));
 char_u *getcmdline_prompt __ARGS((int firstc, char_u *prompt, int attr, int xp_context, char_u *xp_arg));
-int editing_cmdline __ARGS((void));
-void editing_cmdline_msg __ARGS((void));
+int text_locked __ARGS((void));
+void text_locked_msg __ARGS((void));
 char_u *getexline __ARGS((int c, void *dummy, int indent));
 char_u *getexmodeline __ARGS((int promptc, void *dummy, int indent));
 int cmdline_overstrike __ARGS((void));
diff --git a/src/proto/option.pro b/src/proto/option.pro
index 49e1d9a..4a49d89 100644
--- a/src/proto/option.pro
+++ b/src/proto/option.pro
@@ -17,6 +17,7 @@
 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));
 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));
 int get_option_value __ARGS((char_u *name, long *numval, char_u **stringval, int opt_flags));
diff --git a/src/spell.c b/src/spell.c
index 882cc50..ceb5b82 100644
--- a/src/spell.c
+++ b/src/spell.c
@@ -59,7 +59,8 @@
 # define SPELL_PRINTTREE
 #endif
 
-/* Use DEBUG_TRIEWALK to print the changes made in suggest_trie_walk(). */
+/* Use DEBUG_TRIEWALK to print the changes made in suggest_trie_walk() for a
+ * specific word. */
 #if 0
 # define DEBUG_TRIEWALK
 #endif
@@ -328,6 +329,9 @@
 #define WF_HAS_AFF  0x0100	/* word includes affix */
 #define WF_NEEDCOMP 0x0200	/* word only valid in compound */
 
+/* only used for su_badflags */
+#define WF_MIXCAP   0x20	/* mix of upper and lower case: macaRONI */
+
 #define WF_CAPMASK (WF_ONECAP | WF_ALLCAP | WF_KEEPCAP | WF_FIXCAP)
 
 /* flags for <pflags> */
@@ -4328,6 +4332,9 @@
 	    flags |= WF_ALLCAP;
 	else if (first)
 	    flags |= WF_ONECAP;
+
+	if (u >= 2 && l >= 2)	/* maCARONI maCAroni */
+	    flags |= WF_MIXCAP;
     }
     return flags;
 }
@@ -10895,9 +10902,29 @@
 
 		    /* Add the suggestion if the score isn't too bad. */
 		    if (score <= su->su_maxscore)
+		    {
 			add_suggestion(su, &su->su_ga, preword,
 				    sp->ts_fidx - repextra,
 				    score, 0, FALSE, lp->lp_sallang, FALSE);
+
+			if (su->su_badflags & WF_MIXCAP)
+			{
+			    /* We really don't know if the word should be
+			     * upper or lower case, add both. */
+			    c = captype(preword, NULL);
+			    if (c == 0 || c == WF_ALLCAP)
+			    {
+				make_case_word(tword + sp->ts_splitoff,
+					      preword + sp->ts_prewordlen,
+						      c == 0 ? WF_ALLCAP : 0);
+
+				add_suggestion(su, &su->su_ga, preword,
+					sp->ts_fidx - repextra,
+					score + SCORE_ICASE, 0, FALSE,
+					lp->lp_sallang, FALSE);
+			    }
+			}
+		    }
 		}
 	    }
 
diff --git a/src/window.c b/src/window.c
index 680c320..a021805 100644
--- a/src/window.c
+++ b/src/window.c
@@ -2717,10 +2717,10 @@
 win_goto(wp)
     win_T	*wp;
 {
-    if (editing_cmdline())
+    if (text_locked())
     {
 	beep_flush();
-	editing_cmdline_msg();
+	text_locked_msg();
 	return;
     }
 
@@ -4638,7 +4638,8 @@
     char_u	*res;
 
     set_vim_var_string(VV_FNAME, ptr, len);
-    res = eval_to_string_safe(curbuf->b_p_inex, NULL);
+    res = eval_to_string_safe(curbuf->b_p_inex, NULL,
+				 was_set_insecurely((char_u *)"includeexpr"));
     set_vim_var_string(VV_FNAME, NULL, 0);
     return res;
 }