 
 ;;; Code:
 
-(defgroup modeline nil
+(defgroup seanmacs/modeline nil
   "A minimal modeline configuration inspired by doom-modeline."
   :group 'modeline)
 
-(defface modeline-status-mode
+(defface seanmacs/modeline-status-mode
   `((t (:inherit (font-lock-keyword-face))))
   "Face used for mode indicators in the modeline."
-  :group 'modeline)
-
-(defface modeline-status-vc
+  :group 'seanmacs/modeline)
+
+(defface seanmacs/modeline-status-vc
   `((t (:inherit (font-lock-builtin-face))))
   "Face used for vc indicators in the modeline."
-  :group 'modeline)
-
-(defface modeline-status-success
+  :group 'seanmacs/modeline)
+
+(defface seanmacs/modeline-status-success
   `((t (:inherit (success))))
   "Face used for success status indicators in the modeline."
-  :group 'modeline)
-
-(defface modeline-status-warning
+  :group 'seanmacs/modeline)
+
+(defface seanmacs/modeline-status-warning
   '((t (:inherit (warning))))
   "Face for warning status indicators in the modeline."
-  :group 'modeline)
-
-(defface modeline-status-error
+  :group 'seanmacs/modeline)
+
+(defface seanmacs/modeline-status-error
   '((t (:inherit (error))))
   "Face for error stauts indicators in the modeline."
-  :group 'modeline)
-
-(defun modeline-format (left right)
+  :group 'seanmacs/modeline)
+
+(defun seanmacs/modeline-format (left right)
+  "Format the modeling, aligning LEFT and RIGHT."
   (let ((reserve (length right)))
     (when (and (display-graphic-p) (eq 'right (get-scroll-bar-mode)))
       (setq reserve (- reserve 3)))

         "U ")
        (t "  ")))

(defun modeline-segment-buffer-name ()
  "Displays the name of the current buffer in the modeline."
  (propertize "%b " 'face 'mode-line-buffer-id))

(defun modeline-segment-dir ()
  "Display shortened working directory."
  (when default-directory
    (shrink-path-dirs default-directory)))

(defun modeline-segment-position ()
  "Displays the current cursor position in the modeline."
  (let ((fmt-string " %3l:%2c "))
    fmt-string))

(defun modeline-segment-buffer-percent ()
  "Displays the percentage of buffer above current point."
  (let ((fmt-string "%p%% "))
    fmt-string))

(defun modeline-segment-vc ()
  "Displays color-coded version control information in the modeline."
  (when modeline--vc-text
    (propertize modeline--vc-text 'face 'modeline-status-vc)))

(defun modeline-segment-major-mode ()
  "Displays the current major mode in the modeline."
  (propertize " %m" 'face 'modeline-status-mode))

(defun modeline-segment-flycheck ()
  "Displays color-coded flycheck information in the modeline (if available)."
  modeline--flycheck-text)

(defun modeline-segment-process ()
  "Displays the current value of `mode-line-process' in the modeline."
  (when mode-line-process
    (list mode-line-process)))

;;;###autoload
(define-minor-mode seanmacs/modeline-mode
  "Toggle modeline on or off."
  :group 'modeline
  :global t
  :lighter nil
  (if seanmacs/modeline-mode
      (progn

        ;; Setup flycheck hooks
        (add-hook 'flycheck-status-changed-functions #'modeline--update-flycheck-segment)
        (add-hook 'flycheck-mode-hook #'modeline--update-flycheck-segment)

        ;; Setup VC hooks
        (add-hook 'find-file-hook #'modeline--update-vc-segment)
        (add-hook 'after-save-hook #'modeline--update-vc-segment)
        (advice-add #'vc-refresh-state :after #'modeline--update-vc-segment)

        ;; Setup window update hooks
        (add-hook 'window-configuration-change-hook #'modeline--update-selected-window)
        (add-hook 'focus-in-hook #'modeline--update-selected-window)
        (advice-add #'handle-switch-frame :after #'modeline--update-selected-window)
        (advice-add #'select-window :after #'modeline--update-selected-window)

        ;; Set the new modeline-format
        (setq-default mode-line-format
                      '((:eval
                         (modeline-format
                          ;; Left
                          (format-mode-line
                           '((:eval (modeline-segment-position))
                             (:eval (modeline-segment-modified-or-readonly))
                             (:eval (modeline-segment-dir))
                             (:eval (modeline-segment-buffer-name))
                             (:eval (modeline-segment-buffer-percent))))

                          ;; Right
                          (format-mode-line
                           '((:eval (modeline-segment-flycheck))
                             (:eval (modeline-segment-vc))
                             (:eval (modeline-segment-major-mode))
                             (:eval (modeline-segment-process))
                             " ")))))))
    (progn

      ;; Remove flycheck hooks
      (remove-hook 'flycheck-status-changed-functions #'modeline--update-flycheck-segment)
      (remove-hook 'flycheck-mode-hook #'modeline--update-flycheck-segment)

      ;; Remove VC hooks
      (remove-hook 'file-find-hook #'modeline--update-vc-segment)
      (remove-hook 'after-save-hook #'modeline--update-vc-segment)
      (advice-remove #'vc-refresh-state #'modeline--update-vc-segment)

      ;; Remove window update hooks
      (remove-hook 'window-configuration-change-hook #'modeline--update-selected-window)
      (remove-hook 'focus-in-hook #'modeline--update-selected-window)
      (advice-remove #'handle-switch-frame #'modeline--update-selected-window)
      (advice-remove #'select-window #'modeline--update-selected-window)

      ;; Restore the original modeline format
      (setq-default modeline-format modeline--default-modeline))))

(provide 'seanmacs-modeline)
;;; seanmacs-modeline.el ends here

                             (info (or .info 0)))
                         (format "%s/%s/%s "
                                 (if (> error 0)
                                     (propertize (number-to-string error) 'face 'seanmacs/modeline-status-error)
                                   (number-to-string error))
                                 (if (> warning 0)
                                     (propertize (number-to-string warning) 'face 'seanmacs/modeline-status-warning)
                                   (number-to-string warning))
                                 (if (> info 0)
                                     (propertize (number-to-string info) 'face 'seanmacs/modeline-status-success)
                                   (number-to-string info))))))
          ('running "-/-/- ")
          ('no-checker "")
          ('errored (propertize "!!! " 'face 'seanmacs/modeline-status-error))
          ('interrupted "--- "))))

(defun seanmacs/modeline-segment-modified-or-readonly ()
  "Displays a color-coded buffer modification or readonly
indicator in the modeline."
  (cond (buffer-read-only
