diff options
| author | Matthew White <mehw.is.me@inventati.org> | 2021-08-24 02:40:58 +0000 |
|---|---|---|
| committer | Matthew White <mehw.is.me@inventati.org> | 2021-10-20 23:23:31 +0200 |
| commit | 91419fb5997de269ec74170a5383074c8ee32166 (patch) | |
| tree | 1b0f430718423a50b19b35e69d10a77c98ee5ca4 | |
| parent | 34c9f6aaa0942795d5b50b67ad8842ac57e2b02f (diff) | |
persp-remove-buffer: force update current-buffer when burying it
If burying the 'current-buffer' inside 'with-selected-window', then
force update the current buffer after, since 'with-selected-window'
may restore the buried buffer as current buffer after executing its
BODY.
| -rw-r--r-- | CHANGELOG.md | 1 | ||||
| -rw-r--r-- | perspective.el | 7 |
2 files changed, 8 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index d830157..20cae94 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -50,6 +50,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### Fixed +- `persp-remove-buffer`: force update the `current-buffer` to the current window's buffer due to `with-selected-window` saving/restoring the `current-buffer` when executing it's BODY. This properly updates the `current-buffer` to what should be the real current buffer when burying the current buffer. - `persp-activate`: force update the `current-buffer` to the current window's buffer due to `make-persp` saving/restoring the `current-buffer` when executing it's BODY. This properly updates the `current-buffer` to what should be the real current buffer when switching to a new perspective. - `persp-add-buffer`: discard unexisting buffer as argument. - Added a workaround for potential problems caused by recursive minibuffer use. diff --git a/perspective.el b/perspective.el index 3eb6374..784bab2 100644 --- a/perspective.el +++ b/perspective.el @@ -860,12 +860,19 @@ See also `persp-switch' and `persp-add-buffer'." ((get-buffer-window buffer) (let ((window (get-buffer-window buffer))) (while 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. (with-selected-window window (bury-buffer)) (let ((new-window (get-buffer-window buffer))) ;; If `window' is still selected even after being buried, exit ;; the loop because otherwise it will go on infinitely. (setq window (unless (eq window new-window) new-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)))) (defun persp-kill (name) |
