From 10e4dd428794f4c65e602f48051b7bd71b12caaf Mon Sep 17 00:00:00 2001 From: Matthew White Date: Fri, 30 Jul 2021 21:17:13 +0000 Subject: persp-add-buffer: discard unexisting buffer as argument Do not accept unexisting buffers as argument. If the buffer doesn't exist or was killed, discard it and display a reminder. --- CHANGELOG.md | 1 + perspective.el | 12 +++++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a14562b..de41f4c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -42,6 +42,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### Fixed +- `persp-add-buffer`: discard unexisting buffer as argument. - Added a workaround for potential problems caused by recursive minibuffer use. diff --git a/perspective.el b/perspective.el index cf2e06b..9cdb23a 100644 --- a/perspective.el +++ b/perspective.el @@ -777,17 +777,19 @@ create a new main perspective and return \"main\"." :point-marker (point-marker))) persp-initial-frame-name))) -(defun persp-add-buffer (buffer) - "Associate BUFFER with the current perspective. +(defun persp-add-buffer (buffer-or-name) + "Associate BUFFER-OR-NAME with the current perspective. See also `persp-switch' and `persp-remove-buffer'." (interactive (list (let ((read-buffer-function nil)) (read-buffer "Add buffer to perspective: ")))) - (let ((buffer (get-buffer buffer))) - (unless (persp-is-current-buffer buffer) - (push buffer (persp-current-buffers))))) + (let ((buffer (get-buffer buffer-or-name))) + (if (not (buffer-live-p buffer)) + (message "buffer %s doesn't exist" buffer-or-name) + (unless (persp-is-current-buffer buffer) + (push buffer (persp-current-buffers)))))) (defun persp-set-buffer (buffer-name) "Associate BUFFER-NAME with the current perspective and remove it from any other." -- cgit v1.0