News for hackers. Stuff that matters.
Re:Cloudmacs: access your Emacs in browser by mapgrep on Monday November 25, 2019 @10:41PM (#21635495)
“The authors intended redisplay to be used on text terminals over slow links. Emacs, to this day, has code that activates if it thinks you’re running on a connection slower than 2600 baud.” https://m.facebook.com/notes/daniel-colascione/buttery-smoot...

I feel like a grumpy fossil for asking this, but if your problem is “Sometimes you have to use non-personal computers where it's not possible/undesirable to install desktop Emacs,” why not run emacs the way it has been run in exactly those sorts of situations for almost 50 years? Remotely, via shell?

Is the hat trick here that by stuffing emacs into a docker container and accessing it over the web you can consume like 10,000 times the energy and resources of just running it over ssh in a terminal window as God intended ?

Sorry sorry that was a rude question. Now please get off my lawn.

(Honestly though I ran emacs for 5+ years entirely on an overtaxed Sun workstation shared with dozens if not hundreds of other students, over ssh, and it was fine! I believe I even had color working. I began at 14.4kbps and went from there. I saw the machine once, maybe twice.)

Re:Cloudmacs: access your Emacs in browser by pcr910303 on Tuesday November 26, 2019 @01:07AM (#21635976)
> why not run emacs the way it has been run in exactly those sorts of situations for almost 50 years? Remotely, via shell?

You know what? This project is doing exactly that; using Emacs remotely, via a terminal (not a shell BTW, shell is just a name for some specific language’s interpreter, that is good at launching sub processes).

It’s using the gotty[0] library, which is an implementation of the tty[1] in the browser.

It’s a natural extension; ttys have been ported for a few decades, starting from teleprinters[2] to text terminals[3] and terminal emulators[4].

[0] https://github.com/yudai/gotty

[1] https://en.m.wikipedia.org/wiki/Terminal_emulator

[2] https://en.m.wikipedia.org/wiki/Teleprinter

[3] https://en.m.wikipedia.org/wiki/Text_terminal

[4] https://en.m.wikipedia.org/wiki/Terminal_emulator

Re:Cloudmacs: access your Emacs in browser by 0x445442 on Tuesday November 26, 2019 @09:00AM (#21638287)
But the migration from teleprinters to text terminals to terminal emulators was in one direction. I think the comment's point is terminal emulator to terminal emulator embedded in a web browser is a regression.
Re:Cloudmacs: access your Emacs in browser by burke on Tuesday November 26, 2019 @09:08AM (#21638354)
If you squint hard enough, the browser is just a different location for the same old crufty TTY subsystem that normally lives in-kernel.
Re:Cloudmacs: access your Emacs in browser by j88439h84 on Tuesday November 26, 2019 @03:01AM (#21636388)
Great answer.
Re:Cloudmacs: access your Emacs in browser by Spivak on Monday November 25, 2019 @10:57PM (#21635545)
Because “a computer you don’t control” is almost certainly going to have a web browser available but not a SSH client or terminal.

I have personally implemented Linux workstations where access to the terminal or any shell is prohibited.

Re:Cloudmacs: access your Emacs in browser by yjftsjthsd-h on Monday November 25, 2019 @11:18PM (#21635611)
SSH and terminal have long since been ported to browser, fwiw.
Re:Cloudmacs: access your Emacs in browser by karlicoss on Tuesday November 26, 2019 @04:55AM (#21636894)
These are all fair points, thank you!

Primary reason is that computers where I run it might not have shell and emacs installed in the first place, so I can't connect to a remote port.

However you got me thinking: do you know any emacsclient implementations that run purely in browser? Presumably that would be not that hard to implement and will make more sense.

Although I still think I'd not expose emacs daemon to the outside: it's basically shell, so if I was doing it, I'd dockerize it anyway.

Re:Cloudmacs: access your Emacs in browser by jjuel on Tuesday November 26, 2019 @09:19AM (#21638443)
Does this require Docker on the local machine or the remote machine? If it requires it on the local this seems like a non-starter still for a lot of people. If I can't ssh from that machine what are the odds it has Docker or I can install Docker?
Re:Cloudmacs: access your Emacs in browser by karlicoss on Tuesday November 26, 2019 @09:58AM (#21638755)
Docker only on remote host, yep! You're right, if you can run Docker locally you've basically got root permissions anyway.
Re:Cloudmacs: access your Emacs in browser by nambit on Monday November 25, 2019 @11:08PM (#21635585)
Sometimes I'm playing a video game on steam and would like to have the steam overlay browser to do some work while I respawn.
Re:Cloudmacs: access your Emacs in browser by wdr1 on Tuesday November 26, 2019 @11:50AM (#21640002)
> I feel like a grumpy fossil for asking this, but if your problem is “Sometimes you have to use non-personal computers where it's not possible/undesirable to install desktop Emacs,” why not run emacs the way it has been run in exactly those sorts of situations for almost 50 years? Remotely, via shell?

Ugh.

So I did this. Not recently, but in the late 90s/early 2000s.

Our startup was moved across the street from its incubator (Idealab). WiFi wasn't a thing, broadband was far from mainstream, and most generic office space wasn't wired for networking. So we had a microwave link (I think) connecting our workspace to fat pipes across the street.

For anything interactive, it was awful. Waiting >500ms for each keystroke to appear is a very difficult experience.

Thankfully after a week or two, I discovered TRAMP mode.[1]

[1] https://www.emacswiki.org/emacs/TrampMode

Re:Cloudmacs: access your Emacs in browser by nuggien on Monday November 25, 2019 @06:19PM (#21633958)
this seems to be using gotty [1] to run spacemacs and serve it up as a web app.

[1]: https://github.com/yudai/gotty

Re:Cloudmacs: access your Emacs in browser by karlicoss on Monday November 25, 2019 @06:31PM (#21634068)
Yep, should have summarized in a comment, thanks! I've got a 'how does it work section' in readme: https://github.com/karlicoss/cloudmacs#how-does-it-work

- Gotty is a tool that allows accessing any TTY app as a web page (also allows forwarding input)

- We use Gotty to run emacsclient --tty -a '' command, that connects to the existing Emacs instance or starts a new one. That makes the session persist tab closing, connection problems etc.

- Your Emacs configs and files you want to expose to Cloudmacs are mapped in docker-compose.yml file.

Rest of the setup is basically dirty business of setting up Docker container, permissions etc.

Re:Cloudmacs: access your Emacs in browser by jraph on Monday November 25, 2019 @08:38PM (#21634917)
Do you know how gotty compares to shellinabox? I use the latter when I cannot use SSH.

There is WeTTY, too, that is based on xterm.js, which seems interesting. This one is listed in the readme of Gotty.

Re:Cloudmacs: access your Emacs in browser by karlicoss on Monday November 25, 2019 @09:02PM (#21635030)
I did some googling and couldn't find any clear differences, so just settled on gotty. If anyone knows, I'd be happy to add it to readme!
Re:Cloudmacs: access your Emacs in browser by fsiefken on Tuesday November 26, 2019 @06:03AM (#21637221)
With Termux I run spacemacs on my phone and oculus go and quest, but this is neat as well. Now I could theoretically use emacs in Firefox Reality where I have all my other apps handy.
Re:Cloudmacs: access your Emacs in browser by pvinis on Tuesday November 26, 2019 @06:07AM (#21637238)
I would love to read or watch about how you use all that!
Re:Cloudmacs: access your Emacs in browser by karlicoss on Tuesday November 26, 2019 @09:56AM (#21638743)
Yep, would be interested to know as well! I can somewhat comfortably use vim via termux, but emacs seems too much in terms of keybindings. Unless you connect external keyboard?
Re:Cloudmacs: access your Emacs in browser by fsiefken on Wednesday November 27, 2019 @08:51AM (#21647793)
Bluetooth keyboard of course, can't really use vim or spacemacs without it. In Termux I install curl and all the prerequisites for a spacemacs install. Oculus TV can be made to use Android apps like Termux.
Re:Cloudmacs: access your Emacs in browser by Koshkin on Monday November 25, 2019 @06:34PM (#21634100)
Q: a) can emacs be "emscripted"? b) could one access emacs using the web browser built into emacs?
Re:Cloudmacs: access your Emacs in browser by jackcviers3 on Monday November 25, 2019 @11:30PM (#21635649)
No - it doesn't run js.
Re:Cloudmacs: access your Emacs in browser by jordigh on Monday November 25, 2019 @05:32PM (#21633510)
It's a bit old and abandoned, by ymacs is another approach:

http://www.ymacs.org/

Re:Cloudmacs: access your Emacs in browser by hatmatrix on Monday November 25, 2019 @07:48PM (#21634603)
Cloudmacs seems favorable since it's not a rewrite but use of the existing infrastructure, which means all emacs packages are available to it.
Re:Cloudmacs: access your Emacs in browser by alexeiz on Wednesday November 27, 2019 @12:48PM (#21650125)
How does this work with numerous Emacs keybindings which surely conflict with browser shortcuts? If you press Ctrl-N in the Cloudmacs, will your cursor move one line down or will the browser open a new window?
Re:Cloudmacs: access your Emacs in browser by celrod on Friday November 29, 2019 @06:48AM (#21663770)
Chrome has an app mode. From memory, the steps are roughly

1. Press the three dots to the right of the url. 2. Click more tools on the drop down menu. 3. Finally "create shortcut".

This should let you open that website in a mode where it hijacks relatively few keyboard shortcuts, so that `C-N`, `C-W`, etc, work. I don't think it gets all of them though.

Re:Cloudmacs: access your Emacs in browser by selfishgene on Monday November 25, 2019 @07:50PM (#21634628)
Can this run graphical version of emacs or just terminal? Any support for Kui? (https://medium.com/the-graphical-terminal/visualizing-ci-cd-...)

Would like to be able use latex-preview in something like this.

Re:Cloudmacs: access your Emacs in browser by karlicoss on Monday November 25, 2019 @07:58PM (#21634711)
I was aiming for terminal to keep it minimal, and I think gotty only deals with standard text terminals, so I'd guess no.

This setup: https://github.com/JAremko/browsermax seems to deal with X, but not sure if it actually still works, and looks quite complicated.

Re:Cloudmacs: access your Emacs in browser by yjftsjthsd-h on Monday November 25, 2019 @11:26PM (#21635635)
I suppose the GUI analog to gotty is Apache Guacamole, which should run emacs fine (along with most anything else).
Re:Cloudmacs: access your Emacs in browser by georgewsinger on Monday November 25, 2019 @08:45PM (#21634957)
Is this better than using emacs over SSH?
Re:Cloudmacs: access your Emacs in browser by karlicoss on Monday November 25, 2019 @09:07PM (#21635053)
If you have access to ssh client and can connect to your server, then not really.

Could however be better from security perspective if you don't want to expose a shell and the whole filesystem to potentially untrusted computers.

Re:Cloudmacs: access your Emacs in browser by MereInterest on Monday November 25, 2019 @09:58PM (#21635297)
From a security perspective, access to emacs should be considered just as dangerous as a shell. As a trivial example, M-x shell will bring up a shell within emacs.
Re:Cloudmacs: access your Emacs in browser by xtajv on Monday November 25, 2019 @10:09PM (#21635348)
Based on [1] it looks like you could gain root within the docker container. From there, you need a bit of luck to get root on the host [2].

[1] https://github.com/karlicoss/cloudmacs/blob/master/asEnvUser [2] https://security.stackexchange.com/a/153016

Re:Cloudmacs: access your Emacs in browser by karlicoss on Tuesday November 26, 2019 @04:49AM (#21636855)
Within the Docker container, everything runs as root by default, since container can't know your UID in advance. Main reason for this script is to make sure mounted files are not written back as root.

Although a section explaining how to build container that runs as non-root user in the first place (even though it requires modifying Dockerfile, I think) would be useful, so I'll add it, thanks!

Yep, potential kernel/Docker bugs would let you escape the sandbox, but I guess that's the risk I'm accepting.

Re:Cloudmacs: access your Emacs in browser by taude on Monday November 25, 2019 @08:10PM (#21634786)
Has anyone done an Emacs compile to WASM, like someone did for Vim? https://rhysd.github.io/vim.wasm/
Re:Cloudmacs: access your Emacs in browser by nathias on Tuesday November 26, 2019 @07:31AM (#21637680)
emacs in browser, so you can use your emacs in browser while using your browser in emacs