emacs-devel
[Top][All Lists]
Advanced

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

Re: HELP, PLEASE! Syntax problem!


From: Stefan Monnier
Subject: Re: HELP, PLEASE! Syntax problem!
Date: Wed, 25 Nov 2009 09:43:01 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux)

> In the following fragment of code:

> 1   int a = foo (
> 2       1);
> 3   #define X(A, B)                                 \
> 4       do {                                        \
> 5           printf (A, B);                          \
> 6       } while (0)

> 7   int a = foo (
> 8       1);

> , there is a C macro between lines 3 and 6.  The syntax-table properties
> here have been manipulated (see below).  Putting point at the "(" in L5
> and doing C-M-n takes point to after ")" ON LINE 8.  Similar things
> happen with C-M-p, C-M-u from various places inside the macro

> Evidently, all syntactic properties inside the macro have been
> suppressed.  This is not wanted.

The first problem is most likely that `syntax-table' is only special for
text-properties, not for char-properties in general (i.e. when placed
on an overlay, it has no effect).

Of course, the real problem is that the syntax-table hacking you're
doing here is just that: a hack.  Maybe another hack would have fewer
shortcomings?  E.g. maybe you could place a syntax-table property on the
# that says "beginning of comment" and a matching "end of comment" on
the newline that terminates line 6?  Then again, our syntax-tables are
too limited in their comment handling, so given that CC already uses
most forms of comments, it'll be difficult to make sure that # only
matches that particular comment ender and not just "any \n" or "*/", but
maybe just marking the "\\\n" that get in the way as "punctuation" would
solve it?


        Stefan




reply via email to

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