1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-03-04 08:25:51 +01:00

Add support for verbose :set querying of options.

Querying of commands, autocommands, mappings, abbreviations, highlight
groups, and styles should also be supported.
This commit is contained in:
Doug Kearns
2009-08-25 20:05:41 +10:00
parent c56a1ed77b
commit 5f6405be03
4 changed files with 36 additions and 20 deletions

View File

@@ -204,7 +204,7 @@ Command.prototype = {
return; return;
args.count = count; args.count = count;
args.bang = bang; args.bang = bang;
self.action.call(self, args, bang, count, modifiers); self.action.call(self, args, modifiers);
} }
if (this.hereDoc) if (this.hereDoc)

View File

@@ -1028,13 +1028,15 @@ lookup:
let heredocEnd = null; // the string which ends the heredoc let heredocEnd = null; // the string which ends the heredoc
let lines = str.split(/\r\n|[\r\n]/); 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)) for (let [i, line] in Iterator(lines))
{ {
if (heredocEnd) // we already are in a heredoc if (heredocEnd) // we already are in a heredoc
{ {
if (heredocEnd.test(line)) if (heredocEnd.test(line))
{ {
command.execute(heredoc, special, count); execute(heredoc);
heredoc = ""; heredoc = "";
heredocEnd = null; heredocEnd = null;
} }
@@ -1079,15 +1081,11 @@ lookup:
heredocEnd = RegExp("^" + matches[2] + "$", "m"); heredocEnd = RegExp("^" + matches[2] + "$", "m");
if (matches[1]) if (matches[1])
heredoc = matches[1] + "\n"; 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 // if no heredoc-end delimiter is found before EOF then
// process the heredoc anyway - Vim compatible ;-) // process the heredoc anyway - Vim compatible ;-)
if (heredocEnd) if (heredocEnd)
command.execute(heredoc, special, count); execute(heredoc);
} }
if (scriptNames.indexOf(file.path) == -1) if (scriptNames.indexOf(file.path) == -1)

View File

@@ -804,6 +804,7 @@ const liberator = (function () //{{{
try try
{ {
vbs.set(args.count > -1 ? args.count : 1); vbs.set(args.count > -1 ? args.count : 1);
vbs.setFrom = null;
liberator.execute(args[0], null, true); liberator.execute(args[0], null, true);
} }
finally finally

View File

@@ -111,12 +111,18 @@ function Option(names, description, type, defaultValue, extraInfo) //{{{
* @see #has * @see #has
*/ */
this.checkHas = extraInfo.checkHas || null; this.checkHas = extraInfo.checkHas || null;
/** /**
* @property {boolean} Set to true whenever the option is first set. This * @property {boolean} Set to true whenever the option is first set. This
* is useful to see whether it was changed from its default value * is useful to see whether it was changed from its default value
* interactively or by some RC file. * interactively or by some RC file.
*/ */
this.hasChanged = false; 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 // add no{option} variant of boolean {option} to this.names
if (this.type == "boolean") if (this.type == "boolean")
@@ -572,6 +578,7 @@ function Options() //{{{
} }
if (name == "all" && reset) if (name == "all" && reset)
// TODO: Why? --djk
liberator.echoerr("You can't reset all options, it could make " + config.hostApplication + " unusable."); liberator.echoerr("You can't reset all options, it could make " + config.hostApplication + " unusable.");
else if (name == "all") else if (name == "all")
options.listPrefs(onlyNonDefault, ""); options.listPrefs(onlyNonDefault, "");
@@ -620,7 +627,10 @@ function Options() //{{{
option.reset(); option.reset();
} }
else else
{
option.setFrom = modifiers.setFrom || null;
option.reset(); option.reset();
}
} }
// read access // read access
else if (opt.get) else if (opt.get)
@@ -630,9 +640,15 @@ function Options() //{{{
else else
{ {
if (option.type == "boolean") if (option.type == "boolean")
liberator.echo((opt.optionValue ? " " : "no") + option.name); var msg = (opt.optionValue ? " " : "no") + option.name;
else 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(<span highlight="CmdOutput">{msg}</span>);
} }
} }
// write access // write access
@@ -640,6 +656,8 @@ function Options() //{{{
// improved. i.e. Vim's behavior is pretty sloppy to no real benefit // improved. i.e. Vim's behavior is pretty sloppy to no real benefit
else else
{ {
option.setFrom = modifiers.setFrom || null;
if (opt.option.type == "boolean") if (opt.option.type == "boolean")
{ {
if (opt.valueGiven) if (opt.valueGiven)
@@ -832,9 +850,10 @@ function Options() //{{{
commands.add(["setl[ocal]"], commands.add(["setl[ocal]"],
"Set local option", "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, bang: true,
@@ -849,9 +868,10 @@ function Options() //{{{
commands.add(["setg[lobal]"], commands.add(["setg[lobal]"],
"Set global option", "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, bang: true,
@@ -866,10 +886,7 @@ function Options() //{{{
commands.add(["se[t]"], commands.add(["se[t]"],
"Set an option", "Set an option",
function (args) function (args, modifiers) { setAction(args, modifiers); },
{
return setAction(args);
},
{ {
bang: true, bang: true,
completer: function (context, args) completer: function (context, args)