From 0a0cd16d480b310067a3347a8d794b8499b47d61 Mon Sep 17 00:00:00 2001 From: Constantine Vetoshev Date: Sat, 6 Mar 2021 11:32:50 -0800 Subject: Add error reporting to persp-switch-by-number. --- perspective.el | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/perspective.el b/perspective.el index ae79c89..93c9731 100644 --- a/perspective.el +++ b/perspective.el @@ -667,8 +667,15 @@ If NORECORD is non-nil, do not update the (defun persp-switch-by-number (num) "Switch to the perspective given by NUMBER." - (interactive "NEnter perspective number") - (persp-switch (nth (- num 1) (persp-names)))) + (interactive "NSwitch to perspective number: ") + (let* ((persps (persp-names)) + (max-persps (length persps))) + (if (<= num max-persps) + (persp-switch (nth (- num 1) persps)) + (message "Perspective %s not available, there are only %s" num max-persps))) + ;; XXX: Have to force the modestring to update in this case, since the call + ;; inside persp-switch happens too early. + (persp-update-modestring)) (defun persp-activate (persp) "Activate the perspective given by the persp struct PERSP." -- cgit v1.0