News for hackers. Stuff that matters.

Ask HN: How would you make Emacs do this?

For a long while now I've only used two applications almost all the time - a web browser, and Emacs. For reasons I can't quite explain but feel strongly about, I'd love to get that down to just one.

So I have the idea of being able to have a web site that's actually just a gateway to an Emacs instance running on one of my servers.

I don't have a problem imagining how I might do the web app itself - it would probably use html/javascript for presentation, and then a small piece of Flash code to give me a real tcp socket that I can use to talk to Emacs. No problem - I can do these kinds of things easily.

It would be useful to open and save-to local files in addition to ones already on the server. Again, using a little bit of Flash 10, I can make that happen easily.

Now the frontend needs to tell Emacs, via this socket, whenever the user presses a key. And Emacs in turn needs to tell the web app to update the display. I could easily decide on a simple socket protocol for these things.

But on the backend I don't have much idea at all - I've modified my own .emacs a bunch, but I've never actually hacked Emacs.

Does anyone have any pointers? Should I model this after an existing display toolkit (like motiff, gtk, etc)? Or would a different approach work better? Should I start writing this in ELisp, or am I very likely to actually need to drop down to C for some reason?

( 11 comments | 22 points | on HN )
Re:Ask HN: How would you make Emacs do this? by silentbicycle on Monday May 10, 2010 @02:31PM (#1335489)
I don't see why it would really be beneficial - People who want to connect with a remote Emacs session just use ssh + screen or tmux, which is stable and quick to set up. If you really want to implement Emacs-over-the-web, though, familiarity with these might help:

distel - distributed elisp, via integration with Erlang (http://fresh.homeunix.net/~luke/distel/)

TRAMP - remote file editing (See e.g. http://www.emacswiki.org/emacs/TrampMode)

Also, there are decent web browsers for Emacs. I like emacs-w3m. (http://emacs-w3m.namazu.org/)

Re:Ask HN: How would you make Emacs do this? by jimm on Monday May 10, 2010 @02:30PM (#1335486)
How about the opposite: browse the Web from within Emacs? http://www.emacswiki.org/emacs/emacs-w3m

[Edit: link to W3M, not the older W3]

Re:Ask HN: How would you make Emacs do this? by ianb on Monday May 10, 2010 @11:24PM (#1336770)
I've been thinking about this too (http://blog.ianbicking.org/2010/05/04/browser-desktop-develo...) -- but I figured I'd just let go of Emacs in the process, presumably to replace it with Bespin: http://mozillalabs.com/bespin -- it is purported to have some Emacs keybindings (I haven't been able to enable them though).
Re:Ask HN: How would you make Emacs do this? by icey on Monday May 10, 2010 @03:00PM (#1335583)
Re:Ask HN: How would you make Emacs do this? by tonyarkles on Tuesday May 11, 2010 @09:43PM (#1339878)
You could look at Web Sockets (http://en.wikipedia.org/wiki/Web_Sockets). I know Chrome supports it, not sure about other browsers. A friend made a very cool interactive multi-user app using this and was quite impressed at the responsiveness.
Re:Ask HN: How would you make Emacs do this? by marcmarc on Monday May 10, 2010 @06:44PM (#1336174)
You can control Firefox from emacs using MozRepl. This extension allows you execute code on the browser. For example, you can tell emacs to refresh a specific tab when an html file is saved. MozRepl is not the only extension doing that. There are 4 or 5 similar projects.

More info http://www.emacswiki.org/emacs/MozRepl

Re:Ask HN: How would you make Emacs do this? by simplify on Tuesday May 11, 2010 @02:36AM (#1337119)
I think it would be useful as, say, a chrome plugin. A hotkey to open up a new emacs tab right next to my webpage tabs would be nice.
Re:Ask HN: How would you make Emacs do this? by positr0nic on Monday May 10, 2010 @04:24PM (#1335812)
How about something like this? http://nomachine.com/web-player.php Saving files locally might not be straight forward though.
Re:Ask HN: How would you make Emacs do this? by j_baker on Monday May 10, 2010 @02:56PM (#1335567)
For editing remote files, I find that sshfs is extremely useful: http://en.wikipedia.org/wiki/SSHFS
Re:Ask HN: How would you make Emacs do this? by abstractbill on Monday May 10, 2010 @03:03PM (#1335588)
To clarify, I don't have a problem editing remote files - I use TRAMP right now (haven't tried sshfs, but it looks interesting thanks!).

The problem I'm trying to solve is that right now I need to install Emacs on any computer I want to do work on. I'd like to be able to jump onto a random friend's laptop and open Emacs without any setup cost.

Re:Ask HN: How would you make Emacs do this? by njn on Monday May 10, 2010 @06:22PM (#1336130)
I like sshfs as well, but it seems to perform even slower than scp for me, and way slower than ssh.