From f94b098b341fb814e08c68494fb861aa88edd650 Mon Sep 17 00:00:00 2001 From: Trevor Richards Date: Sat, 30 Jul 2022 07:11:21 -0700 Subject: [PATCH] * mood-line.el: Changed mode-line segment control flow I realized while doing other things that I had convoluted the the generation of the modeline needlessly with my modal implementation. By moving my modal tests into a cond form and simply shuffling `mode-line-segment-modified', we get a cleaner, simpler implementation. --- mood-line.el | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/mood-line.el b/mood-line.el index a4cdbfe..93a4cae 100644 --- a/mood-line.el +++ b/mood-line.el @@ -348,10 +348,10 @@ The `Face' may be either a face symbol or a property list of key-value pairs mood-line-meow-state-alist))) (concat (propertize (car mode-cons) 'face (cdr mode-cons)) " ")))) -(defun mood-line--modal-editing-p () - "Determine if modal editing is being used." - (or (bound-and-true-p evil-mode) - (bound-and-true-p meow-mode))) +(defun mood-line-segment-modal () + "Call the correct mode-line segment when the first modal-mode is found." + (cond ((bound-and-true-p evil-mode) (mood-line-segment-evil)) + ((bound-and-true-p meow-mode) (mood-line-segment-meow)))) ;; ;; Activation function @@ -393,15 +393,9 @@ The `Face' may be either a face symbol or a property list of key-value pairs ;; Left (format-mode-line '(" " - (:eval (if (mood-line--modal-editing-p) - (progn - (mood-line-segment-evil) - (mood-line-segment-meow)) - (mood-line-segment-modified))) + (:eval (mood-line-segment-modal)) + (:eval (mood-line-segment-modified)) (:eval (mood-line-segment-buffer-name)) - (:eval (if (mood-line--modal-editing-p) - (concat - (mood-line-segment-modified) " "))) (:eval (mood-line-segment-anzu)) (:eval (mood-line-segment-multiple-cursors)) (:eval (mood-line-segment-position))))