mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-20 08:27:59 +01:00
Add contexts.withContext.
--HG-- branch : groups
This commit is contained in:
@@ -424,10 +424,10 @@ var CommandExMode = Class("CommandExMode", CommandMode, {
|
|||||||
},
|
},
|
||||||
|
|
||||||
onSubmit: function onSubmit(command) {
|
onSubmit: function onSubmit(command) {
|
||||||
io.withSavedValues(["readHeredoc"], function () {
|
contexts.withContext({ file: "[Command Line]", line: 1 },
|
||||||
this.readHeredoc = commandline.readHeredoc;
|
function () {
|
||||||
contexts.withSavedValues(["context"], function () {
|
io.withSavedValues(["readHeredoc"], function () {
|
||||||
this.context = { file: "[Command Line]", line: 1 };
|
this.readHeredoc = commandline.readHeredoc;
|
||||||
commands.repeat = command;
|
commands.repeat = command;
|
||||||
dactyl.execute(command);
|
dactyl.execute(command);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -635,10 +635,8 @@ var Commands = Module("commands", {
|
|||||||
* command string.
|
* command string.
|
||||||
*/
|
*/
|
||||||
execute: function (string, tokens, silent, args, context) {
|
execute: function (string, tokens, silent, args, context) {
|
||||||
contexts.withSavedValues(["context"], function () {
|
contexts.withContext(context || this.context || { file: "[Command Line]", line: 1 },
|
||||||
context = update({}, context || this.context || { file: "[Command Line]", line: 1 });
|
function (context) {
|
||||||
this.context = context;
|
|
||||||
|
|
||||||
io.withSavedValues(["readHeredoc"], function () {
|
io.withSavedValues(["readHeredoc"], function () {
|
||||||
this.readHeredoc = function (end) {
|
this.readHeredoc = function (end) {
|
||||||
let res = [];
|
let res = [];
|
||||||
|
|||||||
@@ -270,7 +270,13 @@ var Contexts = Module("contexts", {
|
|||||||
get default() (contexts.context && contexts.context.group || contexts.user)[name],
|
get default() (contexts.context && contexts.context.group || contexts.user)[name],
|
||||||
|
|
||||||
completer: function (context) completion.group(context)
|
completer: function (context) completion.group(context)
|
||||||
})
|
}),
|
||||||
|
|
||||||
|
withContext: function withContext(defaults, callback, self)
|
||||||
|
this.withSavedValues(["context"], function () {
|
||||||
|
this.context = defaults && update({}, defaults);
|
||||||
|
return callback.call(self, this.context);
|
||||||
|
})
|
||||||
}, {
|
}, {
|
||||||
Context: modules.Script = function Context(file, group, args) {
|
Context: modules.Script = function Context(file, group, args) {
|
||||||
function Const(val) Class.Property({ enumerable: true, value: val });
|
function Const(val) Class.Property({ enumerable: true, value: val });
|
||||||
|
|||||||
@@ -90,8 +90,6 @@ var MOW = Module("mow", {
|
|||||||
* @param {string} highlightGroup
|
* @param {string} highlightGroup
|
||||||
*/
|
*/
|
||||||
echo: function echo(data, highlightGroup, silent) {
|
echo: function echo(data, highlightGroup, silent) {
|
||||||
this.document;
|
|
||||||
util.dump(String(this.widget), String(this.window), String(this.document));
|
|
||||||
let body = this.document.body;
|
let body = this.document.body;
|
||||||
|
|
||||||
this.widgets.message = null;
|
this.widgets.message = null;
|
||||||
|
|||||||
@@ -150,8 +150,7 @@ var IO = Module("io", {
|
|||||||
params = params || {};
|
params = params || {};
|
||||||
|
|
||||||
let time = Date.now();
|
let time = Date.now();
|
||||||
return contexts.withSavedValues(["context"], function _source() {
|
return contexts.withContext(null, function () {
|
||||||
contexts.context = null;
|
|
||||||
try {
|
try {
|
||||||
var file = util.getFile(filename) || io.File(filename);
|
var file = util.getFile(filename) || io.File(filename);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user