diff options
author | Robin Jarry <robin@jarry.cc> | 2023-01-25 01:11:52 +0100 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2023-01-26 00:21:16 +0100 |
commit | 1367fd4246716e3f693f8a1d70630c438489ce03 (patch) | |
tree | 19e46557bfa17167c9ba96142969dd9ff5ec0463 /widgets/compose.go | |
parent | 63f0e0cbc9a5f072d8915717c89d7ab4f4ff94af (diff) | |
download | aerc-1367fd4246716e3f693f8a1d70630c438489ce03.tar.gz |
compose: allow sending format=flowed messages
Allow composing and sending messages with:
Content-Type: text/plain; Format=Flowed
This requires additional configuration in the text editor to actually
produce the required trailing spaces at the end of lines that are part
of the same paragraph. For example, with vim:
"~/.vim/ftplugin/mail.vim
setlocal textwidth=72
setlocal formatoptions=1jnwtcql
setlocal comments+=nb:>
Link: https://www.rfc-editor.org/rfc/rfc3676.html
Signed-off-by: Robin Jarry <robin@jarry.cc>
Tested-by: Moritz Poldrack <moritz@poldrack.dev>
Diffstat (limited to 'widgets/compose.go')
-rw-r--r-- | widgets/compose.go | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/widgets/compose.go b/widgets/compose.go index 3ae41989..5795ccba 100644 --- a/widgets/compose.go +++ b/widgets/compose.go @@ -825,20 +825,20 @@ func (c *Composer) ShouldWarnAttachment() (bool, error) { } func writeMsgImpl(c *Composer, header *mail.Header, writer io.Writer) error { + mimeParams := map[string]string{"Charset": "UTF-8"} + if config.Compose.FormatFlowed { + mimeParams["Format"] = "Flowed" + } if len(c.attachments) == 0 && len(c.textParts) == 0 { // no attachments - return writeInlineBody(header, c.email, writer) + return writeInlineBody(header, c.email, writer, mimeParams) } else { // with attachments w, err := mail.CreateWriter(writer, *header) if err != nil { return errors.Wrap(err, "CreateWriter") } - newPart, err := lib.NewPart( - "text/plain", - map[string]string{"Charset": "UTF-8"}, - c.email, - ) + newPart, err := lib.NewPart("text/plain", mimeParams, c.email) if err != nil { return err } @@ -856,8 +856,13 @@ func writeMsgImpl(c *Composer, header *mail.Header, writer io.Writer) error { return nil } -func writeInlineBody(header *mail.Header, body io.Reader, writer io.Writer) error { - header.SetContentType("text/plain", map[string]string{"charset": "UTF-8"}) +func writeInlineBody( + header *mail.Header, + body io.Reader, + writer io.Writer, + mimeParams map[string]string, +) error { + header.SetContentType("text/plain", mimeParams) w, err := mail.CreateSingleInlineWriter(writer, *header) if err != nil { return errors.Wrap(err, "CreateSingleInlineWriter") |