Editing Web Forms With a Real Editor
John Smathers 7/10/2004One of the biggest drags about using web based applications is that graphical web browsers provide such lame interfaces for editing <textarea> fields. If you're used to the rich interface of an editor like Emacs, using web-based e-mail can feel pretty frustrating. A workaround for this that I have started using is the Mozex extension for the Mozilla web browser. Mozex adds an option to the right-click context menu, which allows you to pipe the textarea content to an external editor, such as Emacs. After editing, simply left-click in the textarea and the text is copied into place. The screenshots at http://mozex.mozdev.org/screenshots.html help to explain.
Installation
Mozex is an XPI package, that can be picked up at http://mozex.mozdev.org. See that page for instructions on how to install the XPI file.Go Edit->Preferences->Mozex to configure the options.
- Specify a directory for temporary files. I like to make a directory called ".mozex" in my home directory for this. For some reason it seems to work best if you specify the full path rather than using "~" as the name for your home directory. For security, be sure to do a chmod 700 on that directory.
- Specify the command for starting your editor in the "Textareas"
field. Example:
/usr/bin/emacs %t
Usage
Right-click in the textarea and go mozex->Edit Textarea. Your external editor will launch. Edit your text. Save the temporary file when finished. Left click in the textarea and your text will be copied into place.Advanced Options
If you use Emacs a lot, it can be moderately annoying to open a separate Emacs window each time you use Mozex. You can use the emacsclient program to use an Emacs that is already running. (XEmacs users can do something similar using gnuserv/gnuclient, but I haven't worked out the setup details for that). There may be a simpler way to do this, but here's what I've been using:- Make a script to load the "edit" function into your shell
environment. I call my script "emacsclient.sh", and I keep it in
/usr/local/bin. My script looks like this:
Change your script according to your version of Emacs.#!/bin/bash # Load the "edit" function which starts Emacs, or runs emacsclient # if an Emacs session is already running. . /usr/share/emacs/21.2/etc/emacs.bash edit $1 exit 0
- Change the mozex preference to use the emacsclient.sh script as
your external editor.
/usr/bin/emacsclient %t
- In Emacs, go "M-x start-server" to allow connections from emacsclient. If you have more than one Emacs running, only do this in the one that you want to use for editing with Mozex.
Enjoy.
Note for Firefox 1.x users: Apparently the Mozex package hasn't been updated for newer versions of Firefox - it works fine, but you can't get to the settings page. There is probably a better workaround for this, but here is the hack that I am using.
Edit the prefs.js file (do not have firefox running while you make the changes):
~/.mozilla/firefox/xu2fextp.default/prefs.js
Add the following lines:
user_pref("mozex.command.aim", "");
user_pref("mozex.command.download", "");
user_pref("mozex.command.ed2k", "");
user_pref("mozex.command.ftp", "");
user_pref("mozex.command.irc", "");
user_pref("mozex.command.mailer", "");
user_pref("mozex.command.news", "");
user_pref("mozex.command.source", "");
user_pref("mozex.command.telnet", "");
user_pref("mozex.command.textarea", "/usr/local/bin/emacsclient.sh %t");
user_pref("mozex.general.tmpdir", "~/.mozilla-extras/mozex");
user_pref("mozex.intercept.ftp", false);
user_pref("mozex.intercept.irc", false);
user_pref("mozex.intercept.mailto", false);
user_pref("mozex.intercept.news", false);
user_pref("mozex.intercept.telnet", false);
user_pref("mozex.universal.command", "");
user_pref("mozex.universal.schemes", "");
