Function: mh-font-lock-add-keywords

mh-font-lock-add-keywords is a function alias for font-lock-add-keywords, defined in font-lock.el.gz.

This function is obsolete since 29.1; use font-lock-add-keywords instead.

Signature

(mh-font-lock-add-keywords MODE KEYWORDS &optional HOW)

Documentation

Add highlighting KEYWORDS for MODE.

MODE should be a symbol, the major mode command name, such as c-mode or nil. If nil, highlighting keywords are added for the current buffer. KEYWORDS should be a list; see the variable font-lock-keywords. By default they are added at the beginning of the current highlighting list. If optional argument HOW is set, they are used to replace the current highlighting list. If HOW is any other non-nil value, they are added at the end of the current highlighting list.

For example:

 (font-lock-add-keywords 'c-mode
  '(("\\\\\\=<\\\\(FIXME\\\\):" 1 'font-lock-warning-face prepend)
    ("\\\\\\=<\\\\(and\\\\|or\\\\|not\\\\)\\\\\\=>" . 'font-lock-keyword-face)))

adds two fontification patterns for C mode, to fontify FIXME: words, even in comments, and to fontify and, or and not words as keywords.

The above procedure will only add the keywords for C mode, not for modes derived from C mode. To add them for derived modes too, pass nil for MODE and add the call to c-mode-hook.

For example:

 (add-hook 'c-mode-hook
  (lambda ()
   (font-lock-add-keywords nil
    '(("\\\\\\=<\\\\(FIXME\\\\):" 1 'font-lock-warning-face prepend)
      ("\\\\\\=<\\\\(and\\\\|or\\\\|not\\\\)\\\\\\=>" .
       'font-lock-keyword-face)))))

The above procedure may fail to add keywords to derived modes if some involved major mode does not follow the standard conventions. File a bug report if this happens, so the major mode can be corrected.

Note that some modes have specialized support for additional patterns, e.g., see the variables c-font-lock-extra-types, c++-font-lock-extra-types, objc-font-lock-extra-types and java-font-lock-extra-types.

Aliases

mh-font-lock-add-keywords (obsolete since 29.1)