Please make mode() return i_CTRL-X sub mode. Currently there seems to be no way to determine this. It would be very helpful for writing completion plugins.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
Since it's a sub mode of insert it should be "ix".
—
You are receiving this because you commented.
but mode() only returns one letter without argument.
—
You are receiving this because you commented.
#ifdef FEAT_INS_EXPAND if (ctrl_x_mode != 0) buf[0] = 'x'; else #endif
I tested the code. mode() all returns x as expected when pressing <C-x> alone, or combined with <C-d>, <C-f>, <C-i>, <C-v>, <C-l>, <C-s>, <C-o>, as well as <C-e>, <C-y>
Pressing <C-x><C-n> or <C-x><C-p>, mode() returns i.
I agree it should be ix since it's a sub-mode.
—
You are receiving this because you commented.
2017-1-20(Fri) 12:44:50 UTC+9 vim-dev ML:
> Hi,
>
>
>
> On Thu, Jan 19, 2017 at 3:56 PM, Zhen-Huan (Kenny) Hu
>
> <vim-dev...@256bit.org> wrote:
>
> > #ifdef FEAT_INS_EXPAND
>
> > if (ctrl_x_mode != 0)
>
> > buf[0] = 'x';
>
> > else
>
> > #endif
>
> >
>
> > I tested the code. mode() all returns x as expected when pressing <C-x>
>
> > alone, or combined with <C-d>, <C-f>, <C-i>, <C-v>, <C-l>, <C-s>, <C-o>, as
>
> > well as <C-e>, <C-y>
>
> >
>
> > Pressing <C-x><C-n> or <C-x><C-p>, mode() returns i.
>
> >
>
> > I agree it should be ix since it's a sub-mode.
>
> >
>
>
>
> An updated patch to return either "ix" or "Rx" is attached.
[...]
How about attached patch?
--
Best regards,
Hirohito Higashi (a.k.a. h_east)
—
diff --git a/src/evalfunc.c b/src/evalfunc.c index 4b6bfaa..1f3164f 100644 --- a/src/evalfunc.c +++ b/src/evalfunc.c @@ -7765,10 +7765,16 @@ f_mode(typval_T *argvars, typval_T *rettv) } else #endif - if (State & REPLACE_FLAG) - buf[0] = 'R'; - else - buf[0] = 'i'; + { + if (State & REPLACE_FLAG) + buf[0] = 'R'; + else + buf[0] = 'i'; +#ifdef FEAT_INS_EXPAND + if (ctrl_x_mode != 0) + buf[1] = 'x'; +#endif + } } else if (State & CMDLINE) {
I tested CTRL-X under both replace mode and insert mode. Under replace mode, mode(1) returns Rx and under insert mode, it returns ix.
As a side note, why CTRL-N/P and CTRL-X + CTRL-N/P behave differently than CTRL-X + others. It seems if CTRL-N/P cannot find a match, it will automatically return to the insert mode. If CTRL-X + others cannot find a match, it will stay under CTRL-X mode?
—
You are receiving this because you commented.
2017-1-21(Sat) 4:20:02 UTC+9 yega...@gmail.com:
That's right. Also, Virtual Replace is the same.
Unfortunately, Two letters are not enough for CTRL-X mode on Virtual Replace mode.
For example, how do we represent it in the following cases?
Type: gR<C-X>
Represent: Rvx ??
Thanks for many advice.
—
2017-1-23(Mon) 2:40:48 UTC+9 yega...@gmail.com:
`ins_compl_active()` should be referenced before referring to `ctrl_x_mode`.
My patch's 'x' means "wait for CTRL-X mode selection".
That is, when the following text is displayed on the last line.
-- ^X mode (^]^D^E^F^I^K^L^N^O^Ps^U^V^Y)
Thanks.
else if (ins_compl_active())
buf[1] = pum_visible() ? 'C' : 'c';
Does this 'C' vs. 'c' mean whether a completion was successful? I don't think pum_visible() alone is able to determine this accurately since it depends on whether the user have completeopt=menuone to have a menu if there is only one match. I'd rather not distinguish it in mode() and let it return 'ic' if ins_compl_active() no matther whether pum_visible().
—
You are receiving this because you commented.
2017-1-24(Tue) 2:03:05 UTC+9 Zhen-Huan (Kenny) Hu:
> else if (ins_compl_active())
>
>
>
> buf[1] = pum_visible() ? 'C' : 'c';
>
>
>
>
>
> Does this 'C' vs. 'c' mean whether a completion was successful? I don't think pum_visible() alone is able to determine this accurately since it depends on whether the user have completeopt=menuone to have a menu if there is only one match. I'd rather not distinguish it in mode() and let it return 'ic' if ins_compl_active() no matther whether pum_visible().
I was also thinking somewhat similar.
It's a idea level proposal.
Adding completion info built-in function ...
completion_info()
Returns a Dictionary with information about insert mode completion:
"active" When completion is active, set to 1.
"matches" Numner of matches.
"Searching_match_done" Searching match done.
"popupmenued" Popup menu displayed.
"inserted" Insert a match from the menu.
"selected" Select a match in the menu.
"ctrl_x_selecting" Waiting for the ctrl-x mode selection.
...
—