aboutsummaryrefslogtreecommitdiff
path: root/perspective.el
diff options
context:
space:
mode:
authorConstantine Vetoshev <gepardcv@gmail.com>2021-03-06 11:32:50 -0800
committerConstantine Vetoshev <gepardcv@gmail.com>2021-03-06 11:32:50 -0800
commit0a0cd16d480b310067a3347a8d794b8499b47d61 (patch)
treeacab92f0d29857b1c45d490fbee4e7217e80c7bb /perspective.el
parent37f962cddb2f39a596505355e2fa1709a575e7e3 (diff)
Add error reporting to persp-switch-by-number.
Diffstat (limited to 'perspective.el')
-rw-r--r--perspective.el11
1 files 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."