Skip to content

Commit 91f164c

Browse files
committed
updated for version 7.3.828
Problem: Mappings are not aware of wildmenu mode. Solution: Add wildmenumode(). (Christian Brabandt)
1 parent f868669 commit 91f164c

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

runtime/doc/eval.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1993,6 +1993,7 @@ undotree() List undo file tree
19931993
values( {dict}) List values in {dict}
19941994
virtcol( {expr}) Number screen column of cursor or mark
19951995
visualmode( [expr]) String last visual mode used
1996+
wildmenumode() Number whether 'wildmenu' mode is active
19961997
winbufnr( {nr}) Number buffer number of window {nr}
19971998
wincol() Number window column of the cursor
19981999
winheight( {nr}) Number height of window {nr}
@@ -6162,6 +6163,18 @@ visualmode([expr]) *visualmode()*
61626163
Dictionary or Float is not a Number or String, thus does not
61636164
cause the mode to be cleared.
61646165

6166+
wildmenumode() *wildmenumode()*
6167+
Returns non-zero when the wildmenu is active and zero
6168+
otherwise. See 'wildmenu' and 'wildmode'.
6169+
This can be used in mappings to handle the 'wildcharm' option
6170+
gracefully. (Makes only sense with |mapmode-c| mappings).
6171+
6172+
For example to make <c-j> work like <down> in wildmode, use: >
6173+
:cnoremap <expr> <C-j> wildmenumode() ? "\<Down>\<Tab>" : "\<c-j>"
6174+
<
6175+
(Note, this needs the 'wildcharm' option set appropriately).
6176+
6177+
61656178
*winbufnr()*
61666179
winbufnr({nr}) The result is a Number, which is the number of the buffer
61676180
associated with window {nr}. When {nr} is zero, the number of

src/eval.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -751,6 +751,7 @@ static void f_undotree __ARGS((typval_T *argvars, typval_T *rettv));
751751
static void f_values __ARGS((typval_T *argvars, typval_T *rettv));
752752
static void f_virtcol __ARGS((typval_T *argvars, typval_T *rettv));
753753
static void f_visualmode __ARGS((typval_T *argvars, typval_T *rettv));
754+
static void f_wildmenumode __ARGS((typval_T *argvars, typval_T *rettv));
754755
static void f_winbufnr __ARGS((typval_T *argvars, typval_T *rettv));
755756
static void f_wincol __ARGS((typval_T *argvars, typval_T *rettv));
756757
static void f_winheight __ARGS((typval_T *argvars, typval_T *rettv));
@@ -8121,6 +8122,7 @@ static struct fst
81218122
{"values", 1, 1, f_values},
81228123
{"virtcol", 1, 1, f_virtcol},
81238124
{"visualmode", 0, 1, f_visualmode},
8125+
{"wildmenumode", 0, 0, f_wildmenumode},
81248126
{"winbufnr", 1, 1, f_winbufnr},
81258127
{"wincol", 0, 0, f_wincol},
81268128
{"winheight", 1, 1, f_winheight},
@@ -18576,6 +18578,20 @@ f_visualmode(argvars, rettv)
1857618578
#endif
1857718579
}
1857818580

18581+
/*
18582+
* "wildmenumode()" function
18583+
*/
18584+
static void
18585+
f_wildmenumode(argvars, rettv)
18586+
typval_T *argvars UNUSED;
18587+
typval_T *rettv UNUSED;
18588+
{
18589+
#ifdef FEAT_WILDMENU
18590+
if (wild_menu_showing)
18591+
rettv->vval.v_number = 1;
18592+
#endif
18593+
}
18594+
1857918595
/*
1858018596
* "winbufnr(nr)" function
1858118597
*/

src/version.c

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

729729
static int included_patches[] =
730730
{ /* Add new patch number below this line */
731+
/**/
732+
828,
731733
/**/
732734
827,
733735
/**/

0 commit comments

Comments
 (0)