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