Subject: Re: bug#52245: Wishlist: cycle input methods

From: André A. Gomes <[email-masked]>
Date: Sat, 11 Dec 2021 20:07:55 +0000

John Ankarström <[email-masked]> writes:

> Eli Zaretskii <[email-masked]> writes:
>
>> The use case that I have in mind is this: even if the user customized
>> the list of input methods to include more than just one, there could
>> be situations where the user needs to use just one input method when
>> typing.  In such situations, it would be good to have a way of
>> toggling, like we do now, instead of cycling through all the other
>> methods.
>>
>> Any reasonable solution to this use case would be welcome.  I'm
>> working with systems which allow you to do something like that, and it
>> frequently annoys me to have to cycle through all the keyboard layouts
>> I defined, just to be able to toggle between US English and some other
>> language.  So I wish that Emacs didn't have such an annoying problem,
>> if possible.
>
> IIRC Windows 10 handles this by implementing the input method list as a
> stack of sorts, so that Win-Space selects an input method similarly to
> how Alt-Tab selects a window. Pressing Win-Space once is a toggle, but
> pressing Win-Space consecutively (while holding Win) cycles through all
> input methods.
>
> Emacs could do something similar. A single C-\ could toggle between the
> two input methods at the top of the list, whereas any number of
> consecutive C-\'s could cycle the list. The implementation would just
> need to check last-command.

Could be a possibility indeed.

Let me raise a concern on this topic.  In Emacs, nil is what we call the
default OS-level IM (or the one dictated by the keyboard firmware).  But
this presents an issue since it both means "the nil input method", which
in itself might be english-us, and that `default-input-method' is
unbound.

I propose thinking about what we have today (no IM cycling, just the
toggle) and see if we need changes before moving on with the more
general case.

Let's think about a simple case - using 2 IMs.  Today you can't easily
go from input method A to B with C-\, unless either A or B is nil.  This
is because `default-input-method' is a buffer-local variable, and it
changes as the user selects IMs.

I suggest that `default-input-method' should be set to "default" and
shouldn't be mutated.  When already in use, fallback to the IM history
ring.  Yes, this requires some re-writing.

--
André A. Gomes
"Free Thought, Free World"