Patch 9.0.0002
Problem:    Map functionality outside of map.c.
Solution:   Move f_hasmapto() to map.c.  Rename a function. (closes #10611)
Files:      src/buffer.c, src/evalfunc.c, src/map.c, src/proto/map.pro


*** ../vim-9.0.0001/src/buffer.c        2022-05-30 14:38:08.000000000 +0100
--- src/buffer.c        2022-06-29 10:29:47.215224340 +0100
***************
*** 1004,1011 ****
  #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
      VIM_CLEAR(buf->b_start_fenc);
  }
  
--- 1004,1011 ----
  #ifdef FEAT_NETBEANS_INTG
      netbeans_file_killed(buf);
  #endif
!     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);
  }
  
*** ../vim-9.0.0001/src/evalfunc.c      2022-06-27 11:45:15.000000000 +0100
--- src/evalfunc.c      2022-06-29 10:30:38.503117138 +0100
***************
*** 75,81 ****
  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);
--- 75,80 ----
***************
*** 6654,6693 ****
  }
  
  /*
-  * "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
   */
      static void
--- 6653,6658 ----
*** ../vim-9.0.0001/src/map.c   2022-06-18 16:46:37.000000000 +0100
--- src/map.c   2022-06-29 10:34:59.958577726 +0100
***************
*** 908,920 ****
  }
  
  /*
!  * Clear all mappings or abbreviations.
!  * 'abbr' should be FALSE for mappings, TRUE for abbreviations.
   */
      static void
  map_clear(
      char_u    *cmdp,
!     char_u    *arg UNUSED,
      int               forceit,
      int               abbr)
  {
--- 908,920 ----
  }
  
  /*
!  * 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,
      int               forceit,
      int               abbr)
  {
***************
*** 929,942 ****
      }
  
      mode = get_map_mode(&cmdp, forceit);
!     map_clear_int(curbuf, mode, local, abbr);
  }
  
  /*
   * Clear all mappings in "mode".
   */
      void
! map_clear_int(
      buf_T     *buf,           // buffer for local mappings
      int               mode,           // mode in which to delete
      int               local,          // TRUE for buffer-local mappings
--- 929,942 ----
      }
  
      mode = get_map_mode(&cmdp, forceit);
!     map_clear_mode(curbuf, mode, local, abbr);
  }
  
  /*
   * Clear all mappings in "mode".
   */
      void
! map_clear_mode(
      buf_T     *buf,           // buffer for local mappings
      int               mode,           // mode in which to delete
      int               local,          // TRUE for buffer-local mappings
***************
*** 2273,2278 ****
--- 2273,2312 ----
  }
  
  /*
+  * "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.
   */
      static void
*** ../vim-9.0.0001/src/proto/map.pro   2022-06-27 23:15:13.000000000 +0100
--- src/proto/map.pro   2022-06-29 10:35:02.690572134 +0100
***************
*** 3,9 ****
  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);
  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);
--- 3,9 ----
  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_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,22 ****
--- 17,23 ----
  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);
*** ../vim-9.0.0001/src/version.c       2022-06-28 20:01:22.912864369 +0100
--- src/version.c       2022-06-29 10:36:33.290387256 +0100
***************
*** 737,738 ****
--- 737,740 ----
  {   /* Add new patch number below this line */
+ /**/
+     2,
  /**/

-- 
How To Keep A Healthy Level Of Insanity:
3. Every time someone asks you to do something, ask if they want fries
   with that.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///                                                                      \\\
\\\        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/20220629094047.7A7671C1F93%40moolenaar.net.

Raspunde prin e-mail lui