]> git.ipfire.org Git - people/ms/ipfire-3.x.git/blob - vim/patches/vim-7.3.311.patch0
libpng: Update to 1.6.10.
[people/ms/ipfire-3.x.git] / vim / patches / vim-7.3.311.patch0
1 To: vim_dev@googlegroups.com
2 Subject: Patch 7.3.311
3 Fcc: outbox
4 From: Bram Moolenaar <Bram@moolenaar.net>
5 Mime-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8 ------------
9
10 Patch 7.3.311 (replaces 7.3.289)
11 Problem: Complete function isn't called when the leader changed.
12 Solution: Allow the complete function to return a dictionary with a flag
13 that indicates ins_compl_restart() is to be called when the leader
14 changes. (Taro Muraoka)
15 Files: runtime/insert.txt, src/edit.c, src/eval.c, src/proto/eval.pro
16
17
18 *** ../vim-7.3.310/src/edit.c 2011-09-05 20:13:37.000000000 +0200
19 --- src/edit.c 2011-09-14 16:43:14.000000000 +0200
20 ***************
21 *** 135,140 ****
22 --- 135,142 ----
23 static int compl_cont_mode = 0;
24 static expand_T compl_xp;
25
26 + static int compl_opt_refresh_always = FALSE;
27 +
28 static void ins_ctrl_x __ARGS((void));
29 static int has_compl_option __ARGS((int dict_opt));
30 static int ins_compl_accept_char __ARGS((int c));
31 ***************
32 *** 153,161 ****
33 static void ins_compl_free __ARGS((void));
34 static void ins_compl_clear __ARGS((void));
35 static int ins_compl_bs __ARGS((void));
36 static void ins_compl_new_leader __ARGS((void));
37 static void ins_compl_addleader __ARGS((int c));
38 ! static int ins_compl_len __ARGS((void));
39 static void ins_compl_restart __ARGS((void));
40 static void ins_compl_set_original_text __ARGS((char_u *str));
41 static void ins_compl_addfrommatch __ARGS((void));
42 --- 155,164 ----
43 static void ins_compl_free __ARGS((void));
44 static void ins_compl_clear __ARGS((void));
45 static int ins_compl_bs __ARGS((void));
46 + static int ins_compl_need_restart __ARGS((void));
47 static void ins_compl_new_leader __ARGS((void));
48 static void ins_compl_addleader __ARGS((int c));
49 ! static int ins_compl_len __ARGS((void));
50 static void ins_compl_restart __ARGS((void));
51 static void ins_compl_set_original_text __ARGS((char_u *str));
52 static void ins_compl_addfrommatch __ARGS((void));
53 ***************
54 *** 163,168 ****
55 --- 166,172 ----
56 static buf_T *ins_compl_next_buf __ARGS((buf_T *buf, int flag));
57 #if defined(FEAT_COMPL_FUNC) || defined(FEAT_EVAL)
58 static void ins_compl_add_list __ARGS((list_T *list));
59 + static void ins_compl_add_dict __ARGS((dict_T *dict));
60 #endif
61 static int ins_compl_get_exp __ARGS((pos_T *ini));
62 static void ins_compl_delete __ARGS((void));
63 ***************
64 *** 3341,3347 ****
65 /* Deleted more than what was used to find matches or didn't finish
66 * finding all matches: need to look for matches all over again. */
67 if (curwin->w_cursor.col <= compl_col + compl_length
68 ! || compl_was_interrupted)
69 ins_compl_restart();
70
71 vim_free(compl_leader);
72 --- 3345,3351 ----
73 /* Deleted more than what was used to find matches or didn't finish
74 * finding all matches: need to look for matches all over again. */
75 if (curwin->w_cursor.col <= compl_col + compl_length
76 ! || ins_compl_need_restart())
77 ins_compl_restart();
78
79 vim_free(compl_leader);
80 ***************
81 *** 3355,3360 ****
82 --- 3359,3378 ----
83 }
84
85 /*
86 + * Return TRUE when we need to find matches again, ins_compl_restart() is to
87 + * be called.
88 + */
89 + static int
90 + ins_compl_need_restart()
91 + {
92 + /* Return TRUE if we didn't complete finding matches or when the
93 + * 'completefunc' returned "always" in the "refresh" dictionary item. */
94 + return compl_was_interrupted
95 + || ((ctrl_x_mode == CTRL_X_FUNCTION || ctrl_x_mode == CTRL_X_OMNI)
96 + && compl_opt_refresh_always);
97 + }
98 +
99 + /*
100 * Called after changing "compl_leader".
101 * Show the popup menu with a different set of matches.
102 * May also search for matches again if the previous search was interrupted.
103 ***************
104 *** 3443,3449 ****
105 ins_char(c);
106
107 /* If we didn't complete finding matches we must search again. */
108 ! if (compl_was_interrupted)
109 ins_compl_restart();
110
111 vim_free(compl_leader);
112 --- 3461,3467 ----
113 ins_char(c);
114
115 /* If we didn't complete finding matches we must search again. */
116 ! if (ins_compl_need_restart())
117 ins_compl_restart();
118
119 vim_free(compl_leader);
120 ***************
121 *** 3871,3882 ****
122 int type; /* CTRL_X_OMNI or CTRL_X_FUNCTION */
123 char_u *base;
124 {
125 ! list_T *matchlist;
126 char_u *args[2];
127 char_u *funcname;
128 pos_T pos;
129 win_T *curwin_save;
130 buf_T *curbuf_save;
131
132 funcname = (type == CTRL_X_FUNCTION) ? curbuf->b_p_cfu : curbuf->b_p_ofu;
133 if (*funcname == NUL)
134 --- 3889,3902 ----
135 int type; /* CTRL_X_OMNI or CTRL_X_FUNCTION */
136 char_u *base;
137 {
138 ! list_T *matchlist = NULL;
139 ! dict_T *matchdict = NULL;
140 char_u *args[2];
141 char_u *funcname;
142 pos_T pos;
143 win_T *curwin_save;
144 buf_T *curbuf_save;
145 + typval_T rettv;
146
147 funcname = (type == CTRL_X_FUNCTION) ? curbuf->b_p_cfu : curbuf->b_p_ofu;
148 if (*funcname == NUL)
149 ***************
150 *** 3889,3895 ****
151 pos = curwin->w_cursor;
152 curwin_save = curwin;
153 curbuf_save = curbuf;
154 ! matchlist = call_func_retlist(funcname, 2, args, FALSE);
155 if (curwin_save != curwin || curbuf_save != curbuf)
156 {
157 EMSG(_(e_complwin));
158 --- 3909,3933 ----
159 pos = curwin->w_cursor;
160 curwin_save = curwin;
161 curbuf_save = curbuf;
162 !
163 ! /* Call a function, which returns a list or dict. */
164 ! if (call_vim_function(funcname, 2, args, FALSE, &rettv) == OK)
165 ! {
166 ! switch (rettv.v_type)
167 ! {
168 ! case VAR_LIST:
169 ! matchlist = rettv.vval.v_list;
170 ! break;
171 ! case VAR_DICT:
172 ! matchdict = rettv.vval.v_dict;
173 ! break;
174 ! default:
175 ! /* TODO: Give error message? */
176 ! clear_tv(&rettv);
177 ! break;
178 ! }
179 ! }
180 !
181 if (curwin_save != curwin || curbuf_save != curbuf)
182 {
183 EMSG(_(e_complwin));
184 ***************
185 *** 3902,3911 ****
186 --- 3940,3954 ----
187 EMSG(_(e_compldel));
188 goto theend;
189 }
190 +
191 if (matchlist != NULL)
192 ins_compl_add_list(matchlist);
193 + else if (matchdict != NULL)
194 + ins_compl_add_dict(matchdict);
195
196 theend:
197 + if (matchdict != NULL)
198 + dict_unref(matchdict);
199 if (matchlist != NULL)
200 list_unref(matchlist);
201 }
202 ***************
203 *** 3934,3939 ****
204 --- 3977,4009 ----
205 }
206
207 /*
208 + * Add completions from a dict.
209 + */
210 + static void
211 + ins_compl_add_dict(dict)
212 + dict_T *dict;
213 + {
214 + dictitem_T *refresh;
215 + dictitem_T *words;
216 +
217 + /* Check for optional "refresh" item. */
218 + compl_opt_refresh_always = FALSE;
219 + refresh = dict_find(dict, (char_u *)"refresh", 7);
220 + if (refresh != NULL && refresh->di_tv.v_type == VAR_STRING)
221 + {
222 + char_u *v = refresh->di_tv.vval.v_string;
223 +
224 + if (v != NULL && STRCMP(v, (char_u *)"always") == 0)
225 + compl_opt_refresh_always = TRUE;
226 + }
227 +
228 + /* Add completions from a "words" list. */
229 + words = dict_find(dict, (char_u *)"words", 5);
230 + if (words != NULL && words->di_tv.v_type == VAR_LIST)
231 + ins_compl_add_list(words->di_tv.vval.v_list);
232 + }
233 +
234 + /*
235 * Add a match to the list of matches from a typeval_T.
236 * If the given string is already in the list of completions, then return
237 * NOTDONE, otherwise add it to the list and return OK. If there is an error,
238 ***************
239 *** 5088,5093 ****
240 --- 5158,5169 ----
241 return FAIL;
242 }
243
244 + /*
245 + * Reset extended parameters of completion, when start new
246 + * completion.
247 + */
248 + compl_opt_refresh_always = FALSE;
249 +
250 if (col < 0)
251 col = curs_col;
252 compl_col = col;
253 *** ../vim-7.3.310/src/eval.c 2011-09-14 14:33:47.000000000 +0200
254 --- src/eval.c 2011-09-14 16:16:47.000000000 +0200
255 ***************
256 *** 380,388 ****
257
258 static void prepare_vimvar __ARGS((int idx, typval_T *save_tv));
259 static void restore_vimvar __ARGS((int idx, typval_T *save_tv));
260 - #if defined(FEAT_USR_CMDS) && defined(FEAT_CMDL_COMPL)
261 - static int call_vim_function __ARGS((char_u *func, int argc, char_u **argv, int safe, typval_T *rettv));
262 - #endif
263 static int ex_let_vars __ARGS((char_u *arg, typval_T *tv, int copy, int semicolon, int var_count, char_u *nextchars));
264 static char_u *skip_var_list __ARGS((char_u *arg, int *var_count, int *semicolon));
265 static char_u *skip_var_one __ARGS((char_u *arg));
266 --- 380,385 ----
267 ***************
268 *** 451,457 ****
269 static void set_ref_in_list __ARGS((list_T *l, int copyID));
270 static void set_ref_in_item __ARGS((typval_T *tv, int copyID));
271 static int rettv_dict_alloc __ARGS((typval_T *rettv));
272 - static void dict_unref __ARGS((dict_T *d));
273 static void dict_free __ARGS((dict_T *d, int recurse));
274 static dictitem_T *dictitem_copy __ARGS((dictitem_T *org));
275 static void dictitem_remove __ARGS((dict_T *dict, dictitem_T *item));
276 --- 448,453 ----
277 ***************
278 *** 1563,1569 ****
279 * arguments are currently supported.
280 * Returns OK or FAIL.
281 */
282 ! static int
283 call_vim_function(func, argc, argv, safe, rettv)
284 char_u *func;
285 int argc;
286 --- 1559,1565 ----
287 * arguments are currently supported.
288 * Returns OK or FAIL.
289 */
290 ! int
291 call_vim_function(func, argc, argv, safe, rettv)
292 char_u *func;
293 int argc;
294 ***************
295 *** 6903,6909 ****
296 * Unreference a Dictionary: decrement the reference count and free it when it
297 * becomes zero.
298 */
299 ! static void
300 dict_unref(d)
301 dict_T *d;
302 {
303 --- 6899,6905 ----
304 * Unreference a Dictionary: decrement the reference count and free it when it
305 * becomes zero.
306 */
307 ! void
308 dict_unref(d)
309 dict_T *d;
310 {
311 *** ../vim-7.3.310/src/proto/eval.pro 2010-08-15 21:57:28.000000000 +0200
312 --- src/proto/eval.pro 2011-09-14 16:16:47.000000000 +0200
313 ***************
314 *** 23,28 ****
315 --- 23,29 ----
316 list_T *eval_spell_expr __ARGS((char_u *badword, char_u *expr));
317 int get_spellword __ARGS((list_T *list, char_u **pp));
318 typval_T *eval_expr __ARGS((char_u *arg, char_u **nextcmd));
319 + int call_vim_function __ARGS((char_u *func, int argc, char_u **argv, int safe, typval_T *rettv));
320 void *call_func_retstr __ARGS((char_u *func, int argc, char_u **argv, int safe));
321 long call_func_retnr __ARGS((char_u *func, int argc, char_u **argv, int safe));
322 void *call_func_retlist __ARGS((char_u *func, int argc, char_u **argv, int safe));
323 ***************
324 *** 52,57 ****
325 --- 53,59 ----
326 int list_append_string __ARGS((list_T *l, char_u *str, int len));
327 int garbage_collect __ARGS((void));
328 dict_T *dict_alloc __ARGS((void));
329 + void dict_unref __ARGS((dict_T *d));
330 dictitem_T *dictitem_alloc __ARGS((char_u *key));
331 void dictitem_free __ARGS((dictitem_T *item));
332 int dict_add __ARGS((dict_T *d, dictitem_T *item));
333 *** ../vim-7.3.310/src/version.c 2011-09-14 16:04:52.000000000 +0200
334 --- src/version.c 2011-09-14 16:25:08.000000000 +0200
335 ***************
336 *** 711,712 ****
337 --- 711,714 ----
338 { /* Add new patch number below this line */
339 + /**/
340 + 311,
341 /**/
342
343 --
344 Contrary to popular belief, it's often your clothing that gets promoted, not
345 you.
346 (Scott Adams - The Dilbert principle)
347
348 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
349 /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
350 \\\ an exciting new programming language -- http://www.Zimbu.org ///
351 \\\ help me help AIDS victims -- http://ICCF-Holland.org ///