#+TITLE: Emacs Tramp Phlogging
#+AUTHOR: screwtape
#+STARTUP: show2levels
#+PROPERTY: header-args :dir /ssh:screwtape@tty.sdf.org:~/tramped/
#+PROPERTY: header-args:C+ :tangle yes :eval never :results none :exports code
* Tramping to SDF with a high latency low latency proxy
Recently I have wanted to use SDF for compilers and code lots and lots. In particular I want to use Emacs org-mode with C and shell compilation. I also use an extremely high latency low latency proxy at 10.9.8.7:65432. I intend this document to be a helpful reference for myself and others.
** Setup
*** On your workstation's ssh config file ; probably ~/.ssh/config
Should contain something like this (using openbsd netcat), if this is what you want:
#+begin_src txt
  Host *.sdf.org
          ProxyCommand sh -c "nc -X5 -x10.9.8.7:65432 %h %p"
#+end_src
This is extra important for emacs tramp mode, and not having to type -o ProxyCommand= generally.
*** Open your sdf home directory in emacs using tramp
Well, for me it was
#+begin_src txt
  C-x C-f /ssh:screwtape@tty.sdf.org:~/
#+end_src
the tramp-mode will carry on from this relative directory, as it will with M-x shell.
*** What about org-mode evaluation
org-babel will do exactly what you don't ever want by default. When evaluating a loaded language, it will write and try to build and run it on your workstation's /tmp, but will try and do what would have made sense on sdf. Furthermore it tries to handle everything autonomously by default, which if you have a slow connection will take a long time until you eventually hear there was a weird build error.

BUT it's an easy fix /for shell/. Simply provide the right :dir header arg as tramp will understand it. See how I provided mine at the top of this file.

For C, save a headache and just tangle it and deal with your compilation and execution in a shell block.
*** Motivation
It's much snappier to work locally on your workstation to the extent possible.

** Usage
*** Explicitly load languages
#+begin_src elisp :results none :exports code
  (org-babel-do-load-languages 'org-babel-load-languages '((shell . t)))
#+end_src
*** shell pwd
#+begin_src shell
  pwd
#+end_src

#+RESULTS:
: /sdf/arpa/ns/s/screwtape/tramped
*** C
Must be tangled instead using C-c C-v t or (org-babel-tangle)
#+begin_src C :results output verbatim
  #include <stdio.h>
  #include <stdlib.h>

  int
  main(void)
  {
    puts("success");
    return EXIT_SUCCESS;
  }
#+end_src
**** Shell build and execute
#+begin_src shell
  pwd
  cc -o sdf-tramp sdf-tramp.C && ./sdf-tramp
#+end_src

#+RESULTS:
| /sdf/arpa/ns/s/screwtape/tramped |
| success                          |
**** Postmortem
I guess you would want to :tangle particular/source.C the source and :tangle particular/Makefile a make, then issue make in particular/. Whatever floats your boats.