]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.0.0002: map functionality outside of map.c v9.0.0002
authorzeertzjq <zeertzjq@outlook.com>
Wed, 29 Jun 2022 09:37:40 +0000 (10:37 +0100)
committerBram Moolenaar <Bram@vim.org>
Wed, 29 Jun 2022 09:37:40 +0000 (10:37 +0100)
Problem:    Map functionality outside of map.c.
Solution:   Move f_hasmapto() to map.c.  Rename a function. (closes #10611)

src/buffer.c
src/evalfunc.c
src/map.c
src/proto/map.pro
src/version.c

index e775398d02949b21c0a20c0feb1d0be8a514c65b..bbbfdb7814ffbb69bb805ed4eb6a287653705eb3 100644 (file)
@@ -1004,8 +1004,8 @@ free_buffer_stuff(
 #ifdef FEAT_NETBEANS_INTG
     netbeans_file_killed(buf);
 #endif
-    map_clear_int(buf, MAP_ALL_MODES, TRUE, FALSE);  // clear local mappings
-    map_clear_int(buf, MAP_ALL_MODES, TRUE, TRUE);   // clear local abbrevs
+    map_clear_mode(buf, MAP_ALL_MODES, TRUE, FALSE);  // clear local mappings
+    map_clear_mode(buf, MAP_ALL_MODES, TRUE, TRUE);   // clear local abbrevs
     VIM_CLEAR(buf->b_start_fenc);
 }
 
index cb12a46c3fe1b7d1836dc6ecfcbbba46520c01d9..0b8fd43966dab23ecd9feb84156a5da430a47982 100644 (file)
@@ -75,7 +75,6 @@ static void f_getregtype(typval_T *argvars, typval_T *rettv);
 static void f_gettagstack(typval_T *argvars, typval_T *rettv);
 static void f_gettext(typval_T *argvars, typval_T *rettv);
 static void f_haslocaldir(typval_T *argvars, typval_T *rettv);
-static void f_hasmapto(typval_T *argvars, typval_T *rettv);
 static void f_hlID(typval_T *argvars, typval_T *rettv);
 static void f_hlexists(typval_T *argvars, typval_T *rettv);
 static void f_hostname(typval_T *argvars, typval_T *rettv);
@@ -6653,40 +6652,6 @@ f_haslocaldir(typval_T *argvars, typval_T *rettv)
        rettv->vval.v_number = 0;
 }
 
-/*
- * "hasmapto()" function
- */
-    static void
-f_hasmapto(typval_T *argvars, typval_T *rettv)
-{
-    char_u     *name;
-    char_u     *mode;
-    char_u     buf[NUMBUFLEN];
-    int                abbr = FALSE;
-
-    if (in_vim9script()
-           && (check_for_string_arg(argvars, 0) == FAIL
-               || check_for_opt_string_arg(argvars, 1) == FAIL
-               || (argvars[1].v_type != VAR_UNKNOWN
-                   && check_for_opt_bool_arg(argvars, 2) == FAIL)))
-       return;
-
-    name = tv_get_string(&argvars[0]);
-    if (argvars[1].v_type == VAR_UNKNOWN)
-       mode = (char_u *)"nvo";
-    else
-    {
-       mode = tv_get_string_buf(&argvars[1], buf);
-       if (argvars[2].v_type != VAR_UNKNOWN)
-           abbr = (int)tv_get_bool(&argvars[2]);
-    }
-
-    if (map_to_exists(name, mode, abbr))
-       rettv->vval.v_number = TRUE;
-    else
-       rettv->vval.v_number = FALSE;
-}
-
 /*
  * "highlightID(name)" function
  */
