From 16ba8f3ae15363e921fca0e97f5c89cf12987b21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Ankarstr=C3=B6m?= Date: Tue, 30 Aug 2022 01:54:45 +0200 Subject: eb.el: Fix eb--fleeting--window-hook. --- eb.el | 41 ++++++++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 15 deletions(-) (limited to 'eb.el') diff --git a/eb.el b/eb.el index 70bdde1..7ca810a 100644 --- a/eb.el +++ b/eb.el @@ -66,23 +66,34 @@ (setq eb--fleeting--window (and eb--fleeting-minor-mode (get-buffer-window)))) (add-hook 'pre-command-hook #'eb--fleeting--pre-command-hook) -(defun eb--fleeting--window-hook () - (when (and eb--fleeting--buffer - eb--fleeting--window) - (if (and (equal eb--fleeting--window (selected-window)) - (not (equal eb--fleeting--buffer (window-buffer)))) - (progn - (with-current-buffer eb--fleeting--buffer +(define-key global-map [f12] (lambda () (interactive) (message "%s" eb--fleeting--buffer))) + +(defun eb--fleeting--window-hook (&rest r) + (let ((fleeting-buffer eb--fleeting--buffer) + (fleeting-window eb--fleeting--window) + (buffer (window-buffer)) + (window (selected-window))) + (when (and fleeting-buffer fleeting-window) + (if (and (equal fleeting-window window) + (equal fleeting-buffer buffer)) + (with-current-buffer fleeting-buffer (eb--fleeting-minor-mode -1)) - (bury-buffer eb--fleeting--buffer) - (let ((new-buffer (window-buffer))) - (select-window (eb--fleeting--main-window eb--fleeting--buffer eb--fleeting--window)) - (switch-to-buffer new-buffer)) - (delete-window eb--fleeting--window)) - (when (not (get-buffer-window eb--fleeting--buffer)) - (with-current-buffer eb--fleeting--buffer - (eb--fleeting-minor-mode -1)))))) + (if (and (equal fleeting-window window) + (not (equal fleeting-buffer buffer))) + (progn + (with-current-buffer fleeting-buffer + (eb--fleeting-minor-mode -1)) + (bury-buffer fleeting-buffer) + (setq eb--fleeting--window nil) + (select-window (eb--fleeting--main-window fleeting-buffer fleeting-window)) + (switch-to-buffer buffer) + (delete-window fleeting-window)) + (if (get-buffer-window fleeting-buffer) + (delete-window fleeting-window) + (with-current-buffer fleeting-buffer + (eb--fleeting-minor-mode -1)))))))) (add-hook 'window-configuration-change-hook #'eb--fleeting--window-hook) +(add-hook 'window-selection-change-functions #'eb--fleeting--window-hook) ;;;###autoload (defun eb-quit-or-bury () -- cgit v1.2.3