2013年5月31日金曜日 15時05分18秒 UTC+9 ZyX:
> Sorry, missed this part of the discussion when writing my previous reply.
>
> On May 31, 2013 7:25 AM, "Shougo" <[email protected]> wrote:
>
> > From your description, I think I'd rather see this as an additional value
> > or values supported in 'completeopt'. Currently the only control over what
> > gets inserted is "longest". If it's there, only part of the match text gets
> > inserted, otherwise, the whole first match gets inserted. Why not add a
> > "noinsert" or something, and maybe a "noselect"?
>
>
> >
>
> > I.e., you could make the list at :help 'completeopt' look like:
>
> >
>
> > menu Use a popup menu to show the possible completions. The
>
> > menu is only shown when there is more than one match and
>
> > sufficient colors are available. |ins-completion-menu|
>
> >
>
> > menuone Use the popup menu also when there is only one match.
>
> > Useful when there is additional information about the
>
> > match, e.g., what file it comes from.
>
> >
>
> > longest Only insert the longest common text of the matches. If
>
> > the menu is displayed you can use CTRL-L to add more
>
> > characters. Whether case is ignored depends on the kind
>
> > of completion. For buffer text the 'ignorecase' option is
>
> > used.
>
> >
>
> > preview Show extra information about the currently selected
>
> > completion in the preview window. Only works in
>
> > combination with "menu" or "menuone".
>
> >
>
> > noinsert Do not insert any text for a match until the user selects
> > a
>
> > match from the menu. Only works in combination with "menu"
>
> > or "menuone". No effect if "longest" is present.
>
> >
>
> > noselect Do not select a match in the menu, force the user to
> > select
>
> > one from the menu. Only works in combination with "menu"
> > or
>
> > "menuone".
>
>
>
> Thank you for the suggestion.
>
> I updated the patch to extend completeopt.
>
> Can you try it?
>
>
>
> --
>
> --
>
> 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.
Thanks for the suggestion.
I and Nayuri Aohime(http://www.vim.org/account/profile.php?user_id=66623)
updated the patch to remove the magic number.
Could you check it?
To Mr.zhaochai,
> noinsert and noselect are not good names. How about autoinsert and
> autoselect? Change (default: "menu,preview") => (default:
> "menu,preview,autoinsert,autoselect")?
Yes. "noinsert" and "noselect" are bad name.
But if users uses below settings, your features will break backward
compatibility..
set completeopt=menuone,preview
And in many plugins, it set completeopt directory(not using +=/-= features).
Example: jedi-vim
https://github.com/davidhalter/jedi-vim/blob/master/ftplugin/python/jedi.vim#L39
if g:jedi#auto_vim_configuration
setlocal completeopt=menuone,longest,preview
if len(mapcheck('<C-c>', 'i')) == 0
inoremap <C-c> <ESC>
end
end
I think backward compatibility is very important in Vim world.
--
--
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 -r b792349dc858 runtime/doc/options.txt
--- a/runtime/doc/options.txt Thu May 30 22:44:02 2013 +0200
+++ b/runtime/doc/options.txt Fri May 31 15:52:21 2013 +0900
@@ -1785,6 +1785,14 @@
completion in the preview window. Only works in
combination with "menu" or "menuone".
+ noinsert Do not insert any text for a match until the user selects
+ a match from the menu. Only works in combination with "menu"
+ or "menuone". No effect if "longest" is present.
+
+ noselect Do not select a match in the menu, force the user to
+ select one from the menu. Only works in combination with "menu"
+ or "menuone".
+
*'concealcursor'* *'cocu'*
'concealcursor' 'cocu' string (default: "")
diff -r b792349dc858 src/edit.c
--- a/src/edit.c Thu May 30 22:44:02 2013 +0200
+++ b/src/edit.c Fri May 31 15:52:21 2013 +0900
@@ -105,6 +105,11 @@
static int compl_get_longest = FALSE; /* put longest common string
in compl_leader */
+static int compl_no_insert = FALSE; /* FALSE: select & insert
+ TRUE: noinsert */
+static int compl_no_select = FALSE; /* FALSE: select & insert
+ TRUE: noselect */
+
static int compl_used_match; /* Selected one of the matches. When
FALSE the match was edited or using
the longest common string. */
@@ -3641,8 +3646,24 @@
if (ctrl_x_mode == CTRL_X_NOT_DEFINED_YET
|| (ctrl_x_mode == 0 && !compl_started))
{
- compl_get_longest = (vim_strchr(p_cot, 'l') != NULL);
+ compl_get_longest = (strstr((char *)p_cot, "longest") != NULL);
compl_used_match = TRUE;
+
+ if (strstr((char *)p_cot, "noselect") != NULL)
+ {
+ compl_no_insert = FALSE;
+ compl_no_select = TRUE;
+ }
+ else if (strstr((char *)p_cot, "noinsert") != NULL)
+ {
+ compl_no_insert = TRUE;
+ compl_no_select = FALSE;
+ }
+ else
+ {
+ compl_no_insert = FALSE;
+ compl_no_select = FALSE;
+ }
}
if (ctrl_x_mode == CTRL_X_NOT_DEFINED_YET)
@@ -4622,6 +4643,7 @@
compl_T *found_compl = NULL;
int found_end = FALSE;
int advance;
+ int started = compl_started;
/* When user complete function return -1 for findstart which is next
* time of 'always', compl_shown_match become NULL. */
@@ -4703,7 +4725,7 @@
return -1;
}
- if (advance)
+ if (!compl_no_select && advance)
{
if (compl_shows_dir == BACKWARD)
--compl_pending;
@@ -4755,7 +4777,11 @@
}
/* Insert the text of the new completion, or the compl_leader. */
- if (insert_match)
+ if (compl_no_insert && !started) {
+ ins_bytes(compl_orig_text + ins_compl_len());
+ compl_used_match = FALSE;
+ }
+ else if (insert_match)
{
if (!compl_get_longest || compl_used_match)
ins_compl_insert();
@@ -4792,7 +4818,10 @@
/* Enter will select a match when the match wasn't inserted and the popup
* menu is visible. */
- compl_enter_selects = !insert_match && compl_match_array != NULL;
+ if (compl_no_insert && !started)
+ compl_enter_selects = TRUE;
+ else
+ compl_enter_selects = !insert_match && compl_match_array != NULL;
/*
* Show the file name for the match (if any)
@@ -4867,7 +4896,7 @@
}
}
}
- if (compl_pending != 0 && !got_int)
+ if (compl_pending != 0 && !got_int && !compl_no_insert)
{
int todo = compl_pending > 0 ? compl_pending : -compl_pending;
diff -r b792349dc858 src/option.c
--- a/src/option.c Thu May 30 22:44:02 2013 +0200
+++ b/src/option.c Fri May 31 15:52:21 2013 +0900
@@ -2994,7 +2994,7 @@
static char *(p_fcl_values[]) = {"all", NULL};
#endif
#ifdef FEAT_INS_EXPAND
-static char *(p_cot_values[]) = {"menu", "menuone", "longest", "preview", NULL};
+static char *(p_cot_values[]) = {"menu", "menuone", "longest", "preview", "noinsert", "noselect", NULL};
#endif
static void set_option_default __ARGS((int, int opt_flags, int compatible));