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 define_keywords("$doc");
11 function define_global_mode (name, enable, disable) {
12 keywords(arguments, $doc = null);
13 var hyphen_name = name.replace(/_/g,"-");
14 var state = name + "_enabled";
16 var enable_hook_name = hyphen_name + "-enable-hook";
17 var disable_hook_name = hyphen_name + "-disable-hook";
18 define_hook(enable_hook_name);
19 define_hook(disable_hook_name);
20 var func = function (arg) {
21 var curstate = conkeror[state];
22 var newstate = (arg == null) ? !curstate : (arg > 0);
23 if (curstate == newstate)
25 conkeror[state] = newstate;
28 conkeror[enable_hook_name].run();
31 conkeror[disable_hook_name].run();
35 interactive(hyphen_name, arguments.$doc, function (I) {
37 func(arg && univ_arg_to_number(arg));
38 I.minibuffer.message(hyphen_name + (conkeror[state] ? " enabled" : " disabled"));
41 ignore_function_for_get_caller_source_code_reference("define_global_mode");