changeset 580:90ee46d7f492 v7.0164

updated for version 7.0164
author vimboss
date Wed, 07 Dec 2005 21:07:59 +0000
parents 1ef373b13126
children ec04f19aed55
files runtime/doc/todo.txt runtime/doc/version7.txt src/eval.c src/ex_cmds.c src/main.c src/memline.c
diffstat 6 files changed, 179 insertions(+), 77 deletions(-) [+]
line wrap: on
line diff
--- a/runtime/doc/todo.txt
+++ b/runtime/doc/todo.txt
@@ -1,4 +1,4 @@
-*todo.txt*      For Vim version 7.0aa.  Last change: 2005 Dec 06
+*todo.txt*      For Vim version 7.0aa.  Last change: 2005 Dec 07
 
 
 		  VIM REFERENCE MANUAL	  by Bram Moolenaar
@@ -37,6 +37,9 @@ differences.  Use Amiga code?
 "^[.?!]\_[\])'"   ]\+"
 Using string that was freed or buffer that is overwritten?
 
+SwapExists with editexisting plugin: Is there a simple way to detect ":tag
+function" and have the remote Vim jump to the tag?
+
 When editing a file "a" that is a symbolic link to "b", while another Vim is
 editing "b", there is no warning.  Follow symlink to make swap file name?
 Patch from Stefano Zacchiroli.  Updated by James Vega, Dec 2.
@@ -157,6 +160,10 @@ Autoload:
 Add ":smap", Select mode mapping?  Otherwise: ":sunmap", so that Visual mode
 mappings for normal keys can be removed from Select mode.
 
+When expanding on the command line, recognize shell commands, such as ":!cmd".
+Complete command names by searching in $PATH.  When completing file names
+escape special characters ";&<>(){}". (Adri Verhoef)
+
 Awaiting response:
 -   Win32: tearoff menu window should have a scrollbar when it's taller than
     the screen.
@@ -902,8 +909,6 @@ 8   Setting 'shellslash' has no immediat
 8   When editing a file on a Samba server, case might matter.  ":e file"
     followed by ":e FILE" will edit "file" again, even though "FILE" might be
     another one.  Set last used name in buflist_new()?  Fix do_ecmd(), etc.
-8   ":mksession" generates a "cd" command where "aa\#bb" means directory "#bb"
-    in "aa", but it's used as "aa#bb". (Ronald Hoellwarth)
 8   When a buffer is editing a file like "ftp://mach/file", which is not going
     to be used like a normal file name, don't change the slashes to
     backslashes. (Ronald Hoellwarth)
@@ -1094,8 +1099,6 @@ 9   When editing a file with 'readonly' 
     one.
 7   When 'showbreak' is set, the amount of space a Tab occupies changes.
     Should work like 'showbreak' is inserted without changing the Tabs.
-7   When there is a "help.txt" window in a session file, restoring that
-    session will not get the "LOCAL ADDITIONS" back.
 7   When 'mousefocus' is set and switching to another window with a typed
     command, the mouse pointer may be moved to a part of the window that's
     covered by another window and we lose focus.  Only move in the y
@@ -1881,7 +1884,6 @@ 7   Make it possible to do any command o
 7   Add function to generate unique number (date in milliseconds).
 7   Automatically load a function from a file when it is called.  Need an
     option for the search path. (Sekera)
-7   Persistent variables: "p:var"; stored in viminfo file and sessions files.
 
 
 Robustness:
@@ -3097,20 +3099,27 @@ 8   Before trying to execute a modeline,
     or not.  Same for .exrc in local dir.
 
 
-Options:
-8   Make ":mksession" store buffer-specific options for the specific buffer.
+Sessions:
+8   DOS/Windows: ":mksession" generates a "cd" command where "aa\#bb" means
+    directory "#bb" in "aa", but it's used as "aa#bb". (Ronald Hoellwarth)
+7   When there is a "help.txt" window in a session file, restoring that
+    session will not get the "LOCAL ADDITIONS" back.
 8   With ":mksession" always store the 'sessionoptions' option, even when
     "options" isn't in it. (St-Amant)
