An Emacs TRAMP method for Glitch

What is your tutorial about?

TRAMP is for transparently accessing remote files from within Emacs.

Who might find this useful?

People who happened to get on the Emacs boat. And the Glitch boat. What a combo!


Tutorial:

TRAMP is way smart. It can figure out the weird TTY-ridden invalid-UTF-8-clobbering thing that is the Glitch terminal. All it needs is a program that connects to that terminal.

1. Get a program that connects to the Glitch terminal

It just so happens that I wrote such a program:

Get version 1.3.0 (or later, in the future :crossed_fingers:)

mkdir -p ~/.local/bin
curl -Lo ~/.local/bin/snail https://github.com/wh0/snail-cli/releases/download/v1.3.0/snail.js
chmod +x ~/.local/bin/snail

(You might have to restart your shell in some distros if .local/bin didn’t exist.)

Set up your Glitch account by getting your persistent token

mkdir -p ~/.config/snail
echo xxxxxxxx-xxxx-4xxx-xxxx-xxxxxxxxxxxx >~/.config/snail/persistent-token

2. Add a custom TRAMP method

Put this in your .emacs:

(with-eval-after-load 'tramp
  (add-to-list 'tramp-methods
   '("snail"
     (tramp-login-program "snail")
     (tramp-login-args (("term") ("-p") ("%h") ("--no-raw")))
     (tramp-remote-shell "/bin/sh")
     (tramp-remote-shell-args ("-c")))))

I think you have to restart Emacs for it to take effect :woman_shrugging:

3. Open a file from a Glitch project

Use the filename format /snail:(your project domain):(path in project).

emacs /snail:snail-cli:src/index.js

It goes in through the terminal, so you have to be a collaborator on the project.

4 Likes

Code like its 1999

2 Likes