1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-01-30 12:21:25 -08:00

Add 'other-window-backward' for a default binding (bug#78803)

This moves in the opposite direction to 'other-window' by
default, and is consistent with its repeat map.
* lisp/window.el (other-window-backward): New function bound to
'C-x O'.
(ctl-x-map): Update definition.
* doc/emacs/windows.texi (Other Window): Update docs.
* etc/NEWS: Annouce the new command.
This commit is contained in:
James Thomas 2025-06-16 01:20:31 +05:30 committed by Eli Zaretskii
parent e52ed1b5d1
commit cd31c3cb42
3 changed files with 18 additions and 5 deletions

View file

@ -158,6 +158,8 @@ this option is @code{nil}.
@table @kbd
@item C-x o
Select another window (@code{other-window}).
@item C-x O
Select another window, backwards (@code{other-window-backward}).
@item C-M-v
Scroll the next window upward (@code{scroll-other-window}).
@item C-M-S-v
@ -183,7 +185,8 @@ cycle in the opposite order. When the minibuffer is active, the
minibuffer window is the last window in the cycle; you can switch from
the minibuffer window to one of the other windows, and later switch
back and finish supplying the minibuffer argument that is requested.
@xref{Minibuffer Edit}.
@xref{Minibuffer Edit}. @kbd{C-x O} is similar, but defaults to the
opposite order.
@findex next-window-any-frame
The @code{other-window} command will normally only switch to the next

View file

@ -333,6 +333,10 @@ helps to restore window buffers across Emacs sessions.
You can use this in 'display-buffer-alist' to match buffers displayed
during the execution of particular commands.
*** New command 'other-window-backward' ('C-x O').
This moves in the opposite direction of 'other-window' and is for its
default keybinding consistent with 'repeat-mode'.
** Frames
+++

View file

@ -4073,6 +4073,14 @@ nil, which considers all windows on the selected frame."
;; Always return nil.
nil))))
(defun other-window-backward (count &optional all-frames interactive)
"Select another window in the reverse cyclic ordering of windows.
COUNT specifies the number of windows to skip, (by default) backward,
starting with the selected window, before making the selection. Like
`other-window', but moves in the opposite direction."
(interactive "p\ni\np")
(other-window (- (or count 1)) all-frames interactive))
(defun other-window-prefix ()
"Display the buffer of the next command in a new window.
The next buffer is the buffer displayed by the next command invoked
@ -11373,6 +11381,7 @@ found by the provided context."
(define-key ctl-x-map "2" 'split-window-below)
(define-key ctl-x-map "3" 'split-window-right)
(define-key ctl-x-map "o" 'other-window)
(define-key ctl-x-map "O" 'other-window-backward)
(define-key ctl-x-map "^" 'enlarge-window)
(define-key ctl-x-map "}" 'enlarge-window-horizontally)
(define-key ctl-x-map "{" 'shrink-window-horizontally)
@ -11386,10 +11395,7 @@ found by the provided context."
:doc "Keymap to repeat `other-window'. Used in `repeat-mode'."
:repeat t
"o" #'other-window
"O" (lambda ()
(interactive)
(setq repeat-map 'other-window-repeat-map)
(other-window -1)))
"O" #'other-window-backward)
(defvar-keymap resize-window-repeat-map
:doc "Keymap to repeat window resizing commands.