From 87aaccbc70e6869acb220c08c3a5aee01d899813 Mon Sep 17 00:00:00 2001 From: deb0ch Date: Sun, 4 Dec 2016 09:34:57 +0100 Subject: [PATCH] select-window-by-number: the negative prefix deletes window 0 --- winum.el | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/winum.el b/winum.el index d331a7b..02e624b 100644 --- a/winum.el +++ b/winum.el @@ -134,19 +134,21 @@ return a number to have it assigned to the current-window, nil otherwise." ;; TODO figure out a way of deleting window 0 ;; -> maybe the negative argument alone could delete window 0 instead of ;; the current window ? + +;; 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. 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. - if called interactively with a numeric prefix argument, use it. -- if prefix argument is the negative argument, delete the window. +- if prefix argument is the negative argument, delete window 0. - if called interactively and no valid argument is provided, read from minibuffer." (interactive "P") (let* ((n (cond ((integerp arg) arg) - ((eq arg '-) (- (winum-get-number))) ; negative-argument + ((eq arg '-) 0) ; negative-argument (arg (winum-get-number)) ((called-interactively-p 'any) (let ((user-input-str (read-from-minibuffer "Window: "))) @@ -155,7 +157,7 @@ There are several ways to provide the number: (string-to-number user-input-str)))) (t (winum-get-number)))) (w (winum-get-window-by-number (abs n))) - (delete (> 0 n))) + (delete (or (eq arg '-) (> 0 n)))) (if delete (delete-window w) (winum--switch-to-window w))))