From 9ca16c6bc394b2f57b3a5651b2baff7f3a62d2e0 Mon Sep 17 00:00:00 2001 From: Nick Drozd Date: Sat, 25 Nov 2017 15:21:20 -0500 Subject: [PATCH] Fix aw-switch-buffer-other-window bug When aw-switch-buffer-other-window is executed, it switches to the selected window, changes the buffer, and then switches back. If the buffer-switching function is canceled, the window won't get switched back. Using unwind-protect ensures that the function ends with the starting window selected. --- ace-window.el | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ace-window.el b/ace-window.el index fc8a592..1a24c7b 100644 --- a/ace-window.el +++ b/ace-window.el @@ -750,10 +750,11 @@ Modify `aw-fair-aspect-ratio' to tweak behavior." (aw-split-window-vert window)))) (defun aw-switch-buffer-other-window (window) - "Switch buffer in WINDOW without selecting WINDOW." + "Switch buffer in WINDOW." (aw-switch-to-window window) - (aw--switch-buffer) - (aw-flip-window)) + (unwind-protect + (aw--switch-buffer) + (aw-flip-window))) (defun aw--face-rel-height () (let ((h (face-attribute 'aw-leading-char-face :height)))