Pages

Tuesday, March 8, 2011

Emacs to edit a Chromium textarea


A nice Chromium alternatives to the FF extension "Its all text" is here :-



https://chrome.google.com/extensions/detail/ljobjlafonikaiipfkggjbhkghgicgoh



Why it needs edit-server.el I'm not 100% - I guess it uses something other than
the emacs daemon emacsclient call. But, it works nicely. I added the following
ot my emacs-init.org and all seems well. I like the double click in a textarea
method to launch an emacs client windows to edit.





(if (and (daemonp) (locate-library "edit-server"))
(progn
(require 'edit-server)
(edit-server-start)))

(add-hook 'edit-server-text-mode-hook
(lambda ()(progn()
(auto-complete-mode)
(flyspell-mode))))








--
My Emacs Files At GitHub

2 comments:

  1. Hi,

    I'm glad you find the extension useful.

    The main reason it doesn't use the existing emacsclient mechanism is because Chrome(ium) extensions are limited in what they can do. The only real mechanism they have to communicate with the outside world is XmlHttpRequests which is what the edit-server.el handles.

    It is possible to write a NAPI style plugin for the extension which could save a temp file a-la It's All Text but it would be considerably less portable. The other option would be to bake edit-server.el's XmlHttp handling into emacs proper as just another mechanism the emacsclient could use. I'm not sure what that would gain though.

    Alex.

    ReplyDelete
  2. Nice idea. I also use edit-server for editing text forms in Chrome sessions. This makes the editing experience a LOT better for me too.

    * Note: You can 'simplify' some of the elisp code. Using (when condition body ...) means you do not need the 'progn' around inside the 'if' form:

    (when (and (daemonp) (locate-library "edit-server"))
    (require 'edit-server)
    (edit-server-start))

    * Note (2): There's also an implicit 'progn' around the body of a lambda form. Some of the mode toggling functions work will merely *toggle* the respective mode without arguments, but they will explicitly turn it *on* if you pass '1' as the first argument (e.g. flyspell-mode, auto-fill-mode, cua-mode, etc. do this).

    The second part can also be written as:

    (add-hook 'edit-server-text-mode-hook
    (lambda ()
    (auto-complete-mode 1)
    (flyspell-mode 1)))

    ReplyDelete