Last active
January 14, 2025 13:19
-
-
Save jidaikobo-shibata/617939cfd02428030de299c8da3718c3 to your computer and use it in GitHub Desktop.
Anythingのプロンプトがある状態でほかのウィンドウに移動したらanything-keyboard-quitする
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; 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