runtime(compilers): ensure compiler! sets global options (#14336)

Commit: 
https://github.com/vim/vim/commit/18d730d7b5728c8f87272ac7047d86354013eeb9
Author: Enno <konf...@users.noreply.github.com>
Date:   Sun Mar 31 18:37:05 2024 +0200

    runtime(compilers): ensure compiler! sets global options 
(https://github.com/vim/vim/issues/14336)
    
    Previously some options were only set locally by
    &l:makeprg/errorformat
    
    This suffices for :compiler (without a trailing bang)
    but falls short for :compiler! that sets &g:makeprg/errorformat as
    well
    
    Also apply kind suggestions by @dkearns and @lifepillar
    
    Signed-off-by: Konfekt <konf...@users.noreply.github.com>
    Signed-off-by: Doug Kearns <dougkea...@gmail.com>
    Signed-off-by: Christian Brabandt <c...@256bit.org>

diff --git a/runtime/compiler/bdf.vim b/runtime/compiler/bdf.vim
index b062e847a..7e08cddda 100644
--- a/runtime/compiler/bdf.vim
+++ b/runtime/compiler/bdf.vim
@@ -1,7 +1,8 @@
 " Vim compiler file
 " Compiler:             BDF to PCF Conversion
 " Previous Maintainer:  Nikolai Weibull <n...@bitwi.se>
-" Latest Revision:      2006-04-19
+" Contributors:         Enno Nagel
+" Last Change:          2024 Mar 29
 
 if exists("current_compiler")
   finish
@@ -11,9 +12,12 @@ let current_compiler = "bdf"
 let s:cpo_save = &cpo
 set cpo-=C
 
-setlocal makeprg=bdftopcf\ $*
+if exists(":CompilerSet") != 2 " Older Vim always used :setlocal
+  command -nargs=* CompilerSet setlocal <args>
+endif
 
-setlocal errorformat=%ABDF\ %trror\ on\ line\ %l:\ %m,
+CompilerSet makeprg=bdftopcf\ $*
+CompilerSet errorformat=%ABDF\ %trror\ on\ line\ %l:\ %m,
       \%-Z%p^,
       \%Cbdftopcf:\ bdf\ input\,\ %f\,\ corrupt,
       \%-G%.%#
diff --git a/runtime/compiler/context.vim b/runtime/compiler/context.vim
index f600936f1..512f81cbe 100644
--- a/runtime/compiler/context.vim
+++ b/runtime/compiler/context.vim
@@ -3,7 +3,8 @@ vim9script
 # Language:           ConTeXt typesetting engine
 # Maintainer:         Nicola Vitacolonna <nvitacolo...@gmail.com>
 # Former Maintainers: Nikolai Weibull <n...@bitwi.se>
-# Latest Revision:    2023 Dec 26
+# Contributors:       Enno Nagel
+# Last Change:        2024 Mar 29
 
 if exists("g:current_compiler")
   finish
@@ -19,7 +20,8 @@ g:current_compiler = 'context'
 
 if get(b:, 'context_ignore_makefile', get(g:, 'context_ignore_makefile', 0)) ||
   (!filereadable('Makefile') && !filereadable('makefile'))
-  &l:makeprg =  join(context.ConTeXtCmd(shellescape(expand('%:p:t'))), ' ')
+  var makeprg =  join(context.ConTeXtCmd(shellescape(expand('%:p:t'))), ' ')
+  execute 'CompilerSet makeprg=' .. escape(makeprg, ' ')
 else
   g:current_compiler = 'make'
 endif
diff --git a/runtime/compiler/mcs.vim b/runtime/compiler/mcs.vim
index c60658687..94a1848d4 100644
--- a/runtime/compiler/mcs.vim
+++ b/runtime/compiler/mcs.vim
@@ -1,8 +1,8 @@
 " Vim compiler file
-" Compiler:    Mono C# Compiler
-" Maintainer:  Jarek Sobiecki <harij...@go2.pl>
-" Last Updated By: Peter Collingbourne
-" Latest Revision: 2012 Jul 19
+" Compiler:     Mono C# Compiler
+" Maintainer:   Jarek Sobiecki <harij...@go2.pl>
+" Contributors: Peter Collingbourne and Enno Nagel
+" Last Change:  2024 Mar 29
 
 if exists("current_compiler")
   finish
@@ -12,7 +12,12 @@ let current_compiler = "mcs"
 let s:cpo_save = &cpo
 set cpo-=C
 
-setlocal errorformat=
+if exists(":CompilerSet") != 2 " Older Vim always used :setlocal
+  command -nargs=* CompilerSet setlocal <args>
+endif
+
+CompilerSet makeprg=mcs
+CompilerSet errorformat=
          \%D%.%#Project\ \"%f/%[%^/\"]%#\"%.%#,
          \%X%.%#Done\ building\ project\ \"%f/%[%^/\"]%#\"%.%#,
          \%-G%\s%.%#,
diff --git a/runtime/compiler/modelsim_vcom.vim 
b/runtime/compiler/modelsim_vcom.vim
index 6aa1bde0b..184b40399 100644
--- a/runtime/compiler/modelsim_vcom.vim
+++ b/runtime/compiler/modelsim_vcom.vim
@@ -1,7 +1,8 @@
 " Vim Compiler File
 " Compiler:    Modelsim Vcom
 " Maintainer:  Paul Baleme <pbal...@mail.com>
-" Last Change: September 8, 2003
+" Contributors: Enno Nagel
+" Last Change: 2024 Mar 29
 " Thanks to:    allanherri...@hotmail.com
 
 if exists("current_compiler")
@@ -13,8 +14,9 @@ if exists(":CompilerSet") != 2                " older Vim 
always used :setlocal
   command -nargs=* CompilerSet setlocal <args>
 endif
 
-"setlocal errorformat=\*\*\ %tRROR:\ %f(%l):\ %m,%tRROR:\ %f(%l):\ 
%m,%tARNING\[%*[0-9]\]:\ %f(%l):\ %m,\*\*\ %tRROR:\ %m,%tRROR:\ 
%m,%tARNING\[%*[0-9]\]:\ %m
+CompilerSet makeprg=vcom
 
+"setlocal errorformat=\*\*\ %tRROR:\ %f(%l):\ %m,%tRROR:\ %f(%l):\ 
%m,%tARNING\[%*[0-9]\]:\ %f(%l):\ %m,\*\*\ %tRROR:\ %m,%tRROR:\ 
%m,%tARNING\[%*[0-9]\]:\ %m
 "setlocal errorformat=%tRROR:\ %f(%l):\ %m,%tARNING\[%*[0-9]\]:\ %m
 CompilerSet errorformat=\*\*\ %tRROR:\ %f(%l):\ %m,\*\*\ %tRROR:\ %m,\*\*\ 
%tARNING:\ %m,\*\*\ %tOTE:\ %m,%tRROR:\ %f(%l):\ %m,%tARNING\[%*[0-9]\]:\ 
%f(%l):\ %m,%tRROR:\ %m,%tARNING\[%*[0-9]\]:\ %m
 
diff --git a/runtime/compiler/powershell.vim b/runtime/compiler/powershell.vim
index 45d5ec219..445a2f6d9 100644
--- a/runtime/compiler/powershell.vim
+++ b/runtime/compiler/powershell.vim
@@ -1,7 +1,8 @@
 " Vim compiler file
 " Compiler:    powershell
 " URL: https://github.com/PProvost/vim-ps1
-" Last Change: 2020 Mar 30
+" Contributors: Enno Nagel
+" Last Change: 2024 Mar 29
 
 if exists("current_compiler")
   finish
@@ -37,7 +38,7 @@ let g:ps1_efm_show_error_categories = get(g:, 
'ps1_efm_show_error_categories', 0
 
 " Use absolute path because powershell requires explicit relative paths
 " (./file.ps1 is okay, but # expands to file.ps1)
-let &l:makeprg = g:ps1_makeprg_cmd .' %:p:S'
+let makeprg = g:ps1_makeprg_cmd .. ' %:p:S'
 
 " Parse file, line, char from callstacks:
 "     Write-Ouput : The term 'Write-Ouput' is not recognized as the name of a
@@ -50,6 +51,8 @@ let &l:makeprg = g:ps1_makeprg_cmd .' %:p:S'
 "         + CategoryInfo          : ObjectNotFound: (Write-Ouput:String) [], 
CommandNotFoundException
 "         + FullyQualifiedErrorId : CommandNotFoundException
 
+execute 'CompilerSet makeprg=' .. escape(makeprg, ' ')
+
 " Showing error in context with underlining.
 CompilerSet errorformat=%+G+%m
 " Error summary.
diff --git a/runtime/compiler/tex.vim b/runtime/compiler/tex.vim
index 65e15cf6e..0925d1768 100644
--- a/runtime/compiler/tex.vim
+++ b/runtime/compiler/tex.vim
@@ -1,7 +1,8 @@
 " Vim compiler file
 " Compiler:     TeX
 " Maintainer:   Artem Chuprina <r...@ran.pp.ru>
-" Last Change:  2012 Apr 30
+" Contributors: Enno Nagel
+" Last Change:  2024 Mar 29
 
 if exists("current_compiler")
        finish
@@ -27,7 +28,8 @@ if exists('b:tex_ignore_makefile') || 
exists('g:tex_ignore_makefile') ||
        else
                let current_compiler = "latex"
        endif
-       let &l:makeprg=current_compiler.' -interaction=nonstopmode'
+       let makeprg=current_compiler .. ' -interaction=nonstopmode'
+       execute 'CompilerSet makeprg=' .. escape(makeprg, ' ')
 else
        let current_compiler = 'make'
 endif

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/E1rqyIp-000IuE-2L%40256bit.org.

Raspunde prin e-mail lui