diff options
| -rw-r--r-- | CHANGELOG.md | 1 | ||||
| -rw-r--r-- | perspective.el | 15 |
2 files changed, 9 insertions, 7 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 6f5399e..6e1e163 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -64,6 +64,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### Fixed +- `persp-new`: do not recreate existing perspectives. This prevents from resetting perspectives to a state where in the perspective there's only the scratch buffer. - `persp-reset-windows`: set `switch-to-buffer-preserve-window-point` to `nil` before calling `delete-window`, that up to Emacs 27.2 updates `window-prev-buffers` of all windows, unless the former is turned off. - `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. diff --git a/perspective.el b/perspective.el index addc909..2ea7ec1 100644 --- a/perspective.el +++ b/perspective.el @@ -551,15 +551,16 @@ window-side creating perspectives." (delete-window)))) (defun persp-new (name) - "Return a new perspective with name NAME. + "Return a perspective named NAME, or create a new one if missing. The new perspective will start with only an `initial-major-mode' buffer called \"*scratch* (NAME)\"." - (make-persp :name name - (switch-to-buffer (persp-scratch-buffer name)) - (funcall initial-major-mode) - (when initial-scratch-message - (insert initial-scratch-message)) - (persp-reset-windows))) + (or (gethash name (perspectives-hash)) + (make-persp :name name + (switch-to-buffer (persp-scratch-buffer name)) + (funcall initial-major-mode) + (when initial-scratch-message + (insert initial-scratch-message)) + (persp-reset-windows)))) (defun persp-reactivate-buffers (buffers) "Raise BUFFERS to the top of the most-recently-selected list. |
