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

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

Re: Want to highlight function calls in c-mode


From: Kevin Rodgers
Subject: Re: Want to highlight function calls in c-mode
Date: Fri, 25 Jun 2004 12:19:36 -0600
User-agent: Mozilla/5.0 (X11; U; SunOS i86pc; en-US; rv:0.9.4.1) Gecko/20020406 Netscape6/6.2.2

John wrote:
> I am faced with a very hairy program and would greatly benefit from
> having the actual function calls highlighted.  I have not been able to
> figure out how to do this however, nor have I located any mention of
> anything that already does this.
>
> Please help if you can.

Here's what font-lock.el suggests:

;;; Adding patterns for modes that already support Font Lock:

;; Though Font Lock highlighting patterns already exist for many modes, it's
;; likely there's something that you want fontified that currently isn't, even
;; at the maximum fontification level.  You can add highlighting patterns via
;; `font-lock-add-keywords'.  For example, say in some C
;; header file you #define the token `and' to expand to `&&', etc., to make
;; your C code almost readable.  In your ~/.emacs there could be:
;;
;;  (font-lock-add-keywords 'c-mode '("\\<\\(and\\|or\\|not\\)\\>"))
;;
;; Some modes provide specific ways to modify patterns based on the values of
;; other variables.  For example, additional C types can be specified via the
;; variable `c-font-lock-extra-types'.

;;; Adding patterns for modes that do not support Font Lock:

;; Not all modes support Font Lock mode.  If you (as a user of the mode) add
;; patterns for a new mode, you must define in your ~/.emacs a variable or
;; variables that specify regexp fontification.  Then, you should indicate to
;; Font Lock mode, via the mode hook setting `font-lock-defaults', exactly what
;; support is required.  For example, say Foo mode should have the following
;; regexps fontified case-sensitively, and comments and strings should not be
;; fontified automagically.  In your ~/.emacs there could be:
;;
;;  (defvar foo-font-lock-keywords
;;    '(("\\<\\(one\\|two\\|three\\)\\>" . font-lock-keyword-face)
;;      ("\\<\\(four\\|five\\|six\\)\\>" . font-lock-type-face))
;;    "Default expressions to highlight in Foo mode.")
;;
;;  (add-hook 'foo-mode-hook
;;   (function (lambda ()
;;               (make-local-variable 'font-lock-defaults)
;;               (setq font-lock-defaults '(foo-font-lock-keywords t)))))

> PS - I relocated this to the bottom.  I figured I shouldn't open with
> it, but I still wanted to vent :
>
> "OK...Google's interface ticks me off.  I had a message all typed but
> I chose to click their "Posing Style Guide" before I sent it -- POOF!
> It completely Toasted everything I typed.  They could at least warn me
> or open the stupid thing in a different window.  GRRRRRRRRRRRRRRRRR"

Whenever I have to compose text for a web browser, I use Emacs and then
cut-and-paste it into the HTML form, to protect me from browser crashes
(which are much more frequent than emacs crashes).  In fact, that's what
I'm doing right now, and I have a dedicated buffer for that purpose:

(pop-to-buffer (get-buffer-create "*Text*"))
(or (eq major-mode 'text-mode)
    (text-mode))

--
Kevin Rodgers



reply via email to

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