Ciarán’s free software notes

Ciaran O’Riordan’s blog, 2006-2008

Launching your favourite editor in Firefox

After a bit of tweaking, I’m now happily using the the It’s All Text! plugin to let me to edit webpage text boxes with Emacs. It also works with other text editors. [UPDATE: Actually, my browser is Iceweasel, not Firefox. See the Mozilla software rebranding article on Wikipedia, and the IceCat project]

To configure it, go to Tools->It’s All Text!->Preferences in Firefox’s menu bar. In the editor field, when I added some command line options to make Emacs start quickly, it gave me the error "Unable to open your editor". So I made a "quickmacs.sh" file and told It’s All Text that that that was my editor. In quickmacs.sh, I put:

#!/bin/sh
gnome-terminal -t "QM $1" -e "emacs -nw -Q –load ~/software/tb.el $1"

The second "$1" is essential. I want Emacs in non-gui mode, so it has to be launched by a terminal program because It’s All Text! doesn’t run the given editor command in a terminal. tb.el is a a cut down version of my emacs.el. It just contains the minimal convenience settings I want for editing textboxes:

(transient-mark-mode t)
(show-paren-mode t)
(menu-bar-mode 0)
(defun ciaran-turn-on-french-input-method ()
   "set the input method to French"
   (interactive)
   (set-input-method "french-alt-postfix"))
(global-set-key [?\C-c ?.] ‘ciaran-turn-on-french-input-method)
(longlines-mode t)

There were two other interesting plugins. The first is EmbeddedEditor 0.1, but you have to make an account and log in if you want to download it, so I ignored it. The second is Firemacs, but that’s adding some Emacs features to Firefox - I prefer to have a full Emacs.

– 
Ciarán O’Riordan,
Support free software: Join FSFE’s Fellowship

5 Responses to “Launching your favourite editor in Firefox”

  1. gerloff Says:

    cool tool

    Thanks Ciaran for pointing me to this! I’m writing this comment in
    gvim — but only because I haven’t figured out how to tell the
    tool to open a shell and start vim inside it. (Hints appreciated)

    Either way, this is so much better than the clumsy web editors that
    blight our digital lives.

    Btw, Plone offers an “edit with external application” thing, but
    that needs to be installed server-side — not much use if you
    can’t persuade the admin to do it.

  2. ciaran Says:

    gnome-terminal -e

    @gerloff: If you give it a command, it doesn’t automatically run a shell for the command. That’s why my command to launch emacs is inside quotes after gnome-terminal -e. The -nw switch to emacs is to get the non-gui version.

  3. gerloff Says:

    no joy there

    @ciaran: the line

    gnome-terminal -e ‘/usr/bin/vim’

    doesn’t work for me for some reason. I’ve had the same problem
    with the Plone external editor thing before.

    Gvim works fine in both cases.

  4. ciaran Says:

    hmmm

    @gerloff: Strange. I copy and pasted your command and I got vim in a gnome-terminal. There’s a gremlin somewhere. It also works when I do:

    xterm -e ‘/usr/bin/vim’

    Trying that might tell you if it’s a vim or a gnome-terminal problem. Typing “alias” at the command line would also show if either command is already redefined in some way. That could mess things up, maybe. Happy debugging :-)

  5. Jonathan McClare Says:

    The problem I see is that you have to explicitly pass the command arguments on to the executed command with gnome-terminal. I had to screw with the parenthesis to get it to do that properly, but I found out how in one of the plugin reviews:
    https://addons.mozilla.org/en-US/firefox/reviews/display/4125?show=20&page=3#review-24790

    Place the following in a file and make it executable:

    #! /bin/bash

    #
    # Open a gnome-terminal running vim with the passed arguments.
    #
    /usr/bin/gnome-terminal -e “/usr/bin/vim $*”

    The $* is what passes the arguments into the command.

    Specify that file in the preferences dialog. It will open a new gnome terminal running vim editing the temp file.