2 * (C) Copyright 2007-2008 Jeremy Maitin-Shepard
4 * Use, modification, and distribution are subject to the terms specified in the
8 require("interactive.js");
10 function define_global_mode (name, enable, disable) {
11 var hyphen_name = name.replace("_","-","g");
12 var state = name + "_enabled";
14 var enable_hook_name = hyphen_name + "-enable-hook";
15 var disable_hook_name = hyphen_name + "-disable-hook";
16 define_hook(enable_hook_name);
17 define_hook(disable_hook_name);
18 var func = function (arg) {
19 var curstate = conkeror[state];
20 var newstate = (arg == null) ? !curstate : (arg > 0);
21 if (curstate == newstate)
23 conkeror[state] = newstate;
26 conkeror[enable_hook_name].run();
29 conkeror[disable_hook_name].run();
33 interactive(hyphen_name, null, function (I) {
35 func(arg && univ_arg_to_number(arg));
36 I.minibuffer.message(hyphen_name + (conkeror[state] ? " enabled" : " disabled"));
39 ignore_function_for_get_caller_source_code_reference("define_global_mode");