Skip to content

Commit eeb6cc4

Browse files
committed
Drop current configuration from the stack
1 parent 4800445 commit eeb6cc4

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

readme.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ panes. Use `W` to cycle in the opposite direction.
4747
- `3`: Split the window vertically.
4848
- `0`: Delete the current window.
4949
- `k`: Delete other windows and save the state on the stack.
50+
- `x`: Drop the current saved state. Switch to another one.
5051
- `s`: Save the state on the stack so you may restore it later.
5152
- `>`: Restore to a previous saved state. Use `<` to restore in the
5253
opposite direction.

resize-window.el

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
;; 3 : Split the window vertically.
5454
;; 0 : Delete the current window.
5555
;; k : Delete other windows and save the state on the stack.
56+
;; x : Drop the current saved state. Switch to another one.
5657
;; s : Save the state on the stack so you may restore it later.
5758
;; > : Restore to a previous saved state.
5859
;; < Restore in the opposite direction.
@@ -160,6 +161,7 @@ should return the fine adjustment (default 1)."
160161
(?3 resize-window--split-window-right "Split right (save state)" nil)
161162
(?0 resize-window--delete-window "Delete window (save state)" nil)
162163
(?k resize-window--kill-other-windows "Delete other windows (save state)" nil)
164+
(?x resize-window--window-drop "Drop state" nil)
163165
(?s resize-window--window-save "Save state" nil)
164166
(?> resize-window--restore-head "Restore succeding (save state)" nil)
165167
(?< resize-window--restore-tail "Restore preceding (save state)" nil)
@@ -367,7 +369,10 @@ CHOICE is a \(key function documentation allows-capitals\).
367369
If SCALED, then call action with the `resize-window-uppercase-argument'."
368370
(let ((action (resize-window--choice-lambda choice))
369371
(description (resize-window--choice-documentation choice)))
370-
(resize-window--notify "%s" description)
372+
(if (resize-window--keys-equal
373+
(resize-window--choice-keybinding choice) [?x])
374+
(resize-window--cancel-notify)
375+
(resize-window--notify "%s" description))
371376
(condition-case nil
372377
(if scaled
373378
(funcall action (resize-window-uppercase-argument))
@@ -871,6 +876,32 @@ Return the removed stack members."
871876
(delq old-member resize-window--window-stack))))
872877
oldest-members))))
873878

879+
(defun resize-window--window-drop ()
880+
"Drop the current window configuration from the stack.
881+
882+
Silently quit if the current window configuration is not saved.
883+
Ask the user confirmation before dropping the state then switch
884+
to another one in respect to `resize-window--restore-forward'."
885+
(if (or resize-window--config-modified
886+
(not (let ((query-replace-map (copy-keymap query-replace-map)))
887+
(define-key query-replace-map [? ] 'skip)
888+
(y-or-n-p "Drop state? "))))
889+
(resize-window--notify-status)
890+
(resize-window--pop-stack-member)
891+
(unless resize-window--restore-forward
892+
(resize-window--push-stack-member
893+
(resize-window--pop-stack-member t)))
894+
(let* ((curr-member (resize-window--get-stack-member))
895+
(curr-config (car curr-member)))
896+
(when curr-config
897+
(resize-window--restore-config curr-config)
898+
(setq curr-config (resize-window--window-config))
899+
(resize-window--stack-member-config curr-config)
900+
(resize-window--stack-member-svtime (current-time))))
901+
(setq resize-window--config-modified
902+
(resize-window--stack-config-modified))
903+
(resize-window--notify "Drop state")))
904+
874905
(defun resize-window--window-save ()
875906
"Save the current window configuration in the stack.
876907
Return its stack member if the configuration is saved.

0 commit comments

Comments
 (0)