mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-23 21:42:27 +01:00
Deprecate :let and dactyl.globalVariables.
This commit is contained in:
@@ -131,6 +131,11 @@ const Command = Class("Command", {
|
|||||||
* @param {Object} modifiers Any modifiers to be passed to {@link #action}.
|
* @param {Object} modifiers Any modifiers to be passed to {@link #action}.
|
||||||
*/
|
*/
|
||||||
execute: function (args, modifiers) {
|
execute: function (args, modifiers) {
|
||||||
|
if (this.deprecated) {
|
||||||
|
let loc = io.sourcing ? io.sourcing.file + ":" + io.sourcing.line + ": " : "";
|
||||||
|
dactyl.echoerr(loc + ":" + this.name + " is deprecated");
|
||||||
|
}
|
||||||
|
|
||||||
let self = this;
|
let self = this;
|
||||||
modifiers = modifiers || {};
|
modifiers = modifiers || {};
|
||||||
|
|
||||||
|
|||||||
@@ -46,6 +46,7 @@
|
|||||||
"modules",
|
"modules",
|
||||||
"storage",
|
"storage",
|
||||||
"util",
|
"util",
|
||||||
|
"dactyl",
|
||||||
"modes",
|
"modes",
|
||||||
"abbreviations",
|
"abbreviations",
|
||||||
"autocommands",
|
"autocommands",
|
||||||
@@ -55,7 +56,6 @@
|
|||||||
"completion",
|
"completion",
|
||||||
"configbase",
|
"configbase",
|
||||||
"config",
|
"config",
|
||||||
"dactyl",
|
|
||||||
"editor",
|
"editor",
|
||||||
"events",
|
"events",
|
||||||
"finder",
|
"finder",
|
||||||
|
|||||||
@@ -25,6 +25,19 @@ const FailedAssertion = Class("FailedAssertion", Error, {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
deprecated.seen = {};
|
||||||
|
function deprecated(fn)
|
||||||
|
function deprecatedMethod() {
|
||||||
|
let frame = Components.stack.caller;
|
||||||
|
let caller = frame.filename + ":" + frame.lineNumber;
|
||||||
|
if (frame.filename != "chrome://dactyl/content/javascript.js" &&
|
||||||
|
!set.add(deprecated.seen, caller))
|
||||||
|
dactyl.echoerr(caller + ": " +
|
||||||
|
(this.className || this.constructor.className) + "." + fn.name +
|
||||||
|
" is deprecated");
|
||||||
|
return fn.apply(this, arguments);
|
||||||
|
}
|
||||||
|
|
||||||
const Dactyl = Module("dactyl", {
|
const Dactyl = Module("dactyl", {
|
||||||
init: function () {
|
init: function () {
|
||||||
window.dactyl = this;
|
window.dactyl = this;
|
||||||
@@ -689,7 +702,10 @@ const Dactyl = Module("dactyl", {
|
|||||||
*
|
*
|
||||||
* These are set and accessed with the "g:" prefix.
|
* These are set and accessed with the "g:" prefix.
|
||||||
*/
|
*/
|
||||||
globalVariables: {},
|
_globalVariables: {},
|
||||||
|
globalVariables: Class.Property({
|
||||||
|
get: deprecated(function globalVariables() this._globalVariables)
|
||||||
|
}),
|
||||||
|
|
||||||
loadPlugins: function () {
|
loadPlugins: function () {
|
||||||
function sourceDirectory(dir) {
|
function sourceDirectory(dir) {
|
||||||
|
|||||||
@@ -406,6 +406,14 @@
|
|||||||
<span dactyl:highlight="HelpOptionalArg">[<xsl:apply-templates select="@*|node()" mode="help-1"/>]</span>
|
<span dactyl:highlight="HelpOptionalArg">[<xsl:apply-templates select="@*|node()" mode="help-1"/>]</span>
|
||||||
</xsl:template>
|
</xsl:template>
|
||||||
|
|
||||||
|
<xsl:template match="dactyl:deprecated" mode="help-2">
|
||||||
|
<p style="clear: both;">
|
||||||
|
<xsl:apply-templates select="@*" mode="help-1"/>
|
||||||
|
<span dactyl:highlight="HelpWarning">Deprecated:</span>
|
||||||
|
<xsl:text> </xsl:text>
|
||||||
|
<xsl:apply-templates select="node()" mode="help-1"/>
|
||||||
|
</p>
|
||||||
|
</xsl:template>
|
||||||
<xsl:template match="dactyl:note" mode="help-2">
|
<xsl:template match="dactyl:note" mode="help-2">
|
||||||
<p style="clear: both;">
|
<p style="clear: both;">
|
||||||
<xsl:apply-templates select="@*" mode="help-1"/>
|
<xsl:apply-templates select="@*" mode="help-1"/>
|
||||||
|
|||||||
@@ -1246,6 +1246,7 @@ const Options = Module("options", {
|
|||||||
commands.add(["let"],
|
commands.add(["let"],
|
||||||
"Set or list a variable",
|
"Set or list a variable",
|
||||||
function (args) {
|
function (args) {
|
||||||
|
let globalVariables = dactyl._globalVariables;
|
||||||
args = (args[0] || "").trim();
|
args = (args[0] || "").trim();
|
||||||
function fmt(value) (typeof value == "number" ? "#" :
|
function fmt(value) (typeof value == "number" ? "#" :
|
||||||
typeof value == "function" ? "*" :
|
typeof value == "function" ? "*" :
|
||||||
@@ -1254,7 +1255,7 @@ const Options = Module("options", {
|
|||||||
let str =
|
let str =
|
||||||
<table>
|
<table>
|
||||||
{
|
{
|
||||||
template.map(dactyl.globalVariables, function ([i, value]) {
|
template.map(globalVariables, function ([i, value]) {
|
||||||
return <tr>
|
return <tr>
|
||||||
<td style="width: 200px;">{i}</td>
|
<td style="width: 200px;">{i}</td>
|
||||||
<td>{fmt(value)}</td>
|
<td>{fmt(value)}</td>
|
||||||
@@ -1276,11 +1277,11 @@ const Options = Module("options", {
|
|||||||
|
|
||||||
dactyl.assert(scope == "g:" || scope == null,
|
dactyl.assert(scope == "g:" || scope == null,
|
||||||
"E461: Illegal variable name: " + scope + name);
|
"E461: Illegal variable name: " + scope + name);
|
||||||
dactyl.assert(dactyl.globalVariables.hasOwnProperty(name) || (expr && !op),
|
dactyl.assert(globalVariables.hasOwnProperty(name) || (expr && !op),
|
||||||
"E121: Undefined variable: " + fullName);
|
"E121: Undefined variable: " + fullName);
|
||||||
|
|
||||||
if (!expr)
|
if (!expr)
|
||||||
dactyl.echo(fullName + "\t\t" + fmt(dactyl.globalVariables[name]));
|
dactyl.echo(fullName + "\t\t" + fmt(globalVariables[name]));
|
||||||
else {
|
else {
|
||||||
try {
|
try {
|
||||||
var newValue = dactyl.userEval(expr);
|
var newValue = dactyl.userEval(expr);
|
||||||
@@ -1291,7 +1292,7 @@ const Options = Module("options", {
|
|||||||
|
|
||||||
let value = newValue;
|
let value = newValue;
|
||||||
if (op) {
|
if (op) {
|
||||||
value = dactyl.globalVariables[name];
|
value = globalVariables[name];
|
||||||
if (op == "+")
|
if (op == "+")
|
||||||
value += newValue;
|
value += newValue;
|
||||||
else if (op == "-")
|
else if (op == "-")
|
||||||
@@ -1299,13 +1300,14 @@ const Options = Module("options", {
|
|||||||
else if (op == ".")
|
else if (op == ".")
|
||||||
value += String(newValue);
|
value += String(newValue);
|
||||||
}
|
}
|
||||||
dactyl.globalVariables[name] = value;
|
globalVariables[name] = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
dactyl.echoerr("E18: Unexpected characters in :let");
|
dactyl.echoerr("E18: Unexpected characters in :let");
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
deprecated: true,
|
||||||
literal: 0
|
literal: 0
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@@ -1386,7 +1388,8 @@ const Options = Module("options", {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
argCount: "+",
|
argCount: "+",
|
||||||
bang: true
|
bang: true,
|
||||||
|
deprecated: true
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
completion: function () {
|
completion: function () {
|
||||||
|
|||||||
@@ -140,6 +140,9 @@
|
|||||||
<spec>:let <a>var-name</a></spec>
|
<spec>:let <a>var-name</a></spec>
|
||||||
<spec>:let</spec>
|
<spec>:let</spec>
|
||||||
<description>
|
<description>
|
||||||
|
<deprecated>All scripts which make use of <ex>:let</ex> should be
|
||||||
|
updated to use the simpler and more powerful options system
|
||||||
|
instead.</deprecated>
|
||||||
<p>
|
<p>
|
||||||
Sets or lists a variable. Sets the variable <a>var-name</a> to the value of the
|
Sets or lists a variable. Sets the variable <a>var-name</a> to the value of the
|
||||||
expression <a>expr1</a>. If no expression is given, the value of the variable is
|
expression <a>expr1</a>. If no expression is given, the value of the variable is
|
||||||
@@ -153,6 +156,9 @@
|
|||||||
<tags>:unl :unlet</tags>
|
<tags>:unl :unlet</tags>
|
||||||
<spec>:unl<oa>et</oa><oa>!</oa> <a>name</a> …</spec>
|
<spec>:unl<oa>et</oa><oa>!</oa> <a>name</a> …</spec>
|
||||||
<description>
|
<description>
|
||||||
|
<deprecated>All scripts which make use of <ex>:let</ex> should be
|
||||||
|
updated to use the simpler and more powerful options system
|
||||||
|
instead.</deprecated>
|
||||||
<p>
|
<p>
|
||||||
Deletes the named variables. When <oa>!</oa> is given, no error
|
Deletes the named variables. When <oa>!</oa> is given, no error
|
||||||
message is output for non-existing variables.
|
message is output for non-existing variables.
|
||||||
|
|||||||
Reference in New Issue
Block a user