]> git.cworth.org Git - notmuch-wiki/blob - remoteusage.mdwn
Added a how-to page on remote usage.
[notmuch-wiki] / remoteusage.mdwn
1 [[!img notmuch-logo.png alt="Notmuch logo" class="left"]]
2 #Using notmuch remotely#
3
4 ##Why?##
5 It is hard to keep nomuch tags in sync across multiple instances of
6 notmuch, on multiple computers. Though you can do this with "notmuch
7 dump" and "notmuch restore", it is often preferable to be able to use
8 notmuch on a remote computer as if it were present on a local
9 computer.
10
11 The following guidelines show how I have accomplished this. It isn't
12 perfect, but it works pretty well, and allows me to access notmuch on
13 my home computer, using only an emacs client on my netbook or work
14 computer, a trivial shell script, a few settings in my .emacs, and
15 ssh.
16
17 Note that this is all something of a hack, and future versions of
18 notmuch will likely make all of these steps much more
19 transparent. I'll note particularly which things should become
20 unneccessary with future version. At the moment though, this does
21 work, and might enable some of you to use notmuch away from your
22 primary computer.
23
24 ##What you will need##
25 You will need to have the following items in place:
26
27 1.  a working notmuch on one computer (let's call that computer
28 "server"). The notmuch should be at least version 0.2.
29 2.  a working notmuch emacs interface on another computer (let's call
30 that computer "client")
31 3.   password-free login (public key authentication) from client to
32 server. [Here](http://sial.org/howto/openssh/publickey-auth/) is a
33 good page on how to set it up.
34 4.   a reasonably fast connection. (This isn't really *neccessary*, but
35 if your connection is too slow, this won't be very pleasant to use,
36 and certainly won't seem transparent.)
37
38 ##Write a simple wrapper shell script##
39 Now we will need to write a simple shell script that replaces the
40 call to the notmuch binary with a call to notmuch over ssh. 
41
42 Note that this shell script also pauses briefly after every ten search
43 entries. This is currently necessary so that the emacs process-filter
44 doesn't chop off messages. It's an obvious hack, and hopefully won't
45 be necessary in the furture.
46
47         #!/usr/bin/env bash
48         
49         SSH_BIN="/path/to/ssh/on/client"
50         USER="user_name"
51         HOST="server_name"
52         NOTMUCH_REMOTE_BIN="/path/to/notmuch/on/server"
53         
54         if [ $1 = "search" ]; then
55             COUNT=0;
56             OUT=`$SSH_BIN $USER@$HOST $NOTMUCH_REMOTE_BIN $@`
57             echo "$OUT" | while read line; do
58                 COUNT=`expr $COUNT + 1`
59                 echo "$line";
60                 if [ $COUNT = 10 ]; then
61                     sleep 0.1;
62                 fi
63             done
64         else
65             $SSH_BIN $USER@$HOST $NOTMUCH_REMOTE_BIN $@
66         fi
67         
68 Save this to a file, "remote-notmuch.sh", in your path.
69
70 ##Configure your emacs client##
71
72 Add the following to your .emacs (this is on your client machine):
73
74     (setq notmuch-command "/path/to/your/remote-notmuch.sh")
75
76 At least until 0.3 or 0.4, you will also need to add the following. It
77 should become unnecessary pretty soon though:
78
79     (setq notmuch-remote-host "user_name@server_name")
80     
81     (defadvice notmuch-show-get-filename (around
82                                       notmuch-show-get-remote-filename
83                                       activate)
84       (setq ad-return-value (concat "/ssh:"
85                                 notmuch-remote-host
86                                 ":"
87                                 ad-do-it)))
88
89 The purpose of these lines is to allow emacs to have access to the raw
90 files, via TRAMP, so that it can extract attachments and parse
91 HTML. Work is afoot to make notmuch handle these tasks itself, so this
92 part should soon be unecessary.
93
94 ##Problems##
95 Some things won't work perfectly, and there might be some unexpected
96 mismatches between normal usage and this sort of usage. If you're
97 using this approach and run into any problems, please feel free to
98 list them here. And, of course, if you improve on any of these
99 approaches, please do edit this page and let people know!
100                                 
101                                 
102
103  
104
105
106     
107
108         
109
110
111