diff options
author | Robin Jarry <robin@jarry.cc> | 2022-12-01 20:17:04 +0100 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2022-12-05 17:25:12 +0100 |
commit | c9524d265793775e4c3e326c7191471d982c1e66 (patch) | |
tree | e6d3cee41885f94dd3ce00c09c774536af748f1d /config/config.go | |
parent | be8154d1a77c9dce313a94e51e1b5bea7a21d7b7 (diff) | |
download | aerc-c9524d265793775e4c3e326c7191471d982c1e66.tar.gz |
filters: add wrap utility written in go
I had started writing this as an awk script but quickly got stuck with
obscure code which did not even work properly. I jumped the gun and re
did it in go. Bonus, we will not have MacOS's 1987 BSD awk issues. On
the other hand, instead of a 20.0K awk script, we now have a 2.2M static
go binary. If this makes people scream, I challenge them to do that with
BSD awk :)
Basically, this takes text from stdin or from a file and wraps long
lines on word boundaries. It takes care of not breaking up email quotes
nor list items (numbered as well). Also, it is conservative by default
and only wraps long lines and lines that end with a space (indicating
a format=flowed message).
If the AERC_SUBJECT environment variable is defined and contains the
word PATCH, the text is not modified at all (i.e. wrap behaves as
cat(1)).
There are a few command line options to control behavior:
Usage of ./wrap:
-f string
read from file instead of stdin
-l int
minimum percentage of letters in a line to be considered
a paragaph (default 50)
-r reflow all paragraphs even if no trailing space
-w int
preferred wrap margin (default 80)
Update docs, makefile and default config file with examples.
Add a torture test to ensure it works as expected.
Signed-off-by: Robin Jarry <robin@jarry.cc>
Tested-by: Bence Ferdinandy <bence@ferdinandy.com>
Diffstat (limited to 'config/config.go')
0 files changed, 0 insertions, 0 deletions