James Vega wrote:
> >> According to the help for 'formatexpr', "When the function returns
> >> non-zero Vim will fall back to using the internal format mechanism."
> >> Unfortunately, this is only the case when 'formatexpr' is applied for
> >> automatic formatting as the user types.
> >>
> >> This makes it hard to use something like the following because automatic
> >> formatting will work as expected but attempts at manually applying
> >> formatting to an email's body will result in nothing changing.
> >>
> >> $ cat ~/.vim/after/ftplugin/mail.vim
> >> fun! FormatMail()
> >> let headerRegex = 'mailHeader\%(Key\)\=\|mailSubject'
> >> " Ignore formatting for mail headers but let normal formatting
> >> " handle the body
> >> if synIDattr(synID(v:lnum, 1, 1), 'name') !~# headerRegex
> >> return -1
> >> endif
> >> endfun
> >> setl formatexpr=FormatMail()
> >>
> >> I was trying to do something simple like this because 'formatexpr' isn't
> >> particularly clear on what the function is supposed to be doing. That
> >> combined with 'formatexpr' not being used anywhere in the runtime files
> >> that come with Vim made figuring things out rather fun.
> >>
> >> I've since figured it out, but in the end ignoring header formatting is
> >> much simpler than trying to properly wrap headers.
> >>
> >> At any rate, the attached patch will cause manual formatting to fallback
> >> to internal formatting if 'formatexpr' returns non-zero.
> >
> > Looks OK. Perhaps you can also suggest an improvement for the help?
>
> Thanks for applying the patch. I was planning on sending a patch for
> the mail ftplugin to wrap header lines via 'formatexpr' while leaving
> the body to internal formatting, but I haven't had time. So, attached
> is just a patch for some extra help updates regarding 'formatexpr'.
I'll include it, thanks.
--
BLACK KNIGHT: Come on you pansy!
[hah] [parry thrust]
[ARTHUR chops the BLACK KNIGHT's right arm off]
ARTHUR: Victory is mine! [kneeling]
We thank thee Lord, that in thy merc-
[Black Knight kicks Arthur in the head while he is praying]
The Quest for the Holy Grail (Monty Python)
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ download, build and distribute -- http://www.A-A-P.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
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