new public function get-window-by-number
This commit is contained in:
parent
b80f9ce36c
commit
ea0f538005
|
@ -107,10 +107,8 @@ Has effect only when `window-numbering-frame-scope' is not 'frame-local."
|
||||||
(defvar window-numbering--frames-table nil
|
(defvar window-numbering--frames-table nil
|
||||||
"table -> (window vector . number table)")
|
"table -> (window vector . number table)")
|
||||||
|
|
||||||
(defun select-window-by-number (i &optional arg)
|
(defun get-window-by-number (i)
|
||||||
"Select window given number I by `window-numbering-mode'.
|
"Return window numbered I if exists."
|
||||||
If prefix ARG is given, delete the window instead of selecting it."
|
|
||||||
(interactive "P")
|
|
||||||
(let ((windows (if (eq window-numbering-frame-scope 'frame-local)
|
(let ((windows (if (eq window-numbering-frame-scope 'frame-local)
|
||||||
(car (gethash (selected-frame)
|
(car (gethash (selected-frame)
|
||||||
window-numbering--frames-table))
|
window-numbering--frames-table))
|
||||||
|
@ -118,11 +116,18 @@ If prefix ARG is given, delete the window instead of selecting it."
|
||||||
window)
|
window)
|
||||||
(if (and (>= i 0) (< i 10)
|
(if (and (>= i 0) (< i 10)
|
||||||
(setq window (aref windows i)))
|
(setq window (aref windows i)))
|
||||||
(if arg
|
window
|
||||||
(delete-window window)
|
|
||||||
(window-numbering-switch-to-window window))
|
|
||||||
(error "No window numbered %s" i))))
|
(error "No window numbered %s" i))))
|
||||||
|
|
||||||
|
(defun select-window-by-number (i &optional arg)
|
||||||
|
"Select window given number I by `window-numbering-mode'.
|
||||||
|
If prefix ARG is given, delete the window instead of selecting it."
|
||||||
|
(interactive "P")
|
||||||
|
(let ((w (get-window-by-number i)))
|
||||||
|
(if arg
|
||||||
|
(delete-window w)
|
||||||
|
(window-numbering-switch-to-window w))))
|
||||||
|
|
||||||
;; define interactive functions for keymap
|
;; define interactive functions for keymap
|
||||||
(dotimes (i 10)
|
(dotimes (i 10)
|
||||||
(eval `(defun ,(intern (format "select-window-%s" i)) (&optional arg)
|
(eval `(defun ,(intern (format "select-window-%s" i)) (&optional arg)
|
||||||
|
|
Loading…
Reference in a new issue