Example #1
0
exports.parseElisp = function(elisp) {
    var startMatch = elisp.match(/^;;; ([^ ]*)\.el --- (.*)$/m);
    if (!startMatch) throw new SyntaxError("No starting comment for package");

    var filename = startMatch[1];
    var desc = startMatch[2];

    var endRx = new RegExp("^(\\(provide[^)]+\\) +)?;;; " +
                           util.regexpEscape(filename) +
                           "\\.el ends here", "m");
    var endMatch = elisp.match(endRx);
    if (!endMatch) throw new SyntaxError("No closing comment for package");

    elisp = elisp.substring(startMatch.index, endMatch.index + endMatch[0].length);
    var headers = getHeaders(elisp);
    var requires = headers["package-requires"];
    var version = stripRCS(headers["package-version"] ||
                           headers["version"]);
    if (!version)
        throw new SyntaxError('Package does not have a "Version" or ' +
                              '"Package-Version" header');
    var commentary = getSection(elisp, /commentary|documentation/);

    requires = parseRequires(requires);
    version = parseVersion(version);

    return {
        _name: filename.toLowerCase(),
        name: filename,
        description: desc,
        commentary: commentary,
        headers: headers,
        requires: requires,
        version: version,
        type: "single"
    };
};
Example #2
0
Backend.prototype.searchPackages = function(query, opt_fields, opt_opts) {
    // TODO: Use an actual full-text search engine.
    return this.packageStream(
        {_name: new RegExp(util.regexpEscape(this.key(query)))},
        opt_fields, opt_opts);
};