Skip to content

Commit 2b2c821

Browse files
committed
Drop current configuration from the stack
1 parent 79a29b5 commit 2b2c821

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-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: 33 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))
@@ -922,6 +927,33 @@ If STACK-SIZE is nil use `resize-window-stack-size'."
922927
(delq old-member resize-window--window-stack))))
923928
oldest-members))))
924929

930+
(defun resize-window--window-drop ()
931+
"Drop the current window configuration from the stack.
932+
Ask the user for confirmation then return the removed member.
933+
934+
Abort if the configuration isn't in the stack or the user decided
935+
otherwise. If the configuration is dropped, switch to another one
936+
in respect to `resize-window--restore-forward' direction flag."
937+
(if (or (resize-window--stack-config-modified)
938+
(not (let ((query-replace-map (copy-keymap query-replace-map)))
939+
(define-key query-replace-map [? ] 'skip)
940+
(y-or-n-p "Drop saved state? "))))
941+
(resize-window--notify-status)
942+
(prog1
943+
(resize-window--pop-stack-member)
944+
(unless resize-window--restore-forward
945+
(resize-window--stack-shift-member t))
946+
(let* ((curr-member (resize-window--get-stack-member))
947+
(curr-config (car curr-member)))
948+
(when curr-config
949+
(resize-window--restore-config curr-config)
950+
(setq curr-config (resize-window--window-config))
951+
(resize-window--stack-member-config curr-config)
952+
(resize-window--stack-member-svtime (current-time))))
953+
(setq resize-window--config-modified
954+
(resize-window--stack-config-modified))
955+
(resize-window--notify "Drop saved state"))))
956+
925957
(defun resize-window--window-save ()
926958
"Save the current window configuration in the stack.
927959
If the configuration is saved return its stack member.

0 commit comments

Comments
 (0)