1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-02-05 04:15:47 +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;
args.count = count;
args.bang = bang;
self.action.call(self, args, bang, count, modifiers);
self.action.call(self, args, modifiers);
}
if (this.hereDoc)

View File

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

View File

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

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)