minput_config_command(3m17n)

πŸ“¦
version 1.8.4 Β· 2 versions
, in debian trixie, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– 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 keyseqlist is 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 keyseqlist is 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 keyseqlist is NULL, 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 returns 0, otherwise returns -1. the operation fails in these cases: - keyseqlist is not in a valid form. - command is not available for the input method. - language and name do 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 (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