Skip to content

Instantly share code, notes, and snippets.

@glucas
Last active August 29, 2015 14:15
Show Gist options
  • Save glucas/09aea018251cf85c7290 to your computer and use it in GitHub Desktop.
Save glucas/09aea018251cf85c7290 to your computer and use it in GitHub Desktop.
ace-command-other-window
(defun ace-command-other-window (cmd &optional one-win-cmd)
"Execute CMD in another window.
If provided, call ONE-WIN-CMD instead when there is only one window."
(interactive "CM-x (other window) ")
(catch 'done
(when (and one-win-cmd
(not (window-parent)))
(call-interactively one-win-cmd)
(throw 'done t))
(let ((start-window (selected-window))
(dir default-directory))
(unwind-protect
(progn
(aw-switch-to-window
(aw-select " Ace - Command "))
(let ((default-directory dir))
(call-interactively cmd)))
(aw-switch-to-window start-window)))))
(defun ace-find-file ()
"Find a file in another window."
(interactive)
(ace-command-other-window #'ido-find-file
#'ido-find-file-other-window))
(defun ace-switch-buffer ()
"Switch buffers in another window."
(interactive)
(ace-command-other-window #'ido-switch-buffer
#'ido-switch-buffer-other-window))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment