On 12/09/12 21:19, Timothy Madden wrote:
> On 09/12/2012 01:46 PM, Tony Mechelynck wrote:
>> On 12/09/12 01:54, Timothy Madden wrote:
>>> On 09/11/2012 05:37 PM, Tony Mechelynck wrote:
>>> [...]
>>>> That build script consists only of ex-commands, so you can omit the
>>>> leading colons and run Vim in batch mode as follows:
>>>>
>>>> vim -esS build.vim
>>>>
>>>> see
>>>> :help -e
>>>> :help -s-ex
>>>> :help -S
>>>>
>>>> If you want your vimrc to be used, you will need to explicitly add a -u
>>>> argument for it.
>>>>
>>>> You don't need a GUI, so no need to use gvim. If you don't _have_ a
>>>> Console Vim (and are on Windows), well, I don't know if you can avoid
>>>> opening the GUI. But you can try replacing vim by gvim in the above
>>>> command.
>>>
>>> I tried with vim instead of gvim and with the -esS build.vim arguments.
>>> While it is true I no longer get the window, now vim exits with the
>>> return code 2 and I get no vimball built.
>>>
>>> I suspect vim no longer loads plugins with the above switches, so my
>>> %MkVimball vcscommand-repack
>>> command no longer works.ā
>>>
>>> Thank you,
>>> Timothy Madden
>>>
>>
>> Yes, in batch mode (with -es) no scripts are sourced. To source them
>> anyway, add on top of your build.vim
>>
>> if filereadable("$HOME/.vimrc")
>> source ~/.vimrc
>> elseif filereadable("$HOME/_vimrc")
>> source ~/_vimrc
>> endif
>> runtime! plugin/*.vim
>
> Contrary to any and all of my expectations, it actually worked ... !
> And I had already given up hope on this.
>
> However the
> :runtime! plugin/*.vim
> command by itself did not help me. It turns out that -s has another side
> effect: without the .vimrc file being read, Vim never needs to reset
> 'compatible' (which normally happens automatically at the first .vimrc
> line executed)
>
> With 'compatible' on, my plugin (vimballPlugin.vim) would still not
> load. If I use -N on the command line, as Gary Johnson already indicated
> in the answer here, the plugin gets loaded normally, and I do not even
> need the :runtime command anymore.
>
> So in the end the solution was to use this command line:
> vim -NesS build.vim
>
> Now the -s switch to does a good job to hide the window, but at the same
> time it hides all script output, even the errors, which is not so good,
> so one other thing I had to do in addition to the above command line was
> to set verbose to non-zero. Which can also be done from the command
> line, but unfortunately it no longer fits in a shebang command line (it
> already has one other option argument, -S).
>
> Thank you,
> Timothy Madden
>
Ah, yes, setting 'nocompatible' automagically because a vimrc was found
doesn't work when Vim itself doesn't search for the vimrc, including
when it is loaded by -u
If your vimrc sources the vimrc_example.vim, the latter will set
'nocompatible'. Or you can set 'nocompatible' at the top of your vimrc
against the rare case when it will be loaded by -u or in the manner
shown in my earlier post.
Another possibility, to mimic even more closely what Vim normally does,
is the following slight change to the code snippet I gave earlier:
" in batch mode, 'compatible' is on by default
" and Vim doesn't try to find a vimrc. Let's correct that.
if filereadable("$HOME/.vimrc")
set nocompatible
source ~/.vimrc
elseif filereadable("$HOME/_vimrc")
set nocompatible
source ~/_vimrc
endif
" also, global plugins are not sourced. But what if we need them?
runtime! plugin/*.vim
And finally, to set 'verbose' from a shebang line, why not use (untested)
#!/usr/local/bin/vim --cmd 'set verbose=1' -NesS
to which the (script's) filename will be added by the loader? OTOH, of
course you could also set 'verbose' from one of the lines in the script
itself.
Best regards,
Tony.
--
"They make a desert and call it peace."
-- Tacitus (55?-120?)
--
You received this message from the "vim_use" 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
Wednesday, September 12, 2012
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment