diff options
| author | Constantine Vetoshev <gepardcv@gmail.com> | 2021-03-06 11:32:50 -0800 |
|---|---|---|
| committer | Constantine Vetoshev <gepardcv@gmail.com> | 2021-03-06 11:32:50 -0800 |
| commit | 0a0cd16d480b310067a3347a8d794b8499b47d61 (patch) | |
| tree | acab92f0d29857b1c45d490fbee4e7217e80c7bb | |
| parent | 37f962cddb2f39a596505355e2fa1709a575e7e3 (diff) | |
Add error reporting to persp-switch-by-number.
| -rw-r--r-- | perspective.el | 11 |
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." |
