Skip to content

Commit cae92dc

Browse files
committed
patch 8.0.0878: no completion for :mapclear
Problem: No completion for :mapclear. Solution: Add completion (Nobuhiro Takasaki et al. closes #1943)
1 parent 6d81974 commit cae92dc

File tree

8 files changed

+34
-0
lines changed

8 files changed

+34
-0
lines changed

runtime/doc/eval.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4368,6 +4368,7 @@ getcompletion({pat}, {type} [, {filtered}]) *getcompletion()*
43684368
highlight highlight groups
43694369
history :history suboptions
43704370
locale locale names (as output of locale -a)
4371+
mapclear buffer argument
43714372
mapping mapping name
43724373
menu menus
43734374
messages |:messages| suboptions

runtime/doc/map.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1279,6 +1279,7 @@ completion can be enabled:
12791279
-complete=highlight highlight groups
12801280
-complete=history :history suboptions
12811281
-complete=locale locale names (as output of locale -a)
1282+
-complete=mapclear buffer argument
12821283
-complete=mapping mapping name
12831284
-complete=menu menus
12841285
-complete=messages |:messages| suboptions

src/ex_docmd.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4223,6 +4223,19 @@ set_one_cmd_context(
42234223
case CMD_xunmap:
42244224
return set_context_in_map_cmd(xp, cmd, arg, forceit,
42254225
FALSE, TRUE, ea.cmdidx);
4226+
case CMD_mapclear:
4227+
case CMD_nmapclear:
4228+
case CMD_vmapclear:
4229+
case CMD_omapclear:
4230+
case CMD_imapclear:
4231+
case CMD_cmapclear:
4232+
case CMD_lmapclear:
4233+
case CMD_smapclear:
4234+
case CMD_xmapclear:
4235+
xp->xp_context = EXPAND_MAPCLEAR;
4236+
xp->xp_pattern = arg;
4237+
break;
4238+
42264239
case CMD_abbreviate: case CMD_noreabbrev:
42274240
case CMD_cabbrev: case CMD_cnoreabbrev:
42284241
case CMD_iabbrev: case CMD_inoreabbrev:
@@ -5964,6 +5977,7 @@ static struct
59645977
&& (defined(FEAT_GETTEXT) || defined(FEAT_MBYTE))
59655978
{EXPAND_LOCALES, "locale"},
59665979
#endif
5980+
{EXPAND_MAPCLEAR, "mapclear"},
59675981
{EXPAND_MAPPINGS, "mapping"},
59685982
{EXPAND_MENUS, "menu"},
59695983
{EXPAND_MESSAGES, "messages"},
@@ -12083,6 +12097,14 @@ get_messages_arg(expand_T *xp UNUSED, int idx)
1208312097
}
1208412098
#endif
1208512099

12100+
char_u *
12101+
get_mapclear_arg(expand_T *xp UNUSED, int idx)
12102+
{
12103+
if (idx == 0)
12104+
return (char_u *)"<buffer>";
12105+
return NULL;
12106+
}
12107+
1208612108
#ifdef FEAT_AUTOCMD
1208712109
static int filetype_detect = FALSE;
1208812110
static int filetype_plugin = FALSE;

src/ex_getln.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4879,6 +4879,7 @@ ExpandFromContext(
48794879
{
48804880
{EXPAND_COMMANDS, get_command_name, FALSE, TRUE},
48814881
{EXPAND_BEHAVE, get_behave_arg, TRUE, TRUE},
4882+
{EXPAND_MAPCLEAR, get_mapclear_arg, TRUE, TRUE},
48824883
{EXPAND_MESSAGES, get_messages_arg, TRUE, TRUE},
48834884
#ifdef FEAT_CMDHIST
48844885
{EXPAND_HISTORY, get_history_arg, TRUE, TRUE},

src/proto/ex_docmd.pro

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,5 @@ int put_line(FILE *fd, char *s);
6262
void dialog_msg(char_u *buff, char *format, char_u *fname);
6363
char_u *get_behave_arg(expand_T *xp, int idx);
6464
char_u *get_messages_arg(expand_T *xp, int idx);
65+
char_u *get_mapclear_arg(expand_T *xp, int idx);
6566
/* vim: set ft=c : */

src/testdir/test_cmdline.vim

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,11 @@ func Test_getcompletion()
222222
let l = getcompletion('not', 'messages')
223223
call assert_equal([], l)
224224

225+
let l = getcompletion('', 'mapclear')
226+
call assert_true(index(l, '<buffer>') >= 0)
227+
let l = getcompletion('not', 'mapclear')
228+
call assert_equal([], l)
229+
225230
if has('cscope')
226231
let l = getcompletion('', 'cscope')
227232
let cmds = ['add', 'find', 'help', 'kill', 'reset', 'show']

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -769,6 +769,8 @@ static char *(features[]) =
769769

770770
static int included_patches[] =
771771
{ /* Add new patch number below this line */
772+
/**/
773+
878,
772774
/**/
773775
877,
774776
/**/

src/vim.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -808,6 +808,7 @@ extern int (*dyn_libintl_putenv)(const char *envstring);
808808
#define EXPAND_USER_ADDR_TYPE 44
809809
#define EXPAND_PACKADD 45
810810
#define EXPAND_MESSAGES 46
811+
#define EXPAND_MAPCLEAR 47
811812

812813
/* Values for exmode_active (0 is no exmode) */
813814
#define EXMODE_NORMAL 1

0 commit comments

Comments
 (0)