welcome: please sign in

You can't save spelling words.

Clear message
location: MozRepl

The MozRepl extension embeds into Conkeror a JavaScript repl accessible via TCP connection to a port listening on localhost, usually 4242. In some cases, it may be more convenient than M-: and in particular, it includes an Emacs Lisp package that provides an inferior JavaScript shell interface to Conkeror using MozRepl (more information here).

Setup

After installing MozRepl, add one of the following blocks of code to your rc. The first will make the MozRepl server start at Conkeror's startup. The second will start the server immediately, and has the additional property of letting you easily customize the port it listens on.

user_pref('extensions.mozrepl.autoStart', true);

// Mozrepl
//
if ('@hyperstruct.net/mozlab/mozrepl;1' in Cc) {
  let mozrepl = Cc['@hyperstruct.net/mozlab/mozrepl;1']
    .getService(Ci.nsIMozRepl);
  if (! mozrepl.isActive())
    mozrepl.start(4242);
}

Environment Setup

Here is how to set up mozrepl to start in the Conkeror application context. That is the main context that contains all of Conkeror's global objects.

First make a file called ~/.mozrepl-conkeror.js, which contains the code that follows.

var conkeror = Cc["@conkeror.mozdev.org/application;1"]
    .getService().wrappedJSObject;

this.enter(conkeror);

Now put the following code into your .conkerorrc:

let (mozrepl_init = get_home_directory()) {
    mozrepl_init.appendRelativePath(".mozrepl-conkeror.js");
    session_pref('extensions.mozrepl.initUrl', make_uri(mozrepl_init).spec);
}

Scripting Conkeror in bash via MozREPL

I found and improved a library of bash shell script functions for driving MozREPL by someone called Philippe Cassignol and put it on GitHub: https://github.com/PhilHudson/bash-mozrepl

He had the excellent idea of using the expect shell command and built a basic (and, he humbly admitted, somewhat crude) implementation. I cleaned it up, added some sed magic and a trivial expect script change to strip extraneous output passed on from the REPL, changed some code to debug-only and added a debug toggle, un-hard-coded a temporary file location, added a small French-to-English lexicon in a comment block to aid maintainers, and got rid of one misplaced (and commented-out) instruction. Otherwise, it's his work.

To use the functions, you need to load mozrepl.sh into a bash shell script or an interactive bash shell using the . or source command, not execute it.

To use mozrepl.sh with Conkeror, you must not pre-load the .mozrepl-conkeror.js snippets from the "Environment Setup" section above; the library is designed to work with a "vanilla" MozREPL in either Conkeror or Firefox/Iceweasel.

Philippe Cassignol's original code can be found here: http://philippe.cassignol.pagesperso-orange.fr/2012/mozrepl.sh

I will continue to improve the library as ideas occur to me. If you have your own, either fork the project on GitHub and send a pull request with your changes, or raise an issue on the project's GitHub page.

-- PhilHudson 2013-05-21 05:49:26

Conkeror.org: MozRepl (last edited 2013-05-21 05:49:26 by PhilHudson)