[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: .c file has no color for most of code in functions, is this normal?
From: |
jpkotta |
Subject: |
Re: .c file has no color for most of code in functions, is this normal? |
Date: |
Wed, 14 Oct 2009 16:22:43 -0700 (PDT) |
User-agent: |
G2/1.0 |
On Oct 13, 2:16 am, jianli zhao <jianlizh...@gmail.com> wrote:
> main ()
> {int a,b
> a=b; <------the text color of this line is black, no face and color
> for(a=0;a<8;a++) <--------only "for" has color.
> a=b;
>
> }
>
> Emacs must have way to color these code lines, but how to enable it?
> Please help!
I think the default syntax highlighting is a bit flat too. I added
highlighting for brackets, operators, "warning words", and types. The
types should be working by default; I can't remember why I bothered
with them.
;;; begin lisp code
;; extra syntax highlighting
(defface font-lock-bracket-face
'((t (:foreground "cyan3")))
"Font lock mode face for brackets, e.g. '(', ']', etc."
:group 'font-lock-faces)
(defvar font-lock-bracket-face 'font-lock-bracket-face
"Font lock mode face for backets. Changing this directly
affects only new buffers.")
(setq c-operators-regexp
(regexp-opt '("+" "-" "*" "/" "%" "!"
"&" "^" "~" "|"
"=" "<" ">"
"." "," ";" ":")))
(setq c-brackets-regexp
(regexp-opt '("(" ")" "[" "]" "{" "}")))
(setq c-types-regexp
(concat
"\\<[_a-zA-Z][_a-zA-Z0-9]*_t\\>" "\\|"
(regexp-opt '("unsigned" "int" "char" "float" "void") 'words)))
(setq warning-words-regexp
(regexp-opt '("FIXME" "TODO" "BUG" "XXX" "DEBUG")))
(eval-after-load "cc-mode"
'(progn
(font-lock-add-keywords
'c-mode
(list
(cons c-operators-regexp 'font-lock-builtin-face)
(cons c-brackets-regexp 'font-lock-bracket-face)
(cons c-types-regexp 'font-lock-type-face)
(cons warning-words-regexp 'font-lock-warning-face)))
))
;;; end lisp code
- jpkotta