summaryrefslogtreecommitdiffstats
path: root/src/ex_getln.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2012-04-30 18:48:53 +0200
committerBram Moolenaar <Bram@vim.org>2012-04-30 18:48:53 +0200
commit5ae636b9bbcb6ac851cdf6910c0e6b8e1b79ed76 (patch)
treecd78fc2191dbc6f86172e28bfd37b959a4e0c9ac /src/ex_getln.c
parent8320da42bc443fa5c76710d331f6b8c3cfc2981e (diff)
updated for version 7.3.514v7.3.514
Problem: No completion for :history command. Solution: Add the completion and update the docs. Also fix ":behave" completion. (Dominique Pelle)
Diffstat (limited to 'src/ex_getln.c')
-rw-r--r--src/ex_getln.c36
1 files changed, 35 insertions, 1 deletions
diff --git a/src/ex_getln.c b/src/ex_getln.c
index 38775af605..3d0c26f05e 100644
--- a/src/ex_getln.c
+++ b/src/ex_getln.c
@@ -25,7 +25,7 @@ struct cmdline_info
int cmdlen; /* number of chars in command line */
int cmdpos; /* current cursor position */
int cmdspos; /* cursor column on screen */
- int cmdfirstc; /* ':', '/', '?', '=' or NUL */
+ int cmdfirstc; /* ':', '/', '?', '=', '>' or NUL */
int cmdindent; /* number of spaces before cmdline */
char_u *cmdprompt; /* message in front of cmdline */
int cmdattr; /* attributes for prompt */
@@ -111,6 +111,9 @@ static int expand_showtail __ARGS((expand_T *xp));
#ifdef FEAT_CMDL_COMPL
static int expand_shellcmd __ARGS((char_u *filepat, int *num_file, char_u ***file, int flagsarg));
static int ExpandRTDir __ARGS((char_u *pat, int *num_file, char_u ***file, char *dirname[]));
+# ifdef FEAT_CMDHIST
+static char_u *get_history_arg __ARGS((expand_T *xp, int idx));
+# endif
# if defined(FEAT_USR_CMDS) && defined(FEAT_EVAL)
static int ExpandUserDefined __ARGS((expand_T *xp, regmatch_T *regmatch, int *num_file, char_u ***file));
static int ExpandUserList __ARGS((expand_T *xp, int *num_file, char_u ***file));
@@ -4628,6 +4631,9 @@ ExpandFromContext(xp, pat, num_file, file, options)
{
{EXPAND_COMMANDS, get_command_name, FALSE, TRUE},
{EXPAND_BEHAVE, get_behave_arg, TRUE, TRUE},
+#ifdef FEAT_CMDHIST
+ {EXPAND_HISTORY, get_history_arg, TRUE, TRUE},
+#endif
#ifdef FEAT_USR_CMDS
{EXPAND_USER_COMMANDS, get_user_commands, FALSE, TRUE},
{EXPAND_USER_CMD_FLAGS, get_user_cmd_flags, FALSE, TRUE},
@@ -5245,6 +5251,34 @@ static char *(history_names[]) =
NULL
};
+#if defined(FEAT_CMDL_COMPL) || defined(PROTO)
+/*
+ * Function given to ExpandGeneric() to obtain the possible first
+ * arguments of the ":history command.
+ */
+ static char_u *
+get_history_arg(xp, idx)
+ expand_T *xp UNUSED;
+ int idx;
+{
+ static char_u compl[2] = { NUL, NUL };
+ char *short_names = ":=@>?/";
+ int short_names_count = STRLEN(short_names);
+ int history_name_count = sizeof(history_names) / sizeof(char *) - 1;
+
+ if (idx < short_names_count)
+ {
+ compl[0] = (char_u)short_names[idx];
+ return compl;
+ }
+ if (idx < short_names_count + history_name_count)
+ return (char_u *)history_names[idx - short_names_count];
+ if (idx == short_names_count + history_name_count)
+ return (char_u *)"all";
+ return NULL;
+}
+#endif
+
/*
* init_history() - Initialize the command line history.
* Also used to re-allocate the history when the size changes.