1 To: vim_dev@googlegroups.com
4 From: Bram Moolenaar <Bram@moolenaar.net>
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
11 Problem: When exiting with unsaved changes, selecting an existing file in
12 the file dialog, there is no dialog to ask whether the existing
13 file should be overwritten. (Felipe G. Nievinski)
14 Solution: Call check_overwrite() before writing. (Christian Brabandt)
15 Files: src/ex_cmds.c, src/ex_cmds2.c, src/proto/ex_cmds.pro
18 *** ../vim-7.3.506/src/ex_cmds.c 2012-04-25 16:50:44.000000000 +0200
19 --- src/ex_cmds.c 2012-04-25 17:19:53.000000000 +0200
22 static int read_viminfo_up_to_marks __ARGS((vir_T *virp, int forceit, int writing));
25 - static int check_overwrite __ARGS((exarg_T *eap, buf_T *buf, char_u *fname, char_u *ffname, int other));
26 static int check_readonly __ARGS((int *forceit, buf_T *buf));
28 static void delbuf_msg __ARGS((char_u *name));
32 * May set eap->forceit if a dialog says it's OK to overwrite.
33 * Return OK if it's OK, FAIL if it is not.
36 check_overwrite(eap, buf, fname, ffname, other)
40 * May set eap->forceit if a dialog says it's OK to overwrite.
41 * Return OK if it's OK, FAIL if it is not.
44 check_overwrite(eap, buf, fname, ffname, other)
47 *** ../vim-7.3.506/src/ex_cmds2.c 2012-03-23 18:39:10.000000000 +0100
48 --- src/ex_cmds2.c 2012-04-25 17:24:37.000000000 +0200
52 char_u buff[DIALOG_MSG_SIZE];
57 dialog_msg(buff, _("Save changes to \"%s\"?"),
58 (buf->b_fname != NULL) ?
62 ret = vim_dialog_yesnocancel(VIM_QUESTION, NULL, buff, 1);
67 /* May get file name, when there is none */
68 browse_save_fname(buf);
70 ! if (buf->b_fname != NULL) /* didn't hit Cancel */
71 (void)buf_write_all(buf, FALSE);
73 else if (ret == VIM_NO)
76 ret = vim_dialog_yesnocancel(VIM_QUESTION, NULL, buff, 1);
78 + /* Init ea pseudo-structure, this is needed for the check_overwrite()
80 + ea.append = ea.forceit = FALSE;
85 /* May get file name, when there is none */
86 browse_save_fname(buf);
88 ! if (buf->b_fname != NULL && check_overwrite(&ea, buf,
89 ! buf->b_fname, buf->b_ffname, FALSE) == OK)
90 ! /* didn't hit Cancel */
91 (void)buf_write_all(buf, FALSE);
93 else if (ret == VIM_NO)
96 /* May get file name, when there is none */
97 browse_save_fname(buf2);
99 ! if (buf2->b_fname != NULL) /* didn't hit Cancel */
100 (void)buf_write_all(buf2, FALSE);
102 /* an autocommand may have deleted the buffer */
104 /* May get file name, when there is none */
105 browse_save_fname(buf2);
107 ! if (buf2->b_fname != NULL && check_overwrite(&ea, buf2,
108 ! buf2->b_fname, buf2->b_ffname, FALSE) == OK)
109 ! /* didn't hit Cancel */
110 (void)buf_write_all(buf2, FALSE);
112 /* an autocommand may have deleted the buffer */
113 *** ../vim-7.3.506/src/proto/ex_cmds.pro 2010-08-15 21:57:28.000000000 +0200
114 --- src/proto/ex_cmds.pro 2012-04-25 17:25:47.000000000 +0200
118 void ex_update __ARGS((exarg_T *eap));
119 void ex_write __ARGS((exarg_T *eap));
120 int do_write __ARGS((exarg_T *eap));
121 + int check_overwrite __ARGS((exarg_T *eap, buf_T *buf, char_u *fname, char_u *ffname, int other));
122 void ex_wnext __ARGS((exarg_T *eap));
123 void do_wqall __ARGS((exarg_T *eap));
124 int not_writing __ARGS((void));
125 *** ../vim-7.3.506/src/version.c 2012-04-25 17:10:12.000000000 +0200
126 --- src/version.c 2012-04-25 17:17:30.000000000 +0200
130 { /* Add new patch number below this line */
136 BROTHER MAYNARD: Armaments Chapter Two Verses Nine to Twenty One.
137 ANOTHER MONK: And St. Attila raised his hand grenade up on high saying "O
138 Lord bless this thy hand grenade that with it thou mayest
139 blow thine enemies to tiny bits, in thy mercy. "and the Lord
140 did grin and people did feast upon the lambs and sloths and
141 carp and anchovies and orang-utans and breakfast cereals and
143 BROTHER MAYNARD: Skip a bit brother ...
144 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
146 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
147 /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
148 \\\ an exciting new programming language -- http://www.Zimbu.org ///
149 \\\ help me help AIDS victims -- http://ICCF-Holland.org ///