aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew White <mehw.is.me@inventati.org>2021-08-27 01:44:09 +0000
committerMatthew White <mehw.is.me@inventati.org>2021-10-21 01:27:37 +0200
commit18634f6dce7ceed1fb1fc930ebce2e417a0aefa2 (patch)
tree360b4fb23ee0febac6fa00c5b5f47cb86e627083
parent7d5cde4ad48980fd0757375480e39b53c03771d4 (diff)
persp-switch: remove duplicated code
Use 'persp-new' directly to get an existing perspective, or to create a new one.
-rw-r--r--CHANGELOG.md1
-rw-r--r--perspective.el4
2 files changed, 2 insertions, 3 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6e1e163..7f4ba3c 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/).
### Changed
+- `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.
- `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.
diff --git a/perspective.el b/perspective.el
index 2ea7ec1..bd69343 100644
--- a/perspective.el
+++ b/perspective.el
@@ -690,10 +690,8 @@ If NORECORD is non-nil, do not update the
(unless (persp-valid-name-p name)
(setq name (persp-prompt (and (persp-last) (persp-name (persp-last))))))
(if (and (persp-curr) (equal name (persp-current-name))) name
- (let ((persp (gethash name (perspectives-hash))))
+ (let ((persp (persp-new name)))
(set-frame-parameter nil 'persp--last (persp-curr))
- (when (null persp)
- (setq persp (persp-new name)))
(unless norecord
(run-hooks 'persp-before-switch-hook))
(persp-activate persp)