26
26
27
27
; ;; Commentary:
28
28
; ; 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
30
30
; ; lines, then 5 lines, then one and then one. The idea is that the
31
31
; ; normal motions n,p,f,b along with r for reset and w for cycling
32
32
; ; windows allows for super simple resizing of windows. All of this is
37
37
; ; But, just run `M-x resize-window`. There are only a few commands to learn,
38
38
; ; and they mimic the normal motions in emacs.
39
39
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.
47
48
; ; r : reset window layout to standard
48
49
; ; w : cycle through windows so that you can adjust other window
49
50
; ; panes. W cycles in the opposite direction.
@@ -103,7 +104,7 @@ This is also valuable to see that you are in resize mode."
103
104
104
105
(defun resize-window-lowercase-argument ()
105
106
" 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,
107
108
if you have swapped capital and lowercase behavior, then
108
109
this should return the coarse adjustment."
109
110
(if resize-window-swap-capital-and-lowercase-behavior
@@ -112,18 +113,18 @@ this should return the coarse adjustment."
112
113
113
114
(defun resize-window-uppercase-argument ()
114
115
" 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,
116
117
if you have swapped capital and lowercase behavior, then this
117
118
should return the fine adjustment (default 1)."
118
119
(if resize-window-swap-capital-and-lowercase-behavior
119
120
resize-window-fine-argument
120
121
resize-window-coarse-argument))
121
122
122
123
(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 )
127
128
(?r resize-window--reset-windows " Resize - reset window layout" nil )
128
129
(?w resize-window--cycle-window-positive " Resize - cycle window" nil )
129
130
(?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'."
228
229
;;;### autoload
229
230
(defun resize-window ()
230
231
" 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."
233
234
(interactive )
234
235
(setq resize-window--background-overlay (resize-window--make-background))
235
236
(resize-window--notify " Resize mode: enter character, ? for help" )
@@ -254,33 +255,37 @@ to enlarge right."
254
255
(quit (resize-window--delete-overlays))))
255
256
256
257
; ;; 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' "
260
261
(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)))))
263
265
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' "
267
269
(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)))))
270
273
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' "
274
277
(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 ))))
277
281
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' "
281
285
(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 ))))
284
289
285
290
(defun resize-window--reset-windows ()
286
291
" Reset window layout to even spread."
0 commit comments