Sometimes I open ido-find-file
or ido-switch-buffer
but when I find the file I want to open, I realize I want to open it in other-window
. I have key bindings for ido-find-file-other-window
and others, but I would like the option to open the selected ido candidate in other-window
as a persistent option in ido-completion-map
(bound to s-<return>
). Is this possible?
Asked
Active
Viewed 183 times
2

waymondo
- 1,384
- 11
- 16
-
You can probably make your own command using ido-read-file-name. Similar to the updated answer here: http://emacs.stackexchange.com/a/9450/780 – glucas Feb 28 '15 at 02:19
1 Answers
2
I finally figured out a pattern that worked by advising ido-read-internal
with an empty dynamic variable that would get set with a custom command bound to ido-common-completion-map
.
I published the idea as a package called ido-exit-target
, but here's the pattern that solves my question:
(eval-when-compile
(defvar ido-exit-target--target))
(defun ido-exit-target-other-window ()
"Select the current `ido' item for `other-window'. It will create one if it doesn't exist."
(interactive)
(setq ido-exit-target--target 'other-window)
(ido-exit-minibuffer))
(defun ido-exit-target--switch-to-target (orig-fun &rest args)
"Advise `ido-read-internal' on where to view the chosen selection."
(let* (ido-exit-target--target
(res (apply orig-fun args)))
(when (equal ido-exit-target--target 'other-window)
(switch-to-buffer-other-window nil))
res))
(advice-add 'ido-read-internal :around #'ido-exit-target--switch-to-target)
(define-key ido-common-completion-map (kbd "<s-return>") #'ido-exit-target-other-window)

waymondo
- 1,384
- 11
- 16