Next: , Previous: , Up: Advanced customization   [Index]

7.7 DIY Add padding to the mode line

[ Consider using the spacious-padding package from GNU ELPA (by Protesilaos) for more than just the mode line. ]

Emacs faces do not have a concept of “padding” for the space between the text and its box boundaries. We can approximate the effect by adding a ‘:box’ attribute, making its border several pixels thick, and using the mode line’s background color for it. This way the thick border will not stand out and will appear as a continuation of the mode line.

Use theme colors in code with modus-themes-with-colors.

(defun my-modus-themes-custom-faces (&rest _)
  (modus-themes-with-colors
    (custom-set-faces
     ;; Add "padding" to the mode lines
     `(mode-line ((,c :box (:line-width 10 :color ,bg-mode-line-active))))
     `(mode-line-inactive ((,c :box (:line-width 10 :color ,bg-mode-line-inactive)))))))

(add-hook 'modus-themes-after-load-theme-hook #'my-modus-themes-custom-faces)

Using a hook at the post-load-theme phase.

The above has the effect of removing the border around the mode lines. In older versions of the themes, we provided the option for a padded mode line which could also have borders around it. Those were not real border, however, but an underline and an overline. Adjusting the above:

(defun my-modus-themes-custom-faces (&rest _)
  (modus-themes-with-colors
    (custom-set-faces
     ;; Add "padding" to the mode lines
     `(mode-line ((,c :underline ,border-mode-line-active
                      :overline ,border-mode-line-active
                      :box (:line-width 10 :color ,bg-mode-line-active))))
     `(mode-line-inactive ((,c :underline ,border-mode-line-inactive
                               :overline ,border-mode-line-inactive
                               :box (:line-width 10 :color ,bg-mode-line-inactive)))))))

;; ESSENTIAL to make the underline move to the bottom of the box:
(setq x-underline-at-descent-line t)

(add-hook 'modus-themes-after-load-theme-hook #'my-modus-themes-custom-faces)

The reason we no longer provide this option is because it depends on a non-nil value for x-underline-at-descent-line. That variable affects ALL underlines, including those of links. The effect is intrusive and looks awkward in prose.

As such, the Modus themes no longer provide that option but instead offer this piece of documentation to make the user fully aware of the state of affairs.

Reload the theme for changes to take effect.

Next: DIY Remap face with local value, Previous: DIY Do not extend the region background, Up: Advanced customization   [Index]