Emacs has the function other-window that lets you jump between windows. The function's documentation states that it takes an optional argument that tells the function how many windows to jump ahead.
Once upon a time, I defined a keyboard shortcut to call (other-window -1) to jump to the previous window. But at some point (GNU Emacs 25, I think), this stopped working. At first, it did not bother me much, but over time it has become a real nuisance. So if anybody knows a way to replicate that behavior, I would be very grateful!
The function I wrote looks like this:
(defun previous-window ()
(interactive nil)
(other-window -1))
And it is bound to a command key like so:
(global-set-key "\C-xp" 'previous-window)
The error message I get:
other-window: Wrong number of arguments: (lambda nil (interactive nil) (other-window -1)), 3
When I run emacs -Q and enter the function and keybinding manually, I get the same error.
Also, I have a function to switch to the previous frame:
(defun prev-frame ()
(interactive nil)
(other-frame -1))
This function works as expected.
(other-window -1)
works fine for me, and the docstring suggests it should. Try it without your init file (emacs -Q
). If it works appropriately, it's something in your init file that is interfering.interactive
spec.