bard / mozrepl

MozRepl lets you program Firefox and other Mozilla-based applications from the inside.

Home | Edit | New

Emacs integration

Download javascript.el and
moz.el and place them somewhere in Emacs’ load-path. Alternatively, place them in any directory (e.g. “/home/user/emacsfiles”) then add that directory to the load-path, as follows:

Update: We’re now including also espresso.el, an improved version of javascript.el. See below for instructions. Barring problems, espresso.el will replace javascript.el in the near future.


    (add-to-list 'load-path "/home/user/emacsfiles")

moz.el contains a major mode for direct interaction in a buffer (as with telnet) and a minor mode for sending code portions or whole files from other buffers.

Add this to your .emacs file:


    (autoload 'moz-minor-mode "moz" "Mozilla Minor and Inferior Mozilla Modes" t)

    (add-hook 'javascript-mode-hook 'javascript-custom-setup)
    (defun javascript-custom-setup ()
      (moz-minor-mode 1))

Or if you’re trying espresso.el, add this:


    (autoload 'moz-minor-mode "moz" "Mozilla Minor and Inferior Mozilla Modes" t)

    (add-hook 'espresso-mode-hook 'espresso-custom-setup)
    (defun espresso-custom-setup ()
      (moz-minor-mode 1))

Restart Emacs, and every time you open a Javascript file, you will now
have the following keybindings available:

  • C-c C-s: open a MozRepl interaction buffer and switch to it
  • C-c C-l: save the current buffer and load it in MozRepl
  • C-M-x: send the current function (as recognized by c-mark-function) to MozRepl
  • C-c C-c: send the current function to MozRepl and switch to the interaction buffer
  • C-c C-r: send the current region to MozRepl

In the interaction buffer:

  • C-c c: insert the current name of the REPL plus the dot operator (usually repl.)

Tips & tricks

The predictive abbreviation mode
is very handy when working in Javascript source buffers.

Last edited by bard, Tue Apr 07 14:12:24 -0700 2009
Home | Edit | New
Versions: