Skip to content

Commit

Permalink
Add persp-kill-other-buffers.
Browse files Browse the repository at this point in the history
  • Loading branch information
gcv committed Apr 14, 2024
1 parent 460311b commit ec48cb3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- `persp-ibuffer-generate-filter-groups`: load `ibuf-ext` library if needed ([#202](https://github.com/nex3/perspective-el/issues/202)).


### Added

- `persp-kill-other-buffers`: kill other buffers in the current perspectives.


## [2.18] — 2022-09-20

### Added
Expand Down
13 changes: 13 additions & 0 deletions perspective.el
Original file line number Diff line number Diff line change
Expand Up @@ -1605,6 +1605,19 @@ PERSP-SET-IDO-BUFFERS)."
(buffer-name (current-buffer))))))
(kill-buffer buffer-or-name))

;; Buffer killing integration: kill all buffers in the current perspective
;; except the current one and the perspective's scratch buffer.
;;;###autoload
(defun persp-kill-other-buffers ()
"Kill all buffers in the current perspective other than the current one.
Also excludes the perspective's scratch buffer."
(interactive)
(when (y-or-n-p "Are you sure you want to kill all buffers in the current perspective except the current buffer? ")
(cl-loop for buf in (persp-current-buffers)
unless (or (eq buf (current-buffer))
(eq buf (get-buffer (persp-scratch-buffer))))
do (kill-buffer buf))))

;; Buffer switching integration: buffer-menu.
;;;###autoload
(defun persp-buffer-menu (arg)
Expand Down

0 comments on commit ec48cb3

Please sign in to comment.