Function: doom-modeline-remove-segment

doom-modeline-remove-segment is a natively compiled function defined in doom-modeline-core.el.

Signature

(doom-modeline-remove-segment SEGMENT &optional MODELINE)

Documentation

Remove SEGMENT from modeline(s).

SEGMENT is the segment name to remove (a symbol). MODELINE can be a modeline name (symbol) to remove from a specific modeline, or nil/'all to remove from all modelines (respecting doom-modeline-excluded-modelines).

Modelines listed in doom-modeline-excluded-modelines are not modified when removing segments programmatically.

Source Code

;; Defined in /nix/store/1lcicrdd2r4b8rkc91nnn74ymk1jl6yd-emacs-packages-deps/share/emacs/site-lisp/elpa/doom-modeline-20260928.1632/doom-modeline-core.el
(defun doom-modeline-remove-segment (segment &optional modeline)
  "Remove SEGMENT from modeline(s).
SEGMENT is the segment name to remove (a symbol).
MODELINE can be a modeline name (symbol) to remove from a specific modeline,
or nil/'all to remove from all modelines (respecting
`doom-modeline-excluded-modelines').

Modelines listed in `doom-modeline-excluded-modelines' are not modified
when removing segments programmatically."
  (let ((modelines (if (or (null modeline) (eq modeline 'all))
                       doom-modeline--modelines
                     (list (assq modeline doom-modeline--modelines)))))
    (dolist (modeline-def modelines)
      (when modeline-def
        (pcase-let ((`(,name . (,lhs ,rhs)) modeline-def))
          (unless (memq name doom-modeline-excluded-modelines)
            (let ((new-lhs lhs)
                  (new-rhs rhs))
              ;; Try to remove from LHS
              (when (memq segment lhs)
                (setq new-lhs (doom-modeline--remove-segment-from-list lhs segment)))
              ;; Try to remove from RHS
              (when (memq segment rhs)
                (setq new-rhs (doom-modeline--remove-segment-from-list rhs segment)))
              ;; Only redefine if at least one list was modified
              (when (or (not (eq new-lhs lhs))
                        (not (eq new-rhs rhs)))
                (doom-modeline-def-modeline name new-lhs new-rhs)))))))))