aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md2
-rw-r--r--perspective.el7
2 files changed, 9 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index cb36d36..7d59408 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -43,6 +43,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
### Added
+- `persp-switch-to-scratch-buffer`: interactive function to switch to the current perspective's scratch buffer, creating one if missing.
- `persp-get-scratch-buffer`: utility function to properly get/create a scratch buffer.
- `persp-forget-buffer`: disassociate buffer with perspective without the risk of killing it. This balances `persp-add-buffer`. Newly created buffers via `get-buffer-create` are rogue buffers not found in any perspective, this function allows to get back to that state.
- `persp-maybe-kill-buffer`: designed as `kill-buffer-query-functions` hook to keep a perspective's last left buffer from being killed.
@@ -52,6 +53,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
### Changed
+- `perspective-map`: Add binding `C-x x B` to call `persp-switch-to-scratch-buffer`.
- `persp-other-buffer`: call `persp-get-scratch-buffer` to get/create a scratch buffer.
- `persp-new`: call `persp-get-scratch-buffer` to get/create a scratch buffer.
- `persp-switch`: remove duplicated code. It's now possible to call `persp-new` either to get an existing perspective or to create a new one.
diff --git a/perspective.el b/perspective.el
index 0b27c7e..2939281 100644
--- a/perspective.el
+++ b/perspective.el
@@ -233,6 +233,12 @@ Create it if the current perspective doesn't have one yet."
(set-buffer-modified-p nil))))
scratch-buffer))
+(defun persp-switch-to-scratch-buffer ()
+ "Switch to the current perspective's scratch buffer.
+Create the scratch buffer if there isn't one yet."
+ (interactive)
+ (switch-to-buffer (persp-get-scratch-buffer)))
+
(defalias 'persp-killed-p 'persp-killed
"Return whether the perspective CL-X has been killed.")
@@ -308,6 +314,7 @@ Run with the activated perspective active.")
(define-key perspective-map (kbd "a") 'persp-add-buffer)
(define-key perspective-map (kbd "A") 'persp-set-buffer)
(define-key perspective-map (kbd "b") 'persp-switch-to-buffer)
+(define-key perspective-map (kbd "B") 'persp-switch-to-scratch-buffer)
(define-key perspective-map (kbd "i") 'persp-import)
(define-key perspective-map (kbd "n") 'persp-next)
(define-key perspective-map (kbd "<right>") 'persp-next)