vim_snprintf((char *)buf, sizeof(buf), "<buffer> %s %s",
((kmap_T *)curbuf->b_kmap_ga.ga_data)[i].from,
((kmap_T *)curbuf->b_kmap_ga.ga_data)[i].to);
- (void)do_map(2, buf, MODE_LANGMAP, FALSE);
+ (void)do_map(MAPTYPE_NOREMAP, buf, MODE_LANGMAP, FALSE);
}
p_cpo = save_cpo;
for (i = 0; i < curbuf->b_kmap_ga.ga_len; ++i)
{
vim_snprintf((char *)buf, sizeof(buf), "<buffer> %s", kp[i].from);
- (void)do_map(1, buf, MODE_LANGMAP, FALSE);
+ (void)do_map(MAPTYPE_UNMAP, buf, MODE_LANGMAP, FALSE);
}
keymap_clear(&curbuf->b_kmap_ga);
* noreabbr {lhs} {rhs} : same, but no remapping for {rhs}
* unabbr {lhs} : remove abbreviation for {lhs}
*
- * maptype: 0 for :map, 1 for :unmap, 2 for noremap.
+ * maptype: MAPTYPE_MAP for :map
+ * MAPTYPE_UNMAP for :unmap
+ * MAPTYPE_NOREMAP for noremap
*
* arg is pointer to any arguments. Note: arg cannot be a read-only string,
* it will be modified.
abbr_table = &first_abbr;
// For ":noremap" don't remap, otherwise do remap.
- if (maptype == 2)
+ if (maptype == MAPTYPE_NOREMAP)
noremap = REMAP_NONE;
else
noremap = REMAP_YES;
// with :unmap white space is included in the keys, no argument possible.
p = keys;
do_backslash = (vim_strchr(p_cpo, CPO_BSLASH) == NULL);
- while (*p && (maptype == 1 || !VIM_ISWHITE(*p)))
+ while (*p && (maptype == MAPTYPE_UNMAP || !VIM_ISWHITE(*p)))
{
if ((p[0] == Ctrl_V || (do_backslash && p[0] == '\\')) &&
p[1] != NUL)
rhs = p;
hasarg = (*rhs != NUL);
haskey = (*keys != NUL);
- do_print = !haskey || (maptype != 1 && !hasarg);
+ do_print = !haskey || (maptype != MAPTYPE_UNMAP && !hasarg);
// check for :unmap without argument
- if (maptype == 1 && !haskey)
+ if (maptype == MAPTYPE_UNMAP && !haskey)
{
retval = 1;
goto theend;
goto theend;
}
- if (abbrev && maptype != 1)
+ if (abbrev && maptype != MAPTYPE_UNMAP)
{
// If an abbreviation ends in a keyword character, the
// rest must be all keyword-char or all non-keyword-char.
// Check if a new local mapping wasn't already defined globally.
if (unique && map_table == curbuf->b_maphash
- && haskey && hasarg && maptype != 1)
+ && haskey && hasarg && maptype != MAPTYPE_UNMAP)
{
// need to loop over all global hash lists
for (hash = 0; hash < 256 && !got_int; ++hash)
}
// When listing global mappings, also list buffer-local ones here.
- if (map_table != curbuf->b_maphash && !hasarg && maptype != 1)
+ if (map_table != curbuf->b_maphash && !hasarg
+ && maptype != MAPTYPE_UNMAP)
{
// need to loop over all global hash lists
for (hash = 0; hash < 256 && !got_int; ++hash)
// an entry with a matching 'to' part. This was done to allow
// ":ab foo bar" to be unmapped by typing ":unab foo", where "foo" will
// be replaced by "bar" because of the abbreviation.
- for (round = 0; (round == 0 || maptype == 1) && round <= 1
+ for (round = 0; (round == 0 || maptype == MAPTYPE_UNMAP) && round <= 1
&& !did_it && !got_int; ++round)
{
// need to loop over all hash lists
}
if (STRNCMP(p, keys, (size_t)(n < len ? n : len)) == 0)
{
- if (maptype == 1)
+ if (maptype == MAPTYPE_UNMAP)
{
// Delete entry.
// Only accept a full match. For abbreviations
}
}
- if (maptype == 1)
+ if (maptype == MAPTYPE_UNMAP)
{
// delete entry
if (!did_it)
if (arg == NULL)
return;
}
- do_map(1, arg, mode, is_abbr);
+ do_map(MAPTYPE_UNMAP, arg, mode, is_abbr);
vim_free(arg);
(void)map_add(map_table, abbr_table, lhsraw, rhs, orig_rhs, noremap,
# endif
{
for (i = 0; i < (int)ARRAY_LENGTH(cinitmappings); ++i)
- add_map(cinitmappings[i].arg, cinitmappings[i].mode);
+ add_map(cinitmappings[i].arg, cinitmappings[i].mode, FALSE);
}
# endif
# if defined(FEAT_GUI_MSWIN) || defined(MACOS_X)
for (i = 0; i < (int)ARRAY_LENGTH(initmappings); ++i)
- add_map(initmappings[i].arg, initmappings[i].mode);
+ add_map(initmappings[i].arg, initmappings[i].mode, FALSE);
# endif
#endif
}
|| defined(PROTO)
/*
* Add a mapping "map" for mode "mode".
+ * When "nore" is TRUE use MAPTYPE_NOREMAP.
* Need to put string in allocated memory, because do_map() will modify it.
*/
void
-add_map(char_u *map, int mode)
+add_map(char_u *map, int mode, int nore)
{
char_u *s;
char_u *cpo_save = p_cpo;
s = vim_strsave(map);
if (s != NULL)
{
- (void)do_map(0, s, mode, FALSE);
+ (void)do_map(nore ? MAPTYPE_NOREMAP : MAPTYPE_MAP, s, mode, FALSE);
vim_free(s);
}
p_cpo = cpo_save;
cmdp = eap->cmd;
mode = get_map_mode(&cmdp, eap->forceit || isabbrev);
- switch (do_map((*cmdp == 'n') ? 2 : (*cmdp == 'u'),
+ switch (do_map(*cmdp == 'n' ? MAPTYPE_NOREMAP
+ : *cmdp == 'u' ? MAPTYPE_UNMAP : MAPTYPE_MAP,
eap->arg, mode, isabbrev))
{
case 1: emsg(_(e_invalid_argument));