diff options
author | Keith Amidon <keith@nicira.com> | 2009-11-27 05:30:10 -0800 |
---|---|---|
committer | Carl Worth <cworth@cworth.org> | 2009-11-27 21:07:35 -0800 |
commit | c4463d4cb482abebdffe725a85fff35a0eba31a1 (patch) | |
tree | a6b77750f3344a453a1b4eb3074d57fa227b34b8 | |
parent | 30bdcfe6511b9b6efff1f84fbf77320c2da0d76a (diff) |
Factor out message buffer mgmt from notmuch-show-view-all-mime-parts
The ability to temporarily create a buffer containing only the
contents of the currently selected message in notmuch show mode is
generally useful. This commit factors the majority of the code
required to do so out of notmuch-show-view-all-mime-parts into a macro
called with-current-notmuch-show-message and rewrites the original
function in terms of the macro.
A future set of commits will provide additional functionality using
the macro as well.
-rw-r--r-- | notmuch.el | 20 |
1 files changed, 12 insertions, 8 deletions
@@ -283,17 +283,21 @@ buffer." (interactive) (view-file (notmuch-show-get-filename))) +(defmacro with-current-notmuch-show-message (&rest body) + "Evaluate body with current buffer set to the text of current message" + `(save-excursion + (let ((filename (notmuch-show-get-filename))) + (let ((buf (generate-new-buffer (concat "*notmuch-msg-" filename "*")))) + (with-current-buffer buf + (insert-file-contents filename nil nil nil t) + ,@body) + (kill-buffer buf))))) + (defun notmuch-show-view-all-mime-parts () "Use external viewers (according to mailcap) to view all MIME-encoded parts." (interactive) - (save-excursion - (let ((filename (notmuch-show-get-filename))) - (switch-to-buffer (generate-new-buffer (concat "*notmuch-mime-" - filename - "*"))) - (insert-file-contents filename nil nil nil t) - (mm-display-parts (mm-dissect-buffer)) - (kill-this-buffer)))) + (with-current-notmuch-show-message + (mm-display-parts (mm-dissect-buffer)))) (defun notmuch-reply (query-string) (switch-to-buffer (generate-new-buffer "notmuch-draft")) |