On Sun, 28 May 2006, Geoffrey Alan Washburn wrote:

Gerald Lai wrote:
Since 'spellfile' cannot be set from a modeline for security reasons,
you can try placing something like this in your vimrc:

autocmd BufWinEnter *
  \ if expand("%:t") == "myfile1.txt"     |
  \   set spellfile=myspell1.latin1.add   |
  \ elseif expand("%:t") == "myfile2.txt" |
  \   set spellfile=myspell2.utf-8.add    |
  \ else                                  |
  \   set spellfile=                      |
  \ endif                                 |


Ah, this is actually a bit too heavyweight, as it would mean keeping a rather complicated switching block in my .vimrc, that includes the full path of every LaTeX file for which I have a dictionary. Regardless, your suggestion reminded me that I can set a per directory .vimrc, so I just placed one in my project directory and I seem to be set. This isn't quite as nice as my original proposal because it means it only works if I start vim from within that directory.

Somehow I don't see how this is any less of a security risk than allowing what I proposed.

I'm not sure, but if you haven't added any words to the spellfile, then
setting the 'spellfile' option will not create a blank file, I think.
Perhaps then, you can do something like this:

  (untested)
  autocmd BufWinEnter,BufWritePost *
    \ if expand("%") != ""                                    |
    \   let &l:spellfile = expand("%:p").".".&encoding.".add" |
    \ endif                                                   |

With this, you can avoid including the full path of every LaTeX file in
your vimrc.

HTH.
--
Gerald

Reply via email to