[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Bug? in CC-Mode
From: |
Matthieu Lemerre |
Subject: |
Re: Bug? in CC-Mode |
Date: |
Tue, 07 Jun 2005 19:54:03 +0200 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) |
Alan Mackenzie <acm@muc.de> writes:
> Matthieu Lemerre <racin@free.fr> wrote on Tue, 07 Jun 2005 15:00:38
> +0200:
>> Hi,
>
>> I used to have a (c-set-style "gnu") in my .emacs, which was useless
>> but everything worked fine.
>
>> When I tried emacs22 I had the following problem: c-set-style calls
>> c-set-style-1, which calls c-setup-paragraph-variables, which sets
>> globally paragraph-start, which is annoying for many
> reasons. Normally
>> paragraph-start is local to the buffer, but the call to c-set-style
>> change its value before it becomes buffer-local.
>
>> Should this be considered as a bug?
>
> Yes, definitely!
OK. I wasn't sure because it wasn't the normal way to call
c-set-style.
>
> Normally, when you initialise a CC Mode buffer, the initialisation
>process gets to call `c-basic-common-init', which contains the form
>(make-local-variable 'paragraph-start).
>
> So, at a guess, you're calling `c-set-style' in an unusual way, a way
> that by-passes the normal initialisation sequence. Would you please
> show
> us exactly how and where you're calling `c-set-style', so that we can
> fix
> the bug (or fix the documentation ;-).
I can reproduce the bug by just evaluating (c-set-style "gnu") in a
fresh emacs session (launched with emacs -q) with eval-expression. It
also works when CC-mode is already loaded, if I do this in a different
fundamental mode (like the *scratch* buffer.)
I had nothing surrounding the (c-set-style "gnu") of my .emacs. I may
have read c-set-style documentation too quickly.
The faulting lines start line 501 of cc-styles.el:
(setq paragraph-start (concat comment-line-prefix
c-paragraph-start
"\\|"
page-delimiter)
paragraph-separate (concat comment-line-prefix
c-paragraph-separate
"\\|"
page-delimiter)
paragraph-ignore-fill-prefix t
adaptive-fill-mode t
adaptive-fill-regexp
(concat comment-line-prefix
(if (default-value 'adaptive-fill-regexp)
(concat "\\("
(default-value 'adaptive-fill-regexp)
"\\)")
"")))
I tried also a (c-set-style "gnu" t) (setting the dont-override
optional parameter to t) but it does the same thing.
I use Debian GNU/Linux, and the bug can be reproduced by both using an
emacs-snapshot debian package or a recent CVS checkout.
I am interrested in knowing what would be the correct solution : would
it be to check if paragraph-start is buffer-local before setting it?
Or a more complicated scheme?
Thanks,
Matthieu