abo-abo / ace-window

Quickly switch windows in Emacs
977 stars 87 forks source link

How to ignore the minibuffer? #99

Closed thblt closed 7 years ago

thblt commented 7 years ago

Hi,

I can't find a way to have ace-window ignore the minibuffer. I've tried (setq aw-ignore-on t) (add-to-list aw-ignored-buffers "*Minibuf-1*)`, to no avail. I've even tried:

(setq aw-ignored-buffers (append aw-ignored-buffers
                                 (mapcar (lambda (n) (format "*Minibuf-%s*" n))
                                         (number-sequence 0 20))))

Am I missing something obvious?

Thanks!

abo-abo commented 7 years ago

The leading space in the name is important:

(setq aw-ignored-buffers '(" *Minibuf-1*"))

Also, I recommend against ignoring the minibuffer window - if you switch out of it, there's no way to switch back to dismiss it.

thblt commented 7 years ago

The leading space in the name is important:

Thank you, I didn't notice the space, everything works perfectly now.

Also, I recommend against ignoring the minibuffer window

I understand the recommandation, but (in case this is of any interest :) the reason I'm doing this is that I use ace-window as itself (bound to C-x o) but also as a kind of window-numbering emulation mode, where each window is bound to M-number and the minibuffer is always at M-0:

(defun thblt/aw-switch-to-numbered-window (number)
  (aw-switch-to-window (nth number (aw-window-list))))

(defun thblt/switch-to-minibuffer ()
  "Switch to minibuffer window."
  (interactive)
  (if (active-minibuffer-window)
      (select-window (active-minibuffer-window))
    (error "Minibuffer is not active")))

(general-define-key "C-x o" 'ace-window
                    ;; Emulate window-numbering
                    "M-0" 'thblt/switch-to-minibuffer
                    "M-1" (lambda () (interactive) (thblt/aw-switch-to-numbered-window 0))
                    "M-2" (lambda () (interactive) (thblt/aw-switch-to-numbered-window 1))
                    "M-3" (lambda () (interactive) (thblt/aw-switch-to-numbered-window 2))
                    (...))

Thanks again, I'm closing this!