From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by arlo.cworth.org (Postfix) with ESMTP id 375F16DE0E86 for ; Wed, 27 Feb 2019 23:23:29 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: -0.198 X-Spam-Level: X-Spam-Status: No, score=-0.198 tagged_above=-999 required=5 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_PASS=-0.001] autolearn=disabled Received: from arlo.cworth.org ([127.0.0.1]) by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 3BQo_qUcMyXK for ; Wed, 27 Feb 2019 23:23:28 -0800 (PST) Received: from mail-pg1-f193.google.com (mail-pg1-f193.google.com [209.85.215.193]) by arlo.cworth.org (Postfix) with ESMTPS id 787216DE0E84 for ; Wed, 27 Feb 2019 23:23:28 -0800 (PST) Received: by mail-pg1-f193.google.com with SMTP id r124so9273482pgr.3 for ; Wed, 27 Feb 2019 23:23:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:references:date:message-id:mime-version; bh=EFmNr3cGqfZYSPyjt7GVAtDxeI5n1yS6Ma+Qj3MCFtU=; b=R22IM2R2UllW8JKZleYR5/XxT/S5NSGEgLBOE7zhEVIBMsMc6MWjsTWMa5PHz3LfW3 GjG3M10JKf86huulOOnmtvZ3lIopgjUR8+G9NbhiWaZ6TyEoWHkeeguDk75NciEuO3Au vKRHkIIEZLLa+Td8Iq8b//bS/ht+iilDLz8MdsClxlf3dQT1DWZiPNU6dzS9TXTM5bKb HdTSG4ciIbuL/NWntQ4mCpe0ymRtO3JEBoeDC3POwNYqvkhw8SE7Y0UbktSOb+lEhpWF iWIedf3IH1FoUDPIiJ9prVhv02acCwt8JvmOWQeVdA4jw0S6KijcRIwb07HTVxSyej4j Np2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:references:date:message-id :mime-version; bh=EFmNr3cGqfZYSPyjt7GVAtDxeI5n1yS6Ma+Qj3MCFtU=; b=hbJ/chTTHKCst2fPyf3lKwqzI8N3KVpp0JW3JYvodFZwsNeWwDm8ug83FLH3kf01tZ R8tyyNIDfUQurqmxWoJAHNNVJUbliBfCTinugJHTWYv/anMmEb61SGuMyHnvg8RyXiKw DQOqbDnm4PoIQWYufXWDCPB7mZdg7AK0lXkhf1qw2soTwVAX1IOBoq7VymMoUqigWJ2+ b+zK07Vp+jqHZS+Sl22k4NCbkc1vMul4ibut9S3asAQpmzljD18L/pXnYxSeNHbxqsKM dA510BgjNzwXWee+yFIx7YsrfgF3+NWlDLiRihJNkOWzGCM6bFLH+FiluBwHg2NHu0PX fEmw== X-Gm-Message-State: AHQUAubSPxbQAhGBVXznpMcm97Wp9m/VFeHCwKwV0QTlIQzsvSFdq1h3 zY2BrAaQNUb9Qz4SsyNbHA2VvRbe X-Google-Smtp-Source: AHgI3IbCSA31HOll3JUQSV+btBUXD4LYondZ5PLx/mmqp497MK1iac2NiQqEJyvGXp1VfoMR1cqs7w== X-Received: by 2002:a63:e410:: with SMTP id a16mr7175456pgi.28.1551338607505; Wed, 27 Feb 2019 23:23:27 -0800 (PST) Received: from [202.41.76.67] ([14.139.123.52]) by smtp.gmail.com with ESMTPSA id b85sm50281062pfj.56.2019.02.27.23.23.25 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 Feb 2019 23:23:26 -0800 (PST) From: Jayanth R Varma To: notmuch@notmuchmail.org Subject: Re: [RFC] writing HTML email with notmuch References: Date: Thu, 28 Feb 2019 12:53:21 +0530 Message-ID: <871s3s2x7a.fsf@JRVARMAPC.i-did-not-set--mail-host-address--so-tickle-me> MIME-Version: 1.0 Content-Type: text/plain; format=flowed X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 28 Feb 2019 07:23:29 -0000 Antoine Beaupr? writes: > The idea is that you write your email normally, but in > markdown. When > you're done writing that email, you launch the above function > (carefully > bound to "M-x anarcat/notmuch-html-convert" here) which takes > that email > and adds an equivalent HTML part to it. You can then even tweak > that > part to screw around with the raw HTML if you feel depressed or > nostalgic. > > What do people think? Am I insane? Could this work? Does this > belong in > notmuch? Or maybe in the tips section? Should I seek therapy? Do > you > hate markdown? Expand on the relationship between your parents > and text > editors. I do something similar routinely. I have bound the C-c C-c key to a function that presents me with four choices: 1. Send as plain text 2. Send as HTML 3. Preview HTML in emacs (with w3m) 4. Preview HTML with external browser For a few weeks, I suggest religiously previewing HTML in external browser before sending any HTML mail because there are a lot of things that can go wrong (more on this below). After most of the wrinkles are ironed out, you can switch to previewing in emacs-w3m. When you are really sure that everything is working, you can send most simple mails as HTML without preview, but I would still suggest previewing complex mails (for example with tables, embedded code and so on). What can go wrong: 1. Lazy blockquote in markdown means that you must leave a blank line between a quoted message and your response, or else your response will also be part of the blockquote. It is so easy to slip up on this in email. In fact, I am considering adding some code to insert this blank line automatically. 2. Signatures: Since you know your own signature, it is best to search for an exact match for it rather than rely on some heuristics. 3. Attachments. In plain text mail, attachments can be anywhere. Many years ago, I once inserted an attachment by mistake mid-sentence, but the email was sent and received perfectly (apart from an extra line break). So you have to be careful while converting to HTML. My method is to use a regex search to find all attachments and move them to the end of the email. So the converted message begins with a multi-part/alternative with plain text and html alternatives at the top. This is followed by the signature and the attachments. Since these are now all plain text parts (the email default), there is no need for any
 tags for 
the signature.

Conversion to HTML

1. I use pandoc for the conversion because it gives complete 
ability to customize the exact flavour of markdown that you want 
(for example, table formats).

2. Although everything can surely be done in elisp, I prefer to 
delegate most of the pre-processing and previewing to a external 
(python) script which orchestrates everything: creating temp 
files, invoking pandoc, running external browsers and cleaning up 
at the end.

3. I ensure that previewing the HTML does not change the message 
buffer at all (everything happens in other buffers or in temp 
files). So you can keep tweaking the markdown till you get 
everything right, and there is no need to tweak the raw HTML.

PS: I am also a plain text guy. But in email, plain text does not 
mean plain text (as in unicode), it actually means 7-bit ASCII. So 
if you want a euro or yen symbol, Greek letters or mathematical 
symbols, you need HTML just as a wrapper to provide UTF encoding. 

PPS: If you are writing markdown and sending both plain text and 
HTML alternatives, you are not really a sinner. Only the recipient 
who chooses to view the HTML part is sinning (and even that sin 
can be condoned if the recipient uses notmuch/emacs to render the 
HTML).