@@ -133,7 +133,7 @@ should return the fine adjustment (default 1)."
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 )
136
- (?? resize-window--display-menu " Resize - display menu" nil ))
136
+ (?? resize-window--display-menu " Resize - toggle help menu" nil ))
137
137
" List of resize mode bindings.
138
138
Main data structure of the dispatcher with the form:
139
139
\( key function documentation allows-capitals\) " )
@@ -260,9 +260,12 @@ to resize right."
260
260
; ; with t and that method can worry about how to get that
261
261
; ; action
262
262
(resize-window--execute-action capital t ))
263
- (t (setq reading-characters nil )
264
- (resize-window--remove-backgrounds))))))
263
+ (t
264
+ (setq reading-characters nil )
265
+ (resize-window--display-menu 'kill )
266
+ (resize-window--remove-backgrounds))))))
265
267
(quit
268
+ (resize-window--display-menu 'kill )
266
269
(resize-window--remove-backgrounds))))
267
270
268
271
; ;; Function Handlers
@@ -312,9 +315,33 @@ If no SIZE is given, modify by `resize-window-default-argument'"
312
315
(other-window -1 )
313
316
(resize-window--add-backgrounds))
314
317
315
- (defun resize-window--display-menu ()
316
- " Display menu in minibuffer."
317
- (resize-window--notify " %s" (resize-window--get-documentation-strings)))
318
+ (defun resize-window--display-menu (&optional action )
319
+ " Toggle help menu side window or perform ACTION if non-nil.
320
+ ACTION is a symbol of value 'kill or 'open."
321
+ (let* ((buffer (get-buffer-create " *Resize-Window-Help*" ))
322
+ (window (get-buffer-window buffer))
323
+ (add-backgrounds nil ))
324
+ (cond
325
+ ((and window (or (not action) (eq action 'kill )))
326
+ (quit-window t window)
327
+ (setq add-backgrounds t ))
328
+ ((and (not window) (or (not action) (eq action 'open )))
329
+ (setq window (display-buffer-in-side-window buffer nil ))
330
+ (set-window-parameter window 'no-other-window t )
331
+ (set-window-parameter window 'no-delete-other-windows t )
332
+ (with-current-buffer buffer
333
+ (setq buffer-read-only t )
334
+ (setq window-size-fixed t )
335
+ (let ((inhibit-read-only t )
336
+ (window-size-fixed nil ))
337
+ (erase-buffer )
338
+ (insert (resize-window--get-documentation-strings))
339
+ (fit-window-to-buffer window)))
340
+ (setq add-backgrounds t )))
341
+ ; ; NOTE: Just in case the help menu was selected (it shouldn't)
342
+ ; ; refresh the backgrounds even when the help menu is killed.
343
+ (when add-backgrounds
344
+ (resize-window--add-backgrounds))))
318
345
319
346
(defun resize-window--split-window-below ()
320
347
" Split the window vertically."
@@ -332,9 +359,33 @@ If no SIZE is given, modify by `resize-window-default-argument'"
332
359
(delete-window )
333
360
(resize-window--add-backgrounds)))
334
361
362
+ (defun resize-window--window-config ()
363
+ " Return the current window configuration.
364
+ Exclude the help menu from the configuration."
365
+ (let ((display-menu (get-buffer-window " *Resize-Window-Help*" )))
366
+ (prog2
367
+ (resize-window--display-menu 'kill )
368
+ (current-window-configuration )
369
+ (when display-menu
370
+ (resize-window--display-menu 'open )))))
371
+
372
+ (defun resize-window--restore-config (config )
373
+ " Restore the window configuration CONFIG then return it.
374
+ Restore the help menu only if it is currently open."
375
+ (let ((display-menu (get-buffer-window " *Resize-Window-Help*" )))
376
+ (set-window-configuration config)
377
+ ; ; NOTE: If `resize-window--window-config' was used to save the
378
+ ; ; CONFIG there is no help menu to kill. Keep this just in case.
379
+ (resize-window--display-menu 'kill )
380
+ (prog1
381
+ (current-window-configuration )
382
+ (if display-menu
383
+ (resize-window--display-menu 'open )
384
+ (resize-window--add-backgrounds)))))
385
+
335
386
(defun resize-window--window-push ()
336
387
" Save the current state in the stack."
337
- (push (current -window-configuration ) resize-window--window-stack))
388
+ (push (resize -window--window-config ) resize-window--window-stack))
338
389
339
390
(defun resize-window--window-pop ()
340
391
" Return the first element and remove it from the stack."
@@ -350,8 +401,7 @@ If no SIZE is given, modify by `resize-window-default-argument'"
350
401
" Restore the previous state."
351
402
(let ((config (resize-window--window-pop)))
352
403
(when config
353
- (set-window-configuration config)
354
- (resize-window--add-backgrounds))))
404
+ (resize-window--restore-config config))))
355
405
356
406
(defvar resize-window--capital-letters (number-sequence ?A ?Z )
357
407
" List of uppercase letters as characters." )
0 commit comments