Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Using current style in C?

11 views
Skip to first unread message

Doug Lewan

unread,
Mar 4, 2013, 10:04:19 AM3/4/13
to help-gn...@gnu.org
Once upon a time, I'll swear I read somewhere about being able to configure C-mode to "use the current style", but now I can't find it. I'd like to use such a feature.

That is, upon finding a file, I'd like emacs to examine it and use its indentation style while editing it.

Does such a feature really exist? (I have been known to make stuff up.) A quick scan of the emacs Wiki didn't reveal anything to me.

Thanks.

,Douglas
Douglas Lewan
Shubert Ticketing
(201) 489-8600 ext 224

When I do good, I feel good. When I do bad, I feel bad and that's my religion. - Abraham Lincoln


Stefan Monnier

unread,
Mar 4, 2013, 1:59:55 PM3/4/13
to help-gn...@gnu.org
> Once upon a time, I'll swear I read somewhere about being able to configure
> C-mode to "use the current style", but now I can't find it. I'd like to use
> such a feature.

Check c-guess (in cc-guess.el).


Stefan


Doug Lewan

unread,
Mar 4, 2013, 4:38:24 PM3/4/13
to help-gn...@gnu.org
Stefan,

Thank you.

c-guess looks exactly like what I was thinking about. I won't have any more time today to look at it, but tomorrow morning I will give it a try!

,Douglas
Douglas Lewan
Shubert Ticketing
(201) 489-8600 ext 224

When I do good, I feel good. When I do bad, I feel bad and that's my religion. - Abraham Lincoln


"Jérôme M. Berger"

unread,
Mar 4, 2013, 5:14:32 PM3/4/13
to help-gn...@gnu.org
Stefan Monnier wrote:
>> Once upon a time, I'll swear I read somewhere about being able to configure
>> C-mode to "use the current style", but now I can't find it. I'd like to use
>> such a feature.
>
> Check c-guess (in cc-guess.el).
>
Thanks, that could be very useful. However, I just tried adding the
following to my c-mode-hook to configure the style automatically
when I open a file:


(setq c-guess-guessed-basic-offset nil)
(setq c-guess-guessed-offsets-alist nil)
(c-guess-no-install)
(if c-guess-guessed-basic-offset
(setq c-basic-offset c-guess-guessed-basic-offset))
(if c-guess-guessed-offsets-alist
(setq c-offsets-alist c-guess-guessed-offsets-alist))


For some reason, this is horribly slow (takes several minutes to
complete). When I remove those lines and launch c-guess-no-install
interactively with M-x, then it is almost instantaneous (less than
one second). Anybody knows what's happening?

Thanks,
Jerome
--
mailto:jebe...@free.fr
http://jeberger.free.fr
Jabber: jebe...@jabber.fr

signature.asc

Doug Lewan

unread,
Mar 5, 2013, 7:39:16 AM3/5/13
to Stefan Monnier, help-gn...@gnu.org
Stefan,

c-guess does just what I want (and need to remain socially acceptable). Thanks!

,Douglas
Douglas Lewan
Shubert Ticketing
(201) 489-8600 ext 224

When I do good, I feel good. When I do bad, I feel bad and that's my religion. - Abraham Lincoln


> -----Original Message-----
> From: help-gnu-emacs-bounces+dougl=shuberttic...@gnu.org
> [mailto:help-gnu-emacs-bounces+dougl=shuberttic...@gnu.org] On
> Behalf Of Stefan Monnier
> Sent: Monday, 2013 March 04 14:00
> To: help-gn...@gnu.org
> Subject: Re: Using current style in C?
>
> > Once upon a time, I'll swear I read somewhere about being able to
> configure
> > C-mode to "use the current style", but now I can't find it. I'd like
> to use
> > such a feature.
>
> Check c-guess (in cc-guess.el).
>
>
> Stefan
>


0 new messages