[PATCH 2/2] emacs: Access raw messages through cat subcommand
authorMichal Sojka <sojkam1@fel.cvut.cz>
Tue, 20 Apr 2010 07:16:33 +0000 (09:16 +0200)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:36:44 +0000 (09:36 -0800)
d2/0521e69232fb2b76e185af61392fb4a266b499 [new file with mode: 0644]

diff --git a/d2/0521e69232fb2b76e185af61392fb4a266b499 b/d2/0521e69232fb2b76e185af61392fb4a266b499
new file mode 100644 (file)
index 0000000..00bf402
--- /dev/null
@@ -0,0 +1,117 @@
+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 830864196F3\r
+       for <notmuch@notmuchmail.org>; Tue, 20 Apr 2010 00:16:38 -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 AcwwCjFG4BrZ for <notmuch@notmuchmail.org>;\r
+       Tue, 20 Apr 2010 00:16:36 -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 9C2934196F2\r
+       for <notmuch@notmuchmail.org>; Tue, 20 Apr 2010 00:16:36 -0700 (PDT)\r
+Received: from localhost (unknown [192.168.200.4])\r
+       by max.feld.cvut.cz (Postfix) with ESMTP id 8E8B519F339C\r
+       for <notmuch@notmuchmail.org>; Tue, 20 Apr 2010 09:16:35 +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) with ESMTP id V4doBOZl6kYu for <notmuch@notmuchmail.org>;\r
+       Tue, 20 Apr 2010 09:16:34 +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 003F319F3361\r
+       for <notmuch@notmuchmail.org>; Tue, 20 Apr 2010 09:16:33 +0200 (CEST)\r
+Received: from steelpick.2x.cz (k335-30.felk.cvut.cz [147.32.86.30])\r
+       (Authenticated sender: sojkam1)\r
+       by imap.feld.cvut.cz (Postfix) with ESMTPSA id ECFFAFA004\r
+       for <notmuch@notmuchmail.org>; Tue, 20 Apr 2010 09:16:33 +0200 (CEST)\r
+Received: from wsh by steelpick.2x.cz with local (Exim 4.71)\r
+       (envelope-from <sojkam1@fel.cvut.cz>) id 1O47hB-0004Yv-Ng\r
+       for notmuch@notmuchmail.org; Tue, 20 Apr 2010 09:16:33 +0200\r
+From: Michal Sojka <sojkam1@fel.cvut.cz>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 2/2] emacs: Access raw messages through cat subcommand\r
+Date: Tue, 20 Apr 2010 09:16:33 +0200\r
+Message-Id: <1271747793-17507-2-git-send-email-sojkam1@fel.cvut.cz>\r
+X-Mailer: git-send-email 1.7.0.4\r
+In-Reply-To: <1271747793-17507-1-git-send-email-sojkam1@fel.cvut.cz>\r
+References: <1271747793-17507-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: Tue, 20 Apr 2010 07:16:38 -0000\r
+\r
+The following commands now access the messages via the cat subcommand:\r
+view/save attachments, view raw message and pipe message to 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 with local\r
+invocation.\r
+\r
+Signed-off-by: Michal Sojka <sojkam1@fel.cvut.cz>\r
+---\r
+ emacs/notmuch-show.el |   11 ++++++++---\r
+ 1 files changed, 8 insertions(+), 3 deletions(-)\r
+\r
+diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
+index 81276d9..29a726e 100644\r
+--- a/emacs/notmuch-show.el\r
++++ b/emacs/notmuch-show.el\r
+@@ -328,7 +328,11 @@ buffer."\r
+ (defun notmuch-show-view-raw-message ()\r
+   "View the raw email of the current message."\r
+   (interactive)\r
+-  (view-file (notmuch-show-get-filename)))\r
++  (let ((filename (notmuch-show-get-filename)))\r
++    (let ((buf (get-buffer-create (concat "*notmuch-raw-" filename "*"))))\r
++      (switch-to-buffer buf)\r
++      (save-excursion\r
++      (call-process notmuch-command nil t nil "cat" filename)))))\r
\r
+ (defmacro with-current-notmuch-show-message (&rest body)\r
+   "Evaluate body with current buffer set to the text of current message"\r
+@@ -336,7 +340,7 @@ buffer."\r
+      (let ((filename (notmuch-show-get-filename)))\r
+        (let ((buf (generate-new-buffer (concat "*notmuch-msg-" filename "*"))))\r
+          (with-current-buffer buf\r
+-           (insert-file-contents filename nil nil nil t)\r
++          (call-process notmuch-command nil t nil "cat" filename)\r
+            ,@body)\r
+        (kill-buffer buf)))))\r
\r
+@@ -390,7 +394,8 @@ current email message as stdin. Anything printed by the command\r
+ to stdout or stderr will appear in the *Messages* buffer."\r
+   (interactive "sPipe message to command: ")\r
+   (apply 'start-process-shell-command "notmuch-pipe-command" "*notmuch-pipe*"\r
+-       (list command " < " (shell-quote-argument (notmuch-show-get-filename)))))\r
++       (list notmuch-command "cat"\r
++             (shell-quote-argument (notmuch-show-get-filename)) " | " command)))\r
\r
+ (defun notmuch-show-move-to-current-message-summary-line ()\r
+   "Move to the beginning of the one-line summary of the current message.\r
+-- \r
+1.7.0.4\r
+\r