# HG changeset patch # User vimboss # Date 1122933752 0 # Node ID 7f2d3b3c15a2ffbd259c2ee99966124c2c2087ee # Parent d9d38102399f0a2803fe23b5294f8257eeb64689 updated for version 7.0122 diff --git a/runtime/doc/todo.txt b/runtime/doc/todo.txt --- a/runtime/doc/todo.txt +++ b/runtime/doc/todo.txt @@ -1,4 +1,4 @@ -*todo.txt* For Vim version 7.0aa. Last change: 2005 Jul 31 +*todo.txt* For Vim version 7.0aa. Last change: 2005 Aug 01 VIM REFERENCE MANUAL by Bram Moolenaar @@ -30,11 +30,6 @@ be worked on, but only if you sponsor Vi *known-bugs* -------------------- Known bugs and current work ----------------------- -Spell: For Italian we also need to postpone prefixes with a chop string. -Or handle upper/lower case specially? - -":w! /tmp/tt" gives ATTENTION message but no prompt. - Mac unicode patch (Da Woon Jung): - selecting proportional font breaks display - UTF-8 text causes display problems. Font replacement causes this. @@ -1008,6 +1003,7 @@ 8 Vim can overwrite a read-only file w ":w!!" for that. Or ask for permission to overwrite it (if file can be made writable) and restore file to readonly afterwards. + Overwriting a file for which a swap file exists is similar issue. 7 When compiled with "xterm_clipboard", startup can be slower and might get error message for invalid $DISPLAY. Try connecting to the X server in the background (forked), so that Vim starts up quicker? Connect as soon as @@ -1619,7 +1615,6 @@ 7 Pre-parse or compile Vim scripts int .vim file. Problem: distribution. 3. Use a cache directory for each user. How to recognize which cached file belongs to a sourced script? -7 Add "m" flag to search() and searchpair() function to set the '' mark. 7 Add argument to winwidth() to subtract the space taken by 'foldcolumn', signs and/or 'number'. 8 Add functions: @@ -1651,7 +1646,6 @@ 8 Add functions: virtualmode() add argument to obtain whether "$" was used in Visual block mode. getacp() Win32: get codepage (Glenn Maynard) - getbufline() get line from any buffer deletebufline() delete line in any buffer appendbufline() append line in any buffer libcall() Allow more than one argument. @@ -3207,13 +3201,6 @@ 8 Add "g^E" and "g^Y", to scroll a scr 6 Add ":timer" command, to set a command to be executed at a certain interval, or once after some time has elapsed. (Aaron) 8 Add ":confirm" handling in open_exfile(), for when file already exists. -8 Use confirm/dialog stuff to ask the user, when a file has changed outside - of Vim, if he wants to reload it. Triggered when focus gained, after - shell command, when entering another buffer, etc.. - Also do this when editing a new file, and another application creates - the file before doing ":w" in Vim. - Also check if the file protection has changed. When checking a file into - RCS it is made read-only, when checking out it is made read-write. 8 When quitting with changed files, make the dialog list the changed file and allow "write all", "discard all", "write some". The last one would then ask "write" or "discard" for each changed file. Patch in HierAssist diff --git a/runtime/doc/version7.txt b/runtime/doc/version7.txt --- a/runtime/doc/version7.txt +++ b/runtime/doc/version7.txt @@ -1,4 +1,4 @@ -*version7.txt* For Vim version 7.0aa. Last change: 2005 Jul 29 +*version7.txt* For Vim version 7.0aa. Last change: 2005 Aug 01 VIM REFERENCE MANUAL by Bram Moolenaar @@ -62,6 +62,9 @@ In a |literal-string| a single quote can ":echo 'a''b'" would result in "a b", but now that two quotes stand for one it results in "a'b". +When overwriting a file with ":w! fname" there was no warning for when "fname" +was being edited by another Vim. Vim now gives an error message |E768|. + Minor incompatibilities: diff --git a/src/ex_cmds.c b/src/ex_cmds.c --- a/src/ex_cmds.c +++ b/src/ex_cmds.c @@ -2582,34 +2582,83 @@ check_overwrite(eap, buf, fname, ffname, || ((buf->b_flags & BF_NEW) && vim_strchr(p_cpo, CPO_OVERNEW) == NULL) || (buf->b_flags & BF_READERR)) - && !eap->forceit - && !eap->append && !p_wa && vim_fexists(ffname)) { -#ifdef UNIX - /* with UNIX it is possible to open a directory */ - if (mch_isdir(ffname)) + if (!eap->forceit && !eap->append) { - EMSG2(_(e_isadir2), ffname); - return FAIL; - } +#ifdef UNIX + /* with UNIX it is possible to open a directory */ + if (mch_isdir(ffname)) + { + EMSG2(_(e_isadir2), ffname); + return FAIL; + } #endif #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG) - if (p_confirm || cmdmod.confirm) - { - char_u buff[IOSIZE]; - - dialog_msg(buff, _("Overwrite existing file \"%s\"?"), fname); - if (vim_dialog_yesno(VIM_QUESTION, NULL, buff, 2) != VIM_YES) + if (p_confirm || cmdmod.confirm) + { + char_u buff[IOSIZE]; + + dialog_msg(buff, _("Overwrite existing file \"%s\"?"), fname); + if (vim_dialog_yesno(VIM_QUESTION, NULL, buff, 2) != VIM_YES) + return FAIL; + eap->forceit = TRUE; + } + else +#endif + { + EMSG(_(e_exists)); return FAIL; - eap->forceit = TRUE; + } } - else -#endif + + /* For ":w! filename" check that no swap file exists for "filename". */ + if (other && !emsg_silent) { - EMSG(_(e_exists)); - return FAIL; + char_u dir[MAXPATHL]; + char_u *p; + int r; + char_u *swapname; + + /* We only try the first entry in 'directory', without checking if + * it's writable. If the "." directory is not writable the write + * will probably fail anyway. + * Use 'shortname' of the current buffer, since there is no buffer + * for the written file. */ + if (*p_dir == NUL) + STRCPY(dir, "."); + else + { + p = p_dir; + copy_option_part(&p, dir, MAXPATHL, ","); + } + swapname = makeswapname(fname, ffname, curbuf, dir); + r = vim_fexists(swapname); + vim_free(swapname); + if (r) + { +#if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG) + if (p_confirm || cmdmod.confirm) + { + char_u buff[IOSIZE]; + + dialog_msg(buff, + _("Swap file \"%s\" exists, overwrite anyway?"), + swapname); + if (vim_dialog_yesno(VIM_QUESTION, NULL, buff, 2) + != VIM_YES) + return FAIL; + eap->forceit = TRUE; + } + else +#endif + { + EMSG2(_("E768: Swap file exists: %s (:silent! overrides)"), + swapname); + return FAIL; + } + } } } return OK; diff --git a/src/memline.c b/src/memline.c --- a/src/memline.c +++ b/src/memline.c @@ -230,7 +230,6 @@ static bhdr_T *ml_new_data __ARGS((memfi static bhdr_T *ml_new_ptr __ARGS((memfile_T *)); static bhdr_T *ml_find_line __ARGS((buf_T *, linenr_T, int)); static int ml_add_stack __ARGS((buf_T *)); -static char_u *makeswapname __ARGS((buf_T *, char_u *)); static void ml_lineadd __ARGS((buf_T *, int)); static int b0_magic_wrong __ARGS((ZERO_BL *)); #ifdef CHECK_INODE @@ -3384,10 +3383,14 @@ ml_lineadd(buf, count) } /* - * make swap file name out of the file name and a directory name + * Make swap file name out of the file name and a directory name. + * Returns pointer to allocated memory or NULL. */ - static char_u * -makeswapname(buf, dir_name) +/*ARGSUSED*/ + char_u * +makeswapname(fname, ffname, buf, dir_name) + char_u *fname; + char_u *ffname; buf_T *buf; char_u *dir_name; { @@ -3398,7 +3401,7 @@ makeswapname(buf, dir_name) if (after_pathsep(dir_name, s) && s[-1] == s[-2]) { /* Ends with '//', Use Full path */ r = NULL; - if ((s = make_percent_swname(dir_name, buf->b_fname)) != NULL) + if ((s = make_percent_swname(dir_name, fname)) != NULL) { r = modname(s, (char_u *)".swp", FALSE); vim_free(s); @@ -3415,9 +3418,9 @@ makeswapname(buf, dir_name) #endif #ifdef RISCOS /* Avoid problems if fname has special chars, eg */ - buf->b_ffname, + ffname, #else - buf->b_fname, + fname, #endif (char_u *) #if defined(VMS) || defined(RISCOS) @@ -3495,6 +3498,7 @@ get_file_in_dir(fname, dname) * Find out what name to use for the swap file for buffer 'buf'. * * Several names are tried to find one that does not exist + * Returns the name in allocated memory or NULL. * * Note: If BASENAMELEN is not correct, you will get error messages for * not being able to open the swapfile @@ -3547,7 +3551,7 @@ findswapname(buf, dirp, old_fname) if (dir_name == NULL) /* out of memory */ fname = NULL; else - fname = makeswapname(buf, dir_name); + fname = makeswapname(buf->b_fname, buf->b_ffname, buf, dir_name); for (;;) { @@ -3649,7 +3653,8 @@ findswapname(buf, dirp, old_fname) { buf->b_shortname = TRUE; vim_free(fname); - fname = makeswapname(buf, dir_name); + fname = makeswapname(buf->b_fname, buf->b_ffname, + buf, dir_name); continue; /* try again with b_shortname set */ } } @@ -3719,7 +3724,8 @@ findswapname(buf, dirp, old_fname) { buf->b_shortname = TRUE; vim_free(fname); - fname = makeswapname(buf, dir_name); + fname = makeswapname(buf->b_fname, buf->b_ffname, + buf, dir_name); continue; /* try again with '.' replaced with '_' */ } } diff --git a/src/proto/memline.pro b/src/proto/memline.pro --- a/src/proto/memline.pro +++ b/src/proto/memline.pro @@ -24,6 +24,7 @@ int ml_delete __ARGS((linenr_T lnum, int void ml_setmarked __ARGS((linenr_T lnum)); linenr_T ml_firstmarked __ARGS((void)); void ml_clearmarked __ARGS((void)); +char_u *makeswapname __ARGS((char_u *fname, char_u *ffname, buf_T *buf, char_u *dir_name)); char_u *get_file_in_dir __ARGS((char_u *fname, char_u *dname)); void ml_setflags __ARGS((buf_T *buf)); long ml_find_line_or_offset __ARGS((buf_T *buf, linenr_T lnum, long *offp));