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 2687F40D14A for ; Fri, 22 Oct 2010 02:28:33 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -1.9 X-Spam-Level: X-Spam-Status: No, score=-1.9 tagged_above=-999 required=5 tests=[BAYES_00=-1.9] autolearn=ham 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 C86HckQNEXLt for ; Fri, 22 Oct 2010 02:28:18 -0700 (PDT) Received: from max.feld.cvut.cz (max.feld.cvut.cz [147.32.192.36]) by olra.theworths.org (Postfix) with ESMTP id E872040D148 for ; Fri, 22 Oct 2010 02:28:17 -0700 (PDT) Received: from localhost (unknown [192.168.200.4]) by max.feld.cvut.cz (Postfix) with ESMTP id D664719F33CB; Fri, 22 Oct 2010 11:28:16 +0200 (CEST) X-Virus-Scanned: IMAP AMAVIS Received: from max.feld.cvut.cz ([192.168.200.1]) by localhost (styx.feld.cvut.cz [192.168.200.4]) (amavisd-new, port 10044) with ESMTP id kPGf+Ttcd+Rf; Fri, 22 Oct 2010 11:28:15 +0200 (CEST) Received: from imap.feld.cvut.cz (imap.feld.cvut.cz [147.32.192.34]) by max.feld.cvut.cz (Postfix) with ESMTP id F167219F33B2; Fri, 22 Oct 2010 11:28:14 +0200 (CEST) Received: from steelpick.2x.cz (note-sojka.felk.cvut.cz [147.32.86.30]) (Authenticated sender: sojkam1) by imap.feld.cvut.cz (Postfix) with ESMTPSA id 052C5FA007; Fri, 22 Oct 2010 11:28:14 +0200 (CEST) Received: from wsh by steelpick.2x.cz with local (Exim 4.72) (envelope-from ) id 1P9Dv4-0006p2-BR; Fri, 22 Oct 2010 11:28:14 +0200 From: Michal Sojka To: notmuch@notmuchmail.org Subject: [PATCH 2/2] emacs: Access raw messages via cat subcommand Date: Fri, 22 Oct 2010 11:28:04 +0200 Message-Id: <1287739684-26188-3-git-send-email-sojkam1@fel.cvut.cz> X-Mailer: git-send-email 1.7.2.3 In-Reply-To: <1287739684-26188-1-git-send-email-sojkam1@fel.cvut.cz> References: <1287739684-26188-1-git-send-email-sojkam1@fel.cvut.cz> X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 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, 22 Oct 2010 09:28:33 -0000 This patch modifies the following commands to access the messages via cat subcommand: - view/save attachments ('v', 'w'), - view a raw message ('V') and - pipe a message to a command ('|'). With this patch, it is straightforward to use notmuch emacs interface with a remote database accessed over SSH. To do this, it is sufficient to redefine notmuch-command variable to contain the name of a script containing: ssh user@host notmuch "$@" If the ssh client has enabled connection sharing (ControlMaster option in OpenSSH), the emacs interface is almost as responsive as when notmuch is invoked locally. --- emacs/notmuch-show.el | 14 +++++++++----- 1 files changed, 9 insertions(+), 5 deletions(-) diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el index 98d25ef..5d207b9 100644 --- a/emacs/notmuch-show.el +++ b/emacs/notmuch-show.el @@ -85,10 +85,10 @@ any given message." (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 "*")))) + (let ((id (notmuch-show-get-message-id))) + (let ((buf (generate-new-buffer (concat "*notmuch-msg-" id "*")))) (with-current-buffer buf - (insert-file-contents filename nil nil nil t) + (call-process notmuch-command nil t nil "cat" id) ,@body) (kill-buffer buf))))) @@ -918,7 +918,11 @@ any effects from previous calls to (defun notmuch-show-view-raw-message () "View the file holding the current message." (interactive) - (view-file (notmuch-show-get-filename))) + (let ((id (notmuch-show-get-message-id))) + (let ((buf (get-buffer-create (concat "*notmuch-raw-" id "*")))) + (switch-to-buffer buf) + (save-excursion + (call-process notmuch-command nil t nil "cat" id))))) (defun notmuch-show-pipe-message (entire-thread command) "Pipe the contents of the current message (or thread) to the given command. @@ -939,7 +943,7 @@ than only the current message." (mapconcat 'identity (notmuch-show-get-message-ids-for-open-messages) " OR ")) " | " command)) (setq shell-command - (concat command " < " (shell-quote-argument (notmuch-show-get-filename))))) + (concat "notmuch cat " (shell-quote-argument (notmuch-show-get-message-id)) " | " command))) (start-process-shell-command "notmuch-pipe-command" "*notmuch-pipe*" shell-command))) (defun notmuch-show-add-tag (&rest toadd) -- 1.7.2.3