I would definitely go with the latter. It might feel less unwieldy with a shorter variable name than "filename", since that has to be repeated so many times. (It's also not really a filename in the middle of the replace process.) This is splitting hairs, but in my original suggestion, I was thinking something like (let* ((s subject) (s (replace-regexp-in-string "^ *\\(\\[[^]]*\\]\\)? *" "" s)) (s (replace-regexp-in-string "[. ]*$" "" s)) (s (replace-regexp-in-string "[^A-Za-z0-9._-]+" "-" s)) (s (replace-regexp-in-string "\\.+" "." s)) (s (substring s 0 (min (length s) 50)))) (concat s ".patch")) Out of curiosity, where'd the regexps come from? They all seem reasonable, but some of them seem somewhat arbitrary. Quoth David Edmondson on Dec 21 at 9:21 am: > On Tue, 20 Dec 2011 16:52:52 -0500, Austin Clements <amdragon@MIT.EDU> wrote: > > 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 > (let ((filename subject) > (transforms > '(("^ *\\(\\[[^]]*\\]\\)? *" . "") > ("[. ]*$" . "") > ("[^A-Za-z0-9._-]+" . "-") > ("\\.+" . ".")))) > (mapc (lambda (transform) > (setq filename (replace-regexp-in-string (car transform) (cdr transform) 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 > (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.