From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id A6514431FAF for ; Sat, 8 Dec 2012 10:44:04 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: 0 X-Spam-Level: X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none] 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 MNDzYFZcWg7Z for ; Sat, 8 Dec 2012 10:44:04 -0800 (PST) Received: from tesseract.cs.unb.ca (tesseract.cs.unb.ca [131.202.240.238]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 35809431FAE for ; Sat, 8 Dec 2012 10:44:04 -0800 (PST) Received: from fctnnbsc30w-142167090129.dhcp-dynamic.fibreop.nb.bellaliant.net ([142.167.90.129] helo=zancas.localnet) by tesseract.cs.unb.ca with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.72) (envelope-from ) id 1ThPNb-0005qf-0g; Sat, 08 Dec 2012 14:44:03 -0400 Received: from bremner by zancas.localnet with local (Exim 4.80) (envelope-from ) id 1ThPNV-0005iU-Ir; Sat, 08 Dec 2012 14:43:57 -0400 From: david@tethera.net To: notmuch@notmuchmail.org Subject: [RFC PATCH] emacs/show: add command to view a patch using diff mode Date: Sat, 8 Dec 2012 14:43:52 -0400 Message-Id: <1354992232-21791-1-git-send-email-david@tethera.net> X-Mailer: git-send-email 1.7.10.4 X-Spam_bar: - Cc: David Bremner 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: Sat, 08 Dec 2012 18:44:04 -0000 From: David Bremner 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. --- The main thing that worries me is the use of notmuch-get-bodypart-internal. Do we have a canonical way to get the message body? It would also be nice to have "q" actually kill the buffer, but I didn't find a clean way to do that. emacs/notmuch-show.el | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el index 20f8997..442e6ce 100644 --- a/emacs/notmuch-show.el +++ b/emacs/notmuch-show.el @@ -1694,6 +1694,22 @@ 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 "*")))) + (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) + (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.10.4