+8   When using ":mksession", also store a command to reset all options to
+    their default value, before setting the options that are not at their
+    default value.
+7   With ":mksession" also store the tag stack and jump history. (Michal
+    Malecki)
+7   Persistent variables: "p:var"; stored in viminfo file and sessions files.
+ 
+
+Options:
 7   ":with option=value | command": temporarily set an option value and
     restore it after the command has executed.
 7   Setting an option always sets "w_set_curswant", while this is only
     required for a few options.  Only do it for those options to avoid the
     side effect.
-8   When using ":mksession", also store a command to reset all options to
-    their default value, before setting the options that are not at their
-    default value.
-7   With ":mksession" also store the tag stack and jump history. (Michal
-    Malecki)
 8   Make "old" number options that really give a number of effects into string
     options that are a comma separated list.  The old number values should
     also be supported.
--- a/runtime/doc/version7.txt
+++ b/runtime/doc/version7.txt
@@ -1,4 +1,4 @@
-*version7.txt*  For Vim version 7.0aa.  Last change: 2005 Dec 06
+*version7.txt*  For Vim version 7.0aa.  Last change: 2005 Dec 07
 
 
 		  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -847,6 +847,9 @@ Unix: When open() returns EFBIG give an 
 ":mksession" sets the SessionLoad variable to notify plugins.  A modeline is
 added to the session file to set 'filetype' to "vim".
 
+In the ATTENTION prompt put the "Delete it" choice before "Quit" to make it
+more logical.  (Robert Webb)
+
 ==============================================================================
 COMPILE TIME CHANGES					*compile-changes-7*
 
@@ -1408,4 +1411,6 @@ sticking to the first column.
 When using ":wq" and a BufWriteCmd autocmd uses inputsecret() the text was
 echoed anyway.  Set terminal to raw mode in getcmdline().
 
+Unix: ":w a;b~c" caused an error in expanding wildcards.
+
  vim:tw=78:ts=8:ft=help:norl:
--- a/src/eval.c
+++ b/src/eval.c
@@ -338,6 +338,8 @@ static struct vimvar
     {VV_NAME("beval_col",	 VAR_NUMBER), VV_RO},
     {VV_NAME("beval_text",	 VAR_STRING), VV_RO},
     {VV_NAME("scrollstart",	 VAR_STRING), 0},
+    {VV_NAME("swapname",	 VAR_STRING), VV_RO},
+    {VV_NAME("swapchoice",	 VAR_STRING), 0},
 };
 
 /* shorthand */
