--- /dev/null
+Return-Path: <markwalters1009@gmail.com>\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 77E88431FC0\r
+ for <notmuch@notmuchmail.org>; Sat, 8 Dec 2012 18:05:59 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0.201\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0.201 tagged_above=-999 required=5\r
+ tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+ FREEMAIL_ENVFROM_END_DIGIT=1, FREEMAIL_FROM=0.001,\r
+ 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 2uUIJRK29ig7 for <notmuch@notmuchmail.org>;\r
+ Sat, 8 Dec 2012 18:05:59 -0800 (PST)\r
+Received: from mail-wg0-f47.google.com (mail-wg0-f47.google.com\r
+ [74.125.82.47]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client\r
+ certificate requested) by olra.theworths.org (Postfix) with ESMTPS id\r
+ D1F3B431FAE for <notmuch@notmuchmail.org>; Sat, 8 Dec 2012 18:05:58 -0800\r
+ (PST)\r
+Received: by mail-wg0-f47.google.com with SMTP id dq11so896464wgb.2\r
+ for <notmuch@notmuchmail.org>; Sat, 08 Dec 2012 18:05:57 -0800 (PST)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
+ h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references;\r
+ bh=4etN11UF5iy4SQFXMqt/8URJ4RddGc0gfqC36x2hdcw=;\r
+ b=E3mREz57MaDPD03yuZ5A/qlCZQicoCVHNjX+wHYNhpt+tZT9k7KJDaz89P5EMDDjr2\r
+ IqPFheO6BVYNdZeD+QCnsp9NFqCNzBrGxHZCEFEdvCWtpbtnijvXXWEL/o2V6vNtRrIj\r
+ Qx/xkBt3UP/tlBa3iQc8B8jlU2k1Ig+2Hyxez0Z3650ppq0GIPJC2/di3RcNj/T8JWPo\r
+ KCzcnEs6pPOBdnQw38QLL3mufT+F7WWiwFT6Ndc+TJxZTPX5wba9w6iI4fREoopStXLx\r
+ V0/ivYa0wpIoDSgcoiFtKm51EUeR11SPImZViXwm5QQ7D1Z4kXnCqh+zqPt87ULpUWpA\r
+ 4wAg==\r
+Received: by 10.180.81.170 with SMTP id b10mr4824391wiy.16.1355018757513;\r
+ Sat, 08 Dec 2012 18:05:57 -0800 (PST)\r
+Received: from localhost (93-97-24-31.zone5.bethere.co.uk. [93.97.24.31])\r
+ by mx.google.com with ESMTPS id dm3sm4331533wib.9.2012.12.08.18.05.55\r
+ (version=TLSv1/SSLv3 cipher=OTHER);\r
+ Sat, 08 Dec 2012 18:05:56 -0800 (PST)\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH] emacs/show: add command to view a patch using diff mode\r
+Date: Sun, 9 Dec 2012 02:05:49 +0000\r
+Message-Id: <1355018749-12775-1-git-send-email-markwalters1009@gmail.com>\r
+X-Mailer: git-send-email 1.7.9.1\r
+In-Reply-To: <1354992232-21791-1-git-send-email-david@tethera.net>\r
+References: <1354992232-21791-1-git-send-email-david@tethera.net>\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: Sun, 09 Dec 2012 02:05:59 -0000\r
+\r
+From: markwalters1009@gmail.com\r
+\r
+This enables fast navigation between hunks and better highlighting.\r
+\r
+The use of notmuch-get-bodypart-internal could be improved; hard\r
+coding to 1 seems to work for the output of git-format-patch. It also\r
+not so nice to call (insert (notmuch-get-bodypart-internal ...)) since the\r
+last thing n-g-b-i does is call buffer-string.\r
+\r
+Author: David Bremner <bremner@debian.org>\r
+---\r
+\r
+This is a hacked version of which does seem to quit on q. The\r
+difficulty is that diff-mode sets minor-mode-overriding-map-alist to\r
+change the map when the buffer is read-only and it seemed to be\r
+difficult to override without affecting diff-mode maps globally.\r
+\r
+This should be safe in that respect. However, I don't know whether it\r
+is allowed to set a keymap to something within a "let" and what\r
+happens to it after we exit the let. I am also not completely sure\r
+about the lexical-let: but it was what diff-mode used to do this\r
+(those two lines are copied from diff-mode)\r
+\r
+Best wishes\r
+\r
+Mark\r
+\r
+\r
+\r
+ emacs/notmuch-show.el | 20 ++++++++++++++++++++\r
+ 1 files changed, 20 insertions(+), 0 deletions(-)\r
+\r
+diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
+index 20f8997..e150e7c 100644\r
+--- a/emacs/notmuch-show.el\r
++++ b/emacs/notmuch-show.el\r
+@@ -1694,6 +1694,26 @@ to show, nil otherwise."\r
+ (set-buffer-modified-p nil)\r
+ (view-buffer buf 'kill-buffer-if-not-modified)))\r
+ \r
++(defun notmuch-show-view-as-patch ()\r
++ "View the the current message as a patch."\r
++ (interactive)\r
++ (let* ((id (notmuch-show-get-message-id))\r
++ (subject (concat "Subject: " (notmuch-show-get-subject) "\n"))\r
++ (diff-default-read-only t)\r
++ (buf (get-buffer-create (concat "*notmuch-patch-" id "*")))\r
++ (map (make-sparse-keymap)))\r
++ (define-key map "q" 'notmuch-kill-this-buffer)\r
++ (switch-to-buffer buf)\r
++ (let ((inhibit-read-only t))\r
++ (erase-buffer)\r
++ (insert subject)\r
++ (insert (notmuch-get-bodypart-internal id 1 nil)))\r
++ (set-buffer-modified-p nil)\r
++ (diff-mode)\r
++ (lexical-let ((new-ro-bind (cons 'buffer-read-only map)))\r
++ (add-to-list 'minor-mode-overriding-map-alist new-ro-bind))\r
++ (goto-char (point-min))))\r
++\r
+ (defun notmuch-show-pipe-message (entire-thread command)\r
+ "Pipe the contents of the current message (or thread) to the given command.\r
+ \r
+-- \r
+1.7.9.1\r
+\r