Re: [PATCH] emacs: create patch filename from subject for inline patch fake parts
authorAustin Clements <amdragon@MIT.EDU>
Tue, 20 Dec 2011 21:52:52 +0000 (16:52 +1900)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:41:07 +0000 (09:41 -0800)
94/8324beacfa69ef084e949e2767ac986e5d3a62 [new file with mode: 0644]

diff --git a/94/8324beacfa69ef084e949e2767ac986e5d3a62 b/94/8324beacfa69ef084e949e2767ac986e5d3a62
new file mode 100644 (file)
index 0000000..281fad5
--- /dev/null
@@ -0,0 +1,153 @@
+Return-Path: <amdragon@mit.edu>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id D0042431FD0\r
+       for <notmuch@notmuchmail.org>; Tue, 20 Dec 2011 13:51:47 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+       tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id wvniBTc9WMoQ for <notmuch@notmuchmail.org>;\r
+       Tue, 20 Dec 2011 13:51:47 -0800 (PST)\r
+Received: from dmz-mailsec-scanner-1.mit.edu (DMZ-MAILSEC-SCANNER-1.MIT.EDU\r
+       [18.9.25.12])\r
+       by olra.theworths.org (Postfix) with ESMTP id 22357431FB6\r
+       for <notmuch@notmuchmail.org>; Tue, 20 Dec 2011 13:51:47 -0800 (PST)\r
+X-AuditID: 1209190c-b7fad6d000000920-1d-4ef10370130e\r
+Received: from mailhub-auth-3.mit.edu ( [18.9.21.43])\r
+       by dmz-mailsec-scanner-1.mit.edu (Symantec Messaging Gateway) with SMTP\r
+       id F6.C1.02336.07301FE4; Tue, 20 Dec 2011 16:51:44 -0500 (EST)\r
+Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])\r
+       by mailhub-auth-3.mit.edu (8.13.8/8.9.2) with ESMTP id pBKLphAl011602; \r
+       Tue, 20 Dec 2011 16:51:44 -0500\r
+Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91])\r
+       (authenticated bits=0)\r
+       (User authenticated as amdragon@ATHENA.MIT.EDU)\r
+       by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id pBKLpfL7021118\r
+       (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
+       Tue, 20 Dec 2011 16:51:42 -0500 (EST)\r
+Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.77)\r
+       (envelope-from <amdragon@mit.edu>)\r
+       id 1Rd7cC-0004yc-2R; Tue, 20 Dec 2011 16:52:52 -0500\r
+Date: Tue, 20 Dec 2011 16:52:52 -0500\r
+From: Austin Clements <amdragon@MIT.EDU>\r
+To: Jani Nikula <jani@nikula.org>\r
+Subject: Re: [PATCH] emacs: create patch filename from subject for inline\r
+       patch fake parts\r
+Message-ID: <20111220215229.GF10376@mit.edu>\r
+References: <1321657368-13872-1-git-send-email-jani@nikula.org>\r
+       <87aa6nxb3o.fsf@nikula.org>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\r
+Content-Disposition: inline\r
+In-Reply-To: <87aa6nxb3o.fsf@nikula.org>\r
+User-Agent: Mutt/1.5.21 (2010-09-15)\r
+X-Brightmail-Tracker:\r
+ H4sIAAAAAAAAA+NgFupjleLIzCtJLcpLzFFi42IR4hTV1i1g/uhnsH0bv0XTdGeL6zdnMjsw\r
+       edy6/5rd49mqW8wBTFFcNimpOZllqUX6dglcGdf/rmEq2ClRMX3BQvYGxg7hLkZODgkBE4lz\r
+       K9+wQNhiEhfurWfrYuTiEBLYxyixY/EFFghnA6PEjZsH2ECqhAROMkkceCQJkVjCKNFzaRk7\r
+       SIJFQFXi88oDzCA2m4CGxLb9yxlBbBEBRYnNJ/eD2cwC0hLffjczgdjCAjEST/9NAlvNK6Aj\r
+       8fDcV2aIBbESlzf+Z4WIC0qcnPmEBaJXS+LGv5dAvRxgc5b/4wAJcwKtOts2AWy8qICKxJST\r
+       29gmMArNQtI9C0n3LITuBYzMqxhlU3KrdHMTM3OKU5N1i5MT8/JSi3QN9XIzS/RSU0o3MYKD\r
+       WpJnB+Obg0qHGAU4GJV4eAX3f/ATYk0sK67MPcQoycGkJMrrx/TRT4gvKT+lMiOxOCO+qDQn\r
+       tfgQowQHs5IIb8wzoHLelMTKqtSifJiUNAeLkjivitY7PyGB9MSS1OzU1ILUIpisDAeHkgTv\r
+       SZChgkWp6akVaZk5JQhpJg5OkOE8QMOPg9TwFhck5hZnpkPkTzHqcuz9/P0MoxBLXn5eqpQ4\r
+       7wyQIgGQoozSPLg5sGT0ilEc6C1h3qMgVTzARAY36RXQEiagJducQT4oLklESEk1MK51EWpV\r
+       3X7AOkzMdFOKwj69t1yzXae+OyJ6PeqCjJTDHLGPwTft2l53eU7pCNr/yvVEaILRqztem1JK\r
+       rnVvnvLMa4a8byULb+vP21dOWhhJ8d/8d7tc4aq69/L5Z+9GH3bTSCj++7gmkf1MuHaKzJ4w\r
+       gVn71Tu9957g6Ynj38j3yuBL51+rLCWW4oxEQy3mouJEACuZATEhAwAA\r
+Cc: notmuch@notmuchmail.org\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Tue, 20 Dec 2011 21:51:47 -0000\r
+\r
+Seems like a definite improvement, but perhaps a let* instead of all\r
+of the setq's?\r
+\r
+Quoth Jani Nikula on Dec 20 at 10:05 pm:\r
+> \r
+> Shameless promotion of own patches... I suppose not many use the\r
+> notmuch-wash-convert-inline-patch-to-part option, but with this patch\r
+> I've actually started to like it better. An actual patch name from\r
+> subject instead of "inline patch".\r
+> \r
+> As I said, the lisp is less than perfect here, but this is still better\r
+> than what's existing.\r
+> \r
+> Any comments?\r
+> \r
+> \r
+> BR,\r
+> Jani.\r
+> \r
+> \r
+> On Sat, 19 Nov 2011 01:02:48 +0200, Jani Nikula <jani@nikula.org> wrote:\r
+> > Use the mail subject line for creating a descriptive filename for the wash\r
+> > generated inline patch fake parts. The names are similar to the ones\r
+> > created by 'git format-patch', just without the leading numbers.\r
+> > \r
+> > Signed-off-by: Jani Nikula <jani@nikula.org>\r
+> > \r
+> > ---\r
+> > \r
+> > I know notmuch-subject-to-patch-filename is totally un-lispy. Suggestions\r
+> > welcome on how to make it lispy and keep it somewhat readable.\r
+> > \r
+> > If we later want to have a '>' counterpart to '|' to save messages to files\r
+> > rather than pipe, then this could be generalized and re-used for creating\r
+> > the suggested filename for that.\r
+> > \r
+> > I don't even use the notmuch-wash-convert-inline-patch-to-part option that\r
+> > much, but having it suggest "inline patch" as filename is just ugly...\r
+> > ---\r
+> >  emacs/notmuch-wash.el |   16 +++++++++++++++-\r
+> >  1 files changed, 15 insertions(+), 1 deletions(-)\r
+> > \r
+> > diff --git a/emacs/notmuch-wash.el b/emacs/notmuch-wash.el\r
+> > index 1f420b2..755d64a 100644\r
+> > --- a/emacs/notmuch-wash.el\r
+> > +++ b/emacs/notmuch-wash.el\r
+> > @@ -290,6 +290,17 @@ When doing so, maintaining citation leaders in the wrapped text."\r
+> >  \r
+> >  (defvar diff-file-header-re) ; From `diff-mode.el'.\r
+> >  \r
+> > +(defun notmuch-subject-to-patch-filename (str)\r
+> > +  "Convert a typical patch mail subject line into a suitable filename."\r
+> > +  (let ((s str))\r
+> > +    (setq s (replace-regexp-in-string "^ *\\(\\[[^]]*\\]\\)? *" "" s))\r
+> > +    (setq s (replace-regexp-in-string "[. ]*$" "" s))\r
+> > +    (setq s (replace-regexp-in-string "[^A-Za-z0-9._-]+" "-" s))\r
+> > +    (setq s (replace-regexp-in-string "\\.+" "." s))\r
+> > +    (when (> (length s) 52)\r
+> > +      (setq s (substring s 0 52)))\r
+> > +    (concat s ".patch")))\r
+> > +\r
+> >  (defun notmuch-wash-convert-inline-patch-to-part (msg depth)\r
+> >    "Convert an inline patch into a fake 'text/x-diff' attachment.\r
+> >  \r
+> > @@ -316,7 +327,10 @@ for error."\r
+> >        (setq part (plist-put part :content-type "text/x-diff"))\r
+> >        (setq part (plist-put part :content (buffer-string)))\r
+> >        (setq part (plist-put part :id -1))\r
+> > -      (setq part (plist-put part :filename "inline patch"))\r
+> > +      (setq part (plist-put part :filename\r
+> > +                            (notmuch-subject-to-patch-filename\r
+> > +                             (plist-get\r
+> > +                              (plist-get msg :headers) :Subject))))\r
+> >        (delete-region (point-min) (point-max))\r
+> >        (notmuch-show-insert-bodypart nil part depth))))))\r