Emacs integration

Note: this is out of date. Use chrome://mozlab/content/mozrepl/javascript.el together with moz.el, instead of js-mode.el as reported below.

After you install MozLab, grab chrome://mozlab/content/mozrepl/moz.el put it somewhere in Emacs' load-path. moz.el contains:

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

Assuming you want to use java-mode to edit Javascript files, enter the following in your .emacs initialization file:

(add-to-list 'auto-mode-alist '("\\.js$" . java-mode))
(autoload 'moz-minor-mode "moz" "Mozilla Minor and Inferior Mozilla Modes" t)
(add-hook 'java-mode-hook 'java-custom-setup)
(defun java-custom-setup ()
  (moz-minor-mode 1))

Other modes suitable for editing Javascript are js-mode (in chrome://mozlab/content/mozrepl/js-mode.el) and c++-mode. The provided js-mode will only work with Emacs22.

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

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

In the interaction buffer:

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

The predictive abbreviation mode is very useful when working in Javascript source buffers (and most other kinds of buffer, actually).

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options

Captcha
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Syndicate content