]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.1396: 'errorformat' is a global option v9.1.1396
authorglepnir <glephunter@gmail.com>
Fri, 16 May 2025 17:49:23 +0000 (19:49 +0200)
committerChristian Brabandt <cb@256bit.org>
Fri, 16 May 2025 17:49:23 +0000 (19:49 +0200)
Problem:  The 'grepformat' option is global option, but it would be
          useful to have it buffer-local, similar to 'errorformat' and
          other quickfix related options (Dani Dickstein)
Solution: Add the necessary code to support global-local 'grepformat',
          allowing different buffers to parse different grep output
          formats (glepnir)

fixes: #17316
closes: #17315

Signed-off-by: glepnir <glephunter@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
runtime/doc/options.txt
runtime/doc/version9.txt
src/buffer.c
src/option.c
src/option.h
src/optiondefs.h
src/optionstr.c
src/quickfix.c
src/structs.h
src/testdir/test_quickfix.vim
src/version.c

index 274d56e19679c6ad1e12c95f72535436cf4fbab7..e74c5e8a5945ef36bbb7511a3b7fc22cab2aa1f3 100644 (file)
@@ -1,4 +1,4 @@
-*options.txt*  For Vim version 9.1.  Last change: 2025 May 14
+*options.txt*  For Vim version 9.1.  Last change: 2025 May 16
 
 
                  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -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|.
index 52428428e4396e47cc4e7d939adf358aa294b157..e03deedb8dd25d6f0ea0968caf1b410331894aff 100644 (file)
@@ -1,4 +1,4 @@
-*version9.txt*  For Vim version 9.1.  Last change: 2025 May 14
+*version9.txt*  For Vim version 9.1.  Last change: 2025 May 16
 
 
                  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -41634,17 +41634,19 @@ Options: ~
 - the default for 'commentstring' contains whitespace padding to have
   automatic comments look nicer |comment-install|
 - 'completeopt' is now a |global-local| option.
-- 'nrformats' accepts the new "blank" suboption, to determine a signed or
-  unsigned number based on whitespace in front of a minus sign.
 - add 'cpoptions' flag "z" |cpo-z|, to disable some (traditional) vi
   behaviour/inconsistency (see |d-special| and |cw|).
-- 'rulerformat' now supports the |stl-%!| item
-- use 'smoothscroll' logic for CTRL-F / CTRL-B for pagewise scrolling
-  and CTRL-D / CTRL-U for half-pagewise scrolling
-- New option value for 'fillchars':
+- new option values for 'fillchars':
        "trunc"         - configure truncation indicator, 'pummaxwidth'
        "truncrl"       - like "trunc" but in 'rl' mode, 'pummaxwidth'
+       "tpl_vert"      - separators for the 'tabpanel'
+- 'grepformat' is now a |global-local| option.
 - adjust for GTK3 dropping some mouse cursors 'mouseshape'
+- 'nrformats' accepts the new "blank" suboption, to determine a signed or
+  unsigned number based on whitespace in front of a minus sign.
+- 'rulerformat' now supports the |stl-%!| item
+- use 'smoothscroll' logic for CTRL-F / CTRL-B for pagewise scrolling
+  and CTRL-D / CTRL-U for half-pagewise scrolling
 
 Ex commands: ~
 - allow to specify a priority when defining a new sign |:sign-define|
index 48e8cb63bc176647832a344d7129aa3860fb5643..fe19269a492c3d25d0af1ffd00f731abcda4ca8f 100644 (file)
@@ -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);
index d6a009853d8d7601529021eb2f679cab1be7985d..85c3705536ba3bf25302c392b2b809d7ccb46bfe 100644 (file)
@@ -6429,6 +6429,9 @@ unset_global_local_option(char_u *name, void *from)
        case PV_EFM:
            clear_string_option(&buf->b_p_efm);
            break;
+       case PV_GEFM:
+           clear_string_option(&buf->b_p_gefm);
+           break;
        case PV_GP:
            clear_string_option(&buf->b_p_gp);
            break;
@@ -6508,6 +6511,7 @@ get_varp_scope(struct vimoption *p, int scope)
 #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
@@ -6626,6 +6630,8 @@ get_varp(struct vimoption *p)
 #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
@@ -7415,6 +7421,7 @@ buf_copy_options(buf_T *buf, int flags)
            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;
index e78a7cb19233120c1b40c50a05c8fe538f78c0ce..740f6eed5678fe9e14cb8fb47f30c69ef13a5e70 100644 (file)
@@ -1157,6 +1157,7 @@ enum
     , BV_BT
 #ifdef FEAT_QUICKFIX
     , BV_EFM
+    , BV_GEFM
     , BV_GP
     , BV_MP
 #endif
index d5094632a5e0febfafeaeba150e51b04f931eb78..cb4376c716c138741bee4ca6f136526d888c5b75 100644 (file)
@@ -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
@@ -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,
index 8e233e86c3cf8ed180a2b7f458beb3fad848e21e..7a1cd69e452466a4bd2f96794404ec509a5b36be 100644 (file)
@@ -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);
index d012ea0d720bf264ba5a290d9b27c5d19a332003..ab595d7bbc2b1459a9c610a83839cb816bb32dac 100644 (file)
@@ -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;
 
index cd7370d22cf0f243c8da1f0e5fece652ba3eb48a..00b074643815e88454af4c3aea35a94042dca5e6 100644 (file)
@@ -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
index fe85887e59ae1312a2635fc15f12ecc723f3e765..dc2a2a4c5ce34e6b43eb1a8848b3845b3cf53834 100644 (file)
@@ -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.
index e367036ea2bbcfcfd5e008f4972d57fdb610acdc..f282c1f32814ce3e3953bdf462a03318bc224b1f 100644 (file)
@@ -709,6 +709,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1396,
 /**/
     1395,
 /**/