From c9524d265793775e4c3e326c7191471d982c1e66 Mon Sep 17 00:00:00 2001 From: Robin Jarry Date: Thu, 1 Dec 2022 20:17:04 +0100 Subject: 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 Tested-by: Bence Ferdinandy --- .gitignore | 1 + 1 file changed, 1 insertion(+) (limited to '.gitignore') diff --git a/.gitignore b/.gitignore index 7caf227c..2b1b7a4f 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ /aerc2 /aerc /aerc.debug +/wrap /.aerc.d race.log.* raw.log -- cgit