Mercurial > vim
comparison src/ex_cmds.c @ 9915:4da1a3879100 v7.4.2231
commit https://github.com/vim/vim/commit/e11d61a3b1cdedf3144de697a2b38af62c3a78d8
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Aug 20 18:36:54 2016 +0200
patch 7.4.2231
Problem: ":oldfiles" output is a very long list.
Solution: Add a pattern argument. (Coot, closes https://github.com/vim/vim/issues/575)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sat, 20 Aug 2016 18:45:05 +0200 |
parents | 5a667a3a3743 |
children | 05bfc3d37efb |
comparison
equal
deleted
inserted
replaced
9914:a0884512c300 | 9915:4da1a3879100 |
---|---|
8389 eap->cmdidx = CMD_first; | 8389 eap->cmdidx = CMD_first; |
8390 ex_rewind(eap); | 8390 ex_rewind(eap); |
8391 } | 8391 } |
8392 } | 8392 } |
8393 #endif | 8393 #endif |
8394 | |
8395 #if defined(FEAT_EVAL) || defined(PROTO) | |
8396 /* | |
8397 * List v:oldfiles in a nice way. | |
8398 */ | |
8399 void | |
8400 ex_oldfiles(exarg_T *eap UNUSED) | |
8401 { | |
8402 list_T *l = get_vim_var_list(VV_OLDFILES); | |
8403 listitem_T *li; | |
8404 int nr = 0; | |
8405 char_u *reg_pat = NULL; | |
8406 char_u *fname; | |
8407 regmatch_T regmatch; | |
8408 | |
8409 if (l == NULL) | |
8410 msg((char_u *)_("No old files")); | |
8411 else | |
8412 { | |
8413 if (*eap->arg != NUL) | |
8414 { | |
8415 if (skip_vimgrep_pat(eap->arg, ®_pat, NULL) == NULL) | |
8416 { | |
8417 EMSG(_(e_invalpat)); | |
8418 return; | |
8419 } | |
8420 regmatch.regprog = vim_regcomp(reg_pat, p_magic ? RE_MAGIC : 0); | |
8421 if (regmatch.regprog == NULL) | |
8422 return; | |
8423 } | |
8424 | |
8425 msg_start(); | |
8426 msg_scroll = TRUE; | |
8427 for (li = l->lv_first; li != NULL && !got_int; li = li->li_next) | |
8428 { | |
8429 ++nr; | |
8430 fname = get_tv_string(&li->li_tv); | |
8431 if (reg_pat == NULL || *reg_pat == NUL | |
8432 || vim_regexec(®match, fname, (colnr_T)0)) | |
8433 { | |
8434 msg_outnum((long)nr); | |
8435 MSG_PUTS(": "); | |
8436 msg_outtrans(fname); | |
8437 msg_putchar('\n'); | |
8438 out_flush(); /* output one line at a time */ | |
8439 ui_breakcheck(); | |
8440 } | |
8441 } | |
8442 if (*eap->arg != NUL) | |
8443 vim_regfree(regmatch.regprog); | |
8444 | |
8445 /* Assume "got_int" was set to truncate the listing. */ | |
8446 got_int = FALSE; | |
8447 | |
8448 # ifdef FEAT_BROWSE_CMD | |
8449 if (cmdmod.browse) | |
8450 { | |
8451 quit_more = FALSE; | |
8452 nr = prompt_for_number(FALSE); | |
8453 msg_starthere(); | |
8454 if (nr > 0) | |
8455 { | |
8456 char_u *p = list_find_str(get_vim_var_list(VV_OLDFILES), | |
8457 (long)nr); | |
8458 | |
8459 if (p != NULL) | |
8460 { | |
8461 p = expand_env_save(p); | |
8462 eap->arg = p; | |
8463 eap->cmdidx = CMD_edit; | |
8464 cmdmod.browse = FALSE; | |
8465 do_exedit(eap, NULL); | |
8466 vim_free(p); | |
8467 } | |
8468 } | |
8469 } | |
8470 # endif | |
8471 } | |
8472 } | |
8473 #endif | |
8474 |