From f45c6ea0072f247556db1914d775a8ae38c774b9 Mon Sep 17 00:00:00 2001 From: deb0ch Date: Mon, 5 Dec 2016 15:00:31 +0100 Subject: [PATCH] fix bug when using select-window-by-number on nonexistent window --- winum.el | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/winum.el b/winum.el index 3ec9a21..66093a7 100644 --- a/winum.el +++ b/winum.el @@ -195,9 +195,8 @@ If prefix ARG is given, delete the window instead of selecting it." (interactive "P") (select-window-by-number (if arg -9 9))) -;; TODO test negative argument should delete window 0 (defun select-window-by-number (&optional arg) - "Select or delete window iwhich number is specified by ARG. + "Select or delete window which number is specified by ARG. If the number is negative, delete the window instead of selecting it. There are several ways to provide the number: - if called from elisp with an argument, use it. @@ -218,13 +217,15 @@ There are several ways to provide the number: (t (winum-get-number)))) (w (winum-get-window-by-number (abs n))) (delete (or (eq arg '-) (> 0 n)))) - (if delete - (delete-window w) - (winum--switch-to-window w)))) + (if w + (if delete + (delete-window w) + (winum--switch-to-window w)) + (error "No window numbered %d" n)))) ;;;###autoload (defun winum-get-window-by-number (n) - "Return window numbered N if exists." + "Return window numbered N if exists, nil otherwise." (let ((windows (if (eq winum-scope 'frame-local) (car (gethash (selected-frame) winum--frames-table)) winum--window-vector)) @@ -449,6 +450,7 @@ using the `winum-assign-func', or using `winum-auto-assign-0-to-minibuffer'." (select-window window) (error "Got a dead window %S" window)))) +(push "^No window numbered .$" debug-ignored-errors) (push "^Got a dead window .$" debug-ignored-errors) (push "^Invalid `winum-scope': .$" debug-ignored-errors)