vim-patch:7.4.2231
Problem: ":oldfiles" output is a very long list.
Solution: Add a pattern argument. (Coot, closes vim/vim#575)
e11d61a3b1
This commit is contained in:
parent
0df1b6655b
commit
dbdc2d40bb
|
@ -1182,12 +1182,21 @@ running) you have additional options:
|
|||
*:o* *:ol* *:oldfiles*
|
||||
:o[ldfiles] List the files that have marks stored in the ShaDa
|
||||
file. This list is read on startup and only changes
|
||||
afterwards with ":rshada!". Also see |v:oldfiles|.
|
||||
afterwards with `:rshada!`. Also see |v:oldfiles|.
|
||||
The number can be used with |c_#<|.
|
||||
The output can be filtered with |:filter|, e.g.: >
|
||||
filter /\.vim/ oldfiles
|
||||
< The filtering happens on the file name.
|
||||
|
||||
:ol[dfiles] {pat}
|
||||
:ol[dfiles] /{pat}/
|
||||
Like `:oldfiles` but only files matching {pat} will
|
||||
be included. {pat} is a Vim search pattern. Instead
|
||||
of enclosing it in / any non-ID character (see
|
||||
|'isident'|) can be used, so long as it does not
|
||||
appear in {pat}. Without the enclosing character the
|
||||
pattern cannot include the bar character.
|
||||
|
||||
:bro[wse] o[ldfiles][!]
|
||||
List file names as with |:oldfiles|, and then prompt
|
||||
for a number. When the number is valid that file from
|
||||
|
|
|
@ -21779,52 +21779,6 @@ void last_set_msg(scid_T scriptID)
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* List v:oldfiles in a nice way.
|
||||
*/
|
||||
void ex_oldfiles(exarg_T *eap)
|
||||
{
|
||||
list_T *l = get_vim_var_list(VV_OLDFILES);
|
||||
listitem_T *li;
|
||||
long nr = 0;
|
||||
|
||||
if (l == NULL)
|
||||
msg((char_u *)_("No old files"));
|
||||
else {
|
||||
msg_start();
|
||||
msg_scroll = TRUE;
|
||||
for (li = l->lv_first; li != NULL && !got_int; li = li->li_next) {
|
||||
msg_outnum(++nr);
|
||||
MSG_PUTS(": ");
|
||||
msg_outtrans((char_u *)tv_get_string(&li->li_tv));
|
||||
msg_clr_eos();
|
||||
msg_putchar('\n');
|
||||
ui_flush(); /* output one line at a time */
|
||||
os_breakcheck();
|
||||
}
|
||||
/* Assume "got_int" was set to truncate the listing. */
|
||||
got_int = FALSE;
|
||||
|
||||
// File selection prompt on ":browse oldfiles"
|
||||
if (cmdmod.browse) {
|
||||
quit_more = false;
|
||||
nr = prompt_for_number(false);
|
||||
msg_starthere();
|
||||
if (nr > 0 && nr <= l->lv_len) {
|
||||
const char *const p = tv_list_find_str(l, nr - 1);
|
||||
if (p == NULL) {
|
||||
return;
|
||||
}
|
||||
char *const s = (char *)expand_env_save((char_u *)p);
|
||||
eap->arg = (char_u *)s;
|
||||
eap->cmdidx = CMD_edit;
|
||||
do_exedit(eap, NULL);
|
||||
xfree(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// reset v:option_new, v:option_old and v:option_type
|
||||
void reset_v_option_vars(void)
|
||||
{
|
||||
|
|
|
@ -6158,3 +6158,71 @@ void ex_substitute(exarg_T *eap)
|
|||
ga_clear(&save_view);
|
||||
unblock_autocmds();
|
||||
}
|
||||
|
||||
/// List v:oldfiles in a nice way.
|
||||
void ex_oldfiles(exarg_T *eap)
|
||||
{
|
||||
list_T *l = get_vim_var_list(VV_OLDFILES);
|
||||
listitem_T *li;
|
||||
long nr = 0;
|
||||
|
||||
if (l == NULL) {
|
||||
msg((char_u *)_("No old files"));
|
||||
} else {
|
||||
char_u *reg_pat = NULL;
|
||||
regmatch_T regmatch;
|
||||
|
||||
if (*eap->arg != NUL) {
|
||||
if (skip_vimgrep_pat(eap->arg, ®_pat, NULL) == NULL) {
|
||||
EMSG(_(e_invalpat));
|
||||
return;
|
||||
}
|
||||
regmatch.regprog = vim_regcomp(reg_pat, p_magic ? RE_MAGIC : 0);
|
||||
if (regmatch.regprog == NULL) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
msg_start();
|
||||
msg_scroll = TRUE;
|
||||
for (li = l->lv_first; li != NULL && !got_int; li = li->li_next) {
|
||||
nr++;
|
||||
const char *fname = tv_get_string(&li->li_tv);
|
||||
if (reg_pat == NULL || *reg_pat == NUL
|
||||
|| vim_regexec(®match, (char_u *)fname, (colnr_T)0)) {
|
||||
msg_outnum(nr);
|
||||
MSG_PUTS(": ");
|
||||
msg_outtrans((char_u *)tv_get_string(&li->li_tv));
|
||||
msg_clr_eos();
|
||||
msg_putchar('\n');
|
||||
ui_flush(); // output one line at a time
|
||||
os_breakcheck();
|
||||
}
|
||||
}
|
||||
if (*eap->arg != NUL) {
|
||||
vim_regfree(regmatch.regprog);
|
||||
}
|
||||
|
||||
/* Assume "got_int" was set to truncate the listing. */
|
||||
got_int = FALSE;
|
||||
|
||||
// File selection prompt on ":browse oldfiles"
|
||||
if (cmdmod.browse) {
|
||||
quit_more = false;
|
||||
nr = prompt_for_number(false);
|
||||
msg_starthere();
|
||||
if (nr > 0 && nr <= l->lv_len) {
|
||||
const char *const p = tv_list_find_str(l, nr - 1);
|
||||
if (p == NULL) {
|
||||
return;
|
||||
}
|
||||
char *const s = (char *)expand_env_save((char_u *)p);
|
||||
eap->arg = (char_u *)s;
|
||||
eap->cmdidx = CMD_edit;
|
||||
cmdmod.browse = false;
|
||||
do_exedit(eap, NULL);
|
||||
xfree(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1810,7 +1810,7 @@ return {
|
|||
},
|
||||
{
|
||||
command='oldfiles',
|
||||
flags=bit.bor(BANG, TRLBAR, SBOXOK, CMDWIN),
|
||||
flags=bit.bor(BANG, TRLBAR, NOTADR, EXTRA, SBOXOK, CMDWIN),
|
||||
addr_type=ADDR_LINES,
|
||||
func='ex_oldfiles',
|
||||
},
|
||||
|
|
|
@ -213,7 +213,7 @@ static const int included_patches[] = {
|
|||
// 2234 NA
|
||||
2233,
|
||||
// 2232 NA
|
||||
// 2231,
|
||||
2231,
|
||||
2230,
|
||||
// 2229,
|
||||
2228,
|
||||
|
|
Loading…
Reference in New Issue