--- /dev/null
+Return-Path: <dme@dme.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 7ACE5429E3D\r
+ for <notmuch@notmuchmail.org>; Wed, 4 Jan 2012 06:01:27 -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 1LPjc9LL7l3a for <notmuch@notmuchmail.org>;\r
+ Wed, 4 Jan 2012 06:01:23 -0800 (PST)\r
+Received: from mail-we0-f181.google.com (mail-we0-f181.google.com\r
+ [74.125.82.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id 91E50431FD0\r
+ for <notmuch@notmuchmail.org>; Wed, 4 Jan 2012 06:01:23 -0800 (PST)\r
+Received: by werm12 with SMTP id m12so10884530wer.26\r
+ for <notmuch@notmuchmail.org>; Wed, 04 Jan 2012 06:01:22 -0800 (PST)\r
+Received: by 10.216.139.222 with SMTP id c72mr37663113wej.4.1325685682236;\r
+ Wed, 04 Jan 2012 06:01:22 -0800 (PST)\r
+Received: from hotblack-desiato.hh.sledj.net\r
+ (host81-149-164-25.in-addr.btopenworld.com. [81.149.164.25])\r
+ by mx.google.com with ESMTPS id 1sm134836224wiz.11.2012.01.04.06.01.20\r
+ (version=TLSv1/SSLv3 cipher=OTHER);\r
+ Wed, 04 Jan 2012 06:01:21 -0800 (PST)\r
+Received: by hotblack-desiato.hh.sledj.net (Postfix, from userid 30000)\r
+ id 4C3B9A0334; Wed, 4 Jan 2012 14:01:19 +0000 (GMT)\r
+From: David Edmondson <dme@dme.org>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH] emacs: Helpers for notmuch developers.\r
+Date: Wed, 4 Jan 2012 14:01:18 +0000\r
+Message-Id: <1325685678-12710-1-git-send-email-dme@dme.org>\r
+X-Mailer: git-send-email 1.7.7.3\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=UTF-8\r
+Content-Transfer-Encoding: 8bit\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, 04 Jan 2012 14:01:27 -0000\r
+\r
+---\r
+\r
+I've been using this for a few days and decided to share it to get\r
+feedback. Reviewing patches can be tedious, so I tried to make things\r
+a little simpler.\r
+\r
+To use this, load the file and then from `notmuch-show-mode' invoke\r
+`notmuch-dev-show-review-patch'. It assumes that any open messages\r
+contain patches and attempts to build a repository with the patches\r
+applied.\r
+\r
+General management (i.e. keeping up to date) of the repository it uses\r
+is your responsibility, as is cleaning out old branches. You can, of\r
+course, just delete the temporary repository after using it - the code\r
+will re-create it next time.\r
+\r
+If you have a slow network connection then a local copy of the main\r
+repository can be specified by changing\r
+`notmuch-dev-master-repository'.\r
+\r
+Comments?\r
+\r
+ emacs/notmuch-dev.el | 121 ++++++++++++++++++++++++++++++++++++++++++++++++++\r
+ 1 files changed, 121 insertions(+), 0 deletions(-)\r
+ create mode 100644 emacs/notmuch-dev.el\r
+\r
+diff --git a/emacs/notmuch-dev.el b/emacs/notmuch-dev.el\r
+new file mode 100644\r
+index 0000000..63ee490\r
+--- /dev/null\r
++++ b/emacs/notmuch-dev.el\r
+@@ -0,0 +1,121 @@\r
++;; notmuch-dev.el --- help for notmuch developers\r
++;;\r
++;; Copyright © David Edmondson\r
++;;\r
++;; This file is part of Notmuch.\r
++;;\r
++;; Notmuch is free software: you can redistribute it and/or modify it\r
++;; under the terms of the GNU General Public License as published by\r
++;; the Free Software Foundation, either version 3 of the License, or\r
++;; (at your option) any later version.\r
++;;\r
++;; Notmuch is distributed in the hope that it will be useful, but\r
++;; WITHOUT ANY WARRANTY; without even the implied warranty of\r
++;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
++;; General Public License for more details.\r
++;;\r
++;; You should have received a copy of the GNU General Public License\r
++;; along with Notmuch. If not, see <http://www.gnu.org/licenses/>.\r
++;;\r
++;; Authors: David Edmondson <dme@dme.org>\r
++\r
++(require 'notmuch-lib)\r
++(require 'notmuch-show)\r
++(require 'magit)\r
++\r
++(defgroup notmuch-dev nil\r
++ "Helpers for notmuch developers."\r
++ :group 'notmuch)\r
++\r
++(defcustom notmuch-dev-master-repository "git://notmuchmail.org/git/notmuch"\r
++ "The URI of the master notmuch repository."\r
++ :group 'notmuch-dev\r
++ :type 'string)\r
++\r
++(defcustom notmuch-dev-temporary-directory temporary-file-directory\r
++ "A directory in which to place temporary repositories."\r
++ :group 'notmuch-dev\r
++ :type 'string)\r
++\r
++;;\r
++\r
++(defvar notmuch-dev-temporary-repository-name (concat "notmuch-dev-" (user-login-name))\r
++ "The name of the temporary repository.")\r
++\r
++(defvar notmuch-dev-temporary-repository-path\r
++ (file-name-as-directory (file-truename (concat notmuch-dev-temporary-directory "/"\r
++ notmuch-dev-temporary-repository-name)))\r
++ "The path of the temporary repository.")\r
++\r
++(defun notmuch-dev-make-temporary-repository ()\r
++ (unless (file-directory-p notmuch-dev-temporary-repository-path)\r
++ (message "Cloning %s into %s..." \r
++ notmuch-dev-master-repository notmuch-dev-temporary-repository-path)\r
++ (magit-run* (list magit-git-executable "clone"\r
++ notmuch-dev-master-repository\r
++ notmuch-dev-temporary-repository-path))\r
++\r
++ (unless (file-directory-p notmuch-dev-temporary-repository-path)\r
++ (error "git clone failed.")))\r
++\r
++ ;; Causes us to switch to the magit buffer - is that unfortunate in\r
++ ;; some situations?\r
++ (magit-status notmuch-dev-temporary-repository-path))\r
++\r
++(defun notmuch-dev-checkout-master ()\r
++ (magit-checkout "master"))\r
++\r
++(defun notmuch-dev-delete-branch (name)\r
++ (magit-delete-branch name))\r
++\r
++(defun notmuch-dev-create-branch (name)\r
++ ;; Switches to the new branch automatically.\r
++ (magit-create-branch name "master"))\r
++\r
++(defun notmuch-dev-title-to-branch (title)\r
++ (let* ((s (downcase title))\r
++ (s (replace-regexp-in-string "[ \t]+" "-" s))\r
++ (s (replace-regexp-in-string "[\]\[\":]" "" s))\r
++ (s (replace-regexp-in-string ".$" "" s))\r
++ )\r
++ s))\r
++\r
++;;\r
++\r
++(defun notmuch-dev-show-review-patch ()\r
++ "Call this from `notmuch-show-mode'."\r
++ (interactive)\r
++\r
++ (notmuch-dev-review-patch (notmuch-show-get-subject)\r
++ (mapconcat 'identity\r
++ (notmuch-show-get-message-ids-for-open-messages)\r
++ " | ")))\r
++\r
++(defun notmuch-dev-review-patch (title search-terms)\r
++ (let ((patch-name (notmuch-dev-title-to-branch title)))\r
++\r
++ (notmuch-dev-make-temporary-repository)\r
++\r
++ ;; Switch to the repository directory.\r
++ (let ((default-directory notmuch-dev-temporary-repository-path))\r
++\r
++ (notmuch-dev-checkout-master)\r
++ ;; Delete the branch if it exists.\r
++ (condition-case nil\r
++ (notmuch-dev-delete-branch patch-name)\r
++ (error nil))\r
++ (notmuch-dev-create-branch patch-name)\r
++\r
++ ;; Have notmuch generate mailbox format output for the search\r
++ ;; terms and feed that to git-am.\r
++ (shell-command\r
++ (concat\r
++ notmuch-command " show --format=mbox " (shell-quote-argument search-terms)\r
++ " | "\r
++ "git am --quiet"))\r
++\r
++ (magit-status notmuch-dev-temporary-repository-path))))\r
++\r
++;;\r
++\r
++(provide 'notmuch-dev)\r
+-- \r
+1.7.7.3\r
+\r