]> granicus.if.org Git - vim/commitdiff
patch 8.2.3584: "verbose set efm" reports location of the :compiler command v8.2.3584
authorBram Moolenaar <Bram@vim.org>
Fri, 12 Nov 2021 11:25:11 +0000 (11:25 +0000)
committerBram Moolenaar <Bram@vim.org>
Fri, 12 Nov 2021 11:25:11 +0000 (11:25 +0000)
Problem:    "verbose set efm" reports the location of the :compiler command.
            (Gary Johnson)
Solution:   Add the "-keepscript" argument to :command and use it when
            defining CompilerSet.

runtime/doc/map.txt
src/ex_cmds.h
src/ex_cmds2.c
src/testdir/test_compiler.vim
src/usercmd.c
src/version.c

index 2c7735571410bc66363345f835dfd82b17b4e403..f50377b4ef53f626c55527f2c7536d1c34efc9c8 100644 (file)
@@ -1569,6 +1569,9 @@ There are some special cases as well:
        -register   The first argument to the command can be an optional
                    register name (like :del, :put, :yank).
        -buffer     The command will only be available in the current buffer.
+       -keepscript Do not use the location of where the user command was
+                   defined for verbose messages, use the location of where
+                   the user command was invoked.
 
 In the cases of the -count and -register attributes, if the optional argument
 is supplied, it is removed from the argument list and is available to the
index 1ea74422c3b0a0d9c8071779ed24440c3098f4c8..35080dbc62cdaa125fc82e2983e6bfa9503f70f1 100644 (file)
@@ -56,6 +56,7 @@
                                // set; when missing disallows editing another
                                // buffer when curbuf_lock is set
 #define EX_NONWHITE_OK 0x2000000  // command can be followed by non-white
+#define EX_KEEPSCRIPT  0x4000000  // keep sctx of where command was invoked
 
 #define EX_FILES (EX_XFILE | EX_EXTRA) // multiple extra files allowed
 #define EX_FILE1 (EX_FILES | EX_NOSPC) // 1 file, defaults to current file
index 15560d82b75fd5c79c27c4117582ced8f8481328..8e7da18aafba5521bb84ddcb8c1f8f1a390064ce 100644 (file)
@@ -754,7 +754,7 @@ ex_compiler(exarg_T *eap)
                if (old_cur_comp != NULL)
                    old_cur_comp = vim_strsave(old_cur_comp);
                do_cmdline_cmd((char_u *)
-                             "command -nargs=* CompilerSet setlocal <args>");
+                  "command -nargs=* -keepscript CompilerSet setlocal <args>");
            }
            do_unlet((char_u *)"g:current_compiler", TRUE);
            do_unlet((char_u *)"b:current_compiler", TRUE);
index ede307fbfc27a70375bf81dccf2919921020bc6b..09c03f7f20dd8a072941938a9494a825e93d5aca 100644 (file)
@@ -21,6 +21,9 @@ func Test_compiler()
   call assert_equal('perl', b:current_compiler)
   call assert_fails('let g:current_compiler', 'E121:')
 
+  let verbose_efm = execute('verbose set efm')
+  call assert_match('Last set from .*/compiler/perl.vim ', verbose_efm)
+
   call setline(1, ['#!/usr/bin/perl -w', 'use strict;', 'my $foo=1'])
   w!
   call feedkeys(":make\<CR>\<CR>", 'tx')
index 8ead42c5260fd4241333aa0adc4665c1eab183df..0050647ab449d4f5420b7b373d06b00eb59cbe5f 100644 (file)
@@ -360,7 +360,7 @@ get_user_cmd_flags(expand_T *xp UNUSED, int idx)
 {
     static char *user_cmd_flags[] = {
        "addr", "bang", "bar", "buffer", "complete",
-       "count", "nargs", "range", "register"
+       "count", "nargs", "range", "register", "keepscript"
     };
 
     if (idx >= (int)ARRAY_LENGTH(user_cmd_flags))
@@ -735,6 +735,8 @@ uc_scan_attr(
        *flags |= UC_BUFFER;
     else if (STRNICMP(attr, "register", len) == 0)
        *argt |= EX_REGSTR;
+    else if (STRNICMP(attr, "keepscript", len) == 0)
+       *argt |= EX_KEEPSCRIPT;
     else if (STRNICMP(attr, "bar", len) == 0)
        *argt |= EX_TRLBAR;
     else
@@ -1764,13 +1766,17 @@ do_ucmd(exarg_T *eap)
        }
     }
 
-    current_sctx.sc_version = cmd->uc_script_ctx.sc_version;
+    if ((cmd->uc_argt & EX_KEEPSCRIPT) == 0)
+    {
+       current_sctx.sc_version = cmd->uc_script_ctx.sc_version;
 #ifdef FEAT_EVAL
-    current_sctx.sc_sid = cmd->uc_script_ctx.sc_sid;
+       current_sctx.sc_sid = cmd->uc_script_ctx.sc_sid;
 #endif
+    }
     (void)do_cmdline(buf, eap->getline, eap->cookie,
                                   DOCMD_VERBOSE|DOCMD_NOWAIT|DOCMD_KEYTYPED);
-    current_sctx = save_current_sctx;
+    if ((cmd->uc_argt & EX_KEEPSCRIPT) == 0)
+       current_sctx = save_current_sctx;
     vim_free(buf);
     vim_free(split_buf);
 }
index 713b5e78d362b9565679caecf29e744538969af7..c13ea68b96d39b07e2ab98bd107a8fb6ca5a6c09 100644 (file)
@@ -757,6 +757,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    3584,
 /**/
     3583,
 /**/