--- a/src/ex_cmds.c
+++ b/src/ex_cmds.c
@@ -3420,7 +3420,7 @@ do_ecmd(fnum, ffname, sfname, eap, newln
 	topline = curwin->w_topline;
 	if (!oldbuf)			    /* need to read the file */
 	{
-#if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG)
+#if defined(HAS_SWAP_EXISTS_ACTION)
 	    swap_exists_action = SEA_DIALOG;
 #endif
 	    curbuf->b_flags |= BF_CHECK_RO; /* set/reset 'ro' flag */
@@ -3435,7 +3435,7 @@ do_ecmd(fnum, ffname, sfname, eap, newln
 	    (void)open_buffer(FALSE, eap);
 #endif
 
-#if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG)
+#if defined(HAS_SWAP_EXISTS_ACTION)
 	    if (swap_exists_action == SEA_QUIT)
 		retval = FAIL;
 	    handle_swap_exists(old_curbuf);
--- a/src/main.c
+++ b/src/main.c
@@ -116,7 +116,7 @@ static void exe_pre_commands __ARGS((mpa
 static void exe_commands __ARGS((mparm_T *parmp));
 static void source_startup_scripts __ARGS((mparm_T *parmp));
 static void main_start_gui __ARGS((void));
-#if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG)
+#if defined(HAS_SWAP_EXISTS_ACTION)
 static void check_swap_exists_action __ARGS((void));
 #endif
 #ifdef FEAT_CLIENTSERVER
@@ -2150,7 +2150,7 @@ read_stdin()
 {
     int	    i;
 
-#if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG)
+#if defined(HAS_SWAP_EXISTS_ACTION)
     /* When getting the ATTENTION prompt here, use a dialog */
     swap_exists_action = SEA_DIALOG;
 #endif
@@ -2161,7 +2161,7 @@ read_stdin()
     no_wait_return = FALSE;
     msg_didany = i;
     TIME_MSG("reading stdin");
-#if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG)
+#if defined(HAS_SWAP_EXISTS_ACTION)
     check_swap_exists_action();
 #endif
 #if !(defined(AMIGA) || defined(MACOS))
@@ -2245,14 +2245,14 @@ create_windows(parmp)
 		if (p_fdls >= 0)
 		    curwin->w_p_fdl = p_fdls;
 #endif
-#if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG)
+#if defined(HAS_SWAP_EXISTS_ACTION)
 		/* When getting the ATTENTION prompt here, use a dialog */
 		swap_exists_action = SEA_DIALOG;
 #endif
 		set_buflisted(TRUE);
 		(void)open_buffer(FALSE, NULL); /* create memfile, read file */
 
-#if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG)
+#if defined(HAS_SWAP_EXISTS_ACTION)
 		check_swap_exists_action();
 #endif
 #ifdef FEAT_AUTOCMD
@@ -2872,7 +2872,7 @@ usage()
 	mch_exit(0);
 }
 
-#if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG)
+#if defined(HAS_SWAP_EXISTS_ACTION)
 /*
  * Check the result of the ATTENTION dialog:
  * When "Quit" selected, exit Vim.
--- a/src/memline.c
+++ b/src/memline.c
@@ -1595,7 +1595,7 @@ static int process_still_running;
 #endif
 
 /*
- * Give information about an existing swap file
+ * Give information about an existing swap file.
  * Returns timestamp (0 when unknown).
  */
     static time_t
@@ -3494,6 +3494,93 @@ get_file_in_dir(fname, dname)
     return retval;
 }
 
+static void attention_message __ARGS((buf_T *buf, char_u *fname));
+
+/*
+ * Print the ATTENTION message: info about an existing swap file.
+ */
+    static void
+attention_message(buf, fname)
+    buf_T   *buf;	/* buffer being edited */
+    char_u  *fname;	/* swap file name */
+{
+    struct stat st;
+    time_t	x, sx;
+
+    ++no_wait_return;
+    (void)EMSG(_("E325: ATTENTION"));
+    MSG_PUTS(_("\nFound a swap file by the name \""));
+    msg_home_replace(fname);
+    MSG_PUTS("\"\n");
+    sx = swapfile_info(fname);
+    MSG_PUTS(_("While opening file \""));
+    msg_outtrans(buf->b_fname);
+    MSG_PUTS("\"\n");
+    if (mch_stat((char *)buf->b_fname, &st) != -1)
+    {
+	MSG_PUTS(_("             dated: "));
+	x = st.st_mtime;    /* Manx C can't do &st.st_mtime */
+	MSG_PUTS(ctime(&x));
+	if (sx != 0 && x > sx)
+	    MSG_PUTS(_("      NEWER than swap file!\n"));
+    }
+    /* Some of these messages are long to allow translation to
+     * other languages. */
+    MSG_PUTS(_("\n(1) Another program may be editing the same file.\n    If this is the case, be careful not to end up with two\n    different instances of the same file when making changes.\n"));
+    MSG_PUTS(_("    Quit, or continue with caution.\n"));
+    MSG_PUTS(_("\n(2) An edit session for this file crashed.\n"));
+    MSG_PUTS(_("    If this is the case, use \":recover\" or \"vim -r "));
+    msg_outtrans(buf->b_fname);
+    MSG_PUTS(_("\"\n    to recover the changes (see \":help recovery\").\n"));
+    MSG_PUTS(_("    If you did this already, delete the swap file \""));
+    msg_outtrans(fname);
+    MSG_PUTS(_("\"\n    to avoid this message.\n"));
+    cmdline_row = msg_row;
+    --no_wait_return;
+}
+
+#ifdef FEAT_AUTOCMD
+static int do_swapexists __ARGS((buf_T *buf, char_u *fname));
+
+/*
+ * Trigger the SwapExists autocommands.
+ * Returns a value for equivalent to do_dialog() (see below):
+ * 0: still need to ask for a choice
+ * 1: open read-only
+ * 2: edit anyway
+ * 3: recover
+ * 4: delete it
+ * 5: quit
+ * 6: abort
+ */
+    static int
+do_swapexists(buf, fname)
+    buf_T	*buf;
+    char_u	*fname;
+{
+    set_vim_var_string(VV_SWAPNAME, fname, -1);
+    set_vim_var_string(VV_SWAPCHOICE, NULL, -1);
+
+    /* Trigger SwapExists autocommands with <afile> set to the file being
+     * edited. */
+    apply_autocmds(EVENT_SWAPEXISTS, buf->b_fname, NULL, FALSE, NULL);
+
+    set_vim_var_string(VV_SWAPNAME, NULL, -1);
+
+    switch (*get_vim_var_str(VV_SWAPCHOICE))
+    {
+	case 'o': return 1;
+	case 'e': return 2;
+	case 'r': return 3;
+	case 'd': return 4;
+	case 'q': return 5;
+	case 'a': return 6;
+    }
+
+    return 0;
+}
+#endif
+
 /*
  * Find out what name to use for the swap file for buffer 'buf'.
  *
@@ -3511,7 +3598,6 @@ findswapname(buf, dirp, old_fname)
 {
     char_u	*fname;
     int		n;
-    time_t	x, sx;
     char_u	*dir_name;
 #ifdef AMIGA
     BPTR	fh;
@@ -3797,7 +3883,9 @@ findswapname(buf, dirp, old_fname)
 		if (differ == FALSE && !(curbuf->b_flags & BF_RECOVERED)
 			&& vim_strchr(p_shm, SHM_ATTENTION) == NULL)
 		{
-		    struct stat st;
+#if defined(HAS_SWAP_EXISTS_ACTION)
+		    int		choice = 0;
+#endif
 #ifdef CREATE_DUMMY_FILE
 		    int		did_use_dummy = FALSE;
 
@@ -3813,55 +3901,41 @@ findswapname(buf, dirp, old_fname)
 			did_use_dummy = TRUE;
 		    }
 #endif
-#ifdef FEAT_GUI
-		    /* If we are supposed to start the GUI but it wasn't
-		     * completely started yet, start it now.  This makes the
-		     * messages displayed in the Vim window when loading a
-		     * session from the .gvimrc file. */
-		    if (gui.starting && !gui.in_use)
-			gui_start();
-#endif
 
 #if (defined(UNIX) || defined(__EMX__) || defined(VMS)) && (defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG))
 		    process_still_running = FALSE;
 #endif
-		    ++no_wait_return;
-		    (void)EMSG(_("E325: ATTENTION"));
-		    MSG_PUTS(_("\nFound a swap file by the name \""));
-		    msg_home_replace(fname);
-		    MSG_PUTS("\"\n");
-		    sx = swapfile_info(fname);
-		    MSG_PUTS(_("While opening file \""));
-		    msg_outtrans(buf->b_fname);
-		    MSG_PUTS("\"\n");
-		    if (mch_stat((char *)buf->b_fname, &st) != -1)
+#ifdef FEAT_AUTOCMD
+		    /*
+		     * If there is an SwapExists autocommand and we can handle
+		     * the response, trigger it.  It may return 0 to ask the
+		     * user anyway.
+		     */
+		    if (swap_exists_action != SEA_NONE
+			    && has_autocmd(EVENT_SWAPEXISTS, buf->b_fname, buf))
+			choice = do_swapexists(buf, fname);
+
+		    if (choice == 0)
+#endif
 		    {
-			MSG_PUTS(_("             dated: "));
-			x = st.st_mtime;    /* Manx C can't do &st.st_mtime */
-			MSG_PUTS(ctime(&x));
-			if (sx != 0 && x > sx)
-			    MSG_PUTS(_("      NEWER than swap file!\n"));
+#ifdef FEAT_GUI
+			/* If we are supposed to start the GUI but it wasn't
+			 * completely started yet, start it now.  This makes
+			 * the messages displayed in the Vim window when
+			 * loading a session from the .gvimrc file. */
+			if (gui.starting && !gui.in_use)
+			    gui_start();
+#endif
+			/* Show info about the existing swap file. */
+			attention_message(buf, fname);
+
+			/* We don't want a 'q' typed at the more-prompt
+			 * interrupt loading a file. */
+			got_int = FALSE;
 		    }
-		    /* Some of these messages are long to allow translation to
-		     * other languages. */
-		    MSG_PUTS(_("\n(1) Another program may be editing the same file.\n    If this is the case, be careful not to end up with two\n    different instances of the same file when making changes.\n"));
-		    MSG_PUTS(_("    Quit, or continue with caution.\n"));
-		    MSG_PUTS(_("\n(2) An edit session for this file crashed.\n"));
-		    MSG_PUTS(_("    If this is the case, use \":recover\" or \"vim -r "));
-		    msg_outtrans(buf->b_fname);
-		    MSG_PUTS(_("\"\n    to recover the changes (see \":help recovery\").\n"));
-		    MSG_PUTS(_("    If you did this already, delete the swap file \""));
-		    msg_outtrans(fname);
-		    MSG_PUTS(_("\"\n    to avoid this message.\n"));
-		    cmdline_row = msg_row;
-		    --no_wait_return;
-
-		    /* We don't want a 'q' typed at the more-prompt interrupt
-		     * loading a file. */
-		    got_int = FALSE;
 
 #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG)
-		    if (swap_exists_action)
+		    if (swap_exists_action != SEA_NONE && choice == 0)
 		    {
 			char_u	*name;
 
@@ -3875,7 +3949,7 @@ findswapname(buf, dirp, old_fname)
 								  1000, TRUE);
 			    STRCAT(name, _("\" already exists!"));
 			}
-			switch (do_dialog(VIM_WARNING,
+			choice = do_dialog(VIM_WARNING,
 				    (char_u *)_("VIM - ATTENTION"),
 				    name == NULL
 					?  (char_u *)_("Swap file already exists!")
@@ -3884,7 +3958,24 @@ findswapname(buf, dirp, old_fname)
 				    process_still_running
 					? (char_u *)_("&Open Read-Only\n&Edit anyway\n&Recover\n&Quit\n&Abort") :
 # endif
-					(char_u *)_("&Open Read-Only\n&Edit anyway\n&Recover\n&Quit\n&Abort\n&Delete it"), 1, NULL))
+					(char_u *)_("&Open Read-Only\n&Edit anyway\n&Recover\n&Delete it\n&Quit\n&Abort"), 1, NULL);
+
+# if defined(UNIX) || defined(__EMX__) || defined(VMS)
+			if (process_still_running && choice >= 4)
+			    choice++;	/* Skip missing "Delete it" button */
+# endif
+			vim_free(name);
+
+			/* pretend screen didn't scroll, need redraw anyway */
+			msg_scrolled = 0;
+			redraw_all_later(NOT_VALID);
+		    }
+#endif
+
+#if defined(HAS_SWAP_EXISTS_ACTION)
+		    if (choice > 0)
+		    {
+			switch (choice)
 			{
 			    case 1:
 				buf->b_p_ro = TRUE;
@@ -3895,21 +3986,16 @@ findswapname(buf, dirp, old_fname)
 				swap_exists_action = SEA_RECOVER;
 				break;
 			    case 4:
+				mch_remove(fname);
+				break;
+			    case 5:
 				swap_exists_action = SEA_QUIT;
 				break;
-			    case 5:
+			    case 6:
 				swap_exists_action = SEA_QUIT;
 				got_int = TRUE;
 				break;
-			    case 6:
-				mch_remove(fname);
-				break;
 			}
-			vim_free(name);
-
-			/* pretend screen didn't scroll, need redraw anyway */
-			msg_scrolled = 0;
-			redraw_all_later(NOT_VALID);
 
 			/* If the file was deleted this fname can be used. */
 			if (mch_getperm(fname) < 0)