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 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))))