all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* C type fontification help
@ 2003-05-19 21:35 Kin Cho
  2003-05-19 22:42 ` Stefan Monnier
  0 siblings, 1 reply; 3+ messages in thread
From: Kin Cho @ 2003-05-19 21:35 UTC (permalink / raw)


Hi,

I need help fontifying "FOO(a)" as type and "bar" as variable below:

struct foo {
    FOO(a) bar;
};

I tried adding "FOO([^)]+)" to c-font-lock-extra-types but it
doens't help because c-font-lock-extra-types doens't expect word
delimiters.

Also I'd like to fontify "foobar" below as a variable.

void (*foobar)(char *);

The fontification is important to me because I'm using them to
extract semantic information from header files.

Thanks.

-kin

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: C type fontification help
  2003-05-19 21:35 C type fontification help Kin Cho
@ 2003-05-19 22:42 ` Stefan Monnier
  2003-05-22 17:42   ` Kin Cho
  0 siblings, 1 reply; 3+ messages in thread
From: Stefan Monnier @ 2003-05-19 22:42 UTC (permalink / raw)


> I need help fontifying "FOO(a)" as type and "bar" as variable below:
> struct foo {
>     FOO(a) bar;
> };
> I tried adding "FOO([^)]+)" to c-font-lock-extra-types but it
> doens't help because c-font-lock-extra-types doens't expect word
> delimiters.

You might want to try something like

  (add-hook 'c-mode-hook
    (lambda ()
      (set (make-local-variable 'font-lock-syntactic-keywords)
           '(("FOO([^)]+)" (0 '(2))))))

To first change the syntax-class of the open and close paren to "word".
That's pretty ugly but it should work (probably with some fiddling).


        Stefan

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: C type fontification help
  2003-05-19 22:42 ` Stefan Monnier
@ 2003-05-22 17:42   ` Kin Cho
  0 siblings, 0 replies; 3+ messages in thread
From: Kin Cho @ 2003-05-22 17:42 UTC (permalink / raw)


"Stefan Monnier" <monnier+gnu.emacs.help/news/@flint.cs.yale.edu> writes:

> > I need help fontifying "FOO(a)" as type and "bar" as variable below:
> > struct foo {
> >     FOO(a) bar;
> > };
> > I tried adding "FOO([^)]+)" to c-font-lock-extra-types but it
> > doens't help because c-font-lock-extra-types doens't expect word
> > delimiters.
> 
> You might want to try something like
> 
>   (add-hook 'c-mode-hook
>     (lambda ()
>       (set (make-local-variable 'font-lock-syntactic-keywords)
>            '(("FOO([^)]+)" (0 '(2))))))
> 
> To first change the syntax-class of the open and close paren to "word".
> That's pretty ugly but it should work (probably with some fiddling).

I have given up on relying on font-lock for parsing.

I'm experimenting with xemacs.org's semantic now and it looks
good so far -- although it still wouldn't associate "FOO(a)" as
the type of "bar", but at least "bar" is parsed as a variable.

Thanks.

-kin

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2003-05-22 17:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-05-19 21:35 C type fontification help Kin Cho
2003-05-19 22:42 ` Stefan Monnier
2003-05-22 17:42   ` Kin Cho

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.