Created
June 28, 2025 20:46
-
-
Save mmarshall540/d7597432c3b38380b3c28bfb71dcec0e to your computer and use it in GitHub Desktop.
Set the window to use with `scroll-other-window`
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
(defun my/set-window-4-scrolling (arg) | |
"Set current window as target window for `scroll-other-window'. | |
This ensures that `scroll-other-window' scrolls the desired window, even | |
if Emacs doesn't consider it the \"next-window\" and regardless of which | |
window is selected when `scroll-other-window' is called. | |
Compared to setting the `other-window-scroll-buffer' variable, the | |
method this command uses works even when the window is on another frame | |
and won't cause a duplicate window to pop up on the current frame. | |
This affects any command that uses `other-window-for-scrolling' to | |
choose a target window, including `scroll-other-window-down', | |
`recenter-other-window', `beginning-of-buffer-other-window', and | |
`end-of-buffer-other-window'. | |
With prefix ARG, unset the variable and go back to using `next-window' | |
to choose the other window for scrolling." | |
(interactive "P") | |
(if arg (setq other-window-scroll-default nil) | |
(let* ((owin (selected-window)) | |
(newval (lambda () owin))) | |
(setq other-window-scroll-default newval) | |
(message | |
"Setting %s as other window for scrolling commands." owin)))) | |
(keymap-global-set "C-c S" 'my/set-window-4-scrolling) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment