GNU bug report logs - #15478
cc-mode does not obey electric-indent-mode

Previous Next

Packages: emacs, cc-mode;

Reported by: Stefan Monnier <monnier <at> iro.umontreal.ca>

Date: Sat, 28 Sep 2013 18:12:02 UTC

Severity: normal

Found in version 24.3.50

Done: Alan Mackenzie <acm <at> muc.de>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Josh <josh <at> foxtail.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 15478 <at> debbugs.gnu.org, Alan Mackenzie <acm <at> muc.de>
Subject: bug#15478: cc-mode does not obey electric-indent-mode
Date: Fri, 4 Oct 2013 14:21:22 -0700
[Message part 1 (text/plain, inline)]
On Thu, Oct 3, 2013 at 7:32 AM, Stefan Monnier <monnier <at> iro.umontreal.ca>
wrote:
> > What I'm suggesting is some sort of hook so that electric-indent-mode
> > (and electric-layout-mode, too, I suppose) invokes the "electric
> > engine" in CC Mode rather than trying to do the electric
> > indentation itself.
> Sounds OK.

Unless I'm misunderstanding, the indentation hook you're describing
seems very close to `electric-indent-functions':

    electric-indent-functions is a variable defined in `electric.el'.
    Its value is nil
      This variable may be risky if used as a file-local variable.
    Documentation:
    Special hook run to decide whether to auto-indent.
    Each function is called with one argument (the inserted char), with
    point right after that char, and it should return t to cause
indentation,
    `no-indent' to prevent indentation or nil to let other functions decide.

Is there a reason why CC Mode couldn't supply a function here that
would perform appropriate indentation and then return `no-indent' to
stop traversal of electric-indent-functions?

Delegation of newline insertion decisions is similarly already supported
via `electric-layout-rules':

    electric-layout-rules
    electric-layout-rules is a variable defined in `electric.el'.
    Its value is nil
    Documentation:
    List of rules saying where to automatically insert newlines.
    Each rule has the form (CHAR . WHERE) where CHAR is the char
    that was just inserted and WHERE specifies where to insert newlines
    and can be: nil, `before', `after', `around', or a function of no
    arguments that returns one of those symbols.

If either or both of these delegation mechanisms are insufficient to
satisfy CC Mode's requirements, it would be interesting to hear how they
fall short.

Although I agree with your earlier point that major modes are best
suited to make decisions about /how/ to perform electric behavior for
their specific domains, which also seems to be borne out by the existing
delegation support, I've seen no justification for a major mode deciding
to disregard (!) my configuration of /whether/ to perform it at all.  I
read
the electric-*-mode docstrings describing the exact behavior in
question and I disabled it.  That should be the end of the story.

Josh
[Message part 2 (text/html, inline)]

This bug report was last modified 11 years and 92 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.