Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion runtime/doc/options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4062,7 +4062,7 @@ A jump table for the options with a short description can be found at |Q_op|.

*'grepformat'* *'gfm'*
'grepformat' 'gfm' string (default "%f:%l:%m,%f:%l%m,%f %l%m")
global
global or local to buffer |global-local|
Format to recognize for the ":grep" command output.
This is a scanf-like string that uses the same format as the
'errorformat' option: see |errorformat|.
Expand Down
1 change: 1 addition & 0 deletions src/buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -2508,6 +2508,7 @@ free_buf_options(
free_callback(&buf->b_tsrfu_cb);
#endif
#ifdef FEAT_QUICKFIX
clear_string_option(&buf->b_p_gefm);
clear_string_option(&buf->b_p_gp);
clear_string_option(&buf->b_p_mp);
clear_string_option(&buf->b_p_efm);
Expand Down
7 changes: 7 additions & 0 deletions src/option.c
Original file line number Diff line number Diff line change
Expand Up @@ -6429,6 +6429,9 @@
case PV_EFM:
clear_string_option(&buf->b_p_efm);
break;
case PV_GEFM:
clear_string_option(&buf->b_p_gefm);
break;

Check warning on line 6434 in src/option.c

View check run for this annotation

Codecov / codecov/patch

src/option.c#L6432-L6434

Added lines #L6432 - L6434 were not covered by tests
case PV_GP:
clear_string_option(&buf->b_p_gp);
break;
Expand Down Expand Up @@ -6508,6 +6511,7 @@
#endif
#ifdef FEAT_QUICKFIX
case PV_EFM: return (char_u *)&(curbuf->b_p_efm);
case PV_GEFM: return (char_u *)&(curbuf->b_p_gefm);
case PV_GP: return (char_u *)&(curbuf->b_p_gp);
case PV_MP: return (char_u *)&(curbuf->b_p_mp);
#endif
Expand Down Expand Up @@ -6626,6 +6630,8 @@
#ifdef FEAT_QUICKFIX
case PV_EFM: return *curbuf->b_p_efm != NUL
? (char_u *)&(curbuf->b_p_efm) : p->var;
case PV_GEFM: return *curbuf->b_p_gefm != NUL
? (char_u *)&(curbuf->b_p_gefm) : p->var;
case PV_GP: return *curbuf->b_p_gp != NUL
? (char_u *)&(curbuf->b_p_gp) : p->var;
case PV_MP: return *curbuf->b_p_mp != NUL
Expand Down Expand Up @@ -7415,6 +7421,7 @@
buf->b_p_bkc = empty_option;
buf->b_bkc_flags = 0;
#ifdef FEAT_QUICKFIX
buf->b_p_gefm = empty_option;
buf->b_p_gp = empty_option;
buf->b_p_mp = empty_option;
buf->b_p_efm = empty_option;
Expand Down
1 change: 1 addition & 0 deletions src/option.h
Original file line number Diff line number Diff line change
Expand Up @@ -1157,6 +1157,7 @@ enum
, BV_BT
#ifdef FEAT_QUICKFIX
, BV_EFM
, BV_GEFM
, BV_GP
, BV_MP
#endif
Expand Down
3 changes: 2 additions & 1 deletion src/optiondefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#define PV_BT OPT_BUF(BV_BT)
#ifdef FEAT_QUICKFIX
# define PV_EFM OPT_BOTH(OPT_BUF(BV_EFM))
# define PV_GEFM OPT_BOTH(OPT_BUF(BV_GEFM))
# define PV_GP OPT_BOTH(OPT_BUF(BV_GP))
# define PV_MP OPT_BOTH(OPT_BUF(BV_MP))
#endif
Expand Down Expand Up @@ -1154,7 +1155,7 @@ static struct vimoption options[] =
{(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
{"grepformat", "gfm", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
#ifdef FEAT_QUICKFIX
(char_u *)&p_gefm, PV_NONE, NULL, NULL,
(char_u *)&p_gefm, PV_GEFM, NULL, NULL,
{(char_u *)DFLT_GREPFORMAT, (char_u *)0L}
#else
(char_u *)NULL, PV_NONE, NULL, NULL,
Expand Down
1 change: 1 addition & 0 deletions src/optionstr.c
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@ check_buf_options(buf_T *buf)
check_string_option(&buf->b_p_keymap);
#endif
#ifdef FEAT_QUICKFIX
check_string_option(&buf->b_p_gefm);
check_string_option(&buf->b_p_gp);
check_string_option(&buf->b_p_mp);
check_string_option(&buf->b_p_efm);
Expand Down
2 changes: 1 addition & 1 deletion src/quickfix.c
Original file line number Diff line number Diff line change
Expand Up @@ -5503,7 +5503,7 @@ ex_make(exarg_T *eap)
incr_quickfix_busy();

if (eap->cmdidx != CMD_make && eap->cmdidx != CMD_lmake)
errorformat = p_gefm;
errorformat = *curbuf->b_p_gefm != NUL ? curbuf->b_p_gefm : p_gefm;
if (eap->cmdidx == CMD_grepadd || eap->cmdidx == CMD_lgrepadd)
newlist = FALSE;

Expand Down
1 change: 1 addition & 0 deletions src/structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -3371,6 +3371,7 @@ struct file_buffer
* local values for options which are normally global
*/
#ifdef FEAT_QUICKFIX
char_u *b_p_gefm; // 'grepformat' local value
char_u *b_p_gp; // 'grepprg' local value
char_u *b_p_mp; // 'makeprg' local value
char_u *b_p_efm; // 'errorformat' local value
Expand Down
19 changes: 19 additions & 0 deletions src/testdir/test_quickfix.vim
Original file line number Diff line number Diff line change
Expand Up @@ -2379,6 +2379,25 @@ func Test_grep()
call s:test_xgrep('l')
endfunc

func Test_local_grepformat()
let save_grepformat = &grepformat
set grepformat=%f:%l:%m
" The following line are used for the local grep test. Don't remove.
" UNIQUEPREFIX:2:3: Local grepformat test
new
setlocal grepformat=UNIQUEPREFIX:%c:%n:%m
call assert_equal('UNIQUEPREFIX:%c:%n:%m', &l:grepformat)
call assert_equal('%f:%l:%m', &g:grepformat)

set grepprg=internal
silent grep "^[[:space:]]*\" UNIQUEPREFIX:" test_quickfix.vim
call assert_equal(1, len(getqflist()))
set grepprg&vim

bwipe!
let &grepformat = save_grepformat
endfunc

func Test_two_windows()
" Use one 'errorformat' for two windows. Add an expression to each of them,
" make sure they each keep their own state.
Expand Down
Loading