]> granicus.if.org Git - vim/commitdiff
patch 8.0.1649: no completion for argument list commands v8.0.1649
authorBram Moolenaar <Bram@vim.org>
Thu, 29 Mar 2018 13:55:38 +0000 (15:55 +0200)
committerBram Moolenaar <Bram@vim.org>
Thu, 29 Mar 2018 13:55:38 +0000 (15:55 +0200)
Problem:    No completion for argument list commands.
Solution:   Add arglist completion. (Yegappan Lakshmanan, closes #2706)

runtime/doc/eval.txt
runtime/doc/map.txt
src/ex_cmds2.c
src/ex_docmd.c
src/ex_getln.c
src/proto/ex_cmds2.pro
src/testdir/test_cmdline.vim
src/version.c
src/vim.h

index 387186f83df0f81b89ad0be8f44e0a4f9f959ac4..e5f0b10a575529084e8e2948bd32b1593a4f782b 100644 (file)
@@ -4469,6 +4469,7 @@ getcompletion({pat}, {type} [, {filtered}])               *getcompletion()*
                specifies what for.  The following completion types are
                supported:
 
+               arglist         file names in argument list
                augroup         autocmd groups
                buffer          buffer names
                behave          :behave suboptions
index 2efeb3bc6190e22cca203d40827ca2acac4139cc..18763f439fc1b99bc02d03be39e412d9ff108c80 100644 (file)
@@ -1272,6 +1272,7 @@ By default, the arguments of user defined commands do not undergo completion.
 However, by specifying one or the other of the following attributes, argument
 completion can be enabled:
 
+       -complete=arglist       file names in argument list
        -complete=augroup       autocmd groups
        -complete=buffer        buffer names
        -complete=behave        :behave suboptions
index ae4ce337d0f56f9dbca71e787d0d09770f62af39..d4ddb82b7b1941123755ab93630b18b93b1e4b56 100644 (file)
@@ -3314,6 +3314,21 @@ alist_add_list(
 
 #endif /* FEAT_LISTCMDS */
 
+#if defined(FEAT_CMDL_COMPL) || defined(PROTO)
+/*
+ * Function given to ExpandGeneric() to obtain the possible arguments of the
+ * argedit and argdelete commands.
+ */
+    char_u *
+get_arglist_name(expand_T *xp UNUSED, int idx)
+{
+    if (idx >= ARGCOUNT)
+       return NULL;
+
+    return alist_name(&ARGLIST[idx]);
+}
+#endif
+
 #ifdef FEAT_EVAL
 /*
  * ":compiler[!] {name}"
index 97bbd042918cc4cc9dde1d8e4c8ebe96386d133c..c2d69670b8eeac73228b0801eecc31bc7b3505d9 100644 (file)
@@ -4293,6 +4293,13 @@ set_one_cmd_context(
            break;
 #endif
 
+       case CMD_argdelete:
+           while ((xp->xp_pattern = vim_strchr(arg, ' ')) != NULL)
+               arg = xp->xp_pattern + 1;
+           xp->xp_context = EXPAND_ARGLIST;
+           xp->xp_pattern = arg;
+           break;
+
 #endif /* FEAT_CMDL_COMPL */
 
        default:
@@ -5879,6 +5886,7 @@ static struct
     char    *name;
 } command_complete[] =
 {
+    {EXPAND_ARGLIST, "arglist"},
     {EXPAND_AUGROUP, "augroup"},
     {EXPAND_BEHAVE, "behave"},
     {EXPAND_BUFFERS, "buffer"},
index 6119ad216361794447d21b8a169fc4ebe5cc2865..48cccf18e04609a2b0606718efefac655889c050 100644 (file)
@@ -4989,6 +4989,7 @@ ExpandFromContext(
 #endif
            {EXPAND_ENV_VARS, get_env_name, TRUE, TRUE},
            {EXPAND_USER, get_users, TRUE, FALSE},
+           {EXPAND_ARGLIST, get_arglist_name, TRUE, FALSE},
        };
        int     i;
 
index 63d377d64bca0f91513b0b14fb8c689c061b07dc..a7d19d768fec7821115aadf33162e8dbac43257f 100644 (file)
@@ -67,6 +67,7 @@ void ex_argedit(exarg_T *eap);
 void ex_argadd(exarg_T *eap);
 void ex_argdelete(exarg_T *eap);
 void ex_listdo(exarg_T *eap);
+char_u *get_arglist_name(expand_T *xp, int idx);
 void ex_compiler(exarg_T *eap);
 void ex_runtime(exarg_T *eap);
 int do_in_path(char_u *path, char_u *name, int flags, void (*callback)(char_u *fname, void *ck), void *cookie);
index 832413e813f957f91f4358e062995571faac0722..8755fbf1aaf9623a822a79f3e58934ec9fa1dbba 100644 (file)
@@ -137,6 +137,11 @@ func Test_getcompletion()
   let l = getcompletion('v:notexists', 'var')
   call assert_equal([], l)
 
+  args a.c b.c
+  let l = getcompletion('', 'arglist')
+  call assert_equal(['a.c', 'b.c'], l)
+  %argdelete
+
   let l = getcompletion('', 'augroup')
   call assert_true(index(l, 'END') >= 0)
   let l = getcompletion('blahblah', 'augroup')
index 00a07bc1068063911ac4aad9c2405e6e89a34fe3..1e277129c3abf56db8bcacbb4eb1ec5fe1d04cd5 100644 (file)
@@ -766,6 +766,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1649,
 /**/
     1648,
 /**/
index 42007edb6fc71142c5f430ab6c968334f1d7c869..626c0ad12015eb58d9730472584f44dbfe74624f 100644 (file)
--- a/src/vim.h
+++ b/src/vim.h
@@ -781,6 +781,7 @@ extern int (*dyn_libintl_putenv)(const char *envstring);
 #define EXPAND_PACKADD         45
 #define EXPAND_MESSAGES                46
 #define EXPAND_MAPCLEAR                47
+#define EXPAND_ARGLIST         48
 
 /* Values for exmode_active (0 is no exmode) */
 #define EXMODE_NORMAL          1