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

(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 :slight_smile:

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:

(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 :frowning:

1 Like

Thank you, that works nice :slight_smile: 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?

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

(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]

1 Like

Thank you, ashraz, really appreciate your help.