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