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 | |
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>
-rw-r--r-- | CHANGELOG.md | 1 | ||||
-rw-r--r-- | config/aerc.conf | 9 | ||||
-rw-r--r-- | config/compose.go | 1 | ||||
-rw-r--r-- | doc/aerc-config.5.scd | 9 | ||||
-rw-r--r-- | widgets/compose.go | 21 |
5 files changed, 33 insertions, 8 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 6742655c..db160094 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - New column-based message list format with `index-columns`. - Add a `msglist_answered` style for answered messages. +- Compose `Format=Flowed` messages with `format-flowed=true` in `aerc.conf`. ### Changed diff --git a/config/aerc.conf b/config/aerc.conf index b09a7ab7..5f58ceb2 100644 --- a/config/aerc.conf +++ b/config/aerc.conf @@ -386,6 +386,15 @@ # #no-attachment-warning= +# +# When set, aerc will generate "format=flowed" bodies with a content type of +# "text/plain; format=flowed" as described in RFC3676. This format is easier to +# handle for some mailing software, and generally just looks like ordinary +# text. To actually make use of this format's features, you'll need support in +# your editor. +# +#format-flowed=false + [multipart-converters] # # Converters allow to generate multipart/alternative messages by converting the diff --git a/config/compose.go b/config/compose.go index 80d93204..14a3087b 100644 --- a/config/compose.go +++ b/config/compose.go @@ -15,6 +15,7 @@ type ComposeConfig struct { ReplyToSelf bool `ini:"reply-to-self"` NoAttachmentWarning *regexp.Regexp `ini:"-"` FilePickerCmd string `ini:"file-picker-cmd"` + FormatFlowed bool `ini:"format-flowed"` } func defaultComposeConfig() *ComposeConfig { diff --git a/doc/aerc-config.5.scd b/doc/aerc-config.5.scd index 22c3a40a..74481b10 100644 --- a/doc/aerc-config.5.scd +++ b/doc/aerc-config.5.scd @@ -563,6 +563,15 @@ These options are configured in the *[compose]* section of _aerc.conf_. Example: *no-attachment-warning* = _^[^>]\*attach(ed|ment)_ +*format-flowed* = _true_|_false_ + When set, aerc will generate _Format=Flowed_ bodies with a content type + of _"text/plain; Format=Flowed"_ as described in RFC3676. This format is + easier to handle for some mailing software, and generally just looks + like ordinary text. To actually make use of this format's features, + you'll need support in your editor. + + Default: _false_ + # MULTIPART CONVERTERS Converters allow generating _multipart/alternative_ messages by converting the 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") |