Skip to content

Commit 2d97e5a

Browse files
committed
updated for version 7.3.514
Problem: No completion for :history command. Solution: Add the completion and update the docs. Also fix ":behave" completion. (Dominique Pelle)
1 parent f1375ac commit 2d97e5a

File tree

6 files changed

+59
-8
lines changed

6 files changed

+59
-8
lines changed

runtime/doc/cmdline.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -330,12 +330,12 @@ terminals)
330330

331331
:his[tory] [{name}] [{first}][, [{last}]]
332332
List the contents of history {name} which can be:
333-
c[md] or : command-line history
334-
s[earch] or / search string history
335-
e[xpr] or = expression register history
336-
i[nput] or @ input line history
337-
d[ebug] or > debug command history
338-
a[ll] all of the above
333+
c[md] or : command-line history
334+
s[earch] or / or ? search string history
335+
e[xpr] or = expression register history
336+
i[nput] or @ input line history
337+
d[ebug] or > debug command history
338+
a[ll] all of the above
339339
{not in Vi}
340340

341341
If the numbers {first} and/or {last} are given, the respective

runtime/doc/map.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1219,6 +1219,7 @@ completion can be enabled:
12191219

12201220
-complete=augroup autocmd groups
12211221
-complete=buffer buffer names
1222+
-complete=behave :behave suboptions
12221223
-complete=color color schemes
12231224
-complete=command Ex command (and arguments)
12241225
-complete=compiler compilers
@@ -1233,6 +1234,7 @@ completion can be enabled:
12331234
-complete=function function name
12341235
-complete=help help subjects
12351236
-complete=highlight highlight groups
1237+
-complete=history :history suboptions
12361238
-complete=locale locale names (as output of locale -a)
12371239
-complete=mapping mapping name
12381240
-complete=menu menus

src/ex_docmd.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3920,8 +3920,16 @@ set_one_cmd_context(xp, buff)
39203920
#endif
39213921
case CMD_behave:
39223922
xp->xp_context = EXPAND_BEHAVE;
3923+
xp->xp_pattern = arg;
39233924
break;
39243925

3926+
#if defined(FEAT_CMDHIST)
3927+
case CMD_history:
3928+
xp->xp_context = EXPAND_HISTORY;
3929+
xp->xp_pattern = arg;
3930+
break;
3931+
#endif
3932+
39253933
#endif /* FEAT_CMDL_COMPL */
39263934

