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