4 From: Bram Moolenaar <Bram@moolenaar.net>
6 Content-Type: text/plain; charset=ISO-8859-1
7 Content-Transfer-Encoding: 8bit
11 Problem: No command line completion for ":cscope" command.
12 Solution: Add the completion for ":cscope". (Dominique Pelle)
13 Files: src/ex_docmd.c, src/ex_getln.c, src/if_cscope.c,
14 src/proto/if_cscope.pro, src/vim.h
17 *** ../vim-7.2.142/src/ex_docmd.c Wed Mar 11 15:36:01 2009
18 --- src/ex_docmd.c Wed Mar 11 15:45:04 2009
23 set_context_in_highlight_cmd(xp, arg);
27 + set_context_in_cscope_cmd(xp, arg);
36 {EXPAND_AUGROUP, "augroup"},
37 {EXPAND_BUFFERS, "buffer"},
38 {EXPAND_COMMANDS, "command"},
39 + #if defined(FEAT_CSCOPE)
40 + {EXPAND_CSCOPE, "cscope"},
42 #if defined(FEAT_EVAL) && defined(FEAT_CMDL_COMPL)
43 {EXPAND_USER_DEFINED, "custom"},
44 {EXPAND_USER_LIST, "customlist"},
45 *** ../vim-7.2.142/src/ex_getln.c Thu Mar 5 03:13:51 2009
46 --- src/ex_getln.c Wed Mar 11 15:45:04 2009
50 {EXPAND_EVENTS, get_event_name, TRUE},
51 {EXPAND_AUGROUP, get_augroup_name, TRUE},
54 + {EXPAND_CSCOPE, get_cscope_name, TRUE},
56 #if (defined(HAVE_LOCALE_H) || defined(X_LOCALE)) \
57 && (defined(FEAT_GETTEXT) || defined(FEAT_MBYTE))
58 {EXPAND_LANGUAGE, get_lang_arg, TRUE},
59 *** ../vim-7.2.142/src/if_cscope.c Wed Jan 28 16:03:51 2009
60 --- src/if_cscope.c Wed Mar 11 15:56:07 2009
63 (void)EMSG2(_("E560: Usage: cs[cope] %s"), cs_cmds[(int)x].usage);
67 * PRIVATE: do_cscope_general
69 ! * find the command, print help if invalid, and the then call the
70 ! * corresponding command function,
71 ! * called from do_cscope and do_scscope
74 do_cscope_general(eap, make_split)
76 (void)EMSG2(_("E560: Usage: cs[cope] %s"), cs_cmds[(int)x].usage);
79 + #if defined(FEAT_CMDL_COMPL) || defined(PROTO)
83 + EXP_CSCOPE_SUBCMD, /* expand ":cscope" sub-commands */
84 + EXP_CSCOPE_FIND, /* expand ":cscope find" arguments */
85 + EXP_CSCOPE_KILL /* expand ":cscope kill" arguments */
89 + * Function given to ExpandGeneric() to obtain the cscope command
94 + get_cscope_name(xp, idx)
98 + switch (expand_what)
100 + case EXP_CSCOPE_SUBCMD:
101 + /* Complete with sub-commands of ":cscope":
102 + * add, find, help, kill, reset, show */
103 + return (char_u *)cs_cmds[idx].name;
104 + case EXP_CSCOPE_FIND:
106 + const char *query_type[] =
108 + "c", "d", "e", "f", "g", "i", "s", "t", NULL
111 + /* Complete with query type of ":cscope find {query_type}".
112 + * {query_type} can be letters (c, d, ... t) or numbers (0, 1,
113 + * ..., 8) but only complete with letters, since numbers are
115 + return (char_u *)query_type[idx];
117 + case EXP_CSCOPE_KILL:
120 + int current_idx = 0;
121 + static char_u connection[2];
123 + /* ":cscope kill" accepts connection numbers or partial names of
124 + * the pathname of the cscope database as argument. Only complete
125 + * with connection numbers. -1 can also be used to kill all
127 + for (i = 0; i < CSCOPE_MAX_CONNECTIONS; i++)
129 + if (csinfo[i].fname == NULL)
131 + if (current_idx++ == idx)
133 + /* Connection number fits in one character since
134 + * CSCOPE_MAX_CONNECTIONS is < 10 */
135 + connection[0] = i + '0';
136 + connection[1] = NUL;
140 + return (current_idx == idx && idx > 0) ? (char_u *)"-1" : NULL;
148 + * Handle command line completion for :cscope command.
151 + set_context_in_cscope_cmd(xp, arg)
157 + /* Default: expand subcommands */
158 + xp->xp_context = EXPAND_CSCOPE;
159 + expand_what = EXP_CSCOPE_SUBCMD;
160 + xp->xp_pattern = arg;
162 + /* (part of) subcommand already typed */
165 + p = skiptowhite(arg);
166 + if (*p != NUL) /* past first word */
168 + xp->xp_pattern = skipwhite(p);
169 + if (*skiptowhite(xp->xp_pattern) != NUL)
170 + xp->xp_context = EXPAND_NOTHING;
171 + else if (STRNICMP(arg, "add", p - arg) == 0)
172 + xp->xp_context = EXPAND_FILES;
173 + else if (STRNICMP(arg, "kill", p - arg) == 0)
174 + expand_what = EXP_CSCOPE_KILL;
175 + else if (STRNICMP(arg, "find", p - arg) == 0)
176 + expand_what = EXP_CSCOPE_FIND;
178 + xp->xp_context = EXPAND_NOTHING;
183 + #endif /* FEAT_CMDL_COMPL */
186 * PRIVATE: do_cscope_general
188 ! * Find the command, print help if invalid, and then call the corresponding
189 ! * command function.
192 do_cscope_general(eap, make_split)
193 *** ../vim-7.2.142/src/proto/if_cscope.pro Thu Sep 6 17:38:21 2007
194 --- src/proto/if_cscope.pro Wed Mar 11 15:57:03 2009
199 + char_u *get_cscope_name __ARGS((expand_T *xp, int idx));
200 + void set_context_in_cscope_cmd __ARGS((expand_T *xp, char_u *arg));
201 void do_cscope __ARGS((exarg_T *eap));
202 void do_scscope __ARGS((exarg_T *eap));
203 void do_cstag __ARGS((exarg_T *eap));
204 *** ../vim-7.2.142/src/vim.h Sun Feb 22 02:36:36 2009
205 --- src/vim.h Wed Mar 11 15:45:04 2009
209 #define EXPAND_USER_DEFINED 30
210 #define EXPAND_USER_LIST 31
211 #define EXPAND_SHELLCMD 32
212 + #define EXPAND_CSCOPE 33
214 /* Values for exmode_active (0 is no exmode) */
215 #define EXMODE_NORMAL 1
216 *** ../vim-7.2.142/src/version.c Wed Mar 18 12:20:35 2009
217 --- src/version.c Wed Mar 18 12:48:08 2009
221 { /* Add new patch number below this line */
227 hundred-and-one symptoms of being an internet addict:
228 234. You started college as a chemistry major, and walk out four years
229 later as an Internet provider.
231 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
232 /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
233 \\\ download, build and distribute -- http://www.A-A-P.org ///
234 \\\ help me help AIDS victims -- http://ICCF-Holland.org ///