Skip to content

Instantly share code, notes, and snippets.

@jidaikobo-shibata
Last active January 14, 2025 13:19
Show Gist options
  • Save jidaikobo-shibata/617939cfd02428030de299c8da3718c3 to your computer and use it in GitHub Desktop.
Save jidaikobo-shibata/617939cfd02428030de299c8da3718c3 to your computer and use it in GitHub Desktop.
Anythingのプロンプトがある状態でほかのウィンドウに移動したらanything-keyboard-quitする
;; Anythingのプロンプトがある状態でほかのウィンドウに移動したらanything-keyboard-quitする
(defvar my-last-selected-buffer nil
"The buffer that was selected before the current window change.")
(defun my-window-selection-change (frame)
"Handle anything-keyboard-quit when switching from minibuffer."
(let ((current-buffer (buffer-name (window-buffer (selected-window)))))
(when (and my-last-selected-buffer
(stringp (buffer-name my-last-selected-buffer))
(string= (string-trim (buffer-name my-last-selected-buffer)) "*Minibuf-1*")
(anything-window))
(setq my-last-selected-buffer nil)
(when (fboundp 'anything-keyboard-quit)
(anything-keyboard-quit)))
(setq my-last-selected-buffer (or (window-buffer (selected-window)) nil))))
(add-hook 'window-selection-change-functions #'my-window-selection-change)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment