Thank you Bram!
Maybe it's because I forgot to say I have an autocommand.
I am surprised to see out of print('LuaXmlParser') when I source this vim9script.
Thank you again Bram.
NV
# Syntax / Filetype - Helper {{{
def g:SwitchFtHelper(arg: string): void
if (arg == 'leave')
au!
endif
if ( !exists('g:cachebufnr') )
g:cachebufnr = bufnr('%')
g:cacheft = &ft
StampedEcho( 'Cached filetype is ' .. g:cacheft .. ' and bufnr is ' .. g:cachebufnr )
def Scan(timerID: any): number
# g:embedRegions = {
# [beg, end] # linenos of embed langage regions' begin, end
# ..
# }
g:begs = []
g:ends = []
exe "g/\\w\\+\\s\\+<<\\s\\+EOF/call add(g:begs, line('.'))"
exe "g/^EOF/call add(g:ends, line('.'))"
var foo = []
var idx: number = 0
while idx < len(g:begs)
call add(foo, [g:begs[idx], g:ends[idx]])
idx = idx + 1
endwhile
# StampedEcho( 'Scan begin EOF: ' .. string(g:foo))
return 1
enddef
timer_start(1200, Scan, {'repeat': 20} )
endif
lua << EOF
EOF
lua << EOF
print('LuaXmlParser')
EOF
enddef
augroup FOOBAR
au! CursorHold *.vim ++nested call g:SwitchFtHelper('')
# au! BufLeave *.vim aug! FOOB
augroup END