~rjarry/aerc-devel

aerc: compose: prevent trailing spaces on empty headers v1 APPLIED

Jonathan Dowland: 1
 compose: prevent trailing spaces on empty headers

 1 files changed, 8 insertions(+), 1 deletions(-)
#1375564 alpine-edge.yml success
#1375565 openbsd.yml success
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~rjarry/aerc-devel/patches/56121/mbox | git am -3
Learn more about email & git

[PATCH aerc] compose: prevent trailing spaces on empty headers Export this patch

When using format-flowed=true, you need to configure your editor to
format the text accordingly. With (neo)vim, this is achieved by setting
formatoptions+=w (trailing whitespace indicates paragraph continuation).
This may also be combined with +=a (automatically reflow paragraphs as
you edit).

When also using edit-headers=true, empty header lines are considered
part of the same paragraph (by vim) if they have a trailing space. This
can make editing the headers difficult (the editor may mistakenly join
them together).

To prevent this, vary the separator between header field name and body
depending on whether the body is empty. If so, only use the ":".  This
is valid syntax for the populated case too, but including a space is
aesthetically pleasing, so for that case use ": " as the separator.

Signed-off-by: Jonathan Dowland <jon+aerc-devel@dow.land>
---
 app/compose.go | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/app/compose.go b/app/compose.go
index 451981cd..ff2737d7 100644
--- a/app/compose.go
+++ b/app/compose.go
@@ -537,7 +537,14 @@ func (c *Composer) setContents(reader io.Reader) error {
				}
			}
			key := textproto.CanonicalMIMEHeaderKey(h)
			_, err = fmt.Fprintf(c.email, "%s: %s"+lineEnding, key, value)

			var sep string
			if value == "" {
				sep = ":"
			} else {
				sep = ": "
			}
			_, err = fmt.Fprintf(c.email, "%s%s%s%s", key, sep, value, lineEnding)
			if err != nil {
				return err
			}
-- 
2.39.2
aerc/patches: SUCCESS in 2m4s

[compose: prevent trailing spaces on empty headers][0] from [Jonathan Dowland][1]

[0]: https://lists.sr.ht/~rjarry/aerc-devel/patches/56121
[1]: mailto:jon+aerc-devel@dow.land

✓ #1375565 SUCCESS aerc/patches/openbsd.yml     https://builds.sr.ht/~rjarry/job/1375565
✓ #1375564 SUCCESS aerc/patches/alpine-edge.yml https://builds.sr.ht/~rjarry/job/1375564
Jonathan Dowland <jon+aerc-devel@dow.land> wrote: