On Wednesday, October 21, 2015 at 8:32:32 PM UTC+2, Gary Johnson wrote:
> On 2015-10-21, glts wrote:
> > On Tuesday, October 20, 2015 at 8:47:27 PM UTC+2, ZyX wrote:
> > > 2015-10-20 21:11 GMT+03:00 glts <[email protected]>:
> > > > In a plain Vim installation, if I have a personal ftplugin
> > > > ~/.vim/ftplugin/text.vim that contains the line
> > > >
> > > >         setlocal expandtab
> > > 
> > > This file is missing `b:undo_ftplugin` variable, see :h undo_ftplugin.
> > > Examples are in every or nearly every ftplugin file in default
> > > distribution.
> > 
> > That does mean that the information in the user manual at ":h 43.1" is
> > incorrect, though -- or at least incomplete. The example in the user
> > manual has just a setting and a mapping, and no undo boilerplate.
> > 
> > In fact, I get the feeling I'm back to square one regarding personal
> > filetype settings -- is there at all a robust way to tweak settings for
> > some filetype and have them undone properly after another :setfiletype?
> > 
> > This belongs in vim_use, but documentation could be more accurate. And
> > the original request still stands.
> 
> I assume that you added the setting of b:undo_ftplugin to your
> ~/.vim/ftplugin/text.vim and you are still seeing 'expandtab' set in
> help files.
> 
> The problem is that b:undo_ftplugin is also being set in
> $VIMRUNTIME/ftplugin/text.vim and since that file is sourced after
> your ~/.vim/ftplugin/text.vim, its setting is overriding yours.
> 
> The solution is to put your text.vim file into ~/.vim/after/ftplugin
> so that it is sourced after $VIMRUNTIME/ftplugin/text.vim and than
> add the following to your text.vim:
> 
>     if exists("b:undo_ftplugin")
>         let b:undo_ftplugin .= " | setlocal expandtab<"
>     else
>         let b:undo_ftplugin = "setlocal expandtab<"
>     endif
> 
> Yes, the documentation should be updated.
> 
> Regards,
> Gary

Yes. I'm re-reading the documentation and it does seem to imply that
personal customisations go in ~/.vim/ftplugin, and that "after" plugins
are only used in rare circumstances. See ":h after-directory", which
says that an "after" directory is 'rarely needed'.

Thanks to ZyX's explanation, I now understand that ftplugins in
~/.vim/ftplugin aren't really meant for personal settings, as in, you
can't set any settings there and expect proper tear-down via
b:undo_ftplugin to work. In practice, it's really the "after" plugins
where you set stuff like 'expandtab'. Please correct me if I'm wrong.

What's unfortunate about this is that you might still need to set config
variables for some of the distributed ftplugins (say, g:sh_noisk). So,
ultimately I'll need 1) an ftplugin in ~/.vim/ftplugin to set the config
variable, and 2) an "after" plugin -- with substantial boilerplate -- to
set the tab setting. It's a pity that a more convenient approach doesn't
exist.


-- 
David

-- 
-- 
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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui