minput_config_command(3m17n)
π minput_config_command π
okay bestie, welcome to the m17n manual, page minput_config_command(3m17n) β yes it's a mouthful, no we're not changing it, it's iconic. this is the function that lets you reassign key sequences to an input method command, and honestly? it's giving main character energy. π
β¨ SYNOPSIS β¨
int minput_config_command (MSymbol language, MSymbol name, MSymbol
command, MPlist * keyseqlist)
πΈ DESCRIPTION πΈ
so like, the whole vibe of this function, per the original: it's "Configure the key sequence of an input method command." periodt. π
minput_config_command() assigns a list of key sequences keyseqlist to the command command of the input method specified by language and name. that's the tea. π«
here's the part where you gotta pay attention tho, because there are three different flavours of keyseqlist and they all do different things:
- if
keyseqlistis a non-empty plist, it has to be a list of key sequences, and every single key sequence in there must be a plist of symbols. no exceptions, bestie. β¨ - if
keyseqlistis an empty plist, then any configuration and customization of the command gets cancelled, and the default key sequences become effective. it's a reset. a clean slate. we love a fresh start. π¦ - if
keyseqlistisNULL, the configuration of the command is canceled, and the original key sequences become effective β that's whatever was saved in the per-user customization file, or the default one. π
and in those latter two cases (empty plist and NULL), command can be #Mnil to make all the commands of the input method the target of the operation. like, all of them. go off. π
also: if name is #Mnil, this function configures the key assignment of a global command, not that of a specific input method. global. worldwide. no cap. π
now here's the timing thing β the configuration takes effect for input methods opened or re-opened later in the current session. so if you were hoping it'd retroactively fix the input method you already have open, no π. and in order to make the configuration take effect for the future session, it must be saved in a per-user customization file by the function minput_save_config(). don't forget that part or it's gone forever, and not in a cute way. π
@par Return value: if the operation was successful, this function returns0, otherwise returns-1. the operation fails in these cases: -keyseqlistis not in a valid form. -commandis not available for the input method. -languageandnamedo not specify an existing input method.
@par See Also:minput_get_commands(),minput_save_config().
π§ Example π§
ok this is the good part, a whole little code snack. adding "C-x u" to the "start" command of the Unicode input method:
/* Add "C-x u" to the "start" command of Unicode input method. */
{
MSymbol start_command = msymbol ("start");
MSymbol unicode = msymbol ("unicode");
MPlist *cmd, *plist, *key_seq_list, *key_seq;
/* At first get the current key-sequence assignment. */
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 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);
key_seq = mplist();
mplist_add (key_seq, Msymbol, msymbol ("C-x"));
mplist_add (key_seq, Msymbol, msymbol ("u"));
mplist_add (key_seq_list, Mplist, key_seq);
m17n_object_unref (key_seq);
minput_config_command (Mt, unicode, start_command, key_seq_list);
m17n_object_unref (key_seq_list);
}
like, look at that. extract, copy, build, assign, unref. chef's kiss. π₯
π COPYRIGHT π
Copyright (C) 2001 Information-technology Promotion Agency (IPA)
Copyright (C) 2001-2011 National Institute of Advanced Industrial Science and Technology (AIST)
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License <http://www.gnu.org/licenses/fdl.html>.
and that's the whole page bestie!! Version 1.8.4, dated Mon Sep 25 2023, from the minput_config_command(3m17n) crew. go configure something cute, ily, bye πβ¨π
π¦ where this page comes from
- debian trixie: m17n-docs 1.8.4-1
- ubuntu noble: m17n-docs 1.8.4-1
- ubuntu questing: m17n-docs 1.8.4-1
- ubuntu resolute: m17n-docs 1.8.4-1build1
- ubuntu stonking: m17n-docs 1.8.4-1build1
- Copyright (C) 2001 Information-technology Promotion Agency (IPA)
- Copyright (C) 2001-2011 National Institute of Advanced Industrial Science and Technology (AIST)
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms