# Toggle-input-method

**URL:** <https://forum.systemcrafters.net/t/toggle-input-method/184>\
**Category:** Emacs\
**Created:** [February 3, 2024, 5:14pm UTC](https://forum.systemcrafters.net/t/toggle-input-method/184 "2024-02-03T17:14:33Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![milen](https://avatars.discourse-cdn.com/v4/letter/m/4bbf92/32.png) [@milen](https://forum.systemcrafters.net/u/milen)\
**Post date:** [February 3, 2024, 5:14pm UTC](https://forum.systemcrafters.net/t/toggle-input-method/184/1 "2024-02-03T17:14:33Z")

</div>

I’m relatively new to Emacs, I’ve been using it to a year now, manly for python/css/html. Just recently after Prot’s video about language input change I decided to use toggle-inpu-method, so I set it to

```auto
(keymap-global-set "M-o" 'toggle-input-method)

```

to switch between English and Bulgarian layouts.

However this doesn’t work in search (ivy/swiper) i.e. the changed lang input is not effective there (in the search field). My question is how to make the toggled layout work in, I guess, mini buffer?

Apologies for not speaking in exact Emacs jargon, I’m still learning 🙂

---

<div class="post-metadata">

**Author:** ![ashraz](https://yyz1.discourse-cdn.com/flex029/user_avatar/forum.systemcrafters.net/ashraz/32/509_2.png) [@ashraz](https://forum.systemcrafters.net/u/ashraz)\
**Post date:** [February 3, 2024, 5:25pm UTC](https://forum.systemcrafters.net/t/toggle-input-method/184/2 "2024-02-03T17:25:42Z")

</div>

> [@milen](#):
>
> ```lisp
> (keymap-global-set "M-o" 'toggle-input-method)
> 
> ```
> 
> …
> 
> However this doesn’t work in search (ivy/swiper) i.e. the changed lang input is not effective there (in the search field). My question is how to make the toggled layout work in, I guess, mini buffer?

The first check here is usually to use `C-h k` in the same situation, e.g., `M-x C-h k M-o`. This will tell you that `M-o` is suddenly bound to another action, namely `ivy-dispatching-done`. Why? Because `ivy-mode` uses another keymap while you’re in the minibuffer.

You can check the current bindings via `C-h b` (`describe-bindings`), so in this case: `M-x C-h b`. This will show that the `minibuffer-map` contains `M-o`. The actual map in action is the `ivy-minibuffer-map`.

To add the behavior to `ivy` too, you would have to use:

```lisp
(keymap-set ivy-minibuffer-map "M-o" #'toggle-input-method)

```

Note that the same might hold for `swiper`, I’m not sure about that, as I’m a happy `vertico`+`consult` user and haven’t used Ivy and its ecosystem for quite some time ☹

---

<div class="post-metadata">

**Author:** ![milen](https://avatars.discourse-cdn.com/v4/letter/m/4bbf92/32.png) [@milen](https://forum.systemcrafters.net/u/milen)\
**Post date:** [February 3, 2024, 8:15pm UTC](https://forum.systemcrafters.net/t/toggle-input-method/184/3 "2024-02-03T20:15:41Z")

</div>

Thank you, that works nice 🙂 Not sure how layout states are preserved (or not) but if I have the second layout switched for the main buffer and go to mini buffer (ivy), the layout state which I’m currently in is not transferred (preserved) for the mini buffer. Is this by design?

---

<div class="post-metadata">

**Author:** ![ashraz](https://yyz1.discourse-cdn.com/flex029/user_avatar/forum.systemcrafters.net/ashraz/32/509_2.png) [@ashraz](https://forum.systemcrafters.net/u/ashraz)\
**Post date:** [February 3, 2024, 9:34pm UTC](https://forum.systemcrafters.net/t/toggle-input-method/184/4 "2024-02-03T21:34:05Z")

</div>

> [@milen](#):
>
> the layout state which I’m currently in is not transferred (preserved) for the mini buffer. Is this by design?

Yes. `toggle-input-method` is only enabled for the current buffer:

> ```lisp
> (toggle-input-method &optional ARG INTERACTIVE)
> 
> ```
> 
> Enable or disable multilingual text input method _ **for the current buffer.** _  
> Only one input method can be enabled at any time in a given buffer.
> 
> [taken from M-x describe-function RET toggle-input-method RET, emphasis mine]

---

<div class="post-metadata">

**Author:** ![milen](https://avatars.discourse-cdn.com/v4/letter/m/4bbf92/32.png) [@milen](https://forum.systemcrafters.net/u/milen)\
**Post date:** [February 4, 2024, 10:31am UTC](https://forum.systemcrafters.net/t/toggle-input-method/184/5 "2024-02-04T10:31:58Z")

</div>

Thank you, ashraz, really appreciate your help.
