diff options
| author | gcv <gepardcv@gmail.com> | 2019-10-10 09:58:00 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-10-10 09:58:00 -0700 |
| commit | 2e6f76192b192b4e3a3c070f69e6c467401190c1 (patch) | |
| tree | 42e1ec7b847e588420bd484a5c37c3717ec0022e | |
| parent | ecf9daef95d37359ccbc31e9fb093ae5c714c3b4 (diff) | |
| parent | 5c9f1d573f02567ed5f281e864a34b4503f4be87 (diff) | |
Merge pull request #81 from gcv/fix-persp-rename-scratch
Rename perspective-specific scratch buffer when perspective is renamed
| -rw-r--r-- | perspective.el | 8 | ||||
| -rw-r--r-- | test/test-perspective.el | 8 |
2 files changed, 16 insertions, 0 deletions
diff --git a/perspective.el b/perspective.el index b0d0b0d..ad7ea80 100644 --- a/perspective.el +++ b/perspective.el @@ -683,6 +683,14 @@ perspective and no others are killed." (interactive "sNew name: ") (if (gethash name (perspectives-hash)) (persp-error "Perspective `%s' already exists" name) + ;; rename the perspective-specific *scratch* buffer + (let* ((old-scratch-name (format "*scratch* (%s)" (persp-name (persp-curr)))) + (new-scratch-name (format "*scratch* (%s)" name)) + (scratch-buffer (get-buffer old-scratch-name))) + (when scratch-buffer + (with-current-buffer scratch-buffer + (rename-buffer new-scratch-name)))) + ;; rewire the rest of the perspective inside its data structures (remhash (persp-name (persp-curr)) (perspectives-hash)) (puthash name (persp-curr) (perspectives-hash)) (setf (persp-name (persp-curr)) name) diff --git a/test/test-perspective.el b/test/test-perspective.el index fddc8fa..5069cb8 100644 --- a/test/test-perspective.el +++ b/test/test-perspective.el @@ -245,4 +245,12 @@ persp-test-make-sample-environment." (lambda (w) (should-not (memq (window-buffer w) (list A1 A2)))))))) +(ert-deftest issue-81-renaming-scratch-buffers () + (persp-test-with-persp + (persp-switch "A") + (should (get-buffer "*scratch* (A)")) + (persp-rename "B") + (should (not (get-buffer "*scratch* (A)"))) + (should (get-buffer "*scratch* (B)")))) + ;;; test-perspective.el ends here |
