Edit with Emacs

Edit with Emacs is an extension for editing text areas in Google Chrome and FireFox.

The extension requires an “edit server” to handle edit requests from Chrome(ium)/FireFox. This is due to the security model of Chrome preventing the execution of external applications. Fortunately the extension comes with a native elisp edit server which can run in your Emacs daemon session.

Tips and Tricks

Customisation

The extension has a number of variables that allow various behaviours to be customised. Currently they are:

There are currently two hooks

    (lambda () (kill-ring-save (point-min) (point-max)))

Controlling invocation

If you’re already running an instance of Emacs in --daemon mode then you can wrap the code in something like:

 (when (and (daemonp) (require 'edit-server nil :noerror))
   (edit-server-start))

The edit To open pages for editing in a new buffer instead of a new frame on your running Emacs instance do:

(when (require 'edit-server nil :noerror)
  (setq edit-server-new-frame nil)
  (edit-server-start))

Integration with Google Mail

Gmail has switched to a new compose window which unfortunately breaks interaction with edit-server. However fortunately someone has hacked together a solution for this: https://github.com/frobtech/edit-server-htmlize

To use, simply ensure that edit-server-htmlize.el is on your load-path and then do:

(autoload 'edit-server-maybe-dehtmlize-buffer "edit-server-htmlize" "edit-server-htmlize" t)
(autoload 'edit-server-maybe-htmlize-buffer   "edit-server-htmlize" "edit-server-htmlize" t)
(add-hook 'edit-server-start-hook 'edit-server-maybe-dehtmlize-buffer)
(add-hook 'edit-server-done-hook  'edit-server-maybe-htmlize-buffer)

Changing Default Mode

To have edit-server work in some other mode (other than text-mode), edit edit-server.el and change this line:

   (define-derived-mode edit-server-text-mode text-mode "Edit Server Text Mode"

to something like:

   (define-derived-mode edit-server-text-mode markdown-mode "Edit Server Text Mode"

Or instead of editing edit-server.el add this:

  (add-hook 'edit-server-start-hook 'markdown-mode)

Integrating with other modes

TODO: Look at integrating as-external…

On OS X, running Aquamacs 2.1, how would I force Aquamacs to bring the new message frame above Chrome? Currently, a new frame is opened on top of Aquamacs, but below Chrome. Also, i think the ALT+E button doesn’t function on Chrome 10.0.612.1 dev - no Aquamacs window is raised.

On OS X running Aquamacs (version 3.x development) : force Aquamacs to become the front application (bringing all frames forward, not just new “edit” frame) using: (add-hook ‘edit-server-start-hook (lambda () (do-applescript “tell application \“Aquamacs\” to activate”)))

I’ve described how to integrate edit-server with org-mode to save edits to an org-mode task and clock the time spent on them.


CategoryHypermedia