From 1acc3f58a0cf2ea5ad1a518b28982a8fc729ae4c Mon Sep 17 00:00:00 2001 From: David Bremner Date: Mon, 23 Jun 2014 07:51:09 +2100 Subject: [PATCH] Re: [PATCH] emacs/show: add command to view a patch using diff mode --- 2e/873c69b1075c4bf0ee25b255c20dc3c8c80d6f | 93 +++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 2e/873c69b1075c4bf0ee25b255c20dc3c8c80d6f diff --git a/2e/873c69b1075c4bf0ee25b255c20dc3c8c80d6f b/2e/873c69b1075c4bf0ee25b255c20dc3c8c80d6f new file mode 100644 index 000000000..d32bd4346 --- /dev/null +++ b/2e/873c69b1075c4bf0ee25b255c20dc3c8c80d6f @@ -0,0 +1,93 @@ +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 932FE431FAF + for ; Sun, 22 Jun 2014 03:51:18 -0700 (PDT) +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 JXedmo8NCxfm for ; + Sun, 22 Jun 2014 03:51:13 -0700 (PDT) +Received: from yantan.tethera.net (yantan.tethera.net [199.188.72.155]) + (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id D43AE431FAE + for ; Sun, 22 Jun 2014 03:51:13 -0700 (PDT) +Received: from remotemail by yantan.tethera.net with local (Exim 4.80) + (envelope-from ) + id 1WyfMe-0005Fo-CV; Sun, 22 Jun 2014 07:51:12 -0300 +Received: (nullmailer pid 29826 invoked by uid 1000); Sun, 22 Jun 2014 + 10:51:09 -0000 +From: David Bremner +To: Mark Walters , notmuch@notmuchmail.org +Subject: Re: [PATCH] emacs/show: add command to view a patch using diff mode +In-Reply-To: <1355018749-12775-1-git-send-email-markwalters1009@gmail.com> +References: <1354992232-21791-1-git-send-email-david@tethera.net> + <1355018749-12775-1-git-send-email-markwalters1009@gmail.com> +User-Agent: Notmuch/0.18+13~g1adde01 (http://notmuchmail.org) Emacs/24.3.1 + (x86_64-pc-linux-gnu) +Date: Sun, 22 Jun 2014 07:51:09 -0300 +Message-ID: <87wqc9usiq.fsf@zancas.localnet> +MIME-Version: 1.0 +Content-Type: text/plain +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, 22 Jun 2014 10:51:18 -0000 + +Mark Walters writes: + +> 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 + +Recently I had cause to update this function to produce more +"git-format-patch" like output. I didn't yet merge with Mark's proposed +changes. Here it is in case anyone else finds this useful (I used it to +de-quoted-printable a patch). + +(defun notmuch-show-view-as-patch () + "View the the current message as a patch." + (interactive) + (let* ((id (notmuch-show-get-message-id t)) + (date (notmuch-show-get-date)) + (from_ (concat "From " id " " date "\n")) + (from: (concat "From: " (notmuch-show-get-from) "\n")) + (date: (concat "Date: " date "\n")) + (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 from_) + (insert from:) + (insert date:) + (insert subject) + (insert "\n") + (insert (notmuch-get-bodypart-internal (concat "id:" id) 1 nil))) + (set-buffer-modified-p nil) + (diff-mode) + (goto-char (point-min)))) -- 2.26.2