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

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

paren-mismatching problems in cc-mode and paren.el (' inside string)


From: Alan Mackenzie
Subject: paren-mismatching problems in cc-mode and paren.el (' inside string)
Date: 31 Mar 2002 12:40:04 +0200
Date: Sun, 31 Mar 2002 10:40:52 +0000
User-agent: tin/1.4.5-20010409 ("One More Nightmare") (UNIX) (Linux/2.0.35 (i686))

[Mailed to address@hidden; Posted to gnu.emacs.bugs.]

GNU Emacs 21.1.

In the following c-mode snippet:

void print_salaries (int alices, int bobs)
{
    printf ("%i (Alice's salary)\n", alices) ;
    printf ("%i (Bob's salary)\n", bobs) ;
}

the '(' before "Alice's" matches the ')' after "Bob's salary", both in
the highlighting (paren.el ??) and in commands like C-M-p (backward-list)
which cc-mode delegates to ..../emacs-lisp/lisp.el.

The problem is that the apostrophe has string syntax in the cc-mode
syntax table, so that in attempting to match the braces, everything
between the two apostrophes is regarded as an indivisible string.

[I actually found this problem while debugging awk-mode:  There it is
more serious, because / has string syntax by defeault, and a line such as
printf ("Use local dict file? (y/n)")
is not at all contrived or unexpected.]

The root cause in the backward-list case (and probably the paren.el one,
too) is that the scan-lists primitive is used without first ensuring that
point is in a "safe" place (i.e. outside of any strings or comments).

-- 
Alan Mackenzie (Munich, Germany)
Email: address@hidden; to decode, wherever there is a repeated letter
(like "aa"), remove half of them (leaving, say, "a").




reply via email to

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