Jeeves
Jeeves

Reputation: 199

how to make emacs ido not rotate the whole list of options?

In emacs ido options, the currently selected option is always shown first in the list. When we change e.g. by arrow keys, or C-s / C-r : the whole list is rotated instead of currently selected option moving anywhere. This is very disconcerting for me. To illustrate , assume A, B, C and D are buffers are we are running ido-switch-buffer

  1. Current behaviour

    *A* B C D

Press C-s

*B* C D A

Again press C-s

*C* D A B

  1. What I want is

*A* B C D

Press C-s

A *B* C D

Again press C-s

A B *C* D

I tried setting both "ido-rotate" , and "ido-rotate-file-list-default" to nil as well as t, one by one, but nothing changes in this regard. I don't see any other option in customize-group for ido either. How can I make the selected option move instead of the whole list rotating ?

This is for emacs 26.1, built-in ido.

Edit : With the regular ido mode, I could override the next, previous key-bindings in the following manner :

(define-key ido-buffer-completion-map (kbd "M-)") 'ido-next-match)

With ido-grid-mode, all my attempts to do so are failing. It seems to insist on the hard-coded sets of keys to find next option / previous option. This is also not working :

(define-key ido-completion-map (kbd "M-)") 'ido-next-match)

Any hints I could make ido-grid-mode let me override keys ?

Upvotes: 3

Views: 145

Answers (1)

Jeeves
Jeeves

Reputation: 199

Ok, found the answer. The package ido-grid-mode is indeed what i need, thanks @jpkotta. There is a trick to getting my keybinding work with it.

(defun ido-my-keys ()
"Add my keybindings for Ido."
(define-key ido-completion-map (kbd "M-)") 'ido-next-match)
(define-key ido-completion-map (kbd "M-)") 'ido-prev-match)
)
(ido-grid-mode t)
(add-hook 'ido-setup-hook 'ido-my-keys)

That is to say - ido-grid-mode has to be started before setup hook is added for key bindings. I was doing it after, or completely outside the setup hook, which was not working.

EDIT : Forgot to mention, there is another trick. Hack the ido-grid-mode itself. Make the following change in ido-grid-mode.el :

  ;; ('C-s     (define-key ido-completion-map (kbd "C-s")       #'ido-grid-mode-next))                                                                                                                         
  ;; ('C-r     (define-key ido-completion-map (kbd "C-r")       #'ido-grid-mode-previous))                                                                                                                     
  ('C-s     (define-key ido-completion-map (kbd "M-)")       #'ido-grid-mode-next))                                                                                                                            
  ('C-r     (define-key ido-completion-map (kbd "M-(")       #'ido-grid-mode-previous))                                                                                                                        

Upvotes: 0

Related Questions