        (format " %s/%d "
                (if this-oc
                    (- length
-                      (length (cdr
-                               (memq this-oc (sort (append iedit-occurrences-overlays (list))
-                                                   (lambda (x y) (< (overlay-start x) (overlay-start y))))))))
+                      (length (memq this-oc (sort (append iedit-occurrences-overlays nil)
+                                                  #'doom-themes--overlay-sort)))
+                      -1)
                  "-")
                length))
      'face (if (active) 'doom-modeline-panel))))

(def-modeline-segment! vcs
  "Displays the current branch, colored based on its state."
  (when (and vc-mode buffer-file-name)
    (let ((backend (vc-backend buffer-file-name))
          (state   (vc-state buffer-file-name))
          (face    'mode-line-inactive)
          (active  (active))
          (all-the-icons-scale-factor 1.0)
          (all-the-icons-default-adjust -0.1))
      (concat "  "
              (cond ((memq state '(edited added))
                     (if active (setq face 'doom-modeline-info))
                     (all-the-icons-octicon
                      "git-compare"
                      :face face
                      :height 1.2
                      :v-adjust -0.05))
                    ((eq state 'needs-merge)
                     (if active (setq face 'doom-modeline-info))
                     (all-the-icons-octicon "git-merge" :face face))
                    ((eq state 'needs-update)
                     (if active (setq face 'doom-modeline-warning))
                     (all-the-icons-octicon "arrow-down" :face face))
                    ((memq state '(removed conflict unregistered))
                     (if active (setq face 'doom-modeline-urgent))
                     (all-the-icons-octicon "alert" :face face))
                    (t
                     (if active (setq face 'font-lock-doc-face))
                     (all-the-icons-octicon
                      "git-compare"
                      :face face
                      :height 1.2
                      :v-adjust -0.05)))
              " "
              (propertize (substring vc-mode (+ (if (eq backend 'Hg) 2 3) 2))
                          'face (if active face))
              " "))))

;;
(defun +doom-ml-icon (icon &optional text face voffset)
  "Displays an octicon ICON with FACE, followed by TEXT. Uses
`all-the-icons-octicon' to fetch the icon."
  (concat
   (if vc-mode " " "  ")
   (when icon
     (concat
      (all-the-icons-material icon :face face :height 1.1 :v-adjust (or voffset -0.2))
      ;; (all-the-icons-octicon icon :face face :height 1.0 :v-adjust 0)
      (if text +doom-modeline-vspc)))
   (when text
     (propertize text 'face face))
   (if vc-mode "  " " ")))

(def-modeline-segment! flycheck
  "Displays color-coded flycheck error status in the current buffer with pretty

                      (+doom-modeline--anzu)
                      (+doom-modeline--evil-substitute)
                      (+doom-modeline--iedit))))
     (or (and (not (equal meta "")) meta)
         (if buffer-file-name " %I "))))

;; TODO Include other information
(def-modeline-segment! media-info
  "Metadata regarding the current file, such as dimensions for images."
  (cond ((eq major-mode 'image-mode)
         (cl-destructuring-bind (width . height)
             (image-size (image-get-display-property) :pixels)
           (format "  %dx%d  " width height)))))

;; The bar regulates the height of the mode-line in GUI Emacs.
(def-modeline-segment! bar
  (when (display-graphic-p)
    (+doom-modeline--make-xpm
     (face-background (if (active)
                          'doom-modeline-bar
                        'doom-modeline-inactive-bar)
                      nil t)
     +doom-modeline-height
     +doom-modeline-bar-width)))


;;
