4 From: Bram Moolenaar <Bram@moolenaar.net>
6 Content-Type: text/plain; charset=ISO-8859-1
7 Content-Transfer-Encoding: 8bit
11 Problem: After ":file fname" and ":saveas fname" the 'autochdir' option
12 does not take effect. (Yakov Lerner)
13 Commands for handling 'autochdir' are repeated many times.
14 Solution: Add the DO_AUTOCHDIR macro and do_autochdir(). Use it for
15 ":file fname" and ":saveas fname".
16 Files: src/proto/buffer.pro, src/buffer.c, src/ex_cmds.c, src/macros.h,
17 src/option.c, src/window.c
20 *** ../vim-7.0.086/src/proto/buffer.pro Sun Apr 30 20:25:32 2006
21 --- src/proto/buffer.pro Tue Sep 5 16:25:40 2006
25 extern int do_buffer __ARGS((int action, int start, int dir, int count, int forceit));
26 extern void set_curbuf __ARGS((buf_T *buf, int action));
27 extern void enter_buffer __ARGS((buf_T *buf));
28 + extern void do_autochdir __ARGS((void));
29 extern buf_T *buflist_new __ARGS((char_u *ffname, char_u *sfname, linenr_T lnum, int flags));
30 extern void free_buf_options __ARGS((buf_T *buf, int free_p_ff));
31 extern int buflist_getfile __ARGS((int n, linenr_T lnum, int options, int forceit));
32 *** ../vim-7.0.086/src/buffer.c Tue Aug 29 16:52:01 2006
33 --- src/buffer.c Tue Sep 5 15:18:19 2006
37 netbeans_file_closed(buf);
39 ! #ifdef FEAT_AUTOCHDIR
40 ! /* Change directories when the acd option is set on. */
41 ! if (p_acd && curbuf->b_ffname != NULL
42 ! && vim_chdirfile(curbuf->b_ffname) == OK)
43 ! shorten_fnames(TRUE);
47 * Remove the buffer from the list.
50 netbeans_file_closed(buf);
52 ! /* Change directories when the 'acd' option is set. */
56 * Remove the buffer from the list.
59 netbeans_file_activated(curbuf);
62 ! #ifdef FEAT_AUTOCHDIR
63 ! /* Change directories when the acd option is set on. */
64 ! if (p_acd && curbuf->b_ffname != NULL
65 ! && vim_chdirfile(curbuf->b_ffname) == OK)
66 ! shorten_fnames(TRUE);
70 if (curbuf->b_kmap_state & KEYMAP_INIT)
72 netbeans_file_activated(curbuf);
75 ! /* Change directories when the 'acd' option is set. */
79 if (curbuf->b_kmap_state & KEYMAP_INIT)
84 redraw_later(NOT_VALID);
87 + #if defined(FEAT_AUTOCHDIR) || defined(PROTO)
89 + * Change to the directory of the current buffer.
94 + if (curbuf->b_ffname != NULL && vim_chdirfile(curbuf->b_ffname) == OK)
95 + shorten_fnames(TRUE);
100 * functions for dealing with the buffer list
101 *** ../vim-7.0.086/src/ex_cmds.c Tue Aug 29 17:28:56 2006
102 --- src/ex_cmds.c Tue Sep 5 15:24:58 2006
107 apply_autocmds(EVENT_BUFFILEPOST, NULL, NULL, FALSE, curbuf);
109 + /* Change directories when the 'acd' option is set. */
112 /* print full file name if :cd used */
113 fileinfo(FALSE, FALSE, eap->forceit);
116 eap, eap->append, eap->forceit, TRUE, FALSE);
118 /* After ":saveas fname" reset 'readonly'. */
119 ! if (eap->cmdidx == CMD_saveas && retval == OK)
120 ! curbuf->b_p_ro = FALSE;
125 eap, eap->append, eap->forceit, TRUE, FALSE);
127 /* After ":saveas fname" reset 'readonly'. */
128 ! if (eap->cmdidx == CMD_saveas)
131 ! curbuf->b_p_ro = FALSE;
132 ! /* Change directories when the 'acd' option is set. */
140 foldUpdateAll(curwin);
143 ! #ifdef FEAT_AUTOCHDIR
144 ! if (p_acd && curbuf->b_ffname != NULL
145 ! && vim_chdirfile(curbuf->b_ffname) == OK)
146 ! shorten_fnames(TRUE);
149 * Careful: open_buffer() and apply_autocmds() may change the current
152 foldUpdateAll(curwin);
155 ! /* Change directories when the 'acd' option is set. */
159 * Careful: open_buffer() and apply_autocmds() may change the current
164 need_start_insertmode = TRUE;
166 ! #ifdef FEAT_AUTOCHDIR
167 ! /* Change directories when the acd option is set on. */
168 ! if (p_acd && curbuf->b_ffname != NULL
169 ! && vim_chdirfile(curbuf->b_ffname) == OK)
170 ! shorten_fnames(TRUE);
173 #if defined(FEAT_SUN_WORKSHOP) || defined(FEAT_NETBEANS_INTG)
174 if (gui.in_use && curbuf->b_ffname != NULL)
177 need_start_insertmode = TRUE;
179 ! /* Change directories when the 'acd' option is set. */
182 #if defined(FEAT_SUN_WORKSHOP) || defined(FEAT_NETBEANS_INTG)
183 if (gui.in_use && curbuf->b_ffname != NULL)
184 *** ../vim-7.0.086/src/macros.h Wed Mar 1 23:00:25 2006
185 --- src/macros.h Tue Sep 5 15:15:30 2006
189 # define MB_CHARLEN(p) STRLEN(p)
190 # define PTR2CHAR(p) ((int)*(p))
193 + #ifdef FEAT_AUTOCHDIR
194 + # define DO_AUTOCHDIR if (p_acd) do_autochdir();
196 + # define DO_AUTOCHDIR
198 *** ../vim-7.0.086/src/option.c Tue Aug 29 17:28:56 2006
199 --- src/option.c Tue Sep 5 15:20:04 2006
202 #ifdef FEAT_AUTOCHDIR
203 else if ((int *)varp == &p_acd)
205 ! if (p_acd && curbuf->b_ffname != NULL
206 ! && vim_chdirfile(curbuf->b_ffname) == OK)
207 ! shorten_fnames(TRUE);
212 #ifdef FEAT_AUTOCHDIR
213 else if ((int *)varp == &p_acd)
215 ! /* Change directories when the 'acd' option is set now. */
220 *** ../vim-7.0.086/src/window.c Tue Aug 29 17:28:56 2006
221 --- src/window.c Tue Sep 5 15:20:35 2006
224 setmouse(); /* in case jumped to/from help buffer */
227 ! #ifdef FEAT_AUTOCHDIR
228 ! /* Change directories when the 'acd' option is set on and after
229 ! * switching windows. */
230 ! if (p_acd && curbuf->b_ffname != NULL
231 ! && vim_chdirfile(curbuf->b_ffname) == OK)
232 ! shorten_fnames(TRUE);
236 #endif /* FEAT_WINDOWS */
238 setmouse(); /* in case jumped to/from help buffer */
241 ! /* Change directories when the 'acd' option is set. */
245 #endif /* FEAT_WINDOWS */
246 *** ../vim-7.0.086/src/version.c Tue Sep 5 15:36:30 2006
247 --- src/version.c Tue Sep 5 15:52:45 2006
251 { /* Add new patch number below this line */
257 Overflow on /dev/null, please empty the bit bucket.
259 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
260 /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
261 \\\ download, build and distribute -- http://www.A-A-P.org ///
262 \\\ help me help AIDS victims -- http://ICCF-Holland.org ///