emacs-devel
[Top][All Lists]
Advanced

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

Re: [Emacs-diffs] trunk r116461: Connect electric-indent-mode up with CC


From: Alan Mackenzie
Subject: Re: [Emacs-diffs] trunk r116461: Connect electric-indent-mode up with CC Mode. Bug #15478.
Date: Sat, 22 Feb 2014 18:27:04 +0000
User-agent: Mutt/1.5.21 (2010-09-15)

Hi, Stefan.

On Mon, Feb 17, 2014 at 07:11:18PM -0500, Stefan Monnier wrote:
> > +  ;; In Emacs 24.4 onwards, prevent Emacs's built in electric indentation 
> > from
> > +  ;; messing up CC Mode's, and set `c-electric-flag' if 
> > `electric-indent-mode'
> > +  ;; has been called by the user.
> > +  (when (boundp 'electric-indent-inhibit) (setq electric-indent-inhibit t))
> > +  (when (and (boundp 'electric-indent-mode-has-been-called)
> > +        (> electric-indent-mode-has-been-called 1))
> > +    (setq c-electric-flag electric-indent-mode))

> Could you explain what problem this is trying to avoid?

Setting electric-indent-inhibit is intended to protect CC Mode from the
dangers of CC Mode's electricity clashing with electric.el's.  The other
bit takes over the value of c-electric-indent-mode into CC Mode only
when it has been set by the user, thus preventing electric.el's default
overriding CC Mode's.  (As we've already discussed, CC Mode's indentation
doesn't work properly with electric indentation disabled.)

> > +  ;; Emacs has en/disabled `electric-indent-mode'.  Propagate this through 
> > to
> > +  ;; each CC Mode buffer.
> > +  (when (and (boundp 'electric-indent-mode-has-been-called)
> > +        (> electric-indent-mode-has-been-called 1))
> > +    (mapc (lambda (buf)
> > +       (with-current-buffer buf
> > +         (when c-buffer-is-cc-mode
> > +           ;; Don't use `c-toggle-electric-state' here due to recursion.
> > +           (setq c-electric-flag electric-indent-mode)
> > +           (c-update-modeline))))
> > +     (buffer-list))))

> And could you also explain what this one is trying to avoid?

Basically the same thing.  It's preventing an inopportune default (as
contrasted with an explicit user setting) overriding CC Mode's default.

>         Stefan

-- 
Alan Mackenzie (Nuremberg, Germany).



reply via email to

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