"他のtabに移った時にfiletypeの値が消えちゃうのね。
"これではどうだろ。また何か見落としてるかな。

filetype plugin indent on
autocmd FileType php call append ('.', 'ririnrin')
augroup foo
autocmd!
autocmd FileType javascript call append ('.', 'rurunrun') |let b:filetype_js = 1
augroup end
if exists ('b:filetype_js')
setlocal filetype=javascript
endif