diff --git a/common/content/commands.js b/common/content/commands.js index bf9f8207..f1bcd8e4 100644 --- a/common/content/commands.js +++ b/common/content/commands.js @@ -791,7 +791,7 @@ const Commands = Module("commands", { str.replace(/\s*".*$/, ""); // 0 - count, 1 - cmd, 2 - special, 3 - args - let matches = str.match(/^([:\s]*(\d+|%)?([a-zA-Z]+|!)(!)?(\s*))(.*?)?$/); + let matches = str.match(/^([:\s]*(\d+|%)?([a-zA-Z]+|!)(!)?(\s*))((?:.|\n)*?)?$/); //var matches = str.match(/^:*(\d+|%)?([a-zA-Z]+|!)(!)?(?:\s*(.*?)\s*)?$/); if (!matches) return []; @@ -1103,21 +1103,21 @@ const Commands = Module("commands", { completion.ex(context); }, options: [ - { names: ["-bang"], description: "Command may be proceeded by a !" }, - { names: ["-count"], description: "Command may be preceeded by a count" }, + { names: ["-bang", "-b"], description: "Command may be proceeded by a !" }, + { names: ["-count", "-c"], description: "Command may be preceeded by a count" }, { - names: ["-description"], + names: ["-description", "-desc", "-d"], description: "A user-visible description of the command", type: CommandOption.STRING }, { // TODO: "E180: invalid complete value: " + arg - names: ["-complete"], + names: ["-complete", "-C"], description: "The argument completion function", completer: function (context) [[k, ""] for ([k, v] in Iterator(completeOptionMap))], type: CommandOption.STRING, validator: function (arg) arg in completeOptionMap || /custom,\w+/.test(arg), }, { - names: ["-nargs"], + names: ["-nargs", "-a"], description: "The allowed number of arguments", completer: [["0", "No arguments are allowed (default)"], ["1", "One argument is allowed"], diff --git a/common/content/dactyl.js b/common/content/dactyl.js index 65244f87..d0013a2c 100644 --- a/common/content/dactyl.js +++ b/common/content/dactyl.js @@ -2022,17 +2022,7 @@ const Dactyl = Module("dactyl", { // all gui options to their default values, if they have not been // set before by any RC file for (let option in values(options.needInit)) - // FIXME: - // 'encoding' option should not be set at this timing. - // Probably a wrong value is set into the option, - // if current page's encoding is not UTF-8. - try { - if (option.name != "encoding"); - option.value = option.value; - } - catch (e) { - dactyl.reportError(e); - } + option.initValue(); if (dactyl.commandLineOptions.postCommands) dactyl.commandLineOptions.postCommands.forEach(function (cmd) { diff --git a/common/content/hints.js b/common/content/hints.js index 7ded7bb8..255d4e95 100644 --- a/common/content/hints.js +++ b/common/content/hints.js @@ -83,7 +83,7 @@ const Hints = Module("hints", { this._hintNumber = 0; this._hintString = ""; statusline.updateInputBuffer(""); - commandline.command = ""; + commandline.widgets.command = ""; } this._pageHints = []; this._validHints = []; @@ -99,7 +99,7 @@ const Hints = Module("hints", { } if (this.__continue && this._validHints.length <= 1) { this._hintString = ""; - commandline.command = this._hintString; + commandline.widgets.command = this._hintString; this._showHints(); } this._updateStatusline(); diff --git a/common/content/io.js b/common/content/io.js index 305023ed..28c57fef 100644 --- a/common/content/io.js +++ b/common/content/io.js @@ -358,10 +358,7 @@ lookup: else if (/\.css$/.test(filename)) storage.styles.registerSheet(uri.spec, false, true); else { - let heredoc = ""; - let heredocEnd = null; // the string which ends the heredoc - let str = file.read(); - let lines = str.split(/\r\n|[\r\n]/); + let lines = file.read().split(/\r\n|[\r\n]/); this.readHeredoc = function (end) { let res = []; @@ -382,21 +379,26 @@ lookup: for (let [i, line] in iter) { if (this.sourcing.finished) break; + this.sourcing.line = i + 1; - // skip line comments and blank lines + + // Deal with editors from Silly OSs. line = line.replace(/\r$/, ""); - if (!/^\s*(".*)?$/.test(line)) - try { - dactyl.execute(line, { setFrom: file }); - } - catch (e) { - if (!silent) { - dactyl.echoerr("Error detected while processing " + file.path); - dactyl.echomsg("line\t" + this.sourcing.line + ":"); - dactyl.reportError(e, true); - } + // Process escaped new lines + for (; i < lines.length && /^\s*\\/.test(lines[i + 1]); i++) + line += "\n" + iter.next()[1].replace(/^\s*\\/, ""); + + try { + dactyl.execute(line, { setFrom: file }); + } + catch (e) { + if (!silent) { + dactyl.echoerr("Error detected while processing " + file.path); + dactyl.echomsg("line\t" + this.sourcing.line + ":"); + dactyl.reportError(e, true); } + } } } diff --git a/common/content/options.js b/common/content/options.js index 58ff5371..07914b99 100644 --- a/common/content/options.js +++ b/common/content/options.js @@ -71,6 +71,10 @@ const Option = Class("Option", { this.globalValue = this.parseValues(this.defaultValue); }, + initValue: function () { + dactyl.trapErrors(function () this.values = this.values, this); + }, + /** @property {value} The option's global value. @see #scope */ get globalValue() options.store.get(this.name, {}).value, set globalValue(val) { options.store.set(this.name, { value: val, time: Date.now() }); }, @@ -683,8 +687,11 @@ const Options = Module("options", { memoize(this._optionMap, name, function () Option(names, description, type, defaultValue, extraInfo)); for (let alias in values(names.slice(1))) memoize(this._optionMap, alias, closure); - if (extraInfo.setter) - memoize(this.needInit, this.needInit.length, closure); + if (extraInfo.setter && (!extraInfo.scope || extraInfo.scope & Option.SCOPE_GLOBAL)) + if (dactyl.initialized) + closure().initValue(); + else + memoize(this.needInit, this.needInit.length, closure); // quickly access options with options["wildmode"]: this.__defineGetter__(name, function () this._optionMap[name].values); diff --git a/pentadactyl/NEWS b/pentadactyl/NEWS index df7b5ff8..ee5dc1bf 100644 --- a/pentadactyl/NEWS +++ b/pentadactyl/NEWS @@ -18,7 +18,12 @@ - Backtracks to the first successful match after pressing backspace. - Supports reverse incremental search. - * Multiple Ex commands may now be separated by | + * Ex command parsing improvements, including: + - Multiple Ex commands may now be separated by | + - Commands can continue over multiple lines in RC files by + prefixing the continues lines with a \ + - The \ character is no longer treated specially within single + quotes, i.e., 'fo\o''bar' ⇒ fo\o'bar * Command-line is now hidden by default. Added C and M to 'guioptions'. * Hint mode improvements, including: @@ -41,8 +46,6 @@ directory in 'runtimepath' rather than 'plugin/'. * IMPORTANT: 'loadplugins' is now a regexlist option rather than a boolean. - * IMPORTANT: Single quotes no longer treat \ specially. - I.e., 'fo\o''bar' ≡ fo\o'bar * IMPORTANT: 'cdpath' and 'runtimepath' no longer treat ",," specially. Use "." instead. * IMPORTANT: Option value quoting has changed. List options will