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 11C5B431FC2 for ; Wed, 29 Oct 2014 01:41:30 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.699 X-Spam-Level: X-Spam-Status: No, score=-0.699 tagged_above=-999 required=5 tests=[RCVD_IN_DNSWL_LOW=-0.7, UNPARSEABLE_RELAY=0.001] 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 PCKsS4z3Flxo for ; Wed, 29 Oct 2014 01:41:26 -0700 (PDT) Received: from mail-wi0-f180.google.com (mail-wi0-f180.google.com [209.85.212.180]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 7E821431FB6 for ; Wed, 29 Oct 2014 01:41:26 -0700 (PDT) Received: by mail-wi0-f180.google.com with SMTP id hi2so3872526wib.7 for ; Wed, 29 Oct 2014 01:41:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:to:subject:in-reply-to:references:user-agent :from:date:message-id:mime-version:content-type; bh=XVN2pKdK1fVnTPtKrk0Z5163MfV1YKiwneEeMIioY/I=; b=g/SkJdzsRf2X2I7ZEtqVfrxvMY6G5n2JE9OsCKW5ffpnmbJCTwKC+pC3YGpBbwEpYg l2H+8Y+l37N0/xmkk/kkaXbHWYnyM9s2uuJs2qxMwqRetnKf26/+oWbByCg49kikvMzG te7ExTFQ+lcq3YkPlv+jrMgrmBvSLH8xQQBlpMJ7exKuT7sfVwd2vKGZKzVeOzDCpow4 DRoh2rKGpGwRHi5DTOXJmSEu2ss1CKpOt/wnwMfDJGYhNl94otjYb1tBomAuM+zrn2ZV kIGfcGgszK7oR5OLzdfRPkA6fZ4A+DDD3OYUXVgMyXDKC65W3KfZDPd9btkz5zXYJytV 3mpg== X-Gm-Message-State: ALoCoQkNWXrAxPZ7D3XBCXcfZbx7S0gu5M9/Vad7PlMU/IG2GNw+fMqcfRec5jQ0O2baReQlqhdQ X-Received: by 10.180.82.7 with SMTP id e7mr10702666wiy.27.1414572084207; Wed, 29 Oct 2014 01:41:24 -0700 (PDT) Received: from disaster-area.hh.sledj.net ([2a01:348:1a2:1:ea39:35ff:fe2c:a227]) by mx.google.com with ESMTPSA id bg10sm4377180wjc.47.2014.10.29.01.41.23 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 29 Oct 2014 01:41:23 -0700 (PDT) Received: from localhost (30000@localhost [local]); by localhost (OpenSMTPD) with ESMTPA id 1cc0af54; Wed, 29 Oct 2014 08:41:22 +0000 (UTC) To: Jani Nikula , notmuch@notmuchmail.org Subject: Re: [PATCH] emacs: add stash support for git send-email command line In-Reply-To: <1414525138-838-1-git-send-email-jani@nikula.org> References: <1414525138-838-1-git-send-email-jani@nikula.org> User-Agent: Notmuch/0.18.1 (http://notmuchmail.org) Emacs/24.3.1 (x86_64-apple-darwin14.0.0) From: David Edmondson Date: Wed, 29 Oct 2014 08:41:22 +0000 Message-ID: MIME-Version: 1.0 Content-Type: text/plain 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, 29 Oct 2014 08:41:30 -0000 On Tue, Oct 28 2014, Jani Nikula wrote: > Stash From/To/Cc as --to/--to/--cc, respectively, and Message-Id as > --in-reply-to, suitable for pasting to git send-email command line. > --- > emacs/notmuch-show.el | 25 +++++++++++++++++++++++++ > 1 file changed, 25 insertions(+) > > diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el > index a9974826e824..328c93ba0584 100644 > --- a/emacs/notmuch-show.el > +++ b/emacs/notmuch-show.el > @@ -1274,6 +1274,7 @@ reset based on the original query." > (define-key map "t" 'notmuch-show-stash-to) > (define-key map "l" 'notmuch-show-stash-mlarchive-link) > (define-key map "L" 'notmuch-show-stash-mlarchive-link-and-go) > + (define-key map "G" 'notmuch-show-stash-git-send-email) > (define-key map "?" 'notmuch-subkeymap-help) > map) > "Submap for stash commands") > @@ -2125,6 +2126,30 @@ the user (see `notmuch-show-stash-mlarchive-link-alist')." > (notmuch-show-stash-mlarchive-link mla) > (browse-url (current-kill 0 t))) > > +(defun notmuch-show-stash-git-helper (addresses prefix) > + "Escape, trim, and add PREFIX to each address in list of ADDRESSES." > + (when addresses > + (mapconcat (lambda (x) > + (concat prefix "\"" > + ;; escape double-quotes > + (replace-regexp-in-string > + "\"" "\\\\\"" > + ;; trim leading and trailing spaces > + (replace-regexp-in-string > + "\\(^ *\\| *$\\)" "" > + x)) "\" ")) > + addresses ""))) This doesn't seem quite right. You leave a spurious trailing space. Maybe that's because you need it in the following function to separate the from/to/cc elements? That kind of interaction between the two functions is icky. There's no need to test `addresses' at the head of the list - mapconcat is fine with nil. How about: (defun notmuch-show-stash-git-helper (addresses prefix) "Escape, trim, and add PREFIX to each address in list of ADDRESSES." (mapconcat (lambda (x) (concat prefix "\"" ;; escape double-quotes (replace-regexp-in-string "\"" "\\\\\"" ;; trim leading and trailing spaces (replace-regexp-in-string "\\(^ *\\| *$\\)" "" x)) "\"")) addresses " ")) This would remove the trailing space, so... > + > +(defun notmuch-show-stash-git-send-email () > + "Copy From/To/Cc/Message-Id of current message to kill-ring in a form suitable for pasting to git send-email command line." > + (interactive) > + (notmuch-common-do-stash > + (concat > + (notmuch-show-stash-git-helper (message-tokenize-header (notmuch-show-get-from)) "--to=") > + (notmuch-show-stash-git-helper (message-tokenize-header (notmuch-show-get-to)) "--to=") > + (notmuch-show-stash-git-helper (message-tokenize-header (notmuch-show-get-cc)) "--cc=") > + (concat "--in-reply-to=\"" (notmuch-show-get-message-id t) "\"")))) ...this would have to use something like: (mapconcat 'identity (list (notmuch-show-stash-git-helper (message-tokenize-header (notmuch-show-get-from)) "--to=") (notmuch-show-stash-git-helper (message-tokenize-header (notmuch-show-get-to)) "--to=") (notmuch-show-stash-git-helper (message-tokenize-header (notmuch-show-get-cc)) "--cc=") (concat "--in-reply-to=\"" (notmuch-show-get-message-id t) "\"")) "") to separate the chunks (untested). Could you avoid the double-quote quoting by using single quotes inside the strings? Do the leading and trailing spaces really matter? (Domo: Look, I managed to write 'separate', twice!) > + > ;; Interactive part functions and their helpers > > (defun notmuch-show-generate-part-buffer (message-id nth) > -- > 2.1.1 > > _______________________________________________ > notmuch mailing list > notmuch@notmuchmail.org > http://notmuchmail.org/mailman/listinfo/notmuch