simplify the code using winum--get-[window-vector|numbers-table]

This commit is contained in:
deb0ch 2016-12-26 19:38:36 +01:00
parent 6afa4aa0da
commit 4970e27a18

View file

@ -314,14 +314,8 @@ PREFIX must be a key sequence, like the ones returned by `kbd'."
;;;###autoload ;;;###autoload
(defun winum-get-window-by-number (n) (defun winum-get-window-by-number (n)
"Return window numbered N if exists, nil otherwise." "Return window numbered N if exists, nil otherwise."
(let ((windows (if (eq winum-scope 'frame-local) (when (>= n 0) (< n (1+ winum--window-count))
(car (gethash (selected-frame) winum--frames-table)) (aref (winum--get-window-vector) n)))
winum--window-vector))
window)
(if (and (>= n 0) (< n (1+ winum--window-count))
(setq window (aref windows n)))
window
nil)))
;;;###autoload ;;;###autoload
(defun winum-get-number-string (&optional window) (defun winum-get-number-string (&optional window)
@ -339,9 +333,7 @@ WINDOW: if specified, the window of which we want to know the number.
If not specified, the number of the currently selected window is If not specified, the number of the currently selected window is
returned." returned."
(let ((w (or window (selected-window)))) (let ((w (or window (selected-window))))
(if (eq winum-scope 'frame-local) (gethash w (winum--get-numbers-table))))
(gethash w (cdr (gethash (selected-frame) winum--frames-table)))
(gethash w winum--numbers-table))))
;; Internal functions ---------------------------------------------------------- ;; Internal functions ----------------------------------------------------------