Skip to content

Commit

Permalink
runtime: fix :compiler leaving behind a g:makeprg variable (#14414)
Browse files Browse the repository at this point in the history
Problem:  :compiler may leave behind a g:makeprg variable after #14336.
Solution: Use a script local variable.

Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
  • Loading branch information
zeertzjq committed Apr 5, 2024
1 parent cec44ea commit b73faa1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions runtime/compiler/powershell.vim
Expand Up @@ -4,6 +4,7 @@
" Contributors: Enno Nagel
" Last Change: 2024 Mar 29
" 2024 Apr 03 by The Vim Project (removed :CompilerSet definition)
" 2024 Apr 05 by The Vim Project (avoid leaving behind g:makeprg)

if exists("current_compiler")
finish
Expand Down Expand Up @@ -35,7 +36,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 makeprg = g:ps1_makeprg_cmd .. ' %:p:S'
let s: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
Expand All @@ -48,7 +49,7 @@ let makeprg = g:ps1_makeprg_cmd .. ' %:p:S'
" + CategoryInfo : ObjectNotFound: (Write-Ouput:String) [], CommandNotFoundException
" + FullyQualifiedErrorId : CommandNotFoundException

execute 'CompilerSet makeprg=' .. escape(makeprg, ' ')
execute 'CompilerSet makeprg=' .. escape(s:makeprg, ' ')

" Showing error in context with underlining.
CompilerSet errorformat=%+G+%m
Expand Down
5 changes: 3 additions & 2 deletions runtime/compiler/tex.vim
Expand Up @@ -4,6 +4,7 @@
" Contributors: Enno Nagel
" Last Change: 2024 Mar 29
" 2024 Apr 03 by The Vim Project (removed :CompilerSet definition)
" 2024 Apr 05 by The Vim Project (avoid leaving behind g:makeprg)

if exists("current_compiler")
finish
Expand All @@ -25,8 +26,8 @@ if exists('b:tex_ignore_makefile') || exists('g:tex_ignore_makefile') ||
else
let current_compiler = "latex"
endif
let makeprg=current_compiler .. ' -interaction=nonstopmode'
execute 'CompilerSet makeprg=' .. escape(makeprg, ' ')
let s:makeprg=current_compiler .. ' -interaction=nonstopmode'
execute 'CompilerSet makeprg=' .. escape(s:makeprg, ' ')
else
let current_compiler = 'make'
endif
Expand Down

2 comments on commit b73faa1

@Konfekt
Copy link
Contributor

@Konfekt Konfekt commented on b73faa1 Apr 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dkearns Is a spurious s:makeprg preferred? How about using &l:makeprg, being overwritten anyway?
Edit: I see this has been "discussed" at #14414

@dkearns
Copy link
Contributor

@dkearns dkearns commented on b73faa1 Apr 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Konfekt, that eye-roll in the comment was directed at myself. The differences between legacy and Vim9 script are causing me to frequently miss things like that these days.

Personally, I'd do away with the variable altogether but it's common to 'style' things that way.

Please sign in to comment.