1 To: vim_dev@googlegroups.com
4 From: Bram Moolenaar <Bram@moolenaar.net>
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
11 Problem: No completion for ":lang".
12 Solution: Get locales to complete from. (Dominique Pelle)
13 Files: src/eval.c, src/ex_cmds2.c, src/ex_getln.c,
14 src/proto/ex_cmds2.pro, src/proto/ex_getln.pro, src/vim.h
17 *** ../mercurial/vim73/src/eval.c 2011-05-19 17:25:36.000000000 +0200
18 --- src/eval.c 2011-05-19 17:52:02.000000000 +0200
22 hash_clear(&compat_hashtab);
27 /* global variables */
28 vars_clear(&globvarht);
29 *** ../mercurial/vim73/src/ex_cmds2.c 2011-05-10 16:41:13.000000000 +0200
30 --- src/ex_cmds2.c 2011-05-19 18:16:54.000000000 +0200
36 ! * Ask the user what to do when abondoning a changed buffer.
37 * Must check 'write' option first!
44 ! * Ask the user what to do when abandoning a changed buffer.
45 * Must check 'write' option first!
53 # if defined(FEAT_CMDL_COMPL) || defined(PROTO)
55 + static char_u **locales = NULL; /* Array of all available locales */
56 + static int did_init_locales = FALSE;
58 + static void init_locales __ARGS((void));
59 + static char_u **find_locales __ARGS((void));
62 + * Lazy initialization of all available locales.
67 + if (!did_init_locales)
69 + did_init_locales = TRUE;
70 + locales = find_locales();
74 + /* Return an array of strings for all available locales + NULL for the
75 + * last element. Return NULL in case of error. */
79 + garray_T locales_ga;
82 + /* Find all available locales by running command "locale -a". If this
83 + * doesn't work we won't have completion. */
84 + char_u *locale_a = get_cmd_output((char_u *)"locale -a",
85 + NULL, SHELL_SILENT);
86 + if (locale_a == NULL)
88 + ga_init2(&locales_ga, sizeof(char_u *), 20);
90 + /* Transform locale_a string where each locale is separated by "\n"
91 + * into an array of locale strings. */
92 + loc = (char_u *)strtok((char *)locale_a, "\n");
96 + if (ga_grow(&locales_ga, 1) == FAIL)
98 + loc = vim_strsave(loc);
102 + ((char_u **)locales_ga.ga_data)[locales_ga.ga_len++] = loc;
103 + loc = (char_u *)strtok(NULL, "\n");
105 + vim_free(locale_a);
106 + if (ga_grow(&locales_ga, 1) == FAIL)
108 + ga_clear(&locales_ga);
111 + ((char_u **)locales_ga.ga_data)[locales_ga.ga_len] = NULL;
112 + return (char_u **)locales_ga.ga_data;
115 + # if defined(EXITFREE) || defined(PROTO)
120 + if (locales != NULL)
122 + for (i = 0; locales[i] != NULL; i++)
123 + vim_free(locales[i]);
131 * Function given to ExpandGeneric() to obtain the possible arguments of the
132 * ":language" command.
135 return (char_u *)"ctype";
137 return (char_u *)"time";
143 return (char_u *)"ctype";
145 return (char_u *)"time";
148 ! if (locales == NULL)
150 ! return locales[idx - 3];
154 ! * Function given to ExpandGeneric() to obtain the available locales.
157 ! get_locales(xp, idx)
158 ! expand_T *xp UNUSED;
162 ! if (locales == NULL)
164 ! return locales[idx];
168 *** ../mercurial/vim73/src/ex_getln.c 2011-05-19 14:50:49.000000000 +0200
169 --- src/ex_getln.c 2011-05-19 18:18:49.000000000 +0200
173 char_u *((*func)__ARGS((expand_T *, int)));
177 ! {EXPAND_COMMANDS, get_command_name, FALSE},
178 ! {EXPAND_BEHAVE, get_behave_arg, TRUE},
180 ! {EXPAND_USER_COMMANDS, get_user_commands, FALSE},
181 ! {EXPAND_USER_CMD_FLAGS, get_user_cmd_flags, FALSE},
182 ! {EXPAND_USER_NARGS, get_user_cmd_nargs, FALSE},
183 ! {EXPAND_USER_COMPLETE, get_user_cmd_complete, FALSE},
186 ! {EXPAND_USER_VARS, get_user_var_name, FALSE},
187 ! {EXPAND_FUNCTIONS, get_function_name, FALSE},
188 ! {EXPAND_USER_FUNC, get_user_func_name, FALSE},
189 ! {EXPAND_EXPRESSION, get_expr_name, FALSE},
192 ! {EXPAND_MENUS, get_menu_name, FALSE},
193 ! {EXPAND_MENUNAMES, get_menu_names, FALSE},
196 ! {EXPAND_SYNTAX, get_syntax_name, TRUE},
198 ! {EXPAND_HIGHLIGHT, get_highlight_name, TRUE},
200 ! {EXPAND_EVENTS, get_event_name, TRUE},
201 ! {EXPAND_AUGROUP, get_augroup_name, TRUE},
204 ! {EXPAND_CSCOPE, get_cscope_name, TRUE},
207 ! {EXPAND_SIGN, get_sign_name, TRUE},
210 ! {EXPAND_PROFILE, get_profile_name, TRUE},
212 #if (defined(HAVE_LOCALE_H) || defined(X_LOCALE)) \
213 && (defined(FEAT_GETTEXT) || defined(FEAT_MBYTE))
214 ! {EXPAND_LANGUAGE, get_lang_arg, TRUE},
216 ! {EXPAND_ENV_VARS, get_env_name, TRUE},
222 char_u *((*func)__ARGS((expand_T *, int)));
227 ! {EXPAND_COMMANDS, get_command_name, FALSE, TRUE},
228 ! {EXPAND_BEHAVE, get_behave_arg, TRUE, TRUE},
230 ! {EXPAND_USER_COMMANDS, get_user_commands, FALSE, TRUE},
231 ! {EXPAND_USER_CMD_FLAGS, get_user_cmd_flags, FALSE, TRUE},
232 ! {EXPAND_USER_NARGS, get_user_cmd_nargs, FALSE, TRUE},
233 ! {EXPAND_USER_COMPLETE, get_user_cmd_complete, FALSE, TRUE},
236 ! {EXPAND_USER_VARS, get_user_var_name, FALSE, TRUE},
237 ! {EXPAND_FUNCTIONS, get_function_name, FALSE, TRUE},
238 ! {EXPAND_USER_FUNC, get_user_func_name, FALSE, TRUE},
239 ! {EXPAND_EXPRESSION, get_expr_name, FALSE, TRUE},
242 ! {EXPAND_MENUS, get_menu_name, FALSE, TRUE},
243 ! {EXPAND_MENUNAMES, get_menu_names, FALSE, TRUE},
246 ! {EXPAND_SYNTAX, get_syntax_name, TRUE, TRUE},
248 ! {EXPAND_HIGHLIGHT, get_highlight_name, TRUE, TRUE},
250 ! {EXPAND_EVENTS, get_event_name, TRUE, TRUE},
251 ! {EXPAND_AUGROUP, get_augroup_name, TRUE, TRUE},
254 ! {EXPAND_CSCOPE, get_cscope_name, TRUE, TRUE},
257 ! {EXPAND_SIGN, get_sign_name, TRUE, TRUE},
260 ! {EXPAND_PROFILE, get_profile_name, TRUE, TRUE},
262 #if (defined(HAVE_LOCALE_H) || defined(X_LOCALE)) \
263 && (defined(FEAT_GETTEXT) || defined(FEAT_MBYTE))
264 ! {EXPAND_LANGUAGE, get_lang_arg, TRUE, FALSE},
265 ! {EXPAND_LOCALES, get_locales, TRUE, FALSE},
267 ! {EXPAND_ENV_VARS, get_env_name, TRUE, TRUE},
275 regmatch.rm_ic = TRUE;
276 ! ret = ExpandGeneric(xp, ®match, num_file, file, tab[i].func);
283 regmatch.rm_ic = TRUE;
284 ! ret = ExpandGeneric(xp, ®match, num_file, file,
285 ! tab[i].func, tab[i].escaped);
291 * Returns OK when no problems encountered, FAIL for error (out of memory).
294 ! ExpandGeneric(xp, regmatch, num_file, file, func)
296 regmatch_T *regmatch;
299 char_u *((*func)__ARGS((expand_T *, int)));
300 /* returns a string from the list */
305 * Returns OK when no problems encountered, FAIL for error (out of memory).
308 ! ExpandGeneric(xp, regmatch, num_file, file, func, escaped)
310 regmatch_T *regmatch;
313 char_u *((*func)__ARGS((expand_T *, int)));
314 /* returns a string from the list */
324 ! str = vim_strsave_escaped(str, (char_u *)" \t\\.");
325 (*file)[count] = str;
327 if (func == get_menu_names && str != NULL)
333 ! str = vim_strsave_escaped(str, (char_u *)" \t\\.");
335 ! str = vim_strsave(str);
336 (*file)[count] = str;
338 if (func == get_menu_names && str != NULL)
339 *** ../mercurial/vim73/src/proto/ex_cmds2.pro 2010-05-15 21:22:11.000000000 +0200
340 --- src/proto/ex_cmds2.pro 2011-05-19 17:53:52.000000000 +0200
344 char_u *get_mess_lang __ARGS((void));
345 void set_lang_var __ARGS((void));
346 void ex_language __ARGS((exarg_T *eap));
347 + void free_locales __ARGS((void));
348 char_u *get_lang_arg __ARGS((expand_T *xp, int idx));
349 + char_u *get_locales __ARGS((expand_T *xp, int idx));
350 /* vim: set ft=c : */
351 *** ../mercurial/vim73/src/proto/ex_getln.pro 2010-08-16 21:23:30.000000000 +0200
352 --- src/proto/ex_getln.pro 2011-05-19 17:54:00.000000000 +0200
355 char_u *addstar __ARGS((char_u *fname, int len, int context));
356 void set_cmd_context __ARGS((expand_T *xp, char_u *str, int len, int col));
357 int expand_cmdline __ARGS((expand_T *xp, char_u *str, int col, int *matchcount, char_u ***matches));
358 ! int ExpandGeneric __ARGS((expand_T *xp, regmatch_T *regmatch, int *num_file, char_u ***file, char_u *((*func)(expand_T *, int))));
359 char_u *globpath __ARGS((char_u *path, char_u *file, int expand_options));
360 void init_history __ARGS((void));
361 int get_histtype __ARGS((char_u *name));
363 char_u *addstar __ARGS((char_u *fname, int len, int context));
364 void set_cmd_context __ARGS((expand_T *xp, char_u *str, int len, int col));
365 int expand_cmdline __ARGS((expand_T *xp, char_u *str, int col, int *matchcount, char_u ***matches));
366 ! int ExpandGeneric __ARGS((expand_T *xp, regmatch_T *regmatch, int *num_file, char_u ***file, char_u *((*func)(expand_T *, int)), int escaped));
367 char_u *globpath __ARGS((char_u *path, char_u *file, int expand_options));
368 void init_history __ARGS((void));
369 int get_histtype __ARGS((char_u *name));
370 *** ../mercurial/vim73/src/vim.h 2011-05-19 17:25:36.000000000 +0200
371 --- src/vim.h 2011-05-19 17:52:02.000000000 +0200
375 #define EXPAND_FILETYPE 37
376 #define EXPAND_FILES_IN_PATH 38
377 #define EXPAND_OWNSYNTAX 39
378 + #define EXPAND_LOCALES 40
380 /* Values for exmode_active (0 is no exmode) */
381 #define EXMODE_NORMAL 1
382 *** ../vim-7.3.197/src/version.c 2011-05-19 17:42:54.000000000 +0200
383 --- src/version.c 2011-05-19 18:24:58.000000000 +0200
387 { /* Add new patch number below this line */
393 The primary purpose of the DATA statement is to give names to constants;
394 instead of referring to pi as 3.141592653589793 at every appearance, the
395 variable PI can be given that value with a DATA statement and used instead
396 of the longer form of the constant. This also simplifies modifying the
397 program, should the value of pi change.
398 -- FORTRAN manual for Xerox Computers
400 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
401 /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
402 \\\ an exciting new programming language -- http://www.Zimbu.org ///
403 \\\ help me help AIDS victims -- http://ICCF-Holland.org ///