]> git.cworth.org Git - notmuch-wiki/blobdiff - remoteusage/124.mdwn
News for release 0.38.3
[notmuch-wiki] / remoteusage / 124.mdwn
index 76551a06d54ee837ffc68a38721f78ad041fba5a..9a4fd45d2e0b0bf83f9dcb99799d025082fb9c5e 100644 (file)
@@ -11,6 +11,9 @@ its own connection. As long as master ssh connection is live, slave
 can use it. Disconnecting master all future attempts to connect
 from the script will fail.
 
+It is possible to use this solution without any changes to
+`$HOME/.ssh/config`.
+
 At the end of this document there is information for some possible ways
 how master ssh connection can be done.
 
@@ -20,9 +23,10 @@ Write the following code to a file, for example `remote-notmuch.sh`.
 
        #!/bin/bash
 
-       set -eu
-       # To trace execution, uncomment next line.
-       #BASH_XTRACEFD=6; exec 6>>remote-errors; echo -- >&6; set -x
+       set -euf
+
+       # To trace execution, uncomment next line:
+       #exec 6>>remote-errors; BASH_XTRACEFD=6; echo -- >&6; set -x
 
        : ${REMOTE_NOTMUCH_SSHCTRL_SOCK:=master-notmuch@remote:22}
        : ${REMOTE_NOTMUCH_COMMAND:=notmuch}
@@ -40,7 +44,7 @@ Write the following code to a file, for example `remote-notmuch.sh`.
        else ev=$?
        fi
 
-       # continuing here in case ssh exited with nonzero value.
+       # continuing here in case ssh exited with nonzero value
 
        case $* in
         'config get user.primary_email') echo 'nobody@nowhere.invalid'; exit 0 ;;
@@ -51,7 +55,7 @@ Write the following code to a file, for example `remote-notmuch.sh`.
         'search'*'--output=tags'*) echo 'errors'; exit 0 ;;
        esac
 
-       # for unhandled command line print only to stderr...
+       # fallback exit handler; print only to stderr...
        exec >&2
 
        if ssh $SSH_CONTROL_ARGS -O check 0.1
@@ -60,15 +64,13 @@ Write the following code to a file, for example `remote-notmuch.sh`.
         exit $ev
        fi
 
-       case $0 in */*) dn0=${0%/*} ;; *) dn0=. ;; esac
-       echo "See  $dn0/nottoomuch-remote.rst  for more information"
-
+       echo " See`sed '1d;2d;s/.//;q' "$0"` for help"
        exit $ev
        #eof
 
 Note the `0.1` in ssh command line. It is used to avoid any opportunistic
 behaviour ssh might do; for example if control socket is not alive ssh
-would attempt to do it's own ssh connection to remote ssh server. As
+would attempt to do its own ssh connection to remote ssh server. As
 address `0.1` is invalid this attempt will fail early.
 
 ## Test
@@ -118,7 +120,7 @@ There are 3 options how to handle this with `./nottoomuch-remote.bash`:
 
 3) `REMOTE_NOTMUCH_SSHCTRL_SOCK` can be used via environment; like:
 
-        REMOTE_NOTMUCH_SSHCTRL_SOCK=master-robin@example.org:22 ./nottoomuch-remote.bash help
+      REMOTE_NOTMUCH_SSHCTRL_SOCK=master-robin@example.org:22 ./nottoomuch-remote.bash help
 
 ## Configure Emacs on the client computer ##
 
@@ -158,6 +160,31 @@ wrapper.
 
 (*) general most likely being ~/.emacs
 
+### Yet another possibility -- script to start emacs
+
+Instead of adding new configurations you could also write a special
+script which starts and configures emacs suitable for remote usage.
+Copy the following "template" to a new name e.g. in `$HOME/bin/`,
+edit the value for `master-USER@HOST3:22` and perhaps add more
+post eval-after-load notmuch configs there.
+
+    #!/bin/sh
+    :; exec "${EMACS:-emacs}" --debug-init --load "$0" "$@"; exit
+
+    (setenv "REMOTE_NOTMUCH_SSHCTRL_SOCK" "master-USER@HOST3:22")
+
+    (eval-after-load "notmuch"
+      (lambda ()
+        (setq notmuch-command (concat (file-name-directory load-file-name)
+                                      "remote-notmuch.sh"))
+        ;; place for more post-notmuch-load emacs configs if any
+        ))
+    (notmuch)
+
+    ;; Local Variables:
+    ;; mode: emacs-lisp
+    ;; End:
+
 ## Creating master connection
 
 **(Note: all the examples below use the default master socket written in**
@@ -199,7 +226,7 @@ run
 from command line and observe output. If it looks as it should be next uncomment
 the line
 
-        #BASH_XTRACEFD=6; exec 6>>remote-errors; echo -- >&6; set -x
+        #exec 6>>remote-errors; BASH_XTRACEFD=6; echo -- >&6; set -x
 
 in `./remote-notmuch.sh` and attempt to use it from emacs again -- and then
 examine the contents of `remote-errors` in the working directory emacs was