README 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. Servers
  2. =======
  3. Because the Chrome(ium) security model doesn't allow for extensions
  4. spawning processes we can't just exec() the editor process. Instead we
  5. have to implement an "edit server" which listens to XmlHttp requests
  6. on port 9292 (default) and then sends a response when the edit is
  7. complete. We include a couple here:
  8. * pycl.py - Original version, only edit one file at a time
  9. * edit_server.el - An native Emacs Lisp implementation
  10. There is another project called TextAid which does a similar thing to
  11. Edit with Emacs. It's edit server is implemented in perl and be found
  12. at:
  13. * http://opencoder.net/edit-server
  14. As the edit server concept is fairly simple we will try and keep them
  15. compatible with each other.
  16. Customizing the look of Emacs
  17. =============================
  18. By default, Emacs opens up a new frame upon an edit request. All the
  19. UI elements are removed to better mimic a bare text box. You can
  20. customize the default behavior by `M-x customize-group [RET]
  21. edit-server [RET]`. Or you can set the variables' values directly in
  22. your ~/.emacs.
  23. Hooks
  24. =====
  25. edit-server.el provides two hooks for customising behaviour when edit
  26. requests are being made. These are:
  27. * edit-server-start-hook - called when editing starts
  28. * edit-server-done-hook - called when just before the text returned
  29. For an example of what can be achieved please see Roland McGrath's
  30. excellent edit-server-htmlize.el [1] which provides some example
  31. functions which can be added to these hooks to deal with a popular web
  32. based email client which sends HTML even in plain text mode.
  33. [1] https://github.com/frobtech/edit-server-htmlize
  34. How it works
  35. ============
  36. The browser sends a request to the edit server of the form:
  37. http://${HOSTNAME}:${HOSTPORT}/${CMD}
  38. HOSTNAME is usually localhost, i.e. 127.0.0.1
  39. HOSTPORT is the server port, in our case defaults to 9292
  40. CMD is the command to the edit server, it may be one of the following:
  41. * edit
  42. The edit command is sent as an HTTP POST request. After the headers
  43. the data is the current contents of the text area.
  44. Once the edit is complete the server sends an HTTP 200 (OK) response
  45. with the data containing the new text area text. Any other response
  46. will result in the text area not being updated.
  47. The extension also sets some headers which may be used by the edit
  48. servers to create more identifiable names for the buffers/temp files
  49. to help the user keep track.
  50. x-url: The URL of the source page
  51. x-id: The unique (on the page) ID of the text area
  52. * status
  53. The status command is sent as an HTTP GET request. The intention is to
  54. use it as a simple test for the status of Edit Server and to be used
  55. as a "Are you there?" test.
  56. The response is basically a text string describing the state of the
  57. edit server.