Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 66345429E29 for ; Wed, 21 Dec 2011 01:21:46 -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 JC7f4cT-ZF2H for ; Wed, 21 Dec 2011 01:21:45 -0800 (PST) Received: from mail-qy0-f181.google.com (mail-qy0-f181.google.com [209.85.216.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id D0B43431FB6 for ; Wed, 21 Dec 2011 01:21:45 -0800 (PST) Received: by qcha6 with SMTP id a6so5368187qch.26 for ; Wed, 21 Dec 2011 01:21:45 -0800 (PST) Received: by 10.229.75.135 with SMTP id y7mr2312448qcj.40.1324459305042; Wed, 21 Dec 2011 01:21:45 -0800 (PST) Received: from hotblack-desiato.hh.sledj.net (host81-149-164-25.in-addr.btopenworld.com. [81.149.164.25]) by mx.google.com with ESMTPS id h9sm9388833qac.13.2011.12.21.01.21.42 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 21 Dec 2011 01:21:44 -0800 (PST) Received: by hotblack-desiato.hh.sledj.net (Postfix, from userid 30000) id 10478A0501; Wed, 21 Dec 2011 09:21:41 +0000 (GMT) To: Austin Clements , Jani Nikula Subject: Re: [PATCH] emacs: create patch filename from subject for inline patch fake parts In-Reply-To: <20111220215229.GF10376@mit.edu> References: <1321657368-13872-1-git-send-email-jani@nikula.org> <87aa6nxb3o.fsf@nikula.org> <20111220215229.GF10376@mit.edu> User-Agent: Notmuch/0.10.2+107~ga2d0215 (http://notmuchmail.org) Emacs/24.0.92.1 (x86_64-pc-linux-gnu) From: David Edmondson Date: Wed, 21 Dec 2011 09:21:37 +0000 Message-ID: MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" 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: Wed, 21 Dec 2011 09:21:46 -0000 --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable On Tue, 20 Dec 2011 16:52:52 -0500, Austin Clements wrot= e: > Seems like a definite improvement, but perhaps a let* instead of all > of the setq's? What would be a lispy approach? I tried: (defun notmuch-subject-to-patch-filename (subject) "Convert a typical patch mail subject line into a suitable filename." (concat=20 (let ((filename subject) (transforms '(("^ *\\(\\[[^]]*\\]\\)? *" . "") ("[. ]*$" . "") ("[^A-Za-z0-9._-]+" . "-") ("\\.+" . ".")))) (mapc (lambda (transform) (setq filename (replace-regexp-in-string (car transform) (cdr transfo= rm) filename))) transforms) (substring filename 0 (min (length filename) 50))) ".patch")) ...but that seems a bit unwieldy. `let*' looks best, but still feels a bit odd: (defun notmuch-subject-to-patch-filename (subject) "Convert a typical patch mail subject line into a suitable filename." (concat=20 (let* ((filename (replace-regexp-in-string "^ *\\(\\[[^]]*\\]\\)? *" "" = subject)) (filename (replace-regexp-in-string "[. ]*$" "" filename)) (filename (replace-regexp-in-string "[^A-Za-z0-9._-]+" "-" filename)) (filename (replace-regexp-in-string "\\.+" "." filename))) (substring filename 0 (min (length filename) 50))) ".patch")) dme. =2D-=20 David Edmondson, http://dme.org --=-=-= Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) iEYEARECAAYFAk7xpSEACgkQaezQq/BJZRYGGwCfQYZkbnDdCwCppuPST+dBrgn8 pqgAoIEdLro1vT+U8OnrcAnFIXve/osf =NfGm -----END PGP SIGNATURE----- --=-=-=--