On Thu, Jun 17, 2010 at 1:45 AM, Bram Moolenaar <[email protected]> wrote:
>
> 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'.

-- 
James
GPG Key: 1024D/61326D40 2003-09-02 James Vega <[email protected]>

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

Attachment: formatexpr.diff
Description: Binary data

Raspunde prin e-mail lui