1 Return-Path: <markwalters1009@gmail.com>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by olra.theworths.org (Postfix) with ESMTP id 77E88431FC0
\r
6 for <notmuch@notmuchmail.org>; Sat, 8 Dec 2012 18:05:59 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=0.201 tagged_above=-999 required=5
\r
12 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,
\r
13 FREEMAIL_ENVFROM_END_DIGIT=1, FREEMAIL_FROM=0.001,
\r
14 RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled
\r
15 Received: from olra.theworths.org ([127.0.0.1])
\r
16 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
17 with ESMTP id 2uUIJRK29ig7 for <notmuch@notmuchmail.org>;
\r
18 Sat, 8 Dec 2012 18:05:59 -0800 (PST)
\r
19 Received: from mail-wg0-f47.google.com (mail-wg0-f47.google.com
\r
20 [74.125.82.47]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client
\r
21 certificate requested) by olra.theworths.org (Postfix) with ESMTPS id
\r
22 D1F3B431FAE for <notmuch@notmuchmail.org>; Sat, 8 Dec 2012 18:05:58 -0800
\r
24 Received: by mail-wg0-f47.google.com with SMTP id dq11so896464wgb.2
\r
25 for <notmuch@notmuchmail.org>; Sat, 08 Dec 2012 18:05:57 -0800 (PST)
\r
26 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
\r
27 h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references;
\r
28 bh=4etN11UF5iy4SQFXMqt/8URJ4RddGc0gfqC36x2hdcw=;
\r
29 b=E3mREz57MaDPD03yuZ5A/qlCZQicoCVHNjX+wHYNhpt+tZT9k7KJDaz89P5EMDDjr2
\r
30 IqPFheO6BVYNdZeD+QCnsp9NFqCNzBrGxHZCEFEdvCWtpbtnijvXXWEL/o2V6vNtRrIj
\r
31 Qx/xkBt3UP/tlBa3iQc8B8jlU2k1Ig+2Hyxez0Z3650ppq0GIPJC2/di3RcNj/T8JWPo
\r
32 KCzcnEs6pPOBdnQw38QLL3mufT+F7WWiwFT6Ndc+TJxZTPX5wba9w6iI4fREoopStXLx
\r
33 V0/ivYa0wpIoDSgcoiFtKm51EUeR11SPImZViXwm5QQ7D1Z4kXnCqh+zqPt87ULpUWpA
\r
35 Received: by 10.180.81.170 with SMTP id b10mr4824391wiy.16.1355018757513;
\r
36 Sat, 08 Dec 2012 18:05:57 -0800 (PST)
\r
37 Received: from localhost (93-97-24-31.zone5.bethere.co.uk. [93.97.24.31])
\r
38 by mx.google.com with ESMTPS id dm3sm4331533wib.9.2012.12.08.18.05.55
\r
39 (version=TLSv1/SSLv3 cipher=OTHER);
\r
40 Sat, 08 Dec 2012 18:05:56 -0800 (PST)
\r
41 From: Mark Walters <markwalters1009@gmail.com>
\r
42 To: notmuch@notmuchmail.org
\r
43 Subject: [PATCH] emacs/show: add command to view a patch using diff mode
\r
44 Date: Sun, 9 Dec 2012 02:05:49 +0000
\r
45 Message-Id: <1355018749-12775-1-git-send-email-markwalters1009@gmail.com>
\r
46 X-Mailer: git-send-email 1.7.9.1
\r
47 In-Reply-To: <1354992232-21791-1-git-send-email-david@tethera.net>
\r
48 References: <1354992232-21791-1-git-send-email-david@tethera.net>
\r
49 X-BeenThere: notmuch@notmuchmail.org
\r
50 X-Mailman-Version: 2.1.13
\r
52 List-Id: "Use and development of the notmuch mail system."
\r
53 <notmuch.notmuchmail.org>
\r
54 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
55 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
56 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
57 List-Post: <mailto:notmuch@notmuchmail.org>
\r
58 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
59 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
60 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
61 X-List-Received-Date: Sun, 09 Dec 2012 02:05:59 -0000
\r
63 From: markwalters1009@gmail.com
\r
65 This enables fast navigation between hunks and better highlighting.
\r
67 The use of notmuch-get-bodypart-internal could be improved; hard
\r
68 coding to 1 seems to work for the output of git-format-patch. It also
\r
69 not so nice to call (insert (notmuch-get-bodypart-internal ...)) since the
\r
70 last thing n-g-b-i does is call buffer-string.
\r
72 Author: David Bremner <bremner@debian.org>
\r
75 This is a hacked version of which does seem to quit on q. The
\r
76 difficulty is that diff-mode sets minor-mode-overriding-map-alist to
\r
77 change the map when the buffer is read-only and it seemed to be
\r
78 difficult to override without affecting diff-mode maps globally.
\r
80 This should be safe in that respect. However, I don't know whether it
\r
81 is allowed to set a keymap to something within a "let" and what
\r
82 happens to it after we exit the let. I am also not completely sure
\r
83 about the lexical-let: but it was what diff-mode used to do this
\r
84 (those two lines are copied from diff-mode)
\r
92 emacs/notmuch-show.el | 20 ++++++++++++++++++++
\r
93 1 files changed, 20 insertions(+), 0 deletions(-)
\r
95 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
\r
96 index 20f8997..e150e7c 100644
\r
97 --- a/emacs/notmuch-show.el
\r
98 +++ b/emacs/notmuch-show.el
\r
99 @@ -1694,6 +1694,26 @@ to show, nil otherwise."
\r
100 (set-buffer-modified-p nil)
\r
101 (view-buffer buf 'kill-buffer-if-not-modified)))
\r
103 +(defun notmuch-show-view-as-patch ()
\r
104 + "View the the current message as a patch."
\r
106 + (let* ((id (notmuch-show-get-message-id))
\r
107 + (subject (concat "Subject: " (notmuch-show-get-subject) "\n"))
\r
108 + (diff-default-read-only t)
\r
109 + (buf (get-buffer-create (concat "*notmuch-patch-" id "*")))
\r
110 + (map (make-sparse-keymap)))
\r
111 + (define-key map "q" 'notmuch-kill-this-buffer)
\r
112 + (switch-to-buffer buf)
\r
113 + (let ((inhibit-read-only t))
\r
116 + (insert (notmuch-get-bodypart-internal id 1 nil)))
\r
117 + (set-buffer-modified-p nil)
\r
119 + (lexical-let ((new-ro-bind (cons 'buffer-read-only map)))
\r
120 + (add-to-list 'minor-mode-overriding-map-alist new-ro-bind))
\r
121 + (goto-char (point-min))))
\r
123 (defun notmuch-show-pipe-message (entire-thread command)
\r
124 "Pipe the contents of the current message (or thread) to the given command.
\r