Skip to content

Commit c5ba4ef

Browse files
committed
Resize by pushing/pulling the window divider
f/n key pushes forward/down the current window right/below divider. If there is no right/below divider, it pulls forward/down the left/above. b/p key pulls backward/up the current window right/below divider. If there is no right/below divider, it pushes backward/up the left/above. Update: - readme.md
1 parent 85e04fa commit c5ba4ef

File tree

2 files changed

+49
-43
lines changed

2 files changed

+49
-43
lines changed

readme.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,14 @@ the caps lock key to control.
3131
But, just run `M-x resize-window`. There are only a few commands to learn,
3232
and they mimic the normal motions in emacs.
3333

34-
- `n`: Makes the window vertically bigger, think scrolling down. Use
35-
`N` to enlarge 5 lines at once.
36-
- `p`: Makes the window vertically smaller, again, like scrolling. Use
37-
`P` to shrink 5 lines at once.
38-
- `f`: Makes the window horizontally bigger, like scrolling forward;
39-
`F` for five lines at once.
40-
- `b`: window horizontally smaller, `B` for five lines at once.
34+
- `n`: Resize the window vertically like scrolling down. Use `N` for 5
35+
lines at once.
36+
- `p`: Resize the window vertically like scrolling up. Use `P` for 5
37+
lines at once.
38+
- `f`: Resize the window horizontally like scrolling forward. Use `F`
39+
for 5 lines at once.
40+
- `b`: Resize the window horizontally like scrolling backward. Use `B`
41+
for 5 lines at once.
4142
- `r`: reset window layout to standard
4243
- `w`: cycle through windows so that you can adjust other window
4344
panes. `W` cycles in the opposite direction.

resize-window.el

Lines changed: 41 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
;;; Commentary:
2828
;; Easily allows you to resize windows. Rather than guessing that you
29-
;; want `C-u 17 C-x {`, you could just press FFff, which enlarges 5
29+
;; want `C-u 17 C-x {`, you could just press FFff, which resizes 5
3030
;; lines, then 5 lines, then one and then one. The idea is that the
3131
;; normal motions n,p,f,b along with r for reset and w for cycling
3232
;; windows allows for super simple resizing of windows. All of this is
@@ -37,13 +37,14 @@
3737
;; But, just run `M-x resize-window`. There are only a few commands to learn,
3838
;; and they mimic the normal motions in emacs.
3939

40-
;; n : Makes the window vertically bigger, think scrolling down. Use
41-
;; N to enlarge 5 lines at once.
42-
;; p : Makes the window vertically smaller, again, like scrolling. Use
43-
;; P to shrink 5 lines at once.
44-
;; f : Makes the window horizontally bigger, like scrolling forward;
45-
;; F for five lines at once.
46-
;; b : window horizontally smaller, B for five lines at once.
40+
;; n : Resize the window vertically like scrolling down.
41+
;; N for 5 lines at once.
42+
;; p : Resize the window vertically like scrolling up.
43+
;; P for 5 lines at once.
44+
;; f : Resize the window horizontally like scrolling forward.
45+
;; F for 5 lines at once.
46+
;; b : Resize the window horizontally like scrolling backward.
47+
;; B for 5 lines at once.
4748
;; r : reset window layout to standard
4849
;; w : cycle through windows so that you can adjust other window
4950
;; panes. W cycles in the opposite direction.
@@ -103,7 +104,7 @@ This is also valuable to see that you are in resize mode."
103104

