fix select-window-0-or-10

This commit is contained in:
deb0ch 2016-12-04 20:41:43 +01:00
parent b862a0243c
commit e9f3e96892

View file

@ -135,12 +135,11 @@ numbers in the mode-line.")
(winum--init) (winum--init)
(winum--deinit))) (winum--deinit)))
;; TODO test select-window-0-or-10
(defun select-window-0-or-10 (&optional arg) (defun select-window-0-or-10 (&optional arg)
"Jump to window 0 if assigned or 10 if exists. "Jump to window 0 if assigned or 10 if exists.
If prefix ARG is given, delete the window instead of selecting it." If prefix ARG is given, delete the window instead of selecting it."
(interactive "P") (interactive "P")
(let ((n (if (winum-get-number 0) (let ((n (if (winum-get-window-by-number 0)
(if arg '- 0) (if arg '- 0)
(if arg -10 10)))) (if arg -10 10))))
(select-window-by-number n))) (select-window-by-number n)))
@ -237,7 +236,7 @@ There are several ways to provide the number:
(if (and (>= n 0) (< n (1+ winum--window-count)) (if (and (>= n 0) (< n (1+ winum--window-count))
(setq window (aref windows n))) (setq window (aref windows n)))
window window
(error "No window numbered %s" n)))) nil)))
;;;###autoload ;;;###autoload
(defun winum-get-number-string (&optional window) (defun winum-get-number-string (&optional window)
@ -356,9 +355,6 @@ POSITION: position in the mode-line."
winum--frames-table) winum--frames-table)
(setq winum--window-vector (make-vector (1+ winum--window-count) nil)) (setq winum--window-vector (make-vector (1+ winum--window-count) nil))
(clrhash winum--numbers-table)) (clrhash winum--numbers-table))
(when (and winum-auto-assign-0-to-minibuffer
(active-minibuffer-window))
(winum--assign (active-minibuffer-window) 0))
(when winum-assign-func (when winum-assign-func
(mapc (lambda (w) (mapc (lambda (w)
(with-selected-window w (with-selected-window w
@ -367,6 +363,10 @@ POSITION: position in the mode-line."
(when num (when num
(winum--assign w num)))))) (winum--assign w num))))))
windows)) windows))
(when (and winum-auto-assign-0-to-minibuffer
(active-minibuffer-window)
(not (winum-get-window-by-number 0)))
(winum--assign (active-minibuffer-window) 0))
(dolist (w windows) (dolist (w windows)
(winum--assign w)))) (winum--assign w))))
@ -377,8 +377,8 @@ If NUMBER is not specified, determine it first based on
Returns the assigned number, or nil on error." Returns the assigned number, or nil on error."
(if number (if number
(if (aref (winum--get-window-vector) number) (if (aref (winum--get-window-vector) number)
(progn (message "Number %s assigned to two buffers (%s and %s)" (progn (message "Number %s already assigned to %s, can't assign to %s"
number window (aref winum--window-vector number)) number (aref winum--window-vector number) window)
nil) nil)
(setf (aref (winum--get-window-vector) number) window) (setf (aref (winum--get-window-vector) number) window)
(puthash window number (winum--get-numbers-table)) (puthash window number (winum--get-numbers-table))
@ -456,7 +456,6 @@ using the `winum-assign-func', or using `winum-auto-assign-0-to-minibuffer'."
(select-window window) (select-window window)
(error "Got a dead window %S" window)))) (error "Got a dead window %S" window))))
(push "^No window numbered .$" debug-ignored-errors)
(push "^Got a dead window .$" debug-ignored-errors) (push "^Got a dead window .$" debug-ignored-errors)
(push "^Invalid `winum-scope': .$" debug-ignored-errors) (push "^Invalid `winum-scope': .$" debug-ignored-errors)