diff --git a/common/content/commands.js b/common/content/commands.js index e9ffeaa3..1a696b0e 100644 --- a/common/content/commands.js +++ b/common/content/commands.js @@ -204,7 +204,7 @@ Command.prototype = { return; args.count = count; args.bang = bang; - self.action.call(self, args, bang, count, modifiers); + self.action.call(self, args, modifiers); } if (this.hereDoc) diff --git a/common/content/io.js b/common/content/io.js index 94645256..262f200f 100644 --- a/common/content/io.js +++ b/common/content/io.js @@ -1028,13 +1028,15 @@ lookup: let heredocEnd = null; // the string which ends the heredoc let lines = str.split(/\r\n|[\r\n]/); + function execute(args) { command.execute(args, special, count, { setFrom: file }); } + for (let [i, line] in Iterator(lines)) { if (heredocEnd) // we already are in a heredoc { if (heredocEnd.test(line)) { - command.execute(heredoc, special, count); + execute(heredoc); heredoc = ""; heredocEnd = null; } @@ -1079,15 +1081,11 @@ lookup: heredocEnd = RegExp("^" + matches[2] + "$", "m"); if (matches[1]) heredoc = matches[1] + "\n"; + continue; } - else - command.execute(args, special, count); - } - else - { - // execute a normal liberator command - liberator.execute(line, null, true); } + + execute(args); } } } @@ -1095,7 +1093,7 @@ lookup: // if no heredoc-end delimiter is found before EOF then // process the heredoc anyway - Vim compatible ;-) if (heredocEnd) - command.execute(heredoc, special, count); + execute(heredoc); } if (scriptNames.indexOf(file.path) == -1) diff --git a/common/content/liberator.js b/common/content/liberator.js index 0a211843..26d86046 100644 --- a/common/content/liberator.js +++ b/common/content/liberator.js @@ -804,6 +804,7 @@ const liberator = (function () //{{{ try { vbs.set(args.count > -1 ? args.count : 1); + vbs.setFrom = null; liberator.execute(args[0], null, true); } finally diff --git a/common/content/options.js b/common/content/options.js index d18740e8..0d296c5b 100644 --- a/common/content/options.js +++ b/common/content/options.js @@ -111,12 +111,18 @@ function Option(names, description, type, defaultValue, extraInfo) //{{{ * @see #has */ this.checkHas = extraInfo.checkHas || null; + /** * @property {boolean} Set to true whenever the option is first set. This * is useful to see whether it was changed from its default value * interactively or by some RC file. */ this.hasChanged = false; + /** + * @property {nsIFile} The script in which this option was last set. null + * implies an interactive command. + */ + this.setFrom = null; // add no{option} variant of boolean {option} to this.names if (this.type == "boolean") @@ -572,6 +578,7 @@ function Options() //{{{ } if (name == "all" && reset) + // TODO: Why? --djk liberator.echoerr("You can't reset all options, it could make " + config.hostApplication + " unusable."); else if (name == "all") options.listPrefs(onlyNonDefault, ""); @@ -620,7 +627,10 @@ function Options() //{{{ option.reset(); } else + { + option.setFrom = modifiers.setFrom || null; option.reset(); + } } // read access else if (opt.get) @@ -630,9 +640,15 @@ function Options() //{{{ else { if (option.type == "boolean") - liberator.echo((opt.optionValue ? " " : "no") + option.name); + var msg = (opt.optionValue ? " " : "no") + option.name; else - liberator.echo(" " + option.name + "=" + opt.optionValue); + msg = " " + option.name + "=" + opt.optionValue; + + if (options["verbose"] > 0 && option.setFrom) + msg += "\n Last set from " + option.setFrom.path; + + // FIXME: Message highlight group wrapping messes up the indent up for multi-arg verbose :set queries + liberator.echo({msg}); } } // write access @@ -640,6 +656,8 @@ function Options() //{{{ // improved. i.e. Vim's behavior is pretty sloppy to no real benefit else { + option.setFrom = modifiers.setFrom || null; + if (opt.option.type == "boolean") { if (opt.valueGiven) @@ -832,9 +850,10 @@ function Options() //{{{ commands.add(["setl[ocal]"], "Set local option", - function (args) + function (args, modifiers) { - return setAction(args, { scope: options.OPTION_SCOPE_LOCAL }); + modifiers.scope = options.OPTION_SCOPE_LOCAL; + setAction(args, modifiers); }, { bang: true, @@ -849,9 +868,10 @@ function Options() //{{{ commands.add(["setg[lobal]"], "Set global option", - function (args) + function (args, modifiers) { - return setAction(args, { scope: options.OPTION_SCOPE_GLOBAL }); + modifiers.scope = options.OPTION_SCOPE_GLOBAL; + setAction(args, modifiers); }, { bang: true, @@ -866,10 +886,7 @@ function Options() //{{{ commands.add(["se[t]"], "Set an option", - function (args) - { - return setAction(args); - }, + function (args, modifiers) { setAction(args, modifiers); }, { bang: true, completer: function (context, args)