aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Thomas2025-06-16 01:20:31 +0530
committerEli Zaretskii2025-08-02 17:25:14 +0300
commitcd31c3cb423baaaa9f7f3fa9eab274c09f2db1e9 (patch)
tree57dadad87d5cafe5acb123a6f9ff180af49417c7
parente52ed1b5d1531e7dc15f3f8ddf7042b0a7e71f50 (diff)
downloademacs-cd31c3cb423baaaa9f7f3fa9eab274c09f2db1e9.tar.gz
emacs-cd31c3cb423baaaa9f7f3fa9eab274c09f2db1e9.zip
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.
-rw-r--r--doc/emacs/windows.texi5
-rw-r--r--etc/NEWS4
-rw-r--r--lisp/window.el14
3 files changed, 18 insertions, 5 deletions
diff --git a/doc/emacs/windows.texi b/doc/emacs/windows.texi
index 9473f189c25..4f04dc542eb 100644
--- a/doc/emacs/windows.texi
+++ b/doc/emacs/windows.texi
@@ -158,6 +158,8 @@ this option is @code{nil}.
158@table @kbd 158@table @kbd
159@item C-x o 159@item C-x o
160Select another window (@code{other-window}). 160Select another window (@code{other-window}).
161@item C-x O
162Select another window, backwards (@code{other-window-backward}).
161@item C-M-v 163@item C-M-v
162Scroll the next window upward (@code{scroll-other-window}). 164Scroll the next window upward (@code{scroll-other-window}).
163@item C-M-S-v 165@item C-M-S-v
@@ -183,7 +185,8 @@ cycle in the opposite order. When the minibuffer is active, the
183minibuffer window is the last window in the cycle; you can switch from 185minibuffer window is the last window in the cycle; you can switch from
184the minibuffer window to one of the other windows, and later switch 186the minibuffer window to one of the other windows, and later switch
185back and finish supplying the minibuffer argument that is requested. 187back and finish supplying the minibuffer argument that is requested.
186@xref{Minibuffer Edit}. 188@xref{Minibuffer Edit}. @kbd{C-x O} is similar, but defaults to the
189opposite order.
187 190
188@findex next-window-any-frame 191@findex next-window-any-frame
189The @code{other-window} command will normally only switch to the next 192The @code{other-window} command will normally only switch to the next
diff --git a/etc/NEWS b/etc/NEWS
index 3b9e06f99d9..e12a9dcb127 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -333,6 +333,10 @@ helps to restore window buffers across Emacs sessions.
333You can use this in 'display-buffer-alist' to match buffers displayed 333You can use this in 'display-buffer-alist' to match buffers displayed
334during the execution of particular commands. 334during the execution of particular commands.
335 335
336*** New command 'other-window-backward' ('C-x O').
337This moves in the opposite direction of 'other-window' and is for its
338default keybinding consistent with 'repeat-mode'.
339
336** Frames 340** Frames
337 341
338+++ 342+++
diff --git a/lisp/window.el b/lisp/window.el
index 44cb682d6dd..512e85dc29a 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -4073,6 +4073,14 @@ nil, which considers all windows on the selected frame."
4073 ;; Always return nil. 4073 ;; Always return nil.
4074 nil)))) 4074 nil))))
4075 4075
4076(defun other-window-backward (count &optional all-frames interactive)
4077 "Select another window in the reverse cyclic ordering of windows.
4078COUNT specifies the number of windows to skip, (by default) backward,
4079starting with the selected window, before making the selection. Like
4080`other-window', but moves in the opposite direction."
4081 (interactive "p\ni\np")
4082 (other-window (- (or count 1)) all-frames interactive))
4083
4076(defun other-window-prefix () 4084(defun other-window-prefix ()
4077 "Display the buffer of the next command in a new window. 4085 "Display the buffer of the next command in a new window.
4078The next buffer is the buffer displayed by the next command invoked 4086The next buffer is the buffer displayed by the next command invoked
@@ -11373,6 +11381,7 @@ found by the provided context."
11373(define-key ctl-x-map "2" 'split-window-below) 11381(define-key ctl-x-map "2" 'split-window-below)
11374(define-key ctl-x-map "3" 'split-window-right) 11382(define-key ctl-x-map "3" 'split-window-right)
11375(define-key ctl-x-map "o" 'other-window) 11383(define-key ctl-x-map "o" 'other-window)
11384(define-key ctl-x-map "O" 'other-window-backward)
11376(define-key ctl-x-map "^" 'enlarge-window) 11385(define-key ctl-x-map "^" 'enlarge-window)
11377(define-key ctl-x-map "}" 'enlarge-window-horizontally) 11386(define-key ctl-x-map "}" 'enlarge-window-horizontally)
11378(define-key ctl-x-map "{" 'shrink-window-horizontally) 11387(define-key ctl-x-map "{" 'shrink-window-horizontally)
@@ -11386,10 +11395,7 @@ found by the provided context."
11386 :doc "Keymap to repeat `other-window'. Used in `repeat-mode'." 11395 :doc "Keymap to repeat `other-window'. Used in `repeat-mode'."
11387 :repeat t 11396 :repeat t
11388 "o" #'other-window 11397 "o" #'other-window
11389 "O" (lambda () 11398 "O" #'other-window-backward)
11390 (interactive)
11391 (setq repeat-map 'other-window-repeat-map)
11392 (other-window -1)))
11393 11399
11394(defvar-keymap resize-window-repeat-map 11400(defvar-keymap resize-window-repeat-map
11395 :doc "Keymap to repeat window resizing commands. 11401 :doc "Keymap to repeat window resizing commands.