":verbose set efm?" reports inconsistent file name and line number

11 views
Skip to first unread message

Gary Johnson

unread,
Nov 4, 2021, 5:46:16 PM11/4/21
to vim...@googlegroups.com
When 'efm' is set in a compiler plugin, and the :compile command is
executed in a configuration file, ":verbose set efm?" reports the
file name of the file where :compiler was executed and the line
number of compiler plugin where ":set efm=..." was executed.

I expected to see :verbose report either the name of the file in
which :compiler was executed and the line number of the :compiler
command, or the name of the compiler plugin and the line number
where 'efm' was set. I would prefer the latter.

Here's an illustration of the problem.

Create a file named vimrc (name doesn't matter) in your home
directory (directory doesn't matter) containing only this command on
line 3 (line doesn't matter but I wanted something other than 1).

compiler ant

Execute the following command from the shell prompt:

$ vim -N --noplugin -u vimrc -i NONE

Execute the following command on Vim's command line:

:verbose set efm?
errorformat= %#[%.%#] %#%f:%l:%v:%*\d:%*\d: %t%[%^:]%#:%m,%A %#[%.%#] %f:%l: %m,%-Z %#[%.%#] %p^,%C %#[%.%#] %#%m
Last set from ~/vimrc line 32

'efm' is actually set at line 32 of $VIMRUNTIME/compiler/ant.vim.

A similar problem occurs when executing :compiler from Vim's command
line. For example:

$ vim -N -u NONE -i NONE
:compiler ant
:verbose set efm?
errorformat= %#[%.%#] %#%f:%l:%v:%*\d:%*\d: %t%[%^:]%#:%m,%A %#[%.%#] %f:%l: %m,%-Z %#[%.%#] %p^,%C %#[%.%#] %#%m

In this case, no information at all is given about where 'efm' was
set. I understand an argument that the user set 'efm' from the
command line via the :compiler command, but it's not helpful for
diagnosing problems.

I'm using the latest vim, 8.2.3582, in an xterm on an Ubuntu 20.04.3
system.

Regards,
Gary

Bram Moolenaar

unread,
Nov 12, 2021, 6:17:02 AM11/12/21
to vim...@googlegroups.com, Gary Johnson
It appears this is caused by using the "CompilerSet" user command. The
script context is then set to where the command is defined. This
command is added internally by the :compiler command, thus gets the
script ID of where the :compiler command is executed.

It appears the best solution is to add a flag to :command to have it not
set the script context to where the user command was defined, but use
the context of where the user command is invoked. That would be useful
in other situations as well.

--
A vacation is a period of travel during which you find that you
took twice as many clothes and half as much money as you needed.

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
Reply all
Reply to author
Forward
0 new messages