[PATCH 2/2] emacs: Access raw messages via cat subcommand
authorMichal Sojka <sojkam1@fel.cvut.cz>
Fri, 22 Oct 2010 09:28:04 +0000 (11:28 +0200)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:37:18 +0000 (09:37 -0800)
6f/e64cf591c18212d2b2126d5f8cf5bc0b92b386 [new file with mode: 0644]

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