`On 5/8/06, Thomas Haselwanter <[EMAIL PROTECTED]> wrote:
Yakov Lerner wrote:
> On 5/6/06, Thomas Haselwanter <[EMAIL PROTECTED]> wrote:
>> Hi,
>>
>> Vims excellent script support just asks to be exploited, and I am in the
>> process of putting 2html.vim to use. I have been getting different
>> results from this script, which I've tracked down to synIDattr()
>> returning different attribute values for given syntax IDs depending upon
>> the environment from which vim is called.
>>
>> Calling
>>
>> /usr/bin/vim -e +"syntax on" +"set syntax=c" +"run! syntax/2html.vim"
>> +"wq" +"q" /tmp/helloworld.c
>>
>> from the command line results in a different HTML file than calling it
>> via a system call from within mod_perl. In particular synIDattr()t
>> doesn't return "1" anymore for the attribute bold and for the fg
>> attribute it maps to different cterm colors, even two different colors
>> to the same cterm color which weakens the highlighting effect. This is
>> not a switch from 8 cterm colors to 16 or vice versa, both work with 8
>> colors.
>>
>> I realize that this may possibly need to be fixed in mod_perl and not
>> vim, but at this stage I'm just fishing for pointers what might cause
>> synIDattr() to behave differently. I've verified this behavior in vim
>> 6.3 and the latest 7.0 beta. Any ideas?
>
> Is $TERM environment variable defined identically
> in both cases ?
>
> $TERM value is important where
> terminal capabilities are concerned. To force TERM value,
> you can use either 'vim -T ...', or 'env TERM=... vim', or
> shell command.
You were right Yakov, $TERM wasn't defined identically. It was 'xterm'
on the shell versus not set at all in the mod_perl environment.
However when I modify the system call to '/usr/bin/vim -T xterm -e
+"syntax on" +"set syntax=c" +"run! syntax/2html.vim" +"wq" +"q"
/tmp/helloworld.c', forcing xterm, I still get the exact same different
results for the shell versus mod_perl. I've tried forcing numerous
different terminals without much success.
I tried running the perl systemcall by executing it from the shell with
the perl command, and it works just fine. The same code executed by
mod_perl causes synIDattr() to report strange values again resulting in
a suboptimal XHTML file.
Is there anything else that could have an effect on synIDattr() except
$TERM?
Yes. .vimrc and contents of ~/.vim would be different in two cases,
because $HOME is different. For example, if you have 'colorscheme
darkbrown' in your $HOME/.vimrc, this is probably missing or different
in the httpd $HOME
environment.
You need to find out value of $HOME in
the httpd environment and copy your ~/.vimrc to there,
(and maybe ~/.vim, too).
If that fails, I'd try to add $ENV{TERM}='xterm' to perl
syscall, or system("env TERM=xterm vim ...");
In theory, '-T xterm' is the same, as setting env.var. $TERM,.
but what if it's not ?
Yakov