]>
Commit | Line | Data |
---|---|---|
9b1d76b7 AG |
1 | To: vim-dev@vim.org |
2 | Subject: patch 7.0.214 | |
3 | Fcc: outbox | |
4 | From: Bram Moolenaar <Bram@moolenaar.net> | |
5 | Mime-Version: 1.0 | |
6 | Content-Type: text/plain; charset=ISO-8859-1 | |
7 | Content-Transfer-Encoding: 8bit | |
8 | ------------ | |
9 | ||
10 | Patch 7.0.214 | |
11 | Problem: When using <f-args> in a user command it's not possible to have an | |
12 | argument end in '\ '. | |
13 | Solution: Change the handling of backslashes. (Yakov Lerner) | |
14 | Files: runtime/doc/map.txt, src/ex_docmd.c | |
15 | ||
16 | ||
17 | *** ../vim-7.0.213/runtime/doc/map.txt Sun May 7 16:57:11 2006 | |
18 | --- runtime/doc/map.txt Thu Mar 8 18:00:26 2007 | |
19 | *************** | |
20 | *** 1,4 **** | |
21 | ! *map.txt* For Vim version 7.0. Last change: 2006 May 03 | |
22 | ||
23 | ||
24 | VIM REFERENCE MANUAL by Bram Moolenaar | |
25 | --- 1,4 ---- | |
26 | ! *map.txt* For Vim version 7.0. Last change: 2007 Mar 08 | |
27 | ||
28 | ||
29 | VIM REFERENCE MANUAL by Bram Moolenaar | |
30 | *************** | |
31 | *** 1303,1314 **** | |
32 | <q-args>) then the value is quoted in such a way as to make it a valid value | |
33 | for use in an expression. This uses the argument as one single value. | |
34 | When there is no argument <q-args> is an empty string. | |
35 | ! | |
36 | To allow commands to pass their arguments on to a user-defined function, there | |
37 | is a special form <f-args> ("function args"). This splits the command | |
38 | arguments at spaces and Tabs, quotes each argument individually, and the | |
39 | <f-args> sequence is replaced by the comma-separated list of quoted arguments. | |
40 | See the Mycmd example below. If no arguments are given <f-args> is removed. | |
41 | ||
42 | Examples > | |
43 | ||
44 | --- 1319,1346 ---- | |
45 | <q-args>) then the value is quoted in such a way as to make it a valid value | |
46 | for use in an expression. This uses the argument as one single value. | |
47 | When there is no argument <q-args> is an empty string. | |
48 | ! *<f-args>* | |
49 | To allow commands to pass their arguments on to a user-defined function, there | |
50 | is a special form <f-args> ("function args"). This splits the command | |
51 | arguments at spaces and Tabs, quotes each argument individually, and the | |
52 | <f-args> sequence is replaced by the comma-separated list of quoted arguments. | |
53 | See the Mycmd example below. If no arguments are given <f-args> is removed. | |
54 | + To embed whitespace into an argument of <f-args>, prepend a backslash. | |
55 | + <f-args> replaces every pair of backslashes (\\) with one backslash. A | |
56 | + backslash followed by a character other than white space or a backslash | |
57 | + remains unmodified. Overview: | |
58 | + | |
59 | + command <f-args> ~ | |
60 | + XX ab 'ab' | |
61 | + XX a\b 'a\b' | |
62 | + XX a\ b 'a b' | |
63 | + XX a\ b 'a ', 'b' | |
64 | + XX a\\b 'a\b' | |
65 | + XX a\\ b 'a\', 'b' | |
66 | + XX a\\\b 'a\\b' | |
67 | + XX a\\\ b 'a\ b' | |
68 | + XX a\\\\b 'a\\b' | |
69 | + XX a\\\\ b 'a\\', 'b' | |
70 | ||
71 | Examples > | |
72 | ||
73 | *** ../vim-7.0.213/src/ex_docmd.c Tue Nov 28 21:41:19 2006 | |
74 | --- src/ex_docmd.c Thu Mar 8 17:49:11 2007 | |
75 | *************** | |
76 | *** 5551,5556 **** | |
77 | --- 5551,5559 ---- | |
78 | mch_memmove(cmd, cmd + 1, (gap->ga_len - i) * sizeof(ucmd_T)); | |
79 | } | |
80 | ||
81 | + /* | |
82 | + * split and quote args for <f-args> | |
83 | + */ | |
84 | static char_u * | |
85 | uc_split_args(arg, lenp) | |
86 | char_u *arg; | |
87 | *************** | |
88 | *** 5567,5573 **** | |
89 | ||
90 | while (*p) | |
91 | { | |
92 | ! if (p[0] == '\\' && vim_iswhite(p[1])) | |
93 | { | |
94 | len += 1; | |
95 | p += 2; | |
96 | --- 5570,5581 ---- | |
97 | ||
98 | while (*p) | |
99 | { | |
100 | ! if (p[0] == '\\' && p[1] == '\\') | |
101 | ! { | |
102 | ! len += 2; | |
103 | ! p += 2; | |
104 | ! } | |
105 | ! else if (p[0] == '\\' && vim_iswhite(p[1])) | |
106 | { | |
107 | len += 1; | |
108 | p += 2; | |
109 | *************** | |
110 | *** 5603,5609 **** | |
111 | *q++ = '"'; | |
112 | while (*p) | |
113 | { | |
114 | ! if (p[0] == '\\' && vim_iswhite(p[1])) | |
115 | { | |
116 | *q++ = p[1]; | |
117 | p += 2; | |
118 | --- 5611,5623 ---- | |
119 | *q++ = '"'; | |
120 | while (*p) | |
121 | { | |
122 | ! if (p[0] == '\\' && p[1] == '\\') | |
123 | ! { | |
124 | ! *q++ = '\\'; | |
125 | ! *q++ = '\\'; | |
126 | ! p += 2; | |
127 | ! } | |
128 | ! else if (p[0] == '\\' && vim_iswhite(p[1])) | |
129 | { | |
130 | *q++ = p[1]; | |
131 | p += 2; | |
132 | *************** | |
133 | *** 5735,5741 **** | |
134 | } | |
135 | ||
136 | break; | |
137 | ! case 2: /* Quote and split */ | |
138 | /* This is hard, so only do it once, and cache the result */ | |
139 | if (*split_buf == NULL) | |
140 | *split_buf = uc_split_args(eap->arg, split_len); | |
141 | --- 5749,5755 ---- | |
142 | } | |
143 | ||
144 | break; | |
145 | ! case 2: /* Quote and split (<f-args>) */ | |
146 | /* This is hard, so only do it once, and cache the result */ | |
147 | if (*split_buf == NULL) | |
148 | *split_buf = uc_split_args(eap->arg, split_len); | |
149 | *** ../vim-7.0.213/src/version.c Thu Mar 8 14:54:52 2007 | |
150 | --- src/version.c Thu Mar 8 18:11:47 2007 | |
151 | *************** | |
152 | *** 668,669 **** | |
153 | --- 668,671 ---- | |
154 | { /* Add new patch number below this line */ | |
155 | + /**/ | |
156 | + 214, | |
157 | /**/ | |
158 | ||
159 | -- | |
160 | Microsoft's definition of a boolean: TRUE, FALSE, MAYBE | |
161 | "Embrace and extend"...? | |
162 | ||
163 | /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ | |
164 | /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ | |
165 | \\\ download, build and distribute -- http://www.A-A-P.org /// | |
166 | \\\ help me help AIDS victims -- http://ICCF-Holland.org /// |