unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [RFC PATCH] emacs/show: add command to view a patch using diff mode
@ 2012-12-08 18:43 david
  2012-12-09  2:05 ` [PATCH] " Mark Walters
  0 siblings, 1 reply; 3+ messages in thread
From: david @ 2012-12-08 18:43 UTC (permalink / raw)
  To: notmuch; +Cc: David Bremner

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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-06-22 10:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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

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