Better multipart, working tmpfile cleanup

Tue, 07 Jan 2020 14:27:38 -0600

author
Meredith Howard <mhoward@roomag.org>
date
Tue, 07 Jan 2020 14:27:38 -0600
changeset 847
3d460b026be9
parent 846
2786ee9990c6
child 848
c39d655f455c

Better multipart, working tmpfile cleanup

.muttrc file | annotate | diff | comparison | revisions
bin/mutt-md2multipart file | annotate | diff | comparison | revisions
--- a/.muttrc
+++ b/.muttrc
@@ -100,14 +100,12 @@ macro compose \eh "F mutt-md2html \ny^T^
 # Turn a text/plain markdown part into proper multipart
 macro compose \em \
 "<enter-command>set pipe_decode<enter>\
-<pipe-entry>~/bin/mutt-md2multipart /tmp/$hostname<enter>\
-<enter-command>unset pipe-decode<enter>\
-a^U/tmp/$hostname/msg.txt\n^Da^U/tmp/$hostname/msg.html\n^D^T^Utext/html; charset=utf-8\n\
-=DTT&d^U\n" \
+<pipe-entry>~/bin/mutt-md2html -o /tmp/mutt-$hostname.msg.html<enter>\
+<enter-command>unset pipe_decode<enter>\
+a^U/tmp/mutt-$hostname.msg.html\n^Du^T^Utext/html; charset=utf-8\n\
+=TT&d^U\n" \
 "multipartify"
 
-shutdown-hook 'shell-escape rm -rf /tmp/$hostname'
-
 push <first-entry>
 
 # Appearance
deleted file mode 100755
--- a/bin/mutt-md2multipart
+++ /dev/null
@@ -1,37 +0,0 @@
-#!/bin/sh
-set -eu
-
-output=$1
-
-# Output directory is going to be one-per-process.  I'd like to have a fully
-# random tmpdir but doing that and having it mutt clean up is "hard".  Note
-# that when these two parts get attached, we can't just clean files inside the
-# macro, because they aren't read into memory until send/save.
-
-mkdir -p $output
-
-# Store stdin because we're using it twice.
-cat - > $output/msg.orig
-
-# Noting the above, there may be old output here.  pandoc likes to confirm
-# overwrites so we handle it.
-rm -f $output/msg.{txt,html}
-
-pandoc \
-  --quiet \
-  -f markdown-blank_before_blockquote+smart \
-  -t plain \
-  -o $output/msg.txt \
-  $output/msg.orig
-
-pandoc \
-  --quiet \
-  --standalone \
-  -f markdown-blank_before_blockquote+smart \
-  -t html5 \
-  --self-contained \
-  --template=mail \
-  --highlight-style=monochrome \
-  --email-obfuscation=none \
-  -o $output/msg.html \
-  $output/msg.orig

mercurial