help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Syntax highlighting of operators in C and C++ mode


From: Nordlöw
Subject: Syntax highlighting of operators in C and C++ mode
Date: 17 Apr 2007 07:23:06 -0700
User-agent: G2/1.0

Hey there, Emacs users!

I am trying to get highlighting of operators to work on Emacs-CVS.
Instead the following code ruins most of default font-locking in c-
mode.

(defface font-lock-operator-face
  '((((class color))
     (:inherit font-lock-builtin-face :bold t)))
  "Font Lock mode face used to highlight operators..")

;; Adds fontification for operator += for C mode and modes derived
from C mode
(defun pnw-c-mode-extra-font-locking ()
  (font-lock-add-keywords
   nil
   (list
     (cons (concat "\\(" (regexp-opt (list "+=")) "\\)")
          '(1 font-lock-operator-face prepend))
    )))

(add-hook 'c-mode-hook 'pnw-c-mode-extra-font-locking)


What have done wrong?

Many thanks in advance,
Per Nordlöw



reply via email to

[Prev in Thread] Current Thread [Next in Thread]