Re: [PATCH] emacs: create patch filename from subject for inline patch fake parts
authorJani Nikula <jani@nikula.org>
Wed, 21 Dec 2011 20:21:27 +0000 (22:21 +0200)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:41:09 +0000 (09:41 -0800)
a3/ead7f167660df478f22f3d183712f8e3a614f5 [new file with mode: 0644]

diff --git a/a3/ead7f167660df478f22f3d183712f8e3a614f5 b/a3/ead7f167660df478f22f3d183712f8e3a614f5
new file mode 100644 (file)
index 0000000..7396ae5
--- /dev/null
@@ -0,0 +1,99 @@
+Return-Path: <jani@nikula.org>\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 51607431FD0\r
+       for <notmuch@notmuchmail.org>; Wed, 21 Dec 2011 12:21:37 -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 mlO482GXKpw3 for <notmuch@notmuchmail.org>;\r
+       Wed, 21 Dec 2011 12:21:36 -0800 (PST)\r
+Received: from mail-ee0-f53.google.com (mail-ee0-f53.google.com\r
+ [74.125.83.53])       (using TLSv1 with cipher RC4-SHA (128/128 bits))        (No client\r
+ certificate requested)        by olra.theworths.org (Postfix) with ESMTPS id\r
+ 88B8D431FB6   for <notmuch@notmuchmail.org>; Wed, 21 Dec 2011 12:21:36 -0800\r
+ (PST)\r
+Received: by eekd41 with SMTP id d41so9359248eek.26\r
+       for <notmuch@notmuchmail.org>; Wed, 21 Dec 2011 12:21:33 -0800 (PST)\r
+Received: by 10.213.15.139 with SMTP id k11mr81354eba.69.1324498892337;\r
+       Wed, 21 Dec 2011 12:21:32 -0800 (PST)\r
+Received: from localhost (dsl-hkibrasgw4-fe5cdc00-23.dhcp.inet.fi.\r
+       [80.220.92.23])\r
+       by mx.google.com with ESMTPS id 13sm24640216eeu.1.2011.12.21.12.21.29\r
+       (version=SSLv3 cipher=OTHER); Wed, 21 Dec 2011 12:21:30 -0800 (PST)\r
+From: Jani Nikula <jani@nikula.org>\r
+To: Austin Clements <amdragon@MIT.EDU>, David Edmondson <dme@dme.org>\r
+Subject: Re: [PATCH] emacs: create patch filename from subject for inline\r
+       patch fake parts\r
+In-Reply-To: <20111221144008.GG10376@mit.edu>\r
+References: <1321657368-13872-1-git-send-email-jani@nikula.org>\r
+       <87aa6nxb3o.fsf@nikula.org> <20111220215229.GF10376@mit.edu>\r
+       <cun4nwuxota.fsf@hotblack-desiato.hh.sledj.net>\r
+       <20111221144008.GG10376@mit.edu>\r
+User-Agent: Notmuch/0.10.2+120~ga2d869a (http://notmuchmail.org) Emacs/23.3.1\r
+       (i686-pc-linux-gnu)\r
+Date: Wed, 21 Dec 2011 22:21:27 +0200\r
+Message-ID: <877h1py8u0.fsf@nikula.org>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\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: Wed, 21 Dec 2011 20:21:37 -0000\r
+\r
+On Wed, 21 Dec 2011 09:40:08 -0500, Austin Clements <amdragon@MIT.EDU> wrote:\r
+> I would definitely go with the latter.\r
+> \r
+> It might feel less unwieldy with a shorter variable name than\r
+> "filename", since that has to be repeated so many times.  (It's also\r
+> not really a filename in the middle of the replace process.)\r
+> \r
+> This is splitting hairs, but in my original suggestion, I was thinking\r
+> something like\r
+> \r
+>   (let* ((s subject)\r
+>          (s (replace-regexp-in-string "^ *\\(\\[[^]]*\\]\\)? *" "" s))\r
+>          (s (replace-regexp-in-string "[. ]*$" "" s))\r
+>          (s (replace-regexp-in-string "[^A-Za-z0-9._-]+" "-" s))\r
+>          (s (replace-regexp-in-string "\\.+" "." s))\r
+>          (s (substring s 0 (min (length s) 50))))\r
+>      (concat s ".patch"))\r
+> \r
+> Out of curiosity, where'd the regexps come from?  They all seem\r
+> reasonable, but some of them seem somewhat arbitrary.\r
+\r
+The regexps should definitely have some explanation. I tried to mimic\r
+the 'git format-patch' behaviour [1] using as simple and straightforward\r
+regexps as possible. For simplicity, there's no creation of patch\r
+sequence numbers. The max length is the same as in git, excluding the\r
+sequence number.\r
+\r
+If the patch was sent using git format-patch/send-email, this should\r
+result in re-creation of the same filename as the sender had (apart from\r
+the sequence number, obviously).\r
+\r
+I seem to be missing the trimming of any trailing '.' and '-' after\r
+truncating the string to max length, though.\r
+\r
+\r
+BR,\r
+Jani.\r
+\r
+[1] https://github.com/gitster/git/blob/master/pretty.c#L712\r
+\r