Mercurial > vim
comparison src/map.c @ 28602:398c5b3211f9 v8.2.4825
patch 8.2.4825: can only get a list of mappings
Commit: https://github.com/vim/vim/commit/09661203ecefbee6a6f09438afcff1843e9dbfb4
Author: Ernie Rael <errael@raelity.com>
Date: Mon Apr 25 14:40:44 2022 +0100
patch 8.2.4825: can only get a list of mappings
Problem: Can only get a list of mappings.
Solution: Add the optional {abbr} argument. (Ernie Rael, closes https://github.com/vim/vim/issues/10277)
Rename to maplist(). Rename test file.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 25 Apr 2022 15:45:03 +0200 |
parents | 17251b82b69a |
children | 893af4a8fc08 |
comparison
equal
deleted
inserted
replaced
28601:a4d54a260c59 | 28602:398c5b3211f9 |
---|---|
2387 vim_free(keys_buf); | 2387 vim_free(keys_buf); |
2388 vim_free(alt_keys_buf); | 2388 vim_free(alt_keys_buf); |
2389 } | 2389 } |
2390 | 2390 |
2391 /* | 2391 /* |
2392 * "getmappings()" function | 2392 * "maplist()" function |
2393 */ | 2393 */ |
2394 void | 2394 void |
2395 f_getmappings(typval_T *argvars UNUSED, typval_T *rettv) | 2395 f_maplist(typval_T *argvars UNUSED, typval_T *rettv) |
2396 { | 2396 { |
2397 dict_T *d; | 2397 dict_T *d; |
2398 mapblock_T *mp; | 2398 mapblock_T *mp; |
2399 int buffer_local; | 2399 int buffer_local; |
2400 char_u *keys_buf; | 2400 char_u *keys_buf; |
2401 int did_simplify; | 2401 int did_simplify; |
2402 int hash; | 2402 int hash; |
2403 char_u *lhs; | 2403 char_u *lhs; |
2404 const int flags = REPTERM_FROM_PART | REPTERM_DO_LT; | 2404 const int flags = REPTERM_FROM_PART | REPTERM_DO_LT; |
2405 int abbr = FALSE; | |
2406 | |
2407 if (in_vim9script() && check_for_opt_bool_arg(argvars, 0) == FAIL) | |
2408 return; | |
2409 if (argvars[0].v_type != VAR_UNKNOWN) | |
2410 abbr = tv_get_bool(&argvars[0]); | |
2405 | 2411 |
2406 if (rettv_list_alloc(rettv) != OK) | 2412 if (rettv_list_alloc(rettv) != OK) |
2407 return; | 2413 return; |
2408 | 2414 |
2409 validate_maphash(); | 2415 validate_maphash(); |
2411 // Do it twice: once for global maps and once for local maps. | 2417 // Do it twice: once for global maps and once for local maps. |
2412 for (buffer_local = 0; buffer_local <= 1; ++buffer_local) | 2418 for (buffer_local = 0; buffer_local <= 1; ++buffer_local) |
2413 { | 2419 { |
2414 for (hash = 0; hash < 256; ++hash) | 2420 for (hash = 0; hash < 256; ++hash) |
2415 { | 2421 { |
2416 if (buffer_local) | 2422 if (abbr) |
2423 { | |
2424 if (hash > 0) // there is only one abbr list | |
2425 break; | |
2426 if (buffer_local) | |
2427 mp = curbuf->b_first_abbr; | |
2428 else | |
2429 mp = first_abbr; | |
2430 } | |
2431 else if (buffer_local) | |
2417 mp = curbuf->b_maphash[hash]; | 2432 mp = curbuf->b_maphash[hash]; |
2418 else | 2433 else |
2419 mp = maphash[hash]; | 2434 mp = maphash[hash]; |
2420 for (; mp; mp = mp->m_next) | 2435 for (; mp; mp = mp->m_next) |
2421 { | 2436 { |