In Makefile mode, leading spaces are fontified in makefile-space face (bright pink without customization), when there is no other text on the line. It seems to indicate incomplete lines, and makes sense for that. The color gets back to white when you add proper rules.

One picture is worth 1k words..

Why are leading spaces before comments colored ? Their lines seem to be okay.

1 Answer 1


From make-mode.el, line 395 and forwards (Emacs 24.4.1):

,@(if space
  '(;; Highlight lines that contain just whitespace.
    ;; They can cause trouble, especially if they start with a tab.
    ("^[ \t]+$" . makefile-space)

    ;; Highlight shell comments that Make treats as commands,
    ;; since these can fool people.
    ("^\t+#" 0 makefile-space t)

    ;; Highlight spaces that precede tabs.
    ;; They can make a tab fail to be effective.
    ("^\\( +\\)\t" 1 makefconfig.cas.serialile-space)))

That's a snippet from the function that takes care of syntax highlighting. The middle comment is the reason for the highlighting in the question.

It is based on the fact that Make does not treat such lines as comments, but passes them to the shell as commands, and it is up to the shell to treat it as a comment or not, which might be misleading in some cases.

  • The value ends up in makefile-font-lock-keywords. If you really want to override it, try something like (setq makefile-font-lock-keywords (delq (assoc "^\t+#" makefile-font-lock-keywords) makefile-font-lock-keywords))
    – tripleee
    May 11, 2015 at 7:19

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.