if (! MPLIST_SYMBOL_P (p))
continue;
name = MPLIST_SYMBOL (p);
- if (language == Mnil || name == Mnil)
- continue;
p = MPLIST_NEXT (p);
if (MPLIST_TAIL_P (p))
extra = Mnil;
else if (MPLIST_SYMBOL_P (p))
extra = MPLIST_SYMBOL (p);
- else
+ if (language == Mnil || (name == Mnil && extra == Mnil))
continue;
im_info = new_im_info (NULL, language, name, extra, im_custom_list);
load_im_info (im_data, im_info);
MPlist *global = NULL, *custom = NULL, *config = NULL;
MSymbol name;
MSymbol status;
- MPlist *description = NULL, *keyseq;
+ MPlist *description, *keyseq;
+
+ if (global_cmds && (global = mplist__assq (global_cmds, name)))
+ global = MPLIST_NEXT (MPLIST_PLIST (global));
name = MPLIST_SYMBOL (plist);
plist = MPLIST_NEXT (plist);
if (MPLIST_MTEXT_P (plist) || MPLIST_PLIST_P (plist))
- description = plist;
- else if (global_cmds && ((global = mplist__assq (global_cmds, name))))
- description = global = MPLIST_NEXT (MPLIST_PLIST (global));
- if (MPLIST_TAIL_P (plist))
{
- if (! global
- && global_cmds && ((global = mplist__assq (global_cmds, name))))
- global = MPLIST_NEXT (MPLIST_PLIST (global));
- if (global)
- {
- keyseq = MPLIST_NEXT (global);
- status = Minherited;
- }
- else
- {
- keyseq = plist;
- status = Mnil;
- }
+ description = plist;
+ plist = MPLIST_NEXT (plist);
}
else
{
- keyseq = MPLIST_NEXT (plist);
+ description = global;
+ if (! MPLIST_TAIL_P (plist))
+ plist = MPLIST_NEXT (plist);
+ }
+ if (MPLIST_TAIL_P (plist) && global)
+ {
+ keyseq = MPLIST_NEXT (global);
+ status = Minherited;
+ }
+ else
+ {
+ keyseq = plist;
status = Mnil;
}
if (config_cmds && (config = mplist__assq (config_cmds, name)))
{
+ status = Mconfigured;
config = MPLIST_NEXT (MPLIST_PLIST (config));
if (! MPLIST_TAIL_P (config))
- {
- keyseq = MPLIST_NEXT (config);
- status = Mconfigured;
- }
+ keyseq = MPLIST_NEXT (config);
}
else if (custom_cmds && (custom = mplist__assq (custom_cmds, name)))
{
custom = MPLIST_NEXT (MPLIST_PLIST (custom));
if (! MPLIST_TAIL_P (custom))
{
- keyseq = MPLIST_NEXT (custom);
status = Mcustomized;
+ keyseq = MPLIST_NEXT (custom);
}
}
if (config_vars && (config = mplist__assq (config_vars, name)))
{
+ status = Mconfigured;
config = MPLIST_NEXT (MPLIST_PLIST (config));
if (! MPLIST_TAIL_P (config))
{
value = MPLIST_NEXT (config);
if (MFAILP (check_variable_value (value, global ? global : plist)))
value = NULL;
- status = Mconfigured;
}
}
else if (custom_vars && (custom = mplist__assq (custom_vars, name)))
next = MPLIST_NEXT (next);
}
}
- M17N_OBJECT_UNREF (plist);
+ if (charset)
+ M17N_OBJECT_UNREF (plist);
plist = mplist ();
len = mtext_nchars (mt);
if (len <= column)
= (MIMExternalModule *) mplist_get (im_info->externals,
module);
if (external)
- func = (MIMExternalFunc) mplist_get (external->func_list,
- func_name);
+ func = ((MIMExternalFunc)
+ mplist_get_func (external->func_list, func_name));
}
if (! func)
continue;
{
MIMExternalModule *external = MPLIST_VAL (plist);
MIMExternalFunc func
- = (MIMExternalFunc) mplist_get (external->func_list, Minit);
+ = (MIMExternalFunc) mplist_get_func (external->func_list, Minit);
if (func)
(func) (func_args);
{
MIMExternalModule *external = MPLIST_VAL (plist);
MIMExternalFunc func
- = (MIMExternalFunc) mplist_get (external->func_list, Mfini);
+ = (MIMExternalFunc) mplist_get_func (external->func_list, Mfini);
if (func)
(func) (func_args);
minput_default_driver.filter = filter;
minput_default_driver.lookup = lookup;
minput_default_driver.callback_list = mplist ();
- mplist_put (minput_default_driver.callback_list, Minput_reset,
- (void *) reset_ic);
+ mplist_put_func (minput_default_driver.callback_list, Minput_reset,
+ M17N_FUNC (reset_ic));
minput_driver = &minput_default_driver;
fully_initialized = 0;
if (! cmds)
return NULL;
- plist = mplist_value (cmds); /* (NAME DESCRIPTION KEY-SEQ ...) */
- plist = mplist_next (plist); /* (DESCRIPTION KEY-SEQ ...) */
+ plist = mplist_value (cmds); /* (NAME DESCRIPTION STATUS KEY-SEQ ...) */
+ plist = mplist_next (plist); /* (DESCRIPTION STATUS KEY-SEQ ...) */
return (mplist_key (plist) == Mtext
? (MText *) mplist_value (plist)
: NULL);
If $KEYSEQLIST is a non-empty plist, it must be a list of key
sequences, and each key sequence must be a plist of symbols.
- If $KEYSEQLIST is an empty plist, the command becomes unusable.
+ If $KEYSEQLIST is an empty plist, the default key sequences of the
+ command for the input method is assigned to $COMMAND.
If $KEYSEQLIST is NULL, the configuration of the command for the
input method is canceled, and the default key sequences become
MPlist *cmd, *plist, *key_seq_list, *key_seq;
/* At first get the current key-sequence assignment. */
- cmd = mplist_get_command (Mt, unicode, start_command);
+ cmd = minput_get_command (Mt, unicode, start_command);
if (! cmd)
{
/* The input method does not have the command "start". Here
should come some error handling code. */
}
- /* Now CMD == ((start DESCRIPTION KEY-SEQUENCE ...) ...). Extract
- the part (KEY-SEQUENCE ...). */
- plist = mplist_next (mplist_next (mplist_value (cmd)));
+ /* Now CMD == ((start DESCRIPTION STATUS KEY-SEQUENCE ...) ...).
+ Extract the part (KEY-SEQUENCE ...). */
+ plist = mplist_next (mplist_next (mplist_next (mplist_value (cmd))));
/* Copy it because we should not modify it directly. */
key_seq_list = mplist_copy (plist);
- m17n_object_unref (cmds);
key_seq = mplist ();
mplist_add (key_seq, Msymbol, msymbol ("C-x"));
MINPUT__INIT ();
- if (keyseqlist)
- {
- if (command == Mnil)
- MERROR (MERROR_IM, -1);
- MPLIST_DO (plist, keyseqlist)
- if (! MPLIST_PLIST_P (plist)
- || ! check_command_keyseq (plist))
- MERROR (MERROR_IM, -1);
- }
-
im_info = get_im_info (language, name, Mnil, Mcommand);
if (! im_info)
MERROR (MERROR_IM, -1);
- if (command != Mnil
- && (! im_info->cmds
- || ! mplist__assq (im_info->cmds, command)))
+ if (command == Mnil ? (keyseqlist && ! MPLIST_TAIL_P (keyseqlist))
+ : (! im_info->cmds
+ || ! mplist__assq (im_info->configured_cmds, command)))
MERROR (MERROR_IM, -1);
+ if (keyseqlist && ! MPLIST_TAIL_P (keyseqlist))
+ {
+ MPLIST_DO (plist, keyseqlist)
+ if (! check_command_keyseq (plist))
+ MERROR (MERROR_IM, -1);
+ }
config = get_config_info (im_info);
if (! config)
config->vars = mplist ();
}
+ if (! keyseqlist && MPLIST_TAIL_P (config->cmds))
+ /* Nothing to do. */
+ return 0;
+
if (command == Mnil)
{
- MInputMethodInfo *custom = get_custom_info (im_info);
-
- mplist_set (config->cmds, Mnil, NULL);
- if (custom && custom->cmds)
+ if (! keyseqlist)
{
+ /* Cancal the configuration. */
+ if (MPLIST_TAIL_P (config->cmds))
+ return 0;
+ mplist_set (config->cmds, Mnil, NULL);
+ }
+ else
+ {
+ /* Cancal the customization. */
+ MInputMethodInfo *custom = get_custom_info (im_info);
+
+ if (MPLIST_TAIL_P (config->cmds)
+ && (! custom || ! custom->cmds || MPLIST_TAIL_P (custom->cmds)))
+ /* Nothing to do. */
+ return 0;
+ mplist_set (config->cmds, Mnil, NULL);
MPLIST_DO (plist, custom->cmds)
{
command = MPLIST_SYMBOL (MPLIST_PLIST (plist));
else
{
plist = mplist__assq (config->cmds, command);
- if (plist)
+ if (! keyseqlist)
{
- plist = MPLIST_PLIST (plist); /* (NAME [nil KEY-SEQUENCE ...]) */
- plist = MPLIST_NEXT (plist); /* ([nil ...]) */
- if (! MPLIST_TAIL_P (plist))
- mplist_set (plist, Mnil, NULL); /* () */
+ /* Cancel the configuration. */
+ if (! plist)
+ return 0;
+ mplist__pop_unref (plist);
}
- else
+ else if (MPLIST_TAIL_P (keyseqlist))
{
- plist = mplist ();
- mplist_add (config->cmds, Mplist, plist);
- M17N_OBJECT_UNREF (plist);
- plist = mplist_add (plist, Msymbol, command);
- plist = MPLIST_NEXT (plist);
+ /* Cancel the customization. */
+ MInputMethodInfo *custom = get_custom_info (im_info);
+ int no_custom = (! custom || ! custom->cmds
+ || ! mplist__assq (custom->cmds, command));
+ if (! plist)
+ {
+ if (no_custom)
+ return 0;
+ plist = mplist ();
+ mplist_add (config->cmds, Mplist, plist);
+ M17N_OBJECT_UNREF (plist);
+ plist = mplist_add (plist, Msymbol, command);
+ }
+ else
+ {
+ plist = MPLIST_PLIST (plist); /* (NAME nil KEYSEQ ...) */
+ plist = MPLIST_NEXT (plist);
+ if (MPLIST_TAIL_P (plist))
+ return 0;
+ mplist_set (plist, Mnil, NULL);
+ }
}
- if (keyseqlist)
+ else
{
MPlist *pl;
- plist = mplist_add (plist, Msymbol, Mnil);
+ if (plist)
+ {
+ plist = MPLIST_NEXT (MPLIST_PLIST (plist));
+ if (! MPLIST_TAIL_P (plist))
+ mplist_set (plist, Mnil, NULL);
+ }
+ else
+ {
+ plist = mplist ();
+ mplist_add (config->cmds, Mplist, plist);
+ M17N_OBJECT_UNREF (plist);
+ plist = mplist_add (plist, Msymbol, command);
+ plist = MPLIST_NEXT (plist);
+ }
MPLIST_DO (keyseqlist, keyseqlist)
{
pl = mplist_copy (MPLIST_VAL (keyseqlist));
$NAME.
If $VALUE is not NULL, it must be a plist of one element whose key
- is #Minteger, #Msymbol, or #Mtext, and the value is of the
- corresponding type.
+ is #Minteger, #Msymbol, or #Mtext, or an empty plist. In the
+ former case, the value must be of the corresponding type, and it
+ is assinged to $VARIABLE. In the latter case, the default value
+ for the input method is assigned to $VARIABLE.
If $VALUE is NULL, a configuration for the variable for the input
- method is canceled, and the variable is initialized to the default
- value. In that case, if $VARIABLE is #Mnil, configurations for
- all variables of the input method are canceled.
+ method is canceled, and the variable is initialized to the
+ original value (it may be what saved in per-user configuration
+ file, or the default value of the input method).
+
+ If $VALUE is an empty plist or NULL, $VARIABLE can be #Mnil. In
+ that case, it is applied to all the variables of the input method
+ are canceled.
If $NAME is #Mnil, this function configure the value of global
variable, not that of a specific input method.
im_info = get_im_info (language, name, Mnil, Mvariable);
if (! im_info)
MERROR (MERROR_IM, -1);
- if (variable == Mnil)
- {
- if (value)
- MERROR (MERROR_IM, -1);
- }
- else if (! im_info->vars
- || ! (plist = mplist__assq (im_info->configured_vars, variable)))
+ if (variable == Mnil ? (value && ! MPLIST_TAIL_P (value))
+ : (! im_info->vars
+ || ! (plist = mplist__assq (im_info->configured_vars, variable))))
MERROR (MERROR_IM, -1);
- if (variable != Mnil && value)
+ if (value && ! MPLIST_TAIL_P (value))
{
plist = MPLIST_PLIST (plist);
plist = MPLIST_NEXT (plist); /* (DESC STATUS VALUE VALIDS ...) */
config->vars = mplist ();
}
+ if (! value && MPLIST_TAIL_P (config->vars))
+ /* Nothing to do. */
+ return 0;
+
if (variable == Mnil)
{
- MInputMethodInfo *custom = get_custom_info (im_info);
-
- mplist_set (config->vars, Mnil, NULL);
- if (custom && custom->vars)
+ if (! value)
+ {
+ /* Cancel the configuration. */
+ if (MPLIST_TAIL_P (config->vars))
+ return 0;
+ mplist_set (config->vars, Mnil, NULL);
+ }
+ else
{
+ /* Cancel the customization. */
+ MInputMethodInfo *custom = get_custom_info (im_info);
+
+ if (MPLIST_TAIL_P (config->vars)
+ && (! custom || ! custom->vars || MPLIST_TAIL_P (custom->vars)))
+ /* Nothing to do. */
+ return 0;
+ mplist_set (config->vars, Mnil, NULL);
MPLIST_DO (plist, custom->vars)
{
variable = MPLIST_SYMBOL (MPLIST_PLIST (plist));
else
{
plist = mplist__assq (config->vars, variable);
- if (plist)
+ if (! value)
{
- plist = MPLIST_PLIST (plist); /* (NAME nil VALUE) */
- plist = MPLIST_NEXT (plist); /* ([nil VALUE]) */
- if (! MPLIST_TAIL_P (plist))
- mplist_set (plist, Mnil ,NULL); /* () */
+ /* Cancel the configuration. */
+ if (! plist)
+ return 0;
+ mplist__pop_unref (plist);
}
- else
+ else if (MPLIST_TAIL_P (value))
{
- plist = mplist ();
- mplist_add (config->vars, Mplist, plist);
- M17N_OBJECT_UNREF (plist);
- plist = mplist_add (plist, Msymbol, variable);
- plist = MPLIST_NEXT (plist);
+ /* Cancel the customization. */
+ MInputMethodInfo *custom = get_custom_info (im_info);
+ int no_custom = (! custom || ! custom->vars
+ || ! mplist__assq (custom->vars, variable));
+ if (! plist)
+ {
+ if (no_custom)
+ return 0;
+ plist = mplist ();
+ mplist_add (config->vars, Mplist, plist);
+ M17N_OBJECT_UNREF (plist);
+ plist = mplist_add (plist, Msymbol, variable);
+ }
+ else
+ {
+ plist = MPLIST_PLIST (plist); /* (NAME nil VALUE) */
+ plist = MPLIST_NEXT (plist); /* ([nil VALUE]) */
+ if (! MPLIST_TAIL_P (plist))
+ return 0;
+ mplist_set (plist, Mnil ,NULL);
+ }
}
- if (value)
+ else
{
- plist = mplist_add (plist, Msymbol, Mnil);
+ if (plist)
+ {
+ plist = MPLIST_NEXT (MPLIST_PLIST (plist));
+ if (! MPLIST_TAIL_P (plist))
+ mplist_set (plist, Mnil, NULL);
+ }
+ else
+ {
+ plist = mplist ();
+ mplist_add (config->vars, Mplist, plist);
+ M17N_OBJECT_UNREF (plist);
+ plist = mplist_add (plist, Msymbol, variable);
+ plist = MPLIST_NEXT (plist);
+ }
mplist_add (plist, MPLIST_KEY (value), MPLIST_VAL (value));
}
}
update_custom_info ();
if (! im_custom_list)
im_custom_list = mplist ();
- data = tail = mplist ();
+ /* At first, reflect configuration in customization. */
MPLIST_DO (plist, im_config_list)
{
MPlist *pl = MPLIST_PLIST (plist);
if (MPLIST_TAIL_P (elt))
{
if (p)
- mplist__pop_unref (p);
+ {
+ /* Make customization ignored. */
+ p = MPLIST_NEXT (MPLIST_PLIST (p));
+ mplist_set (p, Mnil, NULL);
+ }
}
else
{
}
M17N_OBJECT_UNREF (im_config_list);
+ /* Next, reflect customization to the actual plist to be written. */
+ data = tail = mplist ();
MPLIST_DO (plist, im_custom_list)
{
MPlist *pl = MPLIST_PLIST (plist);
extra = MPLIST_SYMBOL (pl);
pl = MPLIST_NEXT (pl);
custom = MPLIST_VAL (pl);
+ if ((! custom->cmds || MPLIST_TAIL_P (custom->cmds))
+ && (! custom->vars || MPLIST_TAIL_P (custom->vars)))
+ continue;
im_info = lookup_im_info (im_info_list, language, name, extra);
if (im_info)
{
config_all_variables (im_info);
}
- elt = mplist ();
- tail = mplist_add (tail, Mplist, elt);
- M17N_OBJECT_UNREF (elt);
- pl = mplist ();
- elt = mplist_add (elt, Mplist, pl);
- M17N_OBJECT_UNREF (pl);
- pl = mplist_add (pl, Msymbol, Minput_method);
- pl = mplist_add (pl, Msymbol, language);
- pl = mplist_add (pl, Msymbol, name);
- if (extra != Mnil)
- pl = mplist_add (pl, Msymbol, extra);
+ elt = NULL;
if (custom->cmds && ! MPLIST_TAIL_P (custom->cmds))
{
- pl = mplist ();
- elt = mplist_add (elt, Mplist, pl);
- M17N_OBJECT_UNREF (pl);
- pl = mplist_add (pl, Msymbol, Mcommand);
MPLIST_DO (p, custom->cmds)
- pl = mplist_add (pl, Mplist, MPLIST_PLIST (p));
+ if (! MPLIST_TAIL_P (MPLIST_NEXT (MPLIST_PLIST (p))))
+ break;
+ if (! MPLIST_TAIL_P (p))
+ {
+ elt = mplist ();
+ pl = mplist ();
+ mplist_add (elt, Mplist, pl);
+ M17N_OBJECT_UNREF (pl);
+ pl = mplist_add (pl, Msymbol, Mcommand);
+ MPLIST_DO (p, custom->cmds)
+ if (! MPLIST_TAIL_P (MPLIST_NEXT (MPLIST_PLIST (p))))
+ pl = mplist_add (pl, Mplist, MPLIST_PLIST (p));
+ }
}
if (custom->vars && ! MPLIST_TAIL_P (custom->vars))
{
+ MPLIST_DO (p, custom->vars)
+ if (! MPLIST_TAIL_P (MPLIST_NEXT (MPLIST_PLIST (p))))
+ break;
+ if (! MPLIST_TAIL_P (p))
+ {
+ if (! elt)
+ elt = mplist ();
+ pl = mplist ();
+ mplist_add (elt, Mplist, pl);
+ M17N_OBJECT_UNREF (pl);
+ pl = mplist_add (pl, Msymbol, Mvariable);
+ MPLIST_DO (p, custom->vars)
+ if (! MPLIST_TAIL_P (MPLIST_NEXT (MPLIST_PLIST (p))))
+ pl = mplist_add (pl, Mplist, MPLIST_PLIST (p));
+ }
+ }
+ if (elt)
+ {
pl = mplist ();
- elt = mplist_add (elt, Mplist, pl);
+ mplist_push (elt, Mplist, pl);
M17N_OBJECT_UNREF (pl);
- pl = mplist_add (pl, Msymbol, Mvariable);
- MPLIST_DO (p, custom->vars)
- pl = mplist_add (pl, Mplist, MPLIST_PLIST (p));
+ pl = mplist_add (pl, Msymbol, Minput_method);
+ pl = mplist_add (pl, Msymbol, language);
+ pl = mplist_add (pl, Msymbol, name);
+ if (extra != Mnil)
+ pl = mplist_add (pl, Msymbol, extra);
+ tail = mplist_add (tail, Mplist, elt);
+ M17N_OBJECT_UNREF (elt);
}
}
if (! ic->im->driver.callback_list)
return -1;
- func = (MInputCallbackFunc) mplist_get (ic->im->driver.callback_list,
- command);
+ func = ((MInputCallbackFunc)
+ mplist_get_func (ic->im->driver.callback_list, command));
if (! func)
return -1;
(func) (ic, command);