Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 12D09431FC9 for ; Fri, 27 Nov 2009 05:30:42 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org 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 3f6OlCT4Bcat for ; Fri, 27 Nov 2009 05:30:40 -0800 (PST) Received: from mout.perfora.net (mout.perfora.net [74.208.4.194]) by olra.theworths.org (Postfix) with ESMTP id 583F1431FC4 for ; Fri, 27 Nov 2009 05:30:40 -0800 (PST) Received: from vps.nicira.com (66.7.219.28.static.dimenoc.com [66.7.219.28]) by mx.perfora.net (node=mxus1) with ESMTP (Nemesis) id 0MAPDO-1NK6lh2rco-00BZ3S for notmuch@notmuchmail.org; Fri, 27 Nov 2009 08:30:39 -0500 Received: from [76.210.240.177] (port=36296 helo=kea-nicira-lt) by vps.nicira.com with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.69) (envelope-from ) id 1NE0uD-00048p-SB; Fri, 27 Nov 2009 08:30:39 -0500 Received: by kea-nicira-lt (sSMTP sendmail emulation); Fri, 27 Nov 2009 05:30:36 -0800 From: camalot@picnicpark.org To: notmuch@notmuchmail.org Date: Fri, 27 Nov 2009 05:30:10 -0800 Message-Id: <1259328615-1445-5-git-send-email-camalot@picnicpark.org> X-Mailer: git-send-email 1.6.5.3 In-Reply-To: <1259328615-1445-4-git-send-email-camalot@picnicpark.org> References: <1259328615-1445-1-git-send-email-camalot@picnicpark.org> <1259328615-1445-2-git-send-email-camalot@picnicpark.org> <1259328615-1445-3-git-send-email-camalot@picnicpark.org> <1259328615-1445-4-git-send-email-camalot@picnicpark.org> X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - vps.nicira.com X-AntiAbuse: Original Domain - notmuchmail.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - picnicpark.org X-Source: X-Source-Args: X-Source-Dir: Cc: Keith Amidon Subject: [notmuch] [PATCH 4/9] Factor out message buffer mgmt from notmuch-show-view-all-mime-parts X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.12 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: Fri, 27 Nov 2009 13:30:42 -0000 From: Keith Amidon 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. --- notmuch.el | 20 ++++++++++++-------- 1 files changed, 12 insertions(+), 8 deletions(-) diff --git a/notmuch.el b/notmuch.el index cd6609d..a71a9f7 100644 --- a/notmuch.el +++ b/notmuch.el @@ -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")) -- 1.6.5.3