krudo...@mi.fu-berlin.de wrote:
> Hello,
>
> I have `set spell` in my `.vimrc`. This unfortunately clashes with  
> highlighting for `netrw-browse`. Therefore, I'd like to deactivate the  
> setting locally for that file type (`netrw`).
>
> Manually deactivating via `:setlocal nospell` works fine. However, it  
> does not work as an autocommand. The following minimal `.vimrc` file  
> reproduces the behaviour with VIM 7.0 (latest patch 237, if that's  
> relevant), default settings of the version included in the CentOS  
> distribution.
>
> Steps to reproduce. (Steps 1 and 2 are sufficient to reproduce the  
> unexpected behaviour. Steps 3 and 4 only act as a cross-check to  
> exclude other factors.)
>
> * Step 1: Set the following as `.vimrc` or load via `:source`:
>
>      colors desert
>      set spell
>      autocmd FileType netrw colors desert    " Works
>      autocmd FileType netrw setlocal nospell " Ignored
>      " For reference:
>      autocmd FileType html setlocal nospell  " Works
>
> * Step 2: Load a directory listing into vim, e.g. `:e .`.
>
> (
> *Step 3: Load an arbitrary text file with invalid spelling into vim, e.g.:
>
>      :e new.txt
>      i
>      Text with speling errors
>
> * Step 4: Set file type to HTML: `:set ft=html`
> )
>
> Expected result:
>
> - Colour scheme is switched to `default`.
> - Spelling is switched off.
> - After step 3: vim highlights word "speling".
> - After step 4: spelling is switched off (highlighting vanishes).
>
> Actual result (differences in all caps):
>
> - Colour scheme is switched to `default`.
> - Spelling STAYS SWITCHED ON
> - After step 3: vim highlights word "speling".
> - After step 4: spelling is switched off (highlighting vanishes).
>
> For me, this indicates that both `:autocmd` and `:set nospell` work  
> properly. Only the combination
>
> - FileType `netrw`,
> - use of `autocmd`,
> - sets `nospell`
>
> does not work. This is regardless of whether `:set` or `:setlocal` was  
> used to set `nospell`!
>   
Netrw's strategy has been to 1) enew/get a netrw buffer, 2) save user 
options, 3) impose netrw-friendly options,
4) construct the netrw buffer, and 5) to restore user options.  The 
netrw buffer itself is left as non-modifiable, read-only.

Apparently your autocmd to set nospell takes place before step 5 
(probably just after netrw sets its filetype).  So the
options you had at the onset of using netrw are restored.

I can certainly see where having spell checking of a listing is 
generally unwanted.  However, if I rigged netrw so as to
not restore your original spell option (whether via option, doau 
FileType netrw, etc), then any files that you subsequently
selected would also not have spellchecking enabled.  I'm leaning towards 
putting in the   doau FileType netrw   line, but
that in turn would mean that files that you subsequently selected for 
editing via netrw would not have spellchecking
enabled; for iexample, f you did something like
  :vsplit
  :e someotherfile
which allows one to edit a file not through netrw's auspices.

Its to support the previous type of sequence that I have netrw restore 
user options for itself.

Regards,
Chip Campbell


--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Raspunde prin e-mail lui