From 6f0c4517991e6fc714995882b2ff857b58cddfa8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20de=20Beauch=C3=AAne?= Date: Wed, 7 Nov 2018 01:40:30 +0100 Subject: [PATCH] put mode-line segment into a variable --- winum.el | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/winum.el b/winum.el index c9444f4..ad63cef 100644 --- a/winum.el +++ b/winum.el @@ -404,6 +404,8 @@ WINDOW: if specified, the window of which we want to know the number. (remove-hook 'window-configuration-change-hook 'winum--update) (setq winum--frames-table nil)) +(defvar winum--mode-line-segment '(:eval (winum-get-number-string))) + (defun winum--install-mode-line (&optional position) "Install the window number from `winum-mode' to the mode-line. POSITION: position in the mode-line." @@ -412,8 +414,8 @@ POSITION: position in the mode-line." (dotimes (i (min (or position winum-mode-line-position 1) (length mode-line))) (push (pop mode-line) res)) - (unless (equal (car mode-line) '(:eval (winum-get-number-string))) - (push '(:eval (winum-get-number-string)) res)) + (unless (equal (car mode-line) winum--mode-line-segment) + (push winum--mode-line-segment res)) (while mode-line (push (pop mode-line) res)) (setq-default mode-line-format (nreverse res))) @@ -425,7 +427,7 @@ POSITION: position in the mode-line." (res)) (while mode-line (let ((item (car mode-line))) - (unless (equal item '(:eval (winum-get-number-string))) + (unless (equal item winum--mode-line-segment) (push item res))) (pop mode-line)) (setq-default mode-line-format (nreverse res)))