aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-06-28 12:02:50 -0400
committerCraig Jennings <c@cjennings.net>2026-06-28 12:02:50 -0400
commitd5fba0cc6294a9fc17993f7389e0df9f984165fb (patch)
treeca16505431c0529d7950e1d6ce39990584f40199 /tests
parent16ad2dde87be8d119c85dcb1a70856000603a189 (diff)
downloaddotemacs-d5fba0cc6294a9fc17993f7389e0df9f984165fb.tar.gz
dotemacs-d5fba0cc6294a9fc17993f7389e0df9f984165fb.zip
feat(windows): bind M-arrow to the window pull-away and resize
M-<arrow> now mirrors C-; b <arrow>. From a sole window it pulls a sliver split open on the opposite edge, revealing the previous buffer. In a multi-window layout it nudges the divider via windsize. cj/window-resize-sticky derives the arrow with event-basic-type, so one command serves both chords. M-up/down were unbound, and M-left/right shed word-motion, which stays on C-left/right. org and other modes that own M-arrow still shadow it, so C-; b remains the universal binding.
Diffstat (limited to 'tests')
-rw-r--r--tests/test-ui-navigation--window-resize.el45
1 files changed, 45 insertions, 0 deletions
diff --git a/tests/test-ui-navigation--window-resize.el b/tests/test-ui-navigation--window-resize.el
index 553219755..b011fb063 100644
--- a/tests/test-ui-navigation--window-resize.el
+++ b/tests/test-ui-navigation--window-resize.el
@@ -82,5 +82,50 @@ real window split happens under `--batch'."
(should (eq (keymap-lookup cj/buffer-and-file-map arrow)
#'cj/window-resize-sticky))))
+(ert-deftest test-ui-navigation-window-resize-sticky-meta-arrow-pulls-away ()
+ "Normal: M-<arrow> reaches the same pull-away as the bare arrow. The
+direction is derived with `event-basic-type', so the Meta modifier is stripped
+and a sole window pulls a sliver to the side opposite the arrow, exactly as the
+bare-arrow path does."
+ (dolist (case '((M-down . above)
+ (M-up . below)
+ (M-left . right)
+ (M-right . left)))
+ (let ((pulled nil)
+ (overriding-terminal-local-map nil)
+ (pre-command-hook nil))
+ (cl-letf (((symbol-function 'one-window-p) (lambda (&rest _) t))
+ ((symbol-function 'cj/window--pull-away)
+ (lambda (dir) (setq pulled dir))))
+ (let ((last-command-event (car case)))
+ (cj/window-resize-sticky)))
+ (should (eq pulled (cdr case))) ; meta stripped, pulled to opposite side
+ (should overriding-terminal-local-map)))) ; loop armed
+
+(ert-deftest test-ui-navigation-window-resize-sticky-meta-arrow-resizes ()
+ "Normal: with more than one window, M-<arrow> dispatches the matching
+`windsize' command, same as the bare arrow -- the Meta modifier is stripped
+before the resize-map lookup."
+ (dolist (case '((M-left . windsize-left)
+ (M-right . windsize-right)
+ (M-up . windsize-up)
+ (M-down . windsize-down)))
+ (let ((ran nil)
+ (overriding-terminal-local-map nil)
+ (pre-command-hook nil))
+ (cl-letf (((symbol-function 'one-window-p) (lambda (&rest _) nil))
+ ((symbol-function (cdr case))
+ (lambda (&rest _) (interactive) (setq ran t))))
+ (let ((last-command-event (car case)))
+ (cj/window-resize-sticky)))
+ (should ran)
+ (should overriding-terminal-local-map))))
+
+(ert-deftest test-ui-navigation-window-resize-bound-under-meta-arrow ()
+ "Normal: each global `M-<arrow>' reaches the sticky-resize command."
+ (dolist (arrow '("M-<left>" "M-<right>" "M-<up>" "M-<down>"))
+ (should (eq (keymap-lookup (current-global-map) arrow)
+ #'cj/window-resize-sticky))))
+
(provide 'test-ui-navigation--window-resize)
;;; test-ui-navigation--window-resize.el ends here