- Subject: custom variable configuration ui
- From: "G. Milde" <g.milde@xxxxxx>
- Date: Fri, 17 Feb 2006 18:37:34 +0100
Dear Jed Users,
thinking about a user-friendly way to present the custom variables for the
upcoming dictmode for configuration, I came up with the mode below.
Give it a try, tell me what you think and stay patient, as I will be off
for one week of holiday.
Guenter
% configure.sl
%
% Copyright (c) 2006 Günter Milde
% Released under the terms of the GNU General Public License (ver. 2 or later)
%
% USAGE
%
% * Try it out: evaluate and do
% M-x configure_variables
% or
% M-x configure_init_file
%
% * Use as mode configuration interface
%
% autoload("configure_variables", "configure");
% % Define custom variables (all starting with "Foo_")
% public define foo_configure_custom_vars()
% {
% configure_variables("^Foo_");
% }
%
% NOTE
%
% In slang_mode, I have Alt-Return bound to evalbuffer().
%
% This tool would be even more handsome, if the slang mode menu contained
% an "&evaluate buffer" entry.
%
% VERSIONS
%
% 0.1 2006-02-15 proof of concept
_debug_info = 1;
implements("configure");
define variable_definition_line(var)
{
variable vref, value, help = "";
switch (is_defined(var))
{ case 1 or case 2: return "% " + var + " is a function"; }
{ case 0: return "% variable " + var + " = % (undefined)"; }
vref = __get_reference(var);
!if (__is_initialized(vref))
return "% variable " + var + " = % (uninitialized)";
value = @vref;
#ifexists sprint_variable
value = sprint_variable(value);
#endif
#ifexists help->extract_synopsis
help = help->extract_synopsis(help->help_for_object(var));
if (help != "")
help = " % " + help;
#endif
return sprintf("variable %s = %S;%s", var, value, help);
}
define variable_definition_lines(pattern)
{
variable vars = _apropos("Global", pattern, 0xC);
vars = array_map(String_Type, &variable_definition_line, vars);
return strjoin(vars, "\n");
}
public define configure_variables() % (pattern=NULL)
{
variable pattern;
if (_NARGS)
pattern = ();
else
pattern = read_mini("Configure variables matching regexp:", "", "");
variable result = variable_definition_lines(pattern);
if (result == "")
return vmessage("%% No matching variables for '%s'", pattern);
#ifexists popup_buffer
popup_buffer(sprintf("*configure %s*", pattern));
#else
sw2buf(sprintf("*configure %s*", pattern));
#endif
push_spot();
insert(result + "\n");
pop_spot();
vinsert("%% variables matching '%s'\n", pattern);
set_buffer_modified_flag(0);
set_buffer_undo(1);
slang_mode();
}
public define configure_init_file() % (pattern=NULL)
{
variable pattern;
if (_NARGS)
pattern = ();
else
pattern = read_mini("Configure variables matching regexp:", "", "");
variable init_file;
init_file = dircat (Jed_Home_Directory,
#ifdef UNIX
".jedrc"
#else
"jed.rc"
#endif
);
if (1 != file_status (init_file))
init_file = Default_Jedrc_Startup_File;
find_file(init_file);
eob;
newline();
push_mark();
vinsert("\nVariables matching '%s' (current values shown)\n", pattern);
insert(variable_definition_lines(pattern));
comment_region();
set_buffer_modified_flag(0);
}
--
Milde ife.et.tu-dresden.de
--------------------------
To unsubscribe send email to <jed-users-request@xxxxxxxxxxx> with
the word "unsubscribe" in the message body.
Need help? Email <jed-users-owner@xxxxxxxxxxx>.
[2006 date index]
[2006 thread index]
[Thread Prev] [Thread Next]
[Date Prev] [Date Next]