From: david@tethera.net
To: notmuch@notmuchmail.org
Cc: David Bremner <bremner@debian.org>
Subject: [RFC PATCH] emacs/show: add command to view a patch using diff mode
Date: Sat, 8 Dec 2012 14:43:52 -0400 [thread overview]
Message-ID: <1354992232-21791-1-git-send-email-david@tethera.net> (raw)
From: David Bremner <bremner@debian.org>
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
next reply other threads:[~2012-12-08 18:44 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-08 18:43 david [this message]
2012-12-09 2:05 ` [PATCH] emacs/show: add command to view a patch using diff mode Mark Walters
2014-06-22 10:51 ` David Bremner
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=1354992232-21791-1-git-send-email-david@tethera.net \
--to=david@tethera.net \
--cc=bremner@debian.org \
--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).