refactor: use convenience macro in winum config

This commit is contained in:
Kiana Sheibani 2024-11-14 00:54:29 -05:00
parent cfd5a1c458
commit 2978acd30c
Signed by: toki
GPG key ID: 6CB106C25E86A9F7
2 changed files with 8 additions and 13 deletions

View file

@ -2421,19 +2421,13 @@ With the basic config out of the way, we can implement popup-aware numbering by
(after! winum (after! winum
(defun ~/winum-auto-assign (windows) (defun ~/winum-auto-assign (windows)
"Assign indices to windows, handling popup windows separately." "Assign indices to windows, handling popup windows separately."
(let ((index 1) (popup-index 1)) (let ((index 1) (popup-index '(popup . 1)))
(dolist (w windows) (dolist (w windows)
(if (+popup-window-p w) (if (+popup-window-p w)
(progn (winum--assign-unique
(while (member (cons 'popup popup-index) w popup-index t
winum--assigned-indices) (cons 'popup-index (1+ (cdr popup-index))))
(setq popup-index (1+ popup-index))) (winum--assign-unique w index t)))))
(winum--assign w (cons 'popup popup-index))
(setq popup-index (1+ popup-index)))
(while (member index winum--assigned-indices)
(setq index (1+ index)))
(winum--assign w index)
(setq index (1+ index))))))
(setq winum-auto-assign-function #'~/winum-auto-assign)) (setq winum-auto-assign-function #'~/winum-auto-assign))
#+end_src #+end_src
@ -2467,7 +2461,8 @@ If prefix ARG is given, delete the window instead of selecting it." n)
"Jump to popup window 0, or popup 10 if 0 is not assigned. "Jump to popup window 0, or popup 10 if 0 is not assigned.
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-window-by-index '(popup . 0)) '(popup . 0) '(popup . 10)))) (let ((n (if (winum-get-window-by-index '(popup . 0))
'(popup . 0) '(popup . 10))))
(if arg (if arg
(winum-delete-window-by-index n) (winum-delete-window-by-index n)
(winum-select-window-by-index n)))) (winum-select-window-by-index n))))

@ -1 +1 @@
Subproject commit aca0f74f3a442b1b1a6f4315303c340f7c1005b8 Subproject commit efa0aedb7c4c03fb287210cd248f5fad8d4442c9