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 5F7E8431FD0 for ; Tue, 20 Dec 2011 12:12:41 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.799 X-Spam-Level: X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_FROM=0.001, 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 i-dQgYbxgF1q for ; Tue, 20 Dec 2011 12:12:40 -0800 (PST) Received: from mail-ww0-f45.google.com (mail-ww0-f45.google.com [74.125.82.45]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 806D8431FB6 for ; Tue, 20 Dec 2011 12:12:40 -0800 (PST) Received: by wgbds13 with SMTP id ds13so10716678wgb.2 for ; Tue, 20 Dec 2011 12:12:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:subject:in-reply-to:references:user-agent:date:message-id :mime-version:content-type; bh=w2ja/q75YtfiMa9tA7kS1sQ+BIEdiFmcRTFIN9xVYi8=; b=FBuBy1P5Iab6MjjqAdt8q/EeZsTYmFDCsIWWJimdUmF5N8xG1tf/09jE4Dp18CxL/+ uLm+42/kBd5w1P1bQhnnVgbuC8lrm4QFYffE4TsyweOIZnCoy1E1yzvPVSsqvhWkz3RL 69pMN40binN3dNf1m5uymzoRmEhzp8SdWPIXQ= Received: by 10.216.134.162 with SMTP id s34mr1923598wei.59.1324411958903; Tue, 20 Dec 2011 12:12:38 -0800 (PST) Received: from localhost ([91.144.186.21]) by mx.google.com with ESMTPS id n9sm3253664wbo.16.2011.12.20.12.12.37 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 20 Dec 2011 12:12:38 -0800 (PST) From: Dmitry Kurochkin To: Jani Nikula , notmuch@notmuchmail.org Subject: Re: [PATCH] emacs: create patch filename from subject for inline patch fake parts In-Reply-To: <87aa6nxb3o.fsf@nikula.org> References: <1321657368-13872-1-git-send-email-jani@nikula.org> <87aa6nxb3o.fsf@nikula.org> User-Agent: Notmuch/0.10.2+96~g74e5ae5 (http://notmuchmail.org) Emacs/23.3.1 (x86_64-pc-linux-gnu) Date: Wed, 21 Dec 2011 00:11:55 +0400 Message-ID: <87mxanvw8k.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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 20:12:41 -0000 Hi Jani. On Tue, 20 Dec 2011 22:05:31 +0200, Jani Nikula wrote: > > 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? > I do not use the option but the patch sounds useful to me. I would try to review it soon. I think a simple test would be useful here BTW. Regards, Dmitry > > 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)))))) > > > > -- > > 1.7.5.4 > > > _______________________________________________ > notmuch mailing list > notmuch@notmuchmail.org > http://notmuchmail.org/mailman/listinfo/notmuch