1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-02-16 10:55:46 +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

@@ -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(<span highlight="CmdOutput">{msg}</span>);
}
}
// 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)