Hi clime!

On Mi, 13 Feb 2013, clime wrote:

> With respect to this thread on so:
> http://stackoverflow.com/questions/14842987/vim-wildmenu-move-into-subdirectory-with-a-different-key-than-down
> 
> It seems like command-line mappings aren't interpreted in wildmenu
> mode, and instead exit it and insert the 'wildchar' literally.
>
> Would it be possible to interpret these mappings and potentially add
> wildmenuvisible() - a function analog to the pumvisible()?

Looks like a bug to me. However, I think, if you set wildcharm=<Tab> you 
can make your mapping work:

:set wildcharm=<Tab>
:cnoremap <C-j> <DOWN><Tab>

I agree, this is not really useful, without a wildmodevisual() function, 
so you could do:
:cnoremap <expr> <C-j> wildmodevisible() ? "\<Down>\<Tab>" : "\<c-j>"

Attached patch enables this. Probably needs a test, but not sure how.

regards,
Christian
-- 
Eine dumme, einfältige Frau ist ein Segen des Himmels.
                -- François Marie Voltaire

-- 
-- 
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].
For more options, visit https://groups.google.com/groups/opt_out.


diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt
--- a/runtime/doc/eval.txt
+++ b/runtime/doc/eval.txt
@@ -1992,6 +1992,7 @@
 values( {dict})			List	values in {dict}
 virtcol( {expr})		Number	screen column of cursor or mark
 visualmode( [expr])		String	last visual mode used
+wildmodevisible()		Number	whether 'wildmode' is visible
 winbufnr( {nr})			Number	buffer number of window {nr}
 wincol()			Number	window column of the cursor
 winheight( {nr})		Number	height of window {nr}
@@ -6156,6 +6157,17 @@
 		Dictionary or Float is not a Number or String, thus does not
 		cause the mode to be cleared.
 
+wildmodevisible()					*wildmodevisible()*
+		Returns non-zero when the wildmode is visible, zero
+		otherwise.  See 'wildmode'
+		This can be used in mappings to handle the 'wildcharm' option
+		gracefully. (Makes only sense with |mapmode-c| mappings).
+		For example to make <c-j> work like <down> in wildmode, use: >
+    :cnoremap <expr> <C-j> wildmodevisible() ? "\<Down>\<Tab>" : "\<c-j>"
+<
+		(Note, this needs the 'wildcharm' option set appropriately).
+
+
 							*winbufnr()*
 winbufnr({nr})	The result is a Number, which is the number of the buffer
 		associated with window {nr}.  When {nr} is zero, the number of
diff --git a/runtime/doc/usr_41.txt b/runtime/doc/usr_41.txt
--- a/runtime/doc/usr_41.txt
+++ b/runtime/doc/usr_41.txt
@@ -863,12 +863,15 @@
 	winsaveview()		get view of current window
 	winrestview()		restore saved view of current window
 
+Mappings:				    *mapping-functions*
+	hasmapto()		check if a mapping exists
+	mapcheck()		check if a matching mapping exists
+	maparg()		get rhs of a mapping
+	wildmodevisible()	check if the wildmode is active
+
 Various:					*various-functions*
 	mode()			get current editing mode
 	visualmode()		last visual mode used
-	hasmapto()		check if a mapping exists
-	mapcheck()		check if a matching mapping exists
-	maparg()		get rhs of a mapping
 	exists()		check if a variable, function, etc. exists
 	has()			check if a feature is supported in Vim
 	changenr()		return number of most recent change
diff --git a/src/eval.c b/src/eval.c
--- a/src/eval.c
+++ b/src/eval.c
@@ -748,6 +748,7 @@
 static void f_values __ARGS((typval_T *argvars, typval_T *rettv));
 static void f_virtcol __ARGS((typval_T *argvars, typval_T *rettv));
 static void f_visualmode __ARGS((typval_T *argvars, typval_T *rettv));
+static void f_wimvisible __ARGS((typval_T *argvars, typval_T *rettv));
 static void f_winbufnr __ARGS((typval_T *argvars, typval_T *rettv));
 static void f_wincol __ARGS((typval_T *argvars, typval_T *rettv));
 static void f_winheight __ARGS((typval_T *argvars, typval_T *rettv));
@@ -8114,6 +8115,7 @@
     {"undotree",	0, 0, f_undotree},
     {"values",		1, 1, f_values},
     {"virtcol",		1, 1, f_virtcol},
+    {"wildmodevisible",	0, 0, f_wimvisible},
     {"visualmode",	0, 1, f_visualmode},
     {"winbufnr",	1, 1, f_winbufnr},
     {"wincol",		0, 0, f_wincol},
@@ -18551,6 +18553,19 @@
 	curbuf->b_visual_mode_eval = NUL;
 #endif
 }
+/*
+ * "wildmodevisible()" function
+ */
+    static void
+f_wimvisible(argvars, rettv)
+    typval_T	*argvars UNUSED;
+    typval_T	*rettv UNUSED;
+{
+#ifdef FEAT_WILDMENU
+    if (wild_menu_showing)
+	rettv->vval.v_number = 1;
+#endif
+}
 
 /*
  * "winbufnr(nr)" function

Raspunde prin e-mail lui