Skip to content

Commit 6710a3c

Browse files
committed
Drop current configuration from the stack
1 parent 528568b commit 6710a3c

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
@@ -45,6 +45,7 @@ panes. Use `W` to cycle in the opposite direction.
4545
- `3`: Split the window vertically.
4646
- `0`: Delete the current window.
4747
- `k`: Delete other windows and save the state on the stack.
48+
- `x`: Drop the current saved state. Switch to another one.
4849
- `s`: Save the state on the stack so you may restore it later.
4950
- `>`: Restore to a previous saved state. Use `<` to restore in the
5051
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)
@@ -366,7 +368,10 @@ CHOICE is a \(key function documentation allows-capitals\).
366368
If SCALED, then call action with the `resize-window-uppercase-argument'."
367369
(let ((action (resize-window--choice-lambda choice))
368370
(description (resize-window--choice-documentation choice)))
369-
(resize-window--notify "%s" description)
371+
(if (resize-window--keys-equal
372+
(resize-window--choice-keybinding choice) [?x])
373+
(resize-window--cancel-notify)
374+
(resize-window--notify "%s" description))
370375
(condition-case nil
371376
(if scaled
372377
(funcall action (resize-window-uppercase-argument))
@@ -870,6 +875,32 @@ Return the removed stack members."
870875
(delq old-member resize-window--window-stack))))
871876
oldest-members))))
872877

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

0 commit comments

Comments
 (0)