unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: David Bremner <david@tethera.net>
To: Mark Walters <markwalters1009@gmail.com>, notmuch@notmuchmail.org
Subject: Re: [PATCH] emacs/show: add command to view a patch using diff mode
Date: Sun, 22 Jun 2014 07:51:09 -0300	[thread overview]
Message-ID: <87wqc9usiq.fsf@zancas.localnet> (raw)
In-Reply-To: <1355018749-12775-1-git-send-email-markwalters1009@gmail.com>

Mark Walters <markwalters1009@gmail.com> 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 <bremner@debian.org>

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

      reply	other threads:[~2014-06-22 10:51 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-08 18:43 [RFC PATCH] emacs/show: add command to view a patch using diff mode david
2012-12-09  2:05 ` [PATCH] " Mark Walters
2014-06-22 10:51   ` David Bremner [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87wqc9usiq.fsf@zancas.localnet \
    --to=david@tethera.net \
    --cc=markwalters1009@gmail.com \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).