[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: |
Mon, 24 Mar 2014 22:40:55 +0000 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
Hello, Stefan.
On Sun, Mar 23, 2014 at 09:37:09PM -0400, Stefan wrote:
> > The actual definition of "electricity" is found in the Emacs manual, page
> Use in other packages shows that people have understood the notion of
> "electric" to mean many other things beside the very restricted
> semantics you point to.
Yes, but as used in "electric indentation", I think the terminology, and
the methodology, has been as in C Mode's definition up until very
recently.
> > No. To keep Elisp properly indented, you merely have to depress
> > whichever key is bound to `newline-and-indent', whether that be RET, or
> > C-j, or whatever.
> "whichever key is bound to `newline-and-indent'" would be C-j and not
> RET in all Emacsen released so far, so I see we violently agree.
> > Electric indentation doesn't come into it.
> Of course it does because electric-indent changes the behavior such that
> RET can be (or has to be in 24.4) used instead of C-j. But you knew
> that, obviously.
OK, I meant "electric indentation" as defined in the manual page -
"reindenting the current line". This has nothing to do with which way
round C-j and RET are bound.
> > You'll want electric indentation on some other character you've just
> > typed.
> Indeed that's also good. But I don't know of any such character we
> could use globally in electric-indent-chars, so it's up to each major
> mode to specify which chars to use.
Yes.
> > No. If electric indentation has already happened after typing the
> > semicolon/comma/brace, the alignment of the subsequent comment will
> > remain undisturbed. If RET puts the alignment out, you're cursing it.
> Then I misunderstood and don't know what you're talking about. Can you
> give a scenario?
Assume that electric indentation happens on \n, and not on {. You type
in a { (which is intrinsically 4 characters too indented, for some value
of 4) then do M-; to insert a comment at comment-column. You fill in the
comment, do C-e then RET. The ensuing electric indentation on RET puts
out the alignment of the comment:
if (foo) /* aligned comment */
{ /* coment misaligned by e-i-m */
> >> What would be more optimal?
> > A mode-dependent or buffer-local dependent setting, as well as, rather
> > than instead of.
> We have that: electric-indent-local-mode and electric-indent-inhibit.
OK, for electric-indent-local-mode, which is gradually becoming
prominent. But I though electric-indent-inhibit was a variable for major
modes, not users - a mode initialisation thing, rather than a user
configuration variable.
> > Why can't we simply have RET bound to `newline-and-indent' and C-j
> > bound to `newline' in programming modes, as discussed and, pretty much
> > agreed on, in emacs-devel last autumn?
> Lack of patch implementing this (supposed) simple change?
Here is what I propose, and am willing to do:
1. For electric indentation:
a - Restore `newline' and `newline-and-indent' to their traditional
functionality, and remove `electric-newline-and-maybe-indent'.
b - Simplify `electric-indent-post-self-insert-function' such that it
reindents only the line on which the self-inserting character is
typed.
c - Reform `electric-indent-local-mode' as a first-class minor mode and
`electric-indent-mode' as a global version of it.
2. For making RET indent the new line in programming modes:
a - Bind RET to `newline-and-indent' and C-j to `newline' in
`prog-mode-map' and possibly in certain other major mode maps (to be
discussed).
b - (Maybe) create a minor mode to restore RET and C-j to traditional
bindings.
The above will leave electric-indent-mode functioning pretty much as it
currently does. What do you say?
> > Incidentally, in Emacs -Q, Text Mode and Fundamental Mode have gone back
> > to the unwanted state of RET doing `newline-and-indent'. Should I raise
> > another bug report?
> You can, but it's not a bug. It's a feature (not sure what you mean by
> "back" since it's been this way ever since I enabled
> electric-indent-mode by default, AFAIK).
Apologies: I thought Text Mode had been restored to the traditional
bindings in the last few months.
> So make this bug report specific about a particular circumstance where
> the behavior is undesirable, or about how hard it is to disable it.
I think RMS's bug #16156, reproduced and being discussed on a parallel
thread, is a good enough example, so there's not much point in me opening
a new one.
> Stefan
--
Alan Mackenzie (Nuremberg, Germany).
- Re: [Emacs-diffs] trunk r116461: Connect electric-indent-mode up with CC Mode. Bug #15478., (continued)
- Re: [Emacs-diffs] trunk r116461: Connect electric-indent-mode up with CC Mode. Bug #15478., Alan Mackenzie, 2014/03/22
- Re: [Emacs-diffs] trunk r116461: Connect electric-indent-mode up with CC Mode. Bug #15478., Stefan, 2014/03/22
- Re: [Emacs-diffs] trunk r116461: Connect electric-indent-mode up with CC Mode. Bug #15478., David Caldwell, 2014/03/22
- Re: [Emacs-diffs] trunk r116461: Connect electric-indent-mode up with CC Mode. Bug #15478., David Kastrup, 2014/03/22
- Re: [Emacs-diffs] trunk r116461: Connect electric-indent-mode up with CC Mode. Bug #15478., David Caldwell, 2014/03/22
- Re: [Emacs-diffs] trunk r116461: Connect electric-indent-mode up with CC Mode. Bug #15478., Stefan, 2014/03/23
- Re: [Emacs-diffs] trunk r116461: Connect electric-indent-mode up with CC Mode. Bug #15478., Alan Mackenzie, 2014/03/22
- Re: [Emacs-diffs] trunk r116461: Connect electric-indent-mode up with CC Mode. Bug #15478., Stefan, 2014/03/23
- Re: [Emacs-diffs] trunk r116461: Connect electric-indent-mode up with CC Mode. Bug #15478.,
Alan Mackenzie <=
- Re: [Emacs-diffs] trunk r116461: Connect electric-indent-mode up with CC Mode. Bug #15478., Dmitry Gutov, 2014/03/24
- Re: [Emacs-diffs] trunk r116461: Connect electric-indent-mode up with CC Mode. Bug #15478., Alan Mackenzie, 2014/03/26
- Re: [Emacs-diffs] trunk r116461: Connect electric-indent-mode up with CC Mode. Bug #15478., Dmitry Gutov, 2014/03/27
- Re: [Emacs-diffs] trunk r116461: Connect electric-indent-mode up with CC Mode. Bug #15478., Alan Mackenzie, 2014/03/30
- Re: [Emacs-diffs] trunk r116461: Connect electric-indent-mode up with CC Mode. Bug #15478., Dmitry Gutov, 2014/03/31
- Re: [Emacs-diffs] trunk r116461: Connect electric-indent-mode up with CC Mode. Bug #15478., Stefan, 2014/03/24
- Re: [Emacs-diffs] trunk r116461: Connect electric-indent-mode up with CC Mode. Bug #15478., Alan Mackenzie, 2014/03/26
- Re: [Emacs-diffs] trunk r116461: Connect electric-indent-mode up with CC Mode. Bug #15478., Stefan Monnier, 2014/03/27
- Re: [Emacs-diffs] trunk r116461: Connect electric-indent-mode up with CC Mode. Bug #15478., Alan Mackenzie, 2014/03/30
- Re: [Emacs-diffs] trunk r116461: Connect electric-indent-mode up with CC Mode. Bug #15478., Stefan Monnier, 2014/03/30