To: vim_dev@googlegroups.com Subject: Patch 7.4.2049 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 7.4.2049 Problem: There is no way to get a list of the error lists. Solution: Add ":chistory" and ":lhistory". Files: src/ex_cmds.h, src/quickfix.c, src/ex_docmd.c, src/message.c, src/proto/quickfix.pro, src/testdir/test_quickfix.vim *** ../vim-7.4.2048/src/ex_cmds.h 2016-07-09 17:55:24.902980302 +0200 --- src/ex_cmds.h 2016-07-16 15:05:59.091544898 +0200 *************** *** 310,315 **** --- 310,318 ---- EX(CMD_checktime, "checktime", ex_checktime, RANGE|NOTADR|BUFNAME|COUNT|EXTRA|TRLBAR, ADDR_LINES), + EX(CMD_chistory, "chistory", qf_history, + TRLBAR, + ADDR_LINES), EX(CMD_clist, "clist", qf_list, BANG|EXTRA|TRLBAR|CMDWIN, ADDR_LINES), *************** *** 784,789 **** --- 787,795 ---- EX(CMD_lhelpgrep, "lhelpgrep", ex_helpgrep, EXTRA|NOTRLCOM|NEEDARG, ADDR_LINES), + EX(CMD_lhistory, "lhistory", qf_history, + TRLBAR, + ADDR_LINES), EX(CMD_ll, "ll", ex_cc, RANGE|NOTADR|COUNT|TRLBAR|BANG, ADDR_LINES), *** ../vim-7.4.2048/src/quickfix.c 2016-07-16 14:20:39.871128402 +0200 --- src/quickfix.c 2016-07-16 15:52:36.551749815 +0200 *************** *** 120,126 **** static void ll_free_all(qf_info_T **pqi); static int qf_add_entry(qf_info_T *qi, char_u *dir, char_u *fname, int bufnum, char_u *mesg, long lnum, int col, int vis_col, char_u *pattern, int nr, int type, int valid); static qf_info_T *ll_new_list(void); - static void qf_msg(qf_info_T *qi); static void qf_free(qf_info_T *qi, int idx); static char_u *qf_types(int, int); static int qf_get_fnum(qf_info_T *qi, char_u *, char_u *); --- 120,125 ---- *************** *** 2544,2549 **** --- 2543,2571 ---- buf[i] = NUL; } + static void + qf_msg(qf_info_T *qi, int which, char *lead) + { + char *title = (char *)qi->qf_lists[which].qf_title; + int count = qi->qf_lists[which].qf_count; + char_u buf[IOSIZE]; + + vim_snprintf((char *)buf, IOSIZE, _("%serror list %d of %d; %d errors "), + lead, + which + 1, + qi->qf_listcount, + count); + + if (title != NULL) + { + while (STRLEN(buf) < 34) + STRCAT(buf, " "); + STRCAT(buf, title); + } + trunc_string(buf, buf, Columns - 1, IOSIZE); + msg(buf); + } + /* * ":colder [count]": Up in the quickfix stack. * ":cnewer [count]": Down in the quickfix stack. *************** *** 2591,2610 **** ++qi->qf_curlist; } } ! qf_msg(qi); ! } ! ! static void ! qf_msg(qf_info_T *qi) ! { ! smsg((char_u *)_("error list %d of %d; %d errors"), ! qi->qf_curlist + 1, qi->qf_listcount, ! qi->qf_lists[qi->qf_curlist].qf_count); #ifdef FEAT_WINDOWS qf_update_buffer(qi, NULL); #endif } /* * Free error list "idx". */ --- 2613,2640 ---- ++qi->qf_curlist; } } ! qf_msg(qi, qi->qf_curlist, ""); #ifdef FEAT_WINDOWS qf_update_buffer(qi, NULL); #endif } + void + qf_history(exarg_T *eap) + { + qf_info_T *qi = &ql_info; + int i; + + if (eap->cmdidx == CMD_lhistory) + qi = GET_LOC_LIST(curwin); + if (qi == NULL || (qi->qf_listcount == 0 + && qi->qf_lists[qi->qf_curlist].qf_count == 0)) + MSG(_("No entries")); + else + for (i = 0; i < qi->qf_listcount; ++i) + qf_msg(qi, i, i == qi->qf_curlist ? "> " : " "); + } + /* * Free error list "idx". */ *** ../vim-7.4.2048/src/ex_docmd.c 2016-07-16 14:46:51.123240668 +0200 --- src/ex_docmd.c 2016-07-16 15:06:36.259177513 +0200 *************** *** 122,127 **** --- 122,128 ---- # define ex_cfile ex_ni # define qf_list ex_ni # define qf_age ex_ni + # define qf_history ex_ni # define ex_helpgrep ex_ni # define ex_vimgrep ex_ni #endif *** ../vim-7.4.2048/src/message.c 2016-07-12 21:11:28.711223556 +0200 --- src/message.c 2016-07-16 16:23:29.289072151 +0200 *************** *** 313,321 **** len += n; } ! /* Set the middle and copy the last part. */ ! if (e + 3 < buflen) { mch_memmove(buf + e, "...", (size_t)3); len = (int)STRLEN(s + i) + 1; if (len >= buflen - e - 3) --- 313,337 ---- len += n; } ! ! if (i <= e + 3) ! { ! /* text fits without truncating */ ! if (s != buf) ! { ! len = STRLEN(s); ! if (len >= buflen) ! len = buflen - 1; ! len = len - e + 1; ! if (len < 1) ! buf[e - 1] = NUL; ! else ! mch_memmove(buf + e, s + e, len); ! } ! } ! else if (e + 3 < buflen) { + /* set the middle and copy the last part */ mch_memmove(buf + e, "...", (size_t)3); len = (int)STRLEN(s + i) + 1; if (len >= buflen - e - 3) *************** *** 325,331 **** } else { ! buf[e - 1] = NUL; /* make sure it is truncated */ } } --- 341,348 ---- } else { ! /* can't fit in the "...", just truncate it */ ! buf[e - 1] = NUL; } } *** ../vim-7.4.2048/src/proto/quickfix.pro 2016-07-07 18:58:55.368713570 +0200 --- src/proto/quickfix.pro 2016-07-16 15:18:29.683885559 +0200 *************** *** 5,10 **** --- 5,11 ---- void qf_jump(qf_info_T *qi, int dir, int errornr, int forceit); void qf_list(exarg_T *eap); void qf_age(exarg_T *eap); + void qf_history(exarg_T *eap); void qf_mark_adjust(win_T *wp, linenr_T line1, linenr_T line2, long amount, long amount_after); void ex_cwindow(exarg_T *eap); void ex_cclose(exarg_T *eap); *** ../vim-7.4.2048/src/testdir/test_quickfix.vim 2016-07-09 17:55:24.902980302 +0200 --- src/testdir/test_quickfix.vim 2016-07-16 16:52:36.139720995 +0200 *************** *** 1438,1440 **** --- 1438,1464 ---- call XbottomTests('c') call XbottomTests('l') endfunction + + function HistoryTest(cchar) + call s:setup_commands(a:cchar) + + call assert_fails(a:cchar . 'older 99', 'E380:') + " clear all lists after the first one, then replace the first one. + call g:Xsetlist([]) + Xolder + let entry = {'filename': 'foo', 'lnum': 42} + call g:Xsetlist([entry], 'r') + call g:Xsetlist([entry, entry]) + call g:Xsetlist([entry, entry, entry]) + let res = split(execute(a:cchar . 'hist'), "\n") + call assert_equal(3, len(res)) + let common = 'errors :set' . (a:cchar == 'c' ? 'qf' : 'loc') . 'list()' + call assert_equal(' error list 1 of 3; 1 ' . common, res[0]) + call assert_equal(' error list 2 of 3; 2 ' . common, res[1]) + call assert_equal('> error list 3 of 3; 3 ' . common, res[2]) + endfunc + + func Test_history() + call HistoryTest('c') + call HistoryTest('l') + endfunc *** ../vim-7.4.2048/src/version.c 2016-07-16 14:46:51.135240543 +0200 --- src/version.c 2016-07-16 16:43:37.881065194 +0200 *************** *** 760,761 **** --- 760,763 ---- { /* Add new patch number below this line */ + /**/ + 2049, /**/ -- Yah, well, we had to carve our electrons out of driftwood we'd find. In the winter. Uphill. Both ways. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///