One of my modes uses the header line to display a progress bar/document summary, concatenating spaces with varying background colors and widths (using the display attribute). To clarify the distinction between the header line and the document, I'd like to separate them with a solid line.

How can I draw a thin solid line under the header line?

Things I tried without success:

  • 'face (:box (:line-width -1 :color "grey")): Shows a line all around the mode line, not just under it

  • 'face (:underline (:color "grey")): background color of header line shows below underline


Here is one idea using underline and a filler that is underlined. You can add :eval so that the line length updates as the window width changes.

(defface my-regular-underscore-face
  '((t (:inherit default :underline (:style line :color "red"))))
  "Face for `my-regular-underscore-face'.")

(defface my-filler-underscore-face
  '((t (:inherit default :underline (:style line :color "yellow"))))
  "Face for `my-filler-underscore-face'.")

(setq header-line-format
        'face 'my-regular-underscore-face))
        (make-string (window-width) ?\ )
          'face 'my-filler-underscore-face))))
  • I mentioned this solution in the question, but it doesn't work: the background of my-regular-underscore-face is visible below the underline. – Clément Jun 18 '16 at 3:19
  • Inasmuch as the feature you seek does not exist, the best you will be able to achieve is a compromise -- e.g., setting the background face of the header to match the background face of your buffer; or just use boxes instead of underlines. The new feature would need to be implemented in C, and you would likely need to do this on your own since the Emacs team is difficult to convince regarding adding new features. – lawlist Jun 18 '16 at 16:32
  • Thanks. I use background colors to draw a progress bar, so that's not really an option :/ I was hoping that the feature did exist. – Clément Jun 18 '16 at 17:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.