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 using ":qa" and there is a changed buffer picking the buffer
12 to jump to is not very good.
13 Solution: Consider current and other tab pages. (Hirohito Higashi)
17 *** ../vim-7.3.479/src/ex_cmds2.c 2012-02-22 18:29:29.000000000 +0100
18 --- src/ex_cmds2.c 2012-03-23 17:01:31.000000000 +0100
25 + static void add_bufnum __ARGS((int *bufnrs, int *bufnump, int nr));
28 + * Add a buffer number to "bufnrs", unless it's already there.
31 + add_bufnum(bufnrs, bufnump, nr)
38 + for (i = 0; i < *bufnump; ++i)
39 + if (bufnrs[i] == nr)
41 + bufnrs[*bufnump] = nr;
42 + *bufnump = *bufnump + 1;
46 * Return TRUE if any buffer was changed and cannot be abandoned.
47 * That changed buffer becomes the current buffer.
50 check_changed_any(hidden)
51 int hidden; /* Only check hidden buffers */
61 ! /* check curbuf first: if it was changed we can't abandon it */
62 ! if (!hidden && curbufIsChanged())
66 ! for (buf = firstbuf; buf != NULL; buf = buf->b_next)
67 ! if ((!hidden || buf->b_nwindows == 0) && bufIsChanged(buf))
70 - if (buf == NULL) /* No buffers changed */
73 - /* Try auto-writing the buffer. If this fails but the buffer no
74 - * longer exists it's not changed, that's OK. */
75 - if (check_changed(buf, p_awa, TRUE, FALSE, TRUE) && buf_valid(buf))
76 - break; /* didn't save - still changes */
80 #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG)
83 check_changed_any(hidden)
84 int hidden; /* Only check hidden buffers */
98 ! for (buf = firstbuf; buf != NULL; buf = buf->b_next)
104 ! bufnrs = (int *)alloc(sizeof(int) * bufcount);
105 ! if (bufnrs == NULL)
109 ! bufnrs[bufnum++] = curbuf->b_fnum;
110 ! #ifdef FEAT_WINDOWS
111 ! /* buf in curtab */
112 ! FOR_ALL_WINDOWS(wp)
113 ! if (wp->w_buffer != curbuf)
114 ! add_bufnum(bufnrs, &bufnum, wp->w_buffer->b_fnum);
116 ! /* buf in other tab */
117 ! for (tp = first_tabpage; tp != NULL; tp = tp->tp_next)
119 ! for (wp = tp->tp_firstwin; wp != NULL; wp = wp->w_next)
120 ! add_bufnum(bufnrs, &bufnum, wp->w_buffer->b_fnum);
122 ! /* any other buf */
123 ! for (buf = firstbuf; buf != NULL; buf = buf->b_next)
124 ! add_bufnum(bufnrs, &bufnum, buf->b_fnum);
126 ! for (i = 0; i < bufnum; ++i)
128 ! buf = buflist_findnr(bufnrs[i]);
131 ! if ((!hidden || buf->b_nwindows == 0) && bufIsChanged(buf))
133 ! /* Try auto-writing the buffer. If this fails but the buffer no
134 ! * longer exists it's not changed, that's OK. */
135 ! if (check_changed(buf, p_awa, TRUE, FALSE, TRUE) && buf_valid(buf))
136 ! break; /* didn't save - still changes */
145 #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG)
150 /* Try to find a window that contains the buffer. */
152 ! for (wp = firstwin; wp != NULL; wp = wp->w_next)
153 if (wp->w_buffer == buf)
157 /* Paranoia: did autocms wipe out the buffer with changes? */
165 /* Open the changed buffer in the current window. */
167 set_curbuf(buf, DOBUF_GOTO);
175 /* Try to find a window that contains the buffer. */
177 ! FOR_ALL_TAB_WINDOWS(tp, wp)
178 if (wp->w_buffer == buf)
180 ! goto_tabpage_win(tp, wp);
182 /* Paranoia: did autocms wipe out the buffer with changes? */
193 /* Open the changed buffer in the current window. */
195 set_curbuf(buf, DOBUF_GOTO);
205 home_replace(NULL, SCRIPT_ITEM(i).sn_name,
206 NameBuff, MAXPATHL, TRUE);
207 smsg((char_u *)"%3d: %s", i, NameBuff);
211 # if defined(BACKSLASH_IN_FILENAME) || defined(PROTO)
213 home_replace(NULL, SCRIPT_ITEM(i).sn_name,
214 NameBuff, MAXPATHL, TRUE);
215 smsg((char_u *)"%3d: %s", i, NameBuff);
219 # if defined(BACKSLASH_IN_FILENAME) || defined(PROTO)
220 *** ../vim-7.3.479/src/version.c 2012-03-23 16:25:13.000000000 +0100
221 --- src/version.c 2012-03-23 16:48:06.000000000 +0100
225 { /* Add new patch number below this line */
231 hundred-and-one symptoms of being an internet addict:
232 243. You unsuccessfully try to download a pizza from www.dominos.com.
234 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
235 /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
236 \\\ an exciting new programming language -- http://www.Zimbu.org ///
237 \\\ help me help AIDS victims -- http://ICCF-Holland.org ///