Skip to content

Commit

Permalink
improve(useful): wal-other-window
Browse files Browse the repository at this point in the history
This combines wal-switch-to-other-buffer and wal-other-window-mru.
  • Loading branch information
Walheimat committed May 19, 2024
1 parent 811647e commit 965d800
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/wal-key-bindings.org
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ USER-KEY and LEADER can be used to prefix the key."
(define-key undo-repeat-map "?" #'undo-redo)

;; Bind additional `other-window' commands.
(global-set-key (kbd "M-o") 'wal-other-window-mru)
(global-set-key (kbd "M-o") 'wal-other-window)
(global-set-key (kbd "C-M-o") 'wal-switch-to-other-buffer)

(with-eval-after-load 'window
Expand Down
8 changes: 8 additions & 0 deletions lib/wal-useful.org
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,14 @@ Search using regular expression if REGEXP is t."

(select-window mru-window)))

(defun wal-other-window ()
"Select the mru window or switch buffers."
(interactive)

(if (one-window-p)
(wal-switch-to-other-buffer)
(wal-other-window-mru)))

(defun wal-other-window-for-scrolling ()
"Get the default window to scroll."
(or (get-mru-window nil nil t)
Expand Down
14 changes: 14 additions & 0 deletions test/wal-useful-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,20 @@

(bydi-was-called-with select-window 'current)))

(ert-deftest wal-other-window ()
:tags '(useful windows)

(bydi ((:sometimes one-window-p)
wal-switch-to-other-buffer
wal-other-window-mru)

(wal-other-window)
(bydi-was-called wal-switch-to-other-buffer t)
(bydi-toggle-volatile 'one-window-p)

(wal-other-window)
(bydi-was-called wal-other-window-mru)))

(ert-deftest wal-other-window-for-scrolling ()
:tags '(useful windows)

Expand Down

0 comments on commit 965d800

Please sign in to comment.