4 From: Bram Moolenaar <Bram@moolenaar.net>
6 Content-Type: text/plain; charset=ISO-8859-1
7 Content-Transfer-Encoding: 8bit
11 Problem: No completion for ":sign" command.
12 Solution: Add ":sign" completion. (Dominique Pelle)
13 Files: src/ex_cmds.c, src/ex_docmd.c, src/ex_getln.c, src/vim.h,
17 *** ../vim-7.2.165/src/ex_cmds.c Tue Feb 24 04:28:40 2009
18 --- src/ex_cmds.c Wed Apr 29 17:08:27 2009
21 static void sign_list_defined __ARGS((sign_T *sp));
22 static void sign_undefine __ARGS((sign_T *sp, sign_T *sp_prev));
31 ! char_u *arg = eap->arg;
37 ! static char *cmds[] = {
39 #define SIGNCMD_DEFINE 0
42 static void sign_list_defined __ARGS((sign_T *sp));
43 static void sign_undefine __ARGS((sign_T *sp, sign_T *sp_prev));
45 ! static char *cmds[] = {
47 #define SIGNCMD_DEFINE 0
51 #define SIGNCMD_UNPLACE 4
53 #define SIGNCMD_JUMP 5
54 #define SIGNCMD_LAST 6
57 /* Parse the subcommand. */
61 ! for (idx = 0; ; ++idx)
63 ! if (idx == SIGNCMD_LAST)
65 ! EMSG2(_("E160: Unknown sign command: %s"), arg);
68 ! if (STRCMP(arg, cmds[idx]) == 0)
74 #define SIGNCMD_UNPLACE 4
76 #define SIGNCMD_JUMP 5
78 #define SIGNCMD_LAST 6
82 ! * Find index of a ":sign" subcmd from its name.
83 ! * "*end_cmd" must be writable.
86 ! sign_cmd_idx(begin_cmd, end_cmd)
87 ! char *begin_cmd; /* begin of sign subcmd */
88 ! char *end_cmd; /* just after sign subcmd */
91 ! char save = *end_cmd;
94 ! for (idx = 0; ; ++idx)
95 ! if (cmds[idx] == NULL || STRCMP(begin_cmd, cmds[idx]) == 0)
108 ! char_u *arg = eap->arg;
115 /* Parse the subcommand. */
116 p = skiptowhite(arg);
117 ! idx = sign_cmd_idx(arg, p);
118 ! if (idx == SIGNCMD_LAST)
120 ! EMSG2(_("E160: Unknown sign command: %s"), arg);
131 + #if defined(FEAT_CMDL_COMPL) || defined(PROTO)
134 + EXP_SUBCMD, /* expand :sign sub-commands */
135 + EXP_DEFINE, /* expand :sign define {name} args */
136 + EXP_PLACE, /* expand :sign place {id} args */
137 + EXP_UNPLACE, /* expand :sign unplace" */
138 + EXP_SIGN_NAMES /* expand with name of placed signs */
142 + * Function given to ExpandGeneric() to obtain the sign command
147 + get_sign_name(xp, idx)
154 + switch (expand_what)
157 + return (char_u *)cmds[idx];
160 + char *define_arg[] =
162 + "icon=", "linehl=", "text=", "texthl=", NULL
164 + return (char_u *)define_arg[idx];
168 + char *place_arg[] =
170 + "line=", "name=", "file=", "buffer=", NULL
172 + return (char_u *)place_arg[idx];
176 + char *unplace_arg[] = { "file=", "buffer=", NULL };
177 + return (char_u *)unplace_arg[idx];
179 + case EXP_SIGN_NAMES:
180 + /* Complete with name of signs already defined */
182 + for (sp = first_sign; sp != NULL; sp = sp->sn_next)
183 + if (current_idx++ == idx)
184 + return sp->sn_name;
192 + * Handle command line completion for :sign command.
195 + set_context_in_sign_cmd(xp, arg)
200 + char_u *end_subcmd;
203 + char_u *begin_subcmd_args;
205 + /* Default: expand subcommands. */
206 + xp->xp_context = EXPAND_SIGN;
207 + expand_what = EXP_SUBCMD;
208 + xp->xp_pattern = arg;
210 + end_subcmd = skiptowhite(arg);
211 + if (*end_subcmd == NUL)
212 + /* expand subcmd name
213 + * :sign {subcmd}<CTRL-D>*/
216 + cmd_idx = sign_cmd_idx(arg, end_subcmd);
218 + /* :sign {subcmd} {subcmd_args}
220 + * begin_subcmd_args */
221 + begin_subcmd_args = skipwhite(end_subcmd);
222 + p = skiptowhite(begin_subcmd_args);
226 + * Expand first argument of subcmd when possible.
227 + * For ":jump {id}" and ":unplace {id}", we could
228 + * possibly expand the ids of all signs already placed.
230 + xp->xp_pattern = begin_subcmd_args;
234 + case SIGNCMD_UNDEFINE:
235 + /* :sign list <CTRL-D>
236 + * :sign undefine <CTRL-D> */
237 + expand_what = EXP_SIGN_NAMES;
240 + xp->xp_context = EXPAND_NOTHING;
245 + /* expand last argument of subcmd */
247 + /* :sign define {name} {args}...
251 + /* Loop until reaching last argument. */
256 + p = skiptowhite(p);
257 + } while (*p != NUL);
259 + p = vim_strchr(last, '=');
261 + /* :sign define {name} {args}... {last}=
266 + /* Expand last argument name (before equal sign). */
267 + xp->xp_pattern = last;
270 + case SIGNCMD_DEFINE:
271 + expand_what = EXP_DEFINE;
273 + case SIGNCMD_PLACE:
274 + expand_what = EXP_PLACE;
277 + case SIGNCMD_UNPLACE:
278 + expand_what = EXP_UNPLACE;
281 + xp->xp_context = EXPAND_NOTHING;
286 + /* Expand last argument value (after equal sign). */
287 + xp->xp_pattern = p + 1;
290 + case SIGNCMD_DEFINE:
291 + if (STRNCMP(last, "texthl", p - last) == 0 ||
292 + STRNCMP(last, "linehl", p - last) == 0)
293 + xp->xp_context = EXPAND_HIGHLIGHT;
294 + else if (STRNCMP(last, "icon", p - last) == 0)
295 + xp->xp_context = EXPAND_FILES;
297 + xp->xp_context = EXPAND_NOTHING;
299 + case SIGNCMD_PLACE:
300 + if (STRNCMP(last, "name", p - last) == 0)
301 + expand_what = EXP_SIGN_NAMES;
303 + xp->xp_context = EXPAND_NOTHING;
306 + xp->xp_context = EXPAND_NOTHING;
313 #if defined(FEAT_GUI) || defined(FEAT_CLIENTSERVER) || defined(PROTO)
314 *** ../vim-7.2.165/src/ex_docmd.c Wed Apr 22 16:22:44 2009
315 --- src/ex_docmd.c Wed Apr 29 17:05:23 2009
319 set_context_in_cscope_cmd(xp, arg, ea.cmdidx);
324 + set_context_in_sign_cmd(xp, arg);
333 {EXPAND_MENUS, "menu"},
334 {EXPAND_SETTINGS, "option"},
335 {EXPAND_SHELLCMD, "shellcmd"},
336 + #if defined(FEAT_SIGNS)
337 + {EXPAND_SIGN, "sign"},
339 {EXPAND_TAGS, "tag"},
340 {EXPAND_TAGS_LISTFILES, "tag_listfiles"},
341 {EXPAND_USER_VARS, "var"},
342 *** ../vim-7.2.165/src/ex_getln.c Wed Apr 29 12:03:35 2009
343 --- src/ex_getln.c Wed Apr 29 12:51:42 2009
349 ! do_digraph(-1); /* init digraph typahead */
357 ! do_digraph(-1); /* init digraph typeahead */
365 {EXPAND_CSCOPE, get_cscope_name, TRUE},
368 + {EXPAND_SIGN, get_sign_name, TRUE},
370 #if (defined(HAVE_LOCALE_H) || defined(X_LOCALE)) \
371 && (defined(FEAT_GETTEXT) || defined(FEAT_MBYTE))
372 {EXPAND_LANGUAGE, get_lang_arg, TRUE},
373 *** ../vim-7.2.165/src/vim.h Wed Mar 18 12:50:58 2009
374 --- src/vim.h Wed Apr 29 12:51:42 2009
378 #define EXPAND_USER_LIST 31
379 #define EXPAND_SHELLCMD 32
380 #define EXPAND_CSCOPE 33
381 + #define EXPAND_SIGN 34
383 /* Values for exmode_active (0 is no exmode) */
384 #define EXMODE_NORMAL 1
385 *** ../vim-7.2.165/src/proto/ex_cmds.pro Tue Feb 24 04:28:40 2009
386 --- src/proto/ex_cmds.pro Wed Apr 29 17:10:29 2009
389 int read_viminfo_sub_string __ARGS((vir_T *virp, int force));
390 void write_viminfo_sub_string __ARGS((FILE *fp));
391 void free_old_sub __ARGS((void));
392 - void free_signs __ARGS((void));
393 int prepare_tagpreview __ARGS((int undo_sync));
394 void ex_help __ARGS((exarg_T *eap));
395 char_u *check_help_lang __ARGS((char_u *arg));
400 char_u *sign_get_text __ARGS((int typenr));
401 void *sign_get_image __ARGS((int typenr));
402 char_u *sign_typenr2name __ARGS((int typenr));
403 + void free_signs __ARGS((void));
404 + char_u *get_sign_name __ARGS((expand_T *xp, int idx));
405 + void set_context_in_sign_cmd __ARGS((expand_T *xp, char_u *arg));
406 void ex_drop __ARGS((exarg_T *eap));
407 /* vim: set ft=c : */
408 *** ../vim-7.2.165/src/version.c Wed Apr 29 18:01:23 2009
409 --- src/version.c Wed Apr 29 18:43:14 2009
413 { /* Add new patch number below this line */
419 Did you ever stop to think... and forget to start again?
422 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
423 /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
424 \\\ download, build and distribute -- http://www.A-A-P.org ///
425 \\\ help me help AIDS victims -- http://ICCF-Holland.org ///