Skip to content

Commit

Permalink
persp-maybe-kill-buffer-adv: force update current-buffer
Browse files Browse the repository at this point in the history
Due to 'persp-maybe-kill-buffer' amendments, force update the
'current-buffer' to the current window's buffer after calling
'kill-buffer'.
  • Loading branch information
mehw committed Dec 2, 2021
1 parent 0032493 commit 4b0ef93
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

### Changed

- `persp-mode`: when enabling the mode, activate `persp-maybe-kill-buffer-adv`.
- `persp-maybe-kill-buffer-adv`: due to `persp-maybe-kill-buffer` amendments, after calling `kill-buffer` force update the `current-buffer` to the current window's buffer.
- `persp-maybe-kill-buffer`: remove buffers directly accessing the frame's hash table for performance reasons.
- `persp-maybe-kill-buffer`: read perspectives' buffers directly accessing the frame's hash table for performance reasons.
- `persp-maybe-kill-buffer`: implement `persp-feature-flag-directly-kill-ido-ignore-buffers`.
Expand Down
8 changes: 8 additions & 0 deletions perspective.el
Original file line number Diff line number Diff line change
Expand Up @@ -1200,6 +1200,13 @@ is non-nil or with prefix arg, don't switch to the new perspective."
(persp-update-modestring)
(persp-activate persp))))

(defadvice kill-buffer (after persp-maybe-kill-buffer-adv)
"Force set the `current-buffer' to the window's buffer.
See also `persp-maybe-kill-buffer'."
(persp-protect
(set-buffer (window-buffer))))

(defadvice switch-to-buffer (after persp-add-buffer-adv)
"Add BUFFER to the current perspective.
Expand Down Expand Up @@ -1289,6 +1296,7 @@ named collections of buffers and window configurations."
(setq persp-started-after-server-mode t))
;; TODO: Convert to nadvice, which has been available since 24.4 and is
;; the earliest Emacs version Perspective supports.
(ad-activate 'kill-buffer)
(ad-activate 'switch-to-buffer)
(ad-activate 'display-buffer)
(ad-activate 'set-window-buffer)
Expand Down

0 comments on commit 4b0ef93

Please sign in to comment.