On 20/08/10 23:46, Benjamin R. Haskell wrote:
On Fri, 20 Aug 2010, Charles Campbell wrote:
Hello,
I was trying out ownsyntax; I may have found a problem. Using misc1.c
from vim's source code:
vim -u NONE -N misc1.c
:syn on
:vsplit
:ownsyntax tex
The underscores get highlighted with Error highlighting in the left
(ownsyntax tex) window; this is expected.
However, look at the static char_u ... [char] is now highlighted
differently than before. Putting the cursor in that window and typing
":ownsyntax c" doesn't fix things, either. Neither does quitting the
"ownsyntax tex" window.
By the way, I know that viewing C source code as LaTeX source doesn't
make sense :)
It seems to be related to just having two syntax items (in different
syntaxes) with the same name, but different highlighting links.
==> ~/.vim.local/syntax/aaa.vim<==
syn match Foo /ab/
hi link Foo Comment
==> ~/.vim.local/syntax/bbb.vim<==
syn match Foo /cd/
hi link Foo Constant
==> /tmp/foo<==
abcd
sub foo { print "lalalaperl\n"; }
int main(void) { return 42; }
$ vi -u NONE -N /tmp/foo
:syn on
:setf aaa
:vs
:ownsyntax bbb
After the :setf aaa, the 'ab' is highlighted as Comment. As expected.
Same goes for the 'ab' on the right side after the :vs. But, after the
:ownsyntax bbb, both the right-side 'ab' and the left-side 'cd' are
highlighted as Constant.
However, every syntax or highlight group defined in syntax/tex.vim has a
name starting with "tex"; but in syntax/c.vim the pattern /\<tex/ yields
no match in the whole file...
:ownsyntax is implemented approximately as follows:
let s:current_syntax = b:current_syntax
setlocal syntax=<args>
let w:current_syntax = b:current_syntax
let b:current_syntax = s:current_syntax
plus some magic to make syntax elements window-local at step 2. I think
that if the syntax script defines buffer-local variables other than
b:current_syntax (and syntax/tex.vim does it abundantly) they will
"leak" to any other windows on the same buffer.
Best regards,
Tony.
--
Don't kiss an elephant on the lips today.
--
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