@@ -92,8 +92,8 @@ This is also valuable to see that you are in resize mode."
92
92
:type 'boolean
93
93
:group 'resize-window )
94
94
95
- (defvar resize-window--background-overlay ()
96
- " Holder for background overlay ." )
95
+ (defvar resize-window--background-overlays ()
96
+ " List of background overlays ." )
97
97
98
98
(defvar resize-window--window-stack ()
99
99
" Stack for holding window configurations." )
@@ -128,8 +128,8 @@ should return the fine adjustment (default 1)."
128
128
(?r resize-window--reset-windows " Resize - reset window layout" nil )
129
129
(?w resize-window--cycle-window-positive " Resize - cycle window" nil )
130
130
(?W resize-window--cycle-window-negative " Resize - cycle window" nil )
131
- (?2 split-window-below " Split window horizontally" nil )
132
- (?3 split-window-right " Slit window vertically" nil )
131
+ (?2 resize-window-- split-window-below " Split window horizontally" nil )
132
+ (?3 resize-window-- split-window-right " Slit window vertically" nil )
133
133
(?0 resize-window--delete-window " Delete window" nil )
134
134
(?k resize-window--kill-other-windows " Kill other windows (save state)" nil )
135
135
(?y resize-window--restore-windows " (when state) Restore window configuration" nil )
@@ -198,15 +198,25 @@ CHOICE is a \(key function documentation allows-capitals\)."
198
198
resize-window-dispatch-alist)
199
199
" \n " ))
200
200
201
- (defun resize-window--make-background ()
202
- " Place a background over the current window."
201
+ (defun resize-window--add-backgrounds ()
202
+ " Place an overlay background over other windows."
203
+ (resize-window--remove-backgrounds)
203
204
(when resize-window-allow-backgrounds
204
- (let ((ol (make-overlay
205
- (point-min )
206
- (point-max )
207
- (window-buffer ))))
208
- (overlay-put ol 'face 'resize-window-background )
209
- ol)))
205
+ (let ((windows (remq (get-buffer-window ) (window-list nil -1 ))))
206
+ (dolist (window windows)
207
+ (with-current-buffer (window-buffer window)
208
+ (let ((ol (make-overlay
209
+ (point-min )
210
+ (point-max )
211
+ (current-buffer ))))
212
+ (overlay-put ol 'face 'resize-window-background )
213
+ (overlay-put ol 'window window)
214
+ (push ol resize-window--background-overlays)))))))
215
+
216
+ (defun resize-window--remove-backgrounds ()
217
+ " Remove the overlay backgrounds."
218
+ (mapc 'delete-overlay resize-window--background-overlays)
219
+ (setq resize-window--background-overlays nil ))
210
220
211
221
(defun resize-window--execute-action (choice &optional scaled )
212
222
" Given a CHOICE, grab values out of the alist.
@@ -232,27 +242,28 @@ If SCALED, then call action with the `resize-window-uppercase-argument'."
232
242
Press n to resize down, p to resize up, b to resize left and f
233
243
to resize right."
234
244
(interactive )
235
- (setq resize-window--background-overlay (resize-window--make-background) )
245
+ (resize-window--add-backgrounds )
236
246
(resize-window--notify " Resize mode: enter character, ? for help" )
237
247
(condition-case nil
238
- (let ((reading-characters t )
239
- ; ; allow mini-buffer to collapse after displaying menu
240
- (resize-mini-windows t ))
241
- (while reading-characters
242
- (let* ((char (resize-window--match-alias (read-key )))
243
- (choice (assoc char resize-window-dispatch-alist))
244
- (capital (when (numberp char)
245
- (assoc (+ char 32 ) resize-window-dispatch-alist))))
246
- (cond
247
- (choice (resize-window--execute-action choice))
248
- ((and capital (resize-window--allows-capitals capital))
249
- ; ; rather than pass an argument, we tell it to "scale" it
250
- ; ; with t and that method can worry about how to get that
251
- ; ; action
252
- (resize-window--execute-action capital t ))
253
- (t (setq reading-characters nil )
254
- (delete-overlay resize-window--background-overlay))))))
255
- (quit (resize-window--delete-overlays))))
248
+ (let ((reading-characters t )
249
+ ; ; allow mini-buffer to collapse after displaying menu
250
+ (resize-mini-windows t ))
251
+ (while reading-characters
252
+ (let* ((char (resize-window--match-alias (read-key )))
253
+ (choice (assoc char resize-window-dispatch-alist))
254
+ (capital (when (numberp char)
255
+ (assoc (+ char 32 ) resize-window-dispatch-alist))))
256
+ (cond
257
+ (choice (resize-window--execute-action choice))
258
+ ((and capital (resize-window--allows-capitals capital))
259
+ ; ; rather than pass an argument, we tell it to "scale" it
260
+ ; ; with t and that method can worry about how to get that
261
+ ; ; action
262
+ (resize-window--execute-action capital t ))
263
+ (t (setq reading-characters nil )
264
+ (resize-window--remove-backgrounds))))))
265
+ (quit
266
+ (resize-window--remove-backgrounds))))
256
267
257
268
; ;; Function Handlers
258
269
(defun resize-window--resize-downward (&optional size )
@@ -291,36 +302,35 @@ If no SIZE is given, modify by `resize-window-default-argument'"
291
302
" Reset window layout to even spread."
292
303
(balance-windows ))
293
304
294
- (defun resize-window--delete-overlays ()
295
- " Remove overlays."
296
- (delete-overlay resize-window--background-overlay))
297
-
298
- (defun resize-window--create-overlay ()
299
- " Add overlay."
300
- (setq resize-window--background-overlay (resize-window--make-background)))
301
-
302
305
(defun resize-window--cycle-window-positive ()
303
306
" Cycle windows."
304
- (delete-overlay resize-window--background-overlay)
305
307
(other-window 1 )
306
- (setq resize-window--background-overlay (resize-window--make-background) ))
308
+ (resize-window--add-backgrounds ))
307
309
308
310
(defun resize-window--cycle-window-negative ()
309
311
" Cycle windows negative."
310
- (delete-overlay resize-window--background-overlay)
311
312
(other-window -1 )
312
- (setq resize-window--background-overlay (resize-window--make-background) ))
313
+ (resize-window--add-backgrounds ))
313
314
314
315
(defun resize-window--display-menu ()
315
316
" Display menu in minibuffer."
316
317
(resize-window--notify " %s" (resize-window--get-documentation-strings)))
317
318
319
+ (defun resize-window--split-window-below ()
320
+ " Split the window vertically."
321
+ (split-window-below )
322
+ (resize-window--add-backgrounds))
323
+
324
+ (defun resize-window--split-window-right ()
325
+ " Split the window horizontally."
326
+ (split-window-right )
327
+ (resize-window--add-backgrounds))
328
+
318
329
(defun resize-window--delete-window ()
319
330
" Delete the current window."
320
331
(unless (eq (get-buffer-window ) (window-main-window ))
321
- (delete-overlay resize-window--background-overlay)
322
332
(delete-window )
323
- (setq resize-window--background-overlay (resize-window--make-background) )))
333
+ (resize-window--add-backgrounds )))
324
334
325
335
(defun resize-window--window-push ()
326
336
" Save the current state in the stack."
@@ -332,18 +342,16 @@ If no SIZE is given, modify by `resize-window-default-argument'"
332
342
333
343
(defun resize-window--kill-other-windows ()
334
344
" Delete other windows."
335
- (resize-window--delete-overlays)
336
345
(resize-window--window-push)
337
346
(delete-other-windows )
338
- (resize-window--create-overlay ))
347
+ (resize-window--add-backgrounds ))
339
348
340
349
(defun resize-window--restore-windows ()
341
350
" Restore the previous state."
342
351
(let ((config (resize-window--window-pop)))
343
352
(when config
344
- (resize-window--delete-overlays)
345
353
(set-window-configuration config)
346
- (resize-window--create-overlay ))))
354
+ (resize-window--add-backgrounds ))))
347
355
348
356
(defvar resize-window--capital-letters (number-sequence ?A ?Z )
349
357
" List of uppercase letters as characters." )
0 commit comments