To: vim-dev@vim.org Subject: Patch 6.0.081 Fcc: outbox From: Bram Moolenaar MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit ------------ Patch 6.0.081 Problem: After using ":saveas" the new buffer name is added to the Buffers menu with a wrong number. (Chauk-Mean Proum) Solution: Trigger BufFilePre and BufFilePost events for the renamed buffer and BufAdd for the old name (which is with a new buffer). Files: src/ex_cmds.c *** ../vim60.80/src/ex_cmds.c Mon Nov 5 21:04:40 2001 --- src/ex_cmds.c Mon Nov 5 21:16:41 2001 *************** *** 2142,2147 **** --- 2142,2158 ---- if (eap->cmdidx == CMD_saveas && alt_buf != NULL) { + #ifdef FEAT_AUTOCMD + buf_T *was_curbuf = curbuf; + + apply_autocmds(EVENT_BUFFILEPRE, NULL, NULL, FALSE, curbuf); + if (curbuf != was_curbuf) + { + /* buffer changed, don't change name now */ + retval = FAIL; + goto theend; + } + #endif /* Exchange the file names for the current and the alternate buffer. * This makes it look like we are now editing the buffer under the new * name. Must be done before buf_write(), because if there is no file *************** *** 2157,2166 **** curbuf->b_sfname = fname; buf_name_changed(); #ifdef FEAT_AUTOCMD if (!alt_buf->b_p_bl) { alt_buf->b_p_bl = TRUE; ! apply_autocmds(EVENT_BUFADD, NULL, NULL, FALSE, curbuf); } #endif } --- 2168,2184 ---- curbuf->b_sfname = fname; buf_name_changed(); #ifdef FEAT_AUTOCMD + apply_autocmds(EVENT_BUFFILEPOST, NULL, NULL, FALSE, curbuf); if (!alt_buf->b_p_bl) { alt_buf->b_p_bl = TRUE; ! apply_autocmds(EVENT_BUFADD, NULL, NULL, FALSE, alt_buf); ! } ! if (curbuf != was_curbuf) ! { ! /* buffer changed, don't write the file */ ! retval = FAIL; ! goto theend; } #endif } *** ../vim60.80/src/version.c Mon Nov 5 21:04:40 2001 --- src/version.c Mon Nov 5 21:23:51 2001 *************** *** 608,609 **** --- 608,611 ---- { /* Add new patch number below this line */ + /**/ + 81, /**/ -- hundred-and-one symptoms of being an internet addict: 5. You find yourself brainstorming for new subjects to search. /// Bram Moolenaar -- Bram@moolenaar.net -- http://www.moolenaar.net \\\ ((( Creator of Vim -- http://vim.sf.net -- ftp://ftp.vim.org/pub/vim ))) \\\ Help me helping AIDS orphans in Uganda - http://iccf-holland.org ///