mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-20 06:07: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) {
|
||||
io.withSavedValues(["readHeredoc"], function () {
|
||||
this.readHeredoc = commandline.readHeredoc;
|
||||
contexts.withSavedValues(["context"], function () {
|
||||
this.context = { file: "[Command Line]", line: 1 };
|
||||
contexts.withContext({ file: "[Command Line]", line: 1 },
|
||||
function () {
|
||||
io.withSavedValues(["readHeredoc"], function () {
|
||||
this.readHeredoc = commandline.readHeredoc;
|
||||
commands.repeat = command;
|
||||
dactyl.execute(command);
|
||||
});
|
||||
|
||||
@@ -635,10 +635,8 @@ var Commands = Module("commands", {
|
||||
* command string.
|
||||
*/
|
||||
execute: function (string, tokens, silent, args, context) {
|
||||
contexts.withSavedValues(["context"], function () {
|
||||
context = update({}, context || this.context || { file: "[Command Line]", line: 1 });
|
||||
this.context = context;
|
||||
|
||||
contexts.withContext(context || this.context || { file: "[Command Line]", line: 1 },
|
||||
function (context) {
|
||||
io.withSavedValues(["readHeredoc"], function () {
|
||||
this.readHeredoc = function (end) {
|
||||
let res = [];
|
||||
|
||||
@@ -270,7 +270,13 @@ var Contexts = Module("contexts", {
|
||||
get default() (contexts.context && contexts.context.group || contexts.user)[name],
|
||||
|
||||
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) {
|
||||
function Const(val) Class.Property({ enumerable: true, value: val });
|
||||
|
||||
@@ -90,8 +90,6 @@ var MOW = Module("mow", {
|
||||
* @param {string} highlightGroup
|
||||
*/
|
||||
echo: function echo(data, highlightGroup, silent) {
|
||||
this.document;
|
||||
util.dump(String(this.widget), String(this.window), String(this.document));
|
||||
let body = this.document.body;
|
||||
|
||||
this.widgets.message = null;
|
||||
|
||||
@@ -150,8 +150,7 @@ var IO = Module("io", {
|
||||
params = params || {};
|
||||
|
||||
let time = Date.now();
|
||||
return contexts.withSavedValues(["context"], function _source() {
|
||||
contexts.context = null;
|
||||
return contexts.withContext(null, function () {
|
||||
try {
|
||||
var file = util.getFile(filename) || io.File(filename);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user