aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md1
-rw-r--r--perspective.el31
2 files changed, 8 insertions, 24 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4390bc8..6ccd7ef 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -52,6 +52,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- `persp-mode`: add/remove `persp-maybe-kill-buffer` hook.
- `persp-kill`: switch `persp-maybe-kill-buffer` on/off to allow killing a perspective's last left buffer.
- `persp-set-buffer`: walk perspectives rather than using a while `persp-buffer-in-other-p` loop, since the former isn't prone to infinite loops. This is needed due to buffers kept in perspectives by `persp-maybe-kill-buffer` and `persp-remove-buffer` when a buffer is a perspective`s last left buffer.
+- `persp-remove-buffer`: use `persp-forget-buffer` to remove a buffer from a perspective.
- `persp-remove-buffer`: do not kill/remove a perspective's last left buffer.
- `persp-remove-buffer`: when burying a buffer, walk windows rather than using a while loop, since the former isn't prone to infinite loops.
- `make-persp`: document that executing BODY saves/restores the `current-buffer`.
diff --git a/perspective.el b/perspective.el
index 3c2b5a1..b0c439e 100644
--- a/perspective.el
+++ b/perspective.el
@@ -950,7 +950,11 @@ See also `persp-add-buffer' and `persp-remove-buffer'."
(setf (persp-current-buffers) (remq buffer (persp-current-buffers))))
(defun persp-remove-buffer (buffer)
- "Disassociate BUFFER with the current perspective.
+ "Remove BUFFER from the current perspective.
+Kill BUFFER if it falls into limbo (not in any perspective).
+
+To disassociate BUFFER without the chance of killing it, see
+`persp-forget-buffer'.
See also `persp-switch' and `persp-add-buffer'."
(interactive
@@ -964,33 +968,12 @@ See also `persp-switch' and `persp-add-buffer'."
;; could not be enforced when a perspective is killed.
((and (persp-is-current-buffer buffer)
(memq 'persp-maybe-kill-buffer kill-buffer-query-functions)
- (not (remove (buffer-name buffer) (persp-current-buffer-names))))
- (setq buffer nil))
+ (not (remove (buffer-name buffer) (persp-current-buffer-names)))))
;; Only kill the buffer if no other perspectives are using it.
((not (persp-buffer-in-other-p buffer))
(kill-buffer buffer))
;; Make the buffer go away if we can see it.
- ((let (buffer-in-any-window)
- (walk-windows (lambda (window)
- (when (eq buffer (window-buffer window))
- (setq buffer-in-any-window t)
- ;; Burying the current buffer should also
- ;; act as an `unrecord-window-buffer'.
- (with-selected-window window (bury-buffer)))))
- (let ((window (get-buffer-window buffer)))
- (when window
- (error "Buried buffer %s found in window %s, but it shouldn't"
- buffer window)))
- ;; `with-selected-window' restores the `current-buffer'.
- ;; If the current buffer is buried, it should not be the
- ;; next current buffer. Remember to fix it later.
- buffer-in-any-window))
- (t (bury-buffer buffer)))
- ;; If the `current-buffer' was buried in `with-selected-window', set
- ;; the real current buffer, since `with-selected-window' restored it
- ;; as the next current buffer after processing its body.
- (set-buffer (window-buffer))
- (setf (persp-current-buffers) (remq buffer (persp-current-buffers))))
+ ((persp-forget-buffer buffer))))
(defun persp-kill (name)
"Kill the perspective given by NAME.