]> git.pld-linux.org Git - packages/vim.git/blame - 7.2.166
- new
[packages/vim.git] / 7.2.166
CommitLineData
d22eaa71
ER
1To: vim-dev@vim.org
2Subject: Patch 7.2.166
3Fcc: outbox
4From: Bram Moolenaar <Bram@moolenaar.net>
5Mime-Version: 1.0
6Content-Type: text/plain; charset=ISO-8859-1
7Content-Transfer-Encoding: 8bit
8------------
9
10Patch 7.2.166
11Problem: No completion for ":sign" command.
12Solution: Add ":sign" completion. (Dominique Pelle)
13Files: src/ex_cmds.c, src/ex_docmd.c, src/ex_getln.c, src/vim.h,
14 src/proto/ex_cmds.pro
15
16
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
19***************
20*** 6543,6562 ****
21 static void sign_list_defined __ARGS((sign_T *sp));
22 static void sign_undefine __ARGS((sign_T *sp, sign_T *sp_prev));
23
24! /*
25! * ":sign" command
26! */
27! void
28! ex_sign(eap)
29! exarg_T *eap;
30! {
31! char_u *arg = eap->arg;
32! char_u *p;
33! int idx;
34! sign_T *sp;
35! sign_T *sp_prev;
36! buf_T *buf;
37! static char *cmds[] = {
38 "define",
39 #define SIGNCMD_DEFINE 0
40 "undefine",
41--- 6543,6549 ----
42 static void sign_list_defined __ARGS((sign_T *sp));
43 static void sign_undefine __ARGS((sign_T *sp, sign_T *sp_prev));
44
45! static char *cmds[] = {
46 "define",
47 #define SIGNCMD_DEFINE 0
48 "undefine",
49***************
50*** 6569,6590 ****
51 #define SIGNCMD_UNPLACE 4
52 "jump",
53 #define SIGNCMD_JUMP 5
54 #define SIGNCMD_LAST 6
55! };
56
57 /* Parse the subcommand. */
58 p = skiptowhite(arg);
59! if (*p != NUL)
60! *p++ = NUL;
61! for (idx = 0; ; ++idx)
62 {
63! if (idx == SIGNCMD_LAST)
64! {
65! EMSG2(_("E160: Unknown sign command: %s"), arg);
66! return;
67! }
68! if (STRCMP(arg, cmds[idx]) == 0)
69! break;
70 }
71 arg = skipwhite(p);
72
73--- 6556,6606 ----
74 #define SIGNCMD_UNPLACE 4
75 "jump",
76 #define SIGNCMD_JUMP 5
77+ NULL
78 #define SIGNCMD_LAST 6
79! };
80!
81! /*
82! * Find index of a ":sign" subcmd from its name.
83! * "*end_cmd" must be writable.
84! */
85! static int
86! sign_cmd_idx(begin_cmd, end_cmd)
87! char *begin_cmd; /* begin of sign subcmd */
88! char *end_cmd; /* just after sign subcmd */
89! {
90! int idx;
91! char save = *end_cmd;
92!
93! *end_cmd = NUL;
94! for (idx = 0; ; ++idx)
95! if (cmds[idx] == NULL || STRCMP(begin_cmd, cmds[idx]) == 0)
96! break;
97! *end_cmd = save;
98! return idx;
99! }
100!
101! /*
102! * ":sign" command
103! */
104! void
105! ex_sign(eap)
106! exarg_T *eap;
107! {
108! char_u *arg = eap->arg;
109! char_u *p;
110! int idx;
111! sign_T *sp;
112! sign_T *sp_prev;
113! buf_T *buf;
114
115 /* Parse the subcommand. */
116 p = skiptowhite(arg);
117! idx = sign_cmd_idx(arg, p);
118! if (idx == SIGNCMD_LAST)
119 {
120! EMSG2(_("E160: Unknown sign command: %s"), arg);
121! return;
122 }
123 arg = skipwhite(p);
124
125***************
126*** 7110,7115 ****
127--- 7126,7311 ----
128 }
129 #endif
130
131+ #if defined(FEAT_CMDL_COMPL) || defined(PROTO)
132+ static enum
133+ {
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 */
139+ } expand_what;
140+
141+ /*
142+ * Function given to ExpandGeneric() to obtain the sign command
143+ * expansion.
144+ */
145+ /*ARGSUSED*/
146+ char_u *
147+ get_sign_name(xp, idx)
148+ expand_T *xp;
149+ int idx;
150+ {
151+ sign_T *sp;
152+ int current_idx;
153+
154+ switch (expand_what)
155+ {
156+ case EXP_SUBCMD:
157+ return (char_u *)cmds[idx];
158+ case EXP_DEFINE:
159+ {
160+ char *define_arg[] =
161+ {
162+ "icon=", "linehl=", "text=", "texthl=", NULL
163+ };
164+ return (char_u *)define_arg[idx];
165+ }
166+ case EXP_PLACE:
167+ {
168+ char *place_arg[] =
169+ {
170+ "line=", "name=", "file=", "buffer=", NULL
171+ };
172+ return (char_u *)place_arg[idx];
173+ }
174+ case EXP_UNPLACE:
175+ {
176+ char *unplace_arg[] = { "file=", "buffer=", NULL };
177+ return (char_u *)unplace_arg[idx];
178+ }
179+ case EXP_SIGN_NAMES:
180+ /* Complete with name of signs already defined */
181+ current_idx = 0;
182+ for (sp = first_sign; sp != NULL; sp = sp->sn_next)
183+ if (current_idx++ == idx)
184+ return sp->sn_name;
185+ return NULL;
186+ default:
187+ return NULL;
188+ }
189+ }
190+
191+ /*
192+ * Handle command line completion for :sign command.
193+ */
194+ void
195+ set_context_in_sign_cmd(xp, arg)
196+ expand_T *xp;
197+ char_u *arg;
198+ {
199+ char_u *p;
200+ char_u *end_subcmd;
201+ char_u *last;
202+ int cmd_idx;
203+ char_u *begin_subcmd_args;
204+
205+ /* Default: expand subcommands. */
206+ xp->xp_context = EXPAND_SIGN;
207+ expand_what = EXP_SUBCMD;
208+ xp->xp_pattern = arg;
209+
210+ end_subcmd = skiptowhite(arg);
211+ if (*end_subcmd == NUL)
212+ /* expand subcmd name
213+ * :sign {subcmd}<CTRL-D>*/
214+ return;
215+
216+ cmd_idx = sign_cmd_idx(arg, end_subcmd);
217+
218+ /* :sign {subcmd} {subcmd_args}
219+ * |
220+ * begin_subcmd_args */
221+ begin_subcmd_args = skipwhite(end_subcmd);
222+ p = skiptowhite(begin_subcmd_args);
223+ if (*p == NUL)
224+ {
225+ /*
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.
229+ */
230+ xp->xp_pattern = begin_subcmd_args;
231+ switch (cmd_idx)
232+ {
233+ case SIGNCMD_LIST:
234+ case SIGNCMD_UNDEFINE:
235+ /* :sign list <CTRL-D>
236+ * :sign undefine <CTRL-D> */
237+ expand_what = EXP_SIGN_NAMES;
238+ break;
239+ default:
240+ xp->xp_context = EXPAND_NOTHING;
241+ }
242+ return;
243+ }
244+
245+ /* expand last argument of subcmd */
246+
247+ /* :sign define {name} {args}...
248+ * |
249+ * p */
250+
251+ /* Loop until reaching last argument. */
252+ do
253+ {
254+ p = skipwhite(p);
255+ last = p;
256+ p = skiptowhite(p);
257+ } while (*p != NUL);
258+
259+ p = vim_strchr(last, '=');
260+
261+ /* :sign define {name} {args}... {last}=
262+ * | |
263+ * last p */
264+ if (p == NUL)
265+ {
266+ /* Expand last argument name (before equal sign). */
267+ xp->xp_pattern = last;
268+ switch (cmd_idx)
269+ {
270+ case SIGNCMD_DEFINE:
271+ expand_what = EXP_DEFINE;
272+ break;
273+ case SIGNCMD_PLACE:
274+ expand_what = EXP_PLACE;
275+ break;
276+ case SIGNCMD_JUMP:
277+ case SIGNCMD_UNPLACE:
278+ expand_what = EXP_UNPLACE;
279+ break;
280+ default:
281+ xp->xp_context = EXPAND_NOTHING;
282+ }
283+ }
284+ else
285+ {
286+ /* Expand last argument value (after equal sign). */
287+ xp->xp_pattern = p + 1;
288+ switch (cmd_idx)
289+ {
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;
296+ else
297+ xp->xp_context = EXPAND_NOTHING;
298+ break;
299+ case SIGNCMD_PLACE:
300+ if (STRNCMP(last, "name", p - last) == 0)
301+ expand_what = EXP_SIGN_NAMES;
302+ else
303+ xp->xp_context = EXPAND_NOTHING;
304+ break;
305+ default:
306+ xp->xp_context = EXPAND_NOTHING;
307+ }
308+ }
309+ }
310+ #endif
311 #endif
312
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
316***************
317*** 3695,3700 ****
318--- 3695,3705 ----
319 set_context_in_cscope_cmd(xp, arg, ea.cmdidx);
320 break;
321 #endif
322+ #ifdef FEAT_SIGNS
323+ case CMD_sign:
324+ set_context_in_sign_cmd(xp, arg);
325+ break;
326+ #endif
327 #ifdef FEAT_LISTCMDS
328 case CMD_bdelete:
329 case CMD_bwipeout:
330***************
331*** 5218,5223 ****
332--- 5223,5231 ----
333 {EXPAND_MENUS, "menu"},
334 {EXPAND_SETTINGS, "option"},
335 {EXPAND_SHELLCMD, "shellcmd"},
336+ #if defined(FEAT_SIGNS)
337+ {EXPAND_SIGN, "sign"},
338+ #endif
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
344***************
345*** 325,331 ****
346 #endif
347
348 #ifdef FEAT_DIGRAPHS
349! do_digraph(-1); /* init digraph typahead */
350 #endif
351
352 /*
353--- 325,331 ----
354 #endif
355
356 #ifdef FEAT_DIGRAPHS
357! do_digraph(-1); /* init digraph typeahead */
358 #endif
359
360 /*
361***************
362*** 4521,4526 ****
363--- 4521,4529 ----
364 #ifdef FEAT_CSCOPE
365 {EXPAND_CSCOPE, get_cscope_name, TRUE},
366 #endif
367+ #ifdef FEAT_SIGNS
368+ {EXPAND_SIGN, get_sign_name, TRUE},
369+ #endif
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
375***************
376*** 709,714 ****
377--- 709,715 ----
378 #define EXPAND_USER_LIST 31
379 #define EXPAND_SHELLCMD 32
380 #define EXPAND_CSCOPE 33
381+ #define EXPAND_SIGN 34
382
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
387***************
388*** 40,46 ****
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));
396--- 40,45 ----
397***************
398*** 56,60 ****
399--- 55,62 ----
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
410***************
411*** 678,679 ****
412--- 678,681 ----
413 { /* Add new patch number below this line */
414+ /**/
415+ 166,
416 /**/
417
418--
419Did you ever stop to think... and forget to start again?
420 -- Steven Wright
421
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 ///
This page took 0.076511 seconds and 4 git commands to generate.