Rerun initialization when scope changes at runtime.
This commit is contained in:
parent
8e886302c7
commit
e950370d82
17
winum.el
17
winum.el
|
@ -39,8 +39,6 @@
|
||||||
;;
|
;;
|
||||||
;;; Code:
|
;;; Code:
|
||||||
;;
|
;;
|
||||||
;; FIXME: when `winum-scope' is changed from frame-local to non-local in
|
|
||||||
;; customize, the mode-line is messed up until next `winum-update'.
|
|
||||||
;; FIXME: The mode-line's window number is not always up to date in all frames.
|
;; FIXME: The mode-line's window number is not always up to date in all frames.
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
@ -171,6 +169,10 @@ To get a number given a window, use the `cdr' of a value.
|
||||||
|
|
||||||
Such a structure allows for per-frame bidirectional fast access.")
|
Such a structure allows for per-frame bidirectional fast access.")
|
||||||
|
|
||||||
|
(defvar winum--last-used-scope winum-scope
|
||||||
|
"Tracks the last used `winum-scope'.
|
||||||
|
Needed to detect scope changes at runtime.")
|
||||||
|
|
||||||
;; Interactive functions -------------------------------------------------------
|
;; Interactive functions -------------------------------------------------------
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
|
@ -479,6 +481,7 @@ windows, however a higher number can be reserved by the user-defined
|
||||||
|
|
||||||
(defun winum--set-window-vector (window-vector)
|
(defun winum--set-window-vector (window-vector)
|
||||||
"Set WINDOW-VECTOR according to the current `winum-scope'."
|
"Set WINDOW-VECTOR according to the current `winum-scope'."
|
||||||
|
(winum--check-for-scope-change)
|
||||||
(if (eq winum-scope 'frame-local)
|
(if (eq winum-scope 'frame-local)
|
||||||
(puthash (selected-frame)
|
(puthash (selected-frame)
|
||||||
(cons window-vector
|
(cons window-vector
|
||||||
|
@ -489,6 +492,7 @@ windows, however a higher number can be reserved by the user-defined
|
||||||
(defun winum--get-window-vector ()
|
(defun winum--get-window-vector ()
|
||||||
"Return the window vector used to get a window given a number.
|
"Return the window vector used to get a window given a number.
|
||||||
This vector is not stored the same way depending on the value of `winum-scope'."
|
This vector is not stored the same way depending on the value of `winum-scope'."
|
||||||
|
(winum--check-for-scope-change)
|
||||||
(if (eq winum-scope 'frame-local)
|
(if (eq winum-scope 'frame-local)
|
||||||
(car (gethash (selected-frame) winum--frames-table))
|
(car (gethash (selected-frame) winum--frames-table))
|
||||||
winum--window-vector))
|
winum--window-vector))
|
||||||
|
@ -497,6 +501,7 @@ This vector is not stored the same way depending on the value of `winum-scope'."
|
||||||
"Return the numbers hashtable used to get a number given a window.
|
"Return the numbers hashtable used to get a number given a window.
|
||||||
This hashtable is not stored the same way depending on the value of
|
This hashtable is not stored the same way depending on the value of
|
||||||
`winum-scope'"
|
`winum-scope'"
|
||||||
|
(winum--check-for-scope-change)
|
||||||
(if (eq winum-scope 'frame-local)
|
(if (eq winum-scope 'frame-local)
|
||||||
(cdr (gethash (selected-frame) winum--frames-table))
|
(cdr (gethash (selected-frame) winum--frames-table))
|
||||||
winum--numbers-table))
|
winum--numbers-table))
|
||||||
|
@ -520,6 +525,14 @@ 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))))
|
||||||
|
|
||||||
|
(defun winum--check-for-scope-change ()
|
||||||
|
"Check whether the `winum-scope' has been changed.
|
||||||
|
If a change is detected run `winum--init' to reinitialize all
|
||||||
|
internal data structures according to the new scope."
|
||||||
|
(unless (eq winum-scope winum--last-used-scope)
|
||||||
|
(setq winum--last-used-scope winum-scope)
|
||||||
|
(winum--init)))
|
||||||
|
|
||||||
(push "^No window numbered .$" debug-ignored-errors)
|
(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)
|
||||||
|
|
Loading…
Reference in a new issue