From f7b05bd41494ae2d6013ce5bd770a87d580c58a5 Mon Sep 17 00:00:00 2001 From: Constantine Vetoshev Date: Mon, 25 Feb 2019 11:09:01 -0800 Subject: Rename perspective-specific scratch buffer with perspective. --- perspective.el | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/perspective.el b/perspective.el index 97d1a9f..1729e20 100644 --- a/perspective.el +++ b/perspective.el @@ -682,6 +682,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) -- cgit v1.0 From 5c9f1d573f02567ed5f281e864a34b4503f4be87 Mon Sep 17 00:00:00 2001 From: Constantine Vetoshev Date: Fri, 27 Sep 2019 13:40:38 -0700 Subject: Add a test. --- test/test-perspective.el | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/test-perspective.el b/test/test-perspective.el index 1114460..145db6c 100644 --- a/test/test-perspective.el +++ b/test/test-perspective.el @@ -69,4 +69,12 @@ (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 -- cgit v1.0