39273935
default:
@@ -5329,6 +5337,7 @@ static struct
53295337
} command_complete[] =
53305338
{
53315339
{EXPAND_AUGROUP, "augroup"},
5340+
{EXPAND_BEHAVE, "behave"},
53325341
{EXPAND_BUFFERS, "buffer"},
53335342
{EXPAND_COLORS, "color"},
53345343
{EXPAND_COMMANDS, "command"},
@@ -5350,8 +5359,11 @@ static struct
53505359
{EXPAND_FUNCTIONS, "function"},
53515360
{EXPAND_HELP, "help"},
53525361
{EXPAND_HIGHLIGHT, "highlight"},
5362+
#if defined(FEAT_CMDHIST)
5363+
{EXPAND_HISTORY, "history"},
5364+
#endif
53535365
#if (defined(HAVE_LOCALE_H) || defined(X_LOCALE)) \
5354-
&& (defined(FEAT_GETTEXT) || defined(FEAT_MBYTE))
5366+
&& (defined(FEAT_GETTEXT) || defined(FEAT_MBYTE))
53555367
{EXPAND_LOCALES, "locale"},
53565368
#endif
53575369
{EXPAND_MAPPINGS, "mapping"},

src/ex_getln.c

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ struct cmdline_info
2525
int cmdlen; /* number of chars in command line */
2626
int cmdpos; /* current cursor position */
2727
int cmdspos; /* cursor column on screen */
28-
int cmdfirstc; /* ':', '/', '?', '=' or NUL */
28+
int cmdfirstc; /* ':', '/', '?', '=', '>' or NUL */
2929
int cmdindent; /* number of spaces before cmdline */
3030
char_u *cmdprompt; /* message in front of cmdline */
3131
int cmdattr; /* attributes for prompt */
@@ -111,6 +111,9 @@ static int expand_showtail __ARGS((expand_T *xp));
111111
#ifdef FEAT_CMDL_COMPL
112112
static int expand_shellcmd __ARGS((char_u *filepat, int *num_file, char_u ***file, int flagsarg));
113113
static int ExpandRTDir __ARGS((char_u *pat, int *num_file, char_u ***file, char *dirname[]));
114+
# ifdef FEAT_CMDHIST
115+
static char_u *get_history_arg __ARGS((expand_T *xp, int idx));
116+
# endif
114117
# if defined(FEAT_USR_CMDS) && defined(FEAT_EVAL)
115118
static int ExpandUserDefined __ARGS((expand_T *xp, regmatch_T *regmatch, int *num_file, char_u ***file));
116119
static int ExpandUserList __ARGS((expand_T *xp, int *num_file, char_u ***file));
@@ -4628,6 +4631,9 @@ ExpandFromContext(xp, pat, num_file, file, options)
46284631
{
46294632
{EXPAND_COMMANDS, get_command_name, FALSE, TRUE},
46304633
{EXPAND_BEHAVE, get_behave_arg, TRUE, TRUE},
4634+
#ifdef FEAT_CMDHIST
4635+
{EXPAND_HISTORY, get_history_arg, TRUE, TRUE},
4636+
#endif
46314637
#ifdef FEAT_USR_CMDS
46324638
{EXPAND_USER_COMMANDS, get_user_commands, FALSE, TRUE},
46334639
{EXPAND_USER_CMD_FLAGS, get_user_cmd_flags, FALSE, TRUE},
@@ -5245,6 +5251,34 @@ static char *(history_names[]) =
52455251
NULL
52465252
};
52475253

5254+
#if defined(FEAT_CMDL_COMPL) || defined(PROTO)
5255+
/*
5256+
* Function given to ExpandGeneric() to obtain the possible first
5257+
* arguments of the ":history command.
5258+
*/
5259+
static char_u *
5260+
get_history_arg(xp, idx)
5261+
expand_T *xp UNUSED;
5262+
int idx;
5263+
{
5264+
static char_u compl[2] = { NUL, NUL };
5265+
char *short_names = ":=@>?/";
5266+
int short_names_count = STRLEN(short_names);
5267+
int history_name_count = sizeof(history_names) / sizeof(char *) - 1;
5268+
5269+
if (idx < short_names_count)
5270+
{
5271+
compl[0] = (char_u)short_names[idx];
5272+
return compl;
5273+
}
5274+
if (idx < short_names_count + history_name_count)
5275+
return (char_u *)history_names[idx - short_names_count];
5276+
if (idx == short_names_count + history_name_count)
5277+
return (char_u *)"all";
5278+
return NULL;
5279+
}
5280+
#endif
5281+
52485282
/*
52495283
* init_history() - Initialize the command line history.
52505284
* Also used to re-allocate the history when the size changes.

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -714,6 +714,8 @@ static char *(features[]) =
714714

715715
static int included_patches[] =
716716
{ /* Add new patch number below this line */
717+
/**/
718+
514,
717719
/**/
718720
513,
719721
/**/

src/vim.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -781,6 +781,7 @@ extern char *(*dyn_libintl_textdomain)(const char *domainname);
781781
#define EXPAND_FILES_IN_PATH 38
782782
#define EXPAND_OWNSYNTAX 39
783783
#define EXPAND_LOCALES 40
784+
#define EXPAND_HISTORY 41
784785

785786
/* Values for exmode_active (0 is no exmode) */
786787
#define EXMODE_NORMAL 1

0 commit comments

Comments
 (0)