* Bug? in CC-Mode
@ 2005-06-07 13:00 Matthieu Lemerre
0 siblings, 0 replies; 4+ messages in thread
From: Matthieu Lemerre @ 2005-06-07 13:00 UTC (permalink / raw)
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?
Thanks,
Matthieu
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Bug? in CC-Mode
[not found] <mailman.3666.1118149525.25862.help-gnu-emacs@gnu.org>
@ 2005-06-07 16:21 ` Alan Mackenzie
2005-06-07 17:54 ` Matthieu Lemerre
0 siblings, 1 reply; 4+ messages in thread
From: Alan Mackenzie @ 2005-06-07 16:21 UTC (permalink / raw)
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!
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 ;-).
Thanks in advance!
> Matthieu
--
Alan Mackenzie (Munich, Germany)
Email: aacm@muuc.dee; to decode, wherever there is a repeated letter
(like "aa"), remove half of them (leaving, say, "a").
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Bug? in CC-Mode
2005-06-07 16:21 ` Alan Mackenzie
@ 2005-06-07 17:54 ` Matthieu Lemerre
2005-06-07 19:38 ` Kevin Rodgers
0 siblings, 1 reply; 4+ messages in thread
From: Matthieu Lemerre @ 2005-06-07 17:54 UTC (permalink / raw)
Cc: help-gnu-emacs
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Bug? in CC-Mode
2005-06-07 17:54 ` Matthieu Lemerre
@ 2005-06-07 19:38 ` Kevin Rodgers
0 siblings, 0 replies; 4+ messages in thread
From: Kevin Rodgers @ 2005-06-07 19:38 UTC (permalink / raw)
Matthieu Lemerre wrote:
> 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?
Don't call it outside of a CC Mode buffer, i.e. only call it within a
mode hook:
(add-hook 'c-mode-hook (lambda () (c-set-style "gnu")))
BTW, the manual says: The default style in all newly created buffers is
`gnu', but you can change this by setting variable `c-default-style'.
So you shouldn't need to do anything to get the GNU style.
--
Kevin Rodgers
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2005-06-07 19:38 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-06-07 13:00 Bug? in CC-Mode Matthieu Lemerre
[not found] <mailman.3666.1118149525.25862.help-gnu-emacs@gnu.org>
2005-06-07 16:21 ` Alan Mackenzie
2005-06-07 17:54 ` Matthieu Lemerre
2005-06-07 19:38 ` Kevin Rodgers
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).