1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-20 11:18:00 +01:00

Allow \ line continuations in Ex files.

This commit is contained in:
Kris Maglione
2010-10-10 23:05:59 -04:00
parent 7a2d80e675
commit e6672f47c3
6 changed files with 41 additions and 39 deletions

View File

@@ -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"],

View File

@@ -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) {

View File

@@ -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();

View File

@@ -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,11 +379,16 @@ 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))
// 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 });
}

View File

@@ -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,7 +687,10 @@ 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)
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"]:

View File

@@ -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