abo-abo / ace-window

Quickly switch windows in Emacs
970 stars 86 forks source link

ace-window gives `which-key` window a number, and can't be get rid of. #182

Open AmaiKinono opened 5 years ago

AmaiKinono commented 5 years ago

This is a somewhat long question, so please be patient. Use emacs -Q, and do this (I omitted the load-path configuration):

(require 'avy)
(require 'ace-window)
(ace-window-display-mode 1)

(require 'which-key)
(which-key-mode)

Split the window, so window number 1 and 2 are shown in their modelines. Press C-x. When which-key buffer show up, the number becomes 1 and 3:

image

Actually I can tell the which-key window gets number 2, since I did a little hack in my configuration to have window-number shown in the header line:

image

But actually you still have to switch to that other window using number 2. I can tell this since I have a little function to help me switch window:

(defun toki/aw-select-window (win-id)
  "Use `ace-window' to select the window by using window index.
WIN-ID : Window index."
  (let ((wnd (nth (- win-id 1) (aw-window-list))))
    (if wnd
    (aw-switch-to-window wnd)
      (message "No such window."))))

(defun toki-select-window ()
  (interactive)
  (let* ((event last-input-event)
     (key (make-vector 1 event))
     (key-desc (key-description key)))
    (toki/aw-select-window
     (string-to-number (car (nreverse (split-string key-desc "-")))))))

(global-set-key (kbd "C-x 2") #'toki-select-window)
(global-set-key (kbd "C-x 3") #'toki-select-window)

toki-select-window knows the number in my keybindings, and it switches to that window. Pressing C-x 2 leads me to that other window (though it has number 3 in its modeline), and pressing C-x 3 tells me No such window.

I know this is not the usual case, since we usually call ace-window to switch to a window, and by then which-key window already disappears, and we can set which-key-popup-type to 'minibuffer to work around this problem. So just a report, hopefully you could look into this, and feel free to close this issue if you don't want to.

Update: I tried (add-to-list 'aw-ignored-buffers "*which-key*"), but doesn't help.

Update 2: I've noticed https://github.com/abo-abo/ace-window/issues/143, and tried the workaround by seagle0128. But that works for any buffers but *which-key* buffer, which is really weird.