104105
(defun resize-window-lowercase-argument ()
105106
"Return the behavior for lowercase entries.
106-
Example, normally n maps to enlarge vertically by 1. However,
107+
Example, normally n maps to resize vertically by 1. However,
107108
if you have swapped capital and lowercase behavior, then
108109
this should return the coarse adjustment."
109110
(if resize-window-swap-capital-and-lowercase-behavior
@@ -112,18 +113,18 @@ this should return the coarse adjustment."
112113

113114
(defun resize-window-uppercase-argument ()
114115
"Return the behavior for uppercase entries.
115-
Example, normally N maps to enlarge vertically by 5. However,
116+
Example, normally N maps to resize vertically by 5. However,
116117
if you have swapped capital and lowercase behavior, then this
117118
should return the fine adjustment (default 1)."
118119
(if resize-window-swap-capital-and-lowercase-behavior
119120
resize-window-fine-argument
120121
resize-window-coarse-argument))
121122

122123
(defvar resize-window-dispatch-alist
123-
'((?n resize-window--enlarge-down " Resize - Expand down" t)
124-
(?p resize-window--enlarge-up " Resize - Expand up" t)
125-
(?f resize-window--enlarge-horizontally " Resize - horizontally" t)
126-
(?b resize-window--shrink-horizontally " Resize - shrink horizontally" t)
124+
'((?n resize-window--resize-downward " Resize - downward" t)
125+
(?p resize-window--resize-upward " Resize - upward" t)
126+
(?f resize-window--resize-forward " Resize - forward" t)
127+
(?b resize-window--resize-backward " Resize - backward" t)
127128
(?r resize-window--reset-windows " Resize - reset window layout" nil)
128129
(?w resize-window--cycle-window-positive " Resize - cycle window" nil)
129130
(?W resize-window--cycle-window-negative " Resize - cycle window" nil)
@@ -228,8 +229,8 @@ If SCALED, then call action with the `resize-window-uppercase-argument'."
228229
;;;###autoload
229230
(defun resize-window ()
230231
"Resize the window.
231-
Press n to enlarge down, p to enlarge up, b to enlarge left and f
232-
to enlarge right."
232+
Press n to resize down, p to resize up, b to resize left and f
233+
to resize right."
233234
(interactive)
234235
(setq resize-window--background-overlay (resize-window--make-background))
235236
(resize-window--notify "Resize mode: enter character, ? for help")
@@ -254,33 +255,37 @@ to enlarge right."
254255
(quit (resize-window--delete-overlays))))
255256

256257
;;; Function Handlers
257-
(defun resize-window--enlarge-down (&optional size)
258-
"Extend the current window downwards by optional SIZE.
259-
If no SIZE is given, extend by `resize-window-lowercase-argument'."
258+
(defun resize-window--resize-downward (&optional size)
259+
"Resize the window vertically downward by optional SIZE.
260+
If no SIZE is given, modify by `resize-window-default-argument'"
260261
(unless (frame-root-window-p (selected-window))
261-
(let ((size (or size (resize-window-lowercase-argument))))
262-
(enlarge-window size))))
262+
(let ((size (or size (resize-window-lowercase-argument)))
263+
(direction (if (window-in-direction 'below) 1 -1)))
264+
(enlarge-window (* size direction)))))
263265

264-
(defun resize-window--enlarge-up (&optional size)
265-
"Bring bottom edge back up by one or optional SIZE.
266-
If no SIZE is given, extend by `resize-window-lowercase-argument'."
266+
(defun resize-window--resize-upward (&optional size)
267+
"Resize the window vertically upward by optional SIZE.
268+
If no SIZE is given, modify by `resize-window-default-argument'"
267269
(unless (frame-root-window-p (selected-window))
268-
(let ((size (or size (resize-window-lowercase-argument))))
269-
(enlarge-window (- size)))))
270+
(let ((size (or size (resize-window-lowercase-argument)))
271+
(direction (if (window-in-direction 'below) -1 1)))
272+
(enlarge-window (* size direction)))))
270273

271-
(defun resize-window--enlarge-horizontally (&optional size)
272-
"Enlarge the window horizontally by one or optional SIZE.
273-
If no SIZE is given, extend by `resize-window-lowercase-argument'."
274+
(defun resize-window--resize-forward (&optional size)
275+
"Resize the window horizontally forward by optional SIZE.
276+
If no SIZE is given, modify by `resize-window-default-argument'"
274277
(unless (frame-root-window-p (selected-window))
275-
(let ((size (or size (resize-window-lowercase-argument))))
276-
(enlarge-window size t))))
278+
(let ((size (or size (resize-window-lowercase-argument)))
279+
(direction (if (window-in-direction 'right) 1 -1)))
280+
(enlarge-window (* size direction) t))))
277281

278-
(defun resize-window--shrink-horizontally (&optional size)
279-
"Shrink the window horizontally by one or optional SIZE.
280-
If no SIZE is given, extend by `resize-window-lowercase-argument'."
282+
(defun resize-window--resize-backward (&optional size)
283+
"Resize the window horizontally backward by optional SIZE.
284+
If no SIZE is given, modify by `resize-window-default-argument'"
281285
(unless (frame-root-window-p (selected-window))
282-
(let ((size (or size (resize-window-lowercase-argument))))
283-
(enlarge-window (- size) t))))
286+
(let ((size (or size (resize-window-lowercase-argument)))
287+
(direction (if (window-in-direction 'right) -1 1)))
288+
(enlarge-window (* size direction) t))))
284289

285290
(defun resize-window--reset-windows ()
286291
"Reset window layout to even spread."

0 commit comments

Comments
 (0)