From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: jpkotta Newsgroups: gmane.emacs.help 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) Organization: http://groups.google.com Message-ID: <2c6114e6-edd4-4796-83a6-9d60906d2ffa@a31g2000yqn.googlegroups.com> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1255563660 18059 80.91.229.12 (14 Oct 2009 23:41:00 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 14 Oct 2009 23:41:00 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Oct 15 01:40:49 2009 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1MyDSa-0006yc-W5 for geh-help-gnu-emacs@m.gmane.org; Thu, 15 Oct 2009 01:40:49 +0200 Original-Received: from localhost ([127.0.0.1]:44327 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MyDSa-0004NV-F5 for geh-help-gnu-emacs@m.gmane.org; Wed, 14 Oct 2009 19:40:48 -0400 Original-Path: news.stanford.edu!usenet.stanford.edu!news.glorb.com!news2.glorb.com!postnews.google.com!a31g2000yqn.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 55 Original-NNTP-Posting-Host: 64.122.73.112 Original-X-Trace: posting.google.com 1255562564 32556 127.0.0.1 (14 Oct 2009 23:22:44 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Wed, 14 Oct 2009 23:22:44 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: a31g2000yqn.googlegroups.com; posting-host=64.122.73.112; posting-account=EwI0QQoAAADdqmqX_mVfawBNtwyks2YE User-Agent: G2/1.0 X-HTTP-UserAgent: Opera/9.80 (X11; Linux x86_64; U; en) Presto/2.2.15 Version/10.00,gzip(gfe),gzip(gfe) Original-Xref: news.stanford.edu gnu.emacs.help:173885 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:68967 Archived-At: On Oct 13, 2:16=A0am, jianli zhao wrote: > main () > {int a,b > a=3Db; <------the text color of this line is black, no face and color > for(a=3D0;a<8;a++) <--------only "for" has color. > =A0 =A0a=3Db; > > } > > 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 '("+" "-" "*" "/" "%" "!" "&" "^" "~" "|" "=3D" "<" ">" "." "," ";" ":"))) (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