index 2850a3fe249dd1807bc4cc5d025c873431daf4b8..ff4c4968daae0cddb5e19b6e1f3bf8ae1a2117b1 100644 (file)
--- a/src/map.c
+++ b/src/map.c
@@ -908,13 +908,13 @@ get_map_mode(char_u **cmdp, int forceit)
 }
 
 /*
- * Clear all mappings or abbreviations.
- * 'abbr' should be FALSE for mappings, TRUE for abbreviations.
+ * Clear all mappings (":mapclear") or abbreviations (":abclear").
+ * "abbr" should be FALSE for mappings, TRUE for abbreviations.
  */
     static void
 map_clear(
     char_u     *cmdp,
-    char_u     *arg UNUSED,
+    char_u     *arg,
     int                forceit,
     int                abbr)
 {
@@ -929,14 +929,14 @@ map_clear(
     }
 
     mode = get_map_mode(&cmdp, forceit);
-    map_clear_int(curbuf, mode, local, abbr);
+    map_clear_mode(curbuf, mode, local, abbr);
 }
 
 /*
  * Clear all mappings in "mode".
  */
     void
-map_clear_int(
+map_clear_mode(
     buf_T      *buf,           // buffer for local mappings
     int                mode,           // mode in which to delete
     int                local,          // TRUE for buffer-local mappings
@@ -2272,6 +2272,40 @@ check_map(
     return NULL;
 }
 
+/*
+ * "hasmapto()" function
+ */
+    void
+f_hasmapto(typval_T *argvars, typval_T *rettv)
+{
+    char_u     *name;
+    char_u     *mode;
+    char_u     buf[NUMBUFLEN];
+    int                abbr = FALSE;
+
+    if (in_vim9script()
+           && (check_for_string_arg(argvars, 0) == FAIL
+               || check_for_opt_string_arg(argvars, 1) == FAIL
+               || (argvars[1].v_type != VAR_UNKNOWN
+                   && check_for_opt_bool_arg(argvars, 2) == FAIL)))
+       return;
+
+    name = tv_get_string(&argvars[0]);
+    if (argvars[1].v_type == VAR_UNKNOWN)
+       mode = (char_u *)"nvo";
+    else
+    {
+       mode = tv_get_string_buf(&argvars[1], buf);
+       if (argvars[2].v_type != VAR_UNKNOWN)
+           abbr = (int)tv_get_bool(&argvars[2]);
+    }
+
+    if (map_to_exists(name, mode, abbr))
+       rettv->vval.v_number = TRUE;
+    else
+       rettv->vval.v_number = FALSE;
+}
+
 /*
  * Fill in the empty dictionary with items as defined by maparg builtin.
  */
index 5caa85921484e580f3733cc0946a85a8eccf35a5..1ed088dc64284efb7b8dbd11c9489e0600603c54 100644 (file)
@@ -3,7 +3,7 @@ mapblock_T *get_maphash_list(int state, int c);
 mapblock_T *get_buf_maphash_list(int state, int c);
 int is_maphash_valid(void);
 int do_map(int maptype, char_u *arg, int mode, int abbrev);
-void map_clear_int(buf_T *buf, int mode, int local, int abbr);
+void map_clear_mode(buf_T *buf, int mode, int local, int abbr);
 int mode_str2flags(char_u *modechars);
 int map_to_exists(char_u *str, char_u *modechars, int abbr);
 int map_to_exists_mode(char_u *rhs, int mode, int abbr);
@@ -17,6 +17,7 @@ int makemap(FILE *fd, buf_T *buf);
 int put_escstr(FILE *fd, char_u *strstart, int what);
 void check_map_keycodes(void);
 char_u *check_map(char_u *keys, int mode, int exact, int ign_mod, int abbr, mapblock_T **mp_ptr, int *local_ptr);
+void f_hasmapto(typval_T *argvars, typval_T *rettv);
 void f_maplist(typval_T *argvars, typval_T *rettv);
 void f_maparg(typval_T *argvars, typval_T *rettv);
 void f_mapcheck(typval_T *argvars, typval_T *rettv);
index 30abf3488d3d28914ba4564de5bfb3fadc089c9d..74e080ff3958da45d7c0e0a2ffc2497acd8594ee 100644 (file)
@@ -735,6 +735,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2,
 /**/
     1,
 /**/