4 From: Bram Moolenaar <Bram@moolenaar.net>
6 Content-Type: text/plain; charset=ISO-8859-1
7 Content-Transfer-Encoding: 8bit
11 Problem: "expand('<afile>')" returns a bogus value after changing
12 directory. (Dave Fishburn)
13 Solution: Copy "autocmd_fname" to allocated memory and expand to full
14 filename. Shorten the path when expanding <afile>.
15 Files: src/ex_docmd.c, src/fileio.c
18 *** ../vim-7.1.185/src/ex_docmd.c Wed Jan 2 15:12:29 2008
19 --- src/ex_docmd.c Wed Jan 2 20:12:33 2008
33 *errormsg = (char_u *)_("E495: no autocommand file name to substitute for \"<afile>\"");
36 + result = shorten_fname1(result);
39 case SPEC_ABUF: /* buffer number for autocommand */
40 *** ../vim-7.1.185/src/fileio.c Thu Nov 8 20:47:34 2007
41 --- src/fileio.c Wed Jan 2 20:21:43 2008
46 #if defined(FEAT_VIMINFO) || defined(FEAT_BROWSE) || \
47 ! defined(FEAT_QUICKFIX) || defined(PROTO)
49 * Try to find a shortname by comparing the fullname with the current
54 #if defined(FEAT_VIMINFO) || defined(FEAT_BROWSE) || \
55 ! defined(FEAT_QUICKFIX) || defined(FEAT_AUTOCMD) || defined(PROTO)
57 * Try to find a shortname by comparing the fullname with the current
64 * Set the file name to be used for <afile>.
65 + * Make a copy to avoid that changing a buffer name or directory makes it
75 autocmd_fname = fname_io;
76 + if (autocmd_fname != NULL)
77 + autocmd_fname = FullName_save(autocmd_fname, FALSE);
80 * Set the buffer number to be used for <abuf>.
84 vim_free(sourcing_name);
85 sourcing_name = save_sourcing_name;
86 sourcing_lnum = save_sourcing_lnum;
87 + vim_free(autocmd_fname);
88 autocmd_fname = save_autocmd_fname;
89 autocmd_bufnr = save_autocmd_bufnr;
90 autocmd_match = save_autocmd_match;
91 *** ../vim-7.1.185/src/version.c Wed Jan 2 17:48:24 2008
92 --- src/version.c Wed Jan 2 21:06:35 2008
96 { /* Add new patch number below this line */
102 LAUNCELOT leaps into SHOT with a mighty cry and runs the GUARD through and
103 hacks him to the floor. Blood. Swashbuckling music (perhaps).
104 LAUNCELOT races through into the castle screaming.
106 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
108 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
109 /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
110 \\\ download, build and distribute -- http://www.A-A-P.org ///
111 \\\ help me help AIDS victims -- http://ICCF-Holland.org ///