Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Invoke any command using ido in other window / split window, deciding after the fact instead of before
;; This makes ido-find-file-other-window,
;; ido-switch-buffer-other-window, et. al obsolete. It’s a much better
;; abstraction, and I believe it should become apart of ido mode,
;; because any command that uses ido-completing-read can benefit from
;; it without any additional effort, including textmate.el’s
;; textmate-goto-symbol.
(require 'ido)
(defun split-window-vertically-and-switch ()
(other-window 1))
(defun split-window-horizontally-and-switch ()
(other-window 1))
(defun ido-invoke-in-other-window ()
"signals ido mode to switch to (or create) another window after exiting"
(setq ido-exit-minibuffer-target-window 'other)
(defun ido-invoke-in-horizontal-split ()
"signals ido mode to split horizontally and switch after exiting"
(setq ido-exit-minibuffer-target-window 'horizontal)
(defun ido-invoke-in-vertical-split ()
"signals ido mode to split vertically and switch after exiting"
(setq ido-exit-minibuffer-target-window 'vertical)
(defun ido-invoke-in-new-frame ()
"signals ido mode to create a new frame after exiting"
(setq ido-exit-minibuffer-target-window 'frame)
(defadvice ido-read-internal (around ido-read-internal-with-minibuffer-other-window activate)
(let* (ido-exit-minibuffer-target-window
(this-buffer (current-buffer))
(result ad-do-it))
((equal ido-exit-minibuffer-target-window 'other)
(if (= 1 (count-windows))
(other-window 1)))
((equal ido-exit-minibuffer-target-window 'horizontal)
((equal ido-exit-minibuffer-target-window 'vertical)
((equal ido-exit-minibuffer-target-window 'frame)
(switch-to-buffer this-buffer) ;; why? Some ido commands, such as textmate.el's textmate-goto-symbol don't switch the current buffer
(defadvice ido-init-completion-maps (after ido-init-completion-maps-with-other-window-keys activate)
(mapcar (lambda (map)
(define-key map (kbd "C-o") 'ido-invoke-in-other-window)
(define-key map (kbd "C-2") 'ido-invoke-in-vertical-split)
(define-key map (kbd "C-3") 'ido-invoke-in-horizontal-split)
(define-key map (kbd "C-4") 'ido-invoke-in-other-window)
(define-key map (kbd "C-5") 'ido-invoke-in-new-frame))
(list ido-buffer-completion-map

Does this still work? Is it worth having its own repo and actually making it a package?

Would like to get it in MELPA

zakame commented Mar 16, 2016

@milkypostman it still works :) If @timcharper has no issues I can try posting it to MELPA 👍

zakame commented Mar 16, 2016

LOL I realized @timcharper already has it though I made my own (with just a minor change to make splitting to other-window smarter.) Still, the package is missing from MELPA (I don't recall it ever being there, unless git log lies...)

erreina commented Aug 30, 2016

I also would like to get it in MELPA. @timcharper or @zakame would post it any time soon?

zakame commented Oct 5, 2016

@erreina sure, I can try to make mine available. For the meantime, if you're on use-package with quelpa, you can do this:

(use-package ido-other-window
  :quelpa (ido-other-window :fetcher github :repo "zakame/ido-other-window"))

If @timcharper prefers, I can also post my changes as a PR to his repo, and prepare a MELPA recipe (pretty much like that quelpa quip above.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment