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: Stephen J. Turnbull
Subject: Re: [Emacs-diffs] trunk r116461: Connect electric-indent-mode up with CC Mode. Bug #15478.
Date: Tue, 25 Mar 2014 16:44:38 +0900

Stefan writes:

 > > FWIW, effectively doing `reindent-then-newline-and-indent' on RET also
 > > seems gratuitous to me. When I reach the end of a line, usually text on
 > > that line is already indented correctly (automatically, or through me
 > > typing TAB manually),
 > 
 > You might get used to "RET reindents" and stop hitting TAB that often ;-)

I'm very unlikely to get used to it.  Specifically, in the very
annoying case where unconventional indentation gets blown away by it
(TAB won't fix that!)

 > For me one of the reasons why it's not gratuitous is because of things like:
 > 
 >        begin
 >          blabla
 >          blibli
 >        end
 > 
 > Go to just before "blibli" and type "end RET": notice that hitting TAB
 > just before RET won't help you, because you need to reindent the line
 > after the newline is inserted.

I wouldn't do that, because the right indentation for "blibli" depends
on intended semantics.  That is, if I started from syntactically valid
code, after inserting "end" I now have invalid code ("end without
begin").  Non-trivial edits are required to return the buffer to
"well-formed" state, and I personally prefer the now-orphaned fragment
to retain its indentation, indicating its previous semantics.

Therefore I would go to the end of "blabla", and hit RET.  Why would I
care about the "no-op" reindent?  Because it might not be a no-op.
("blabla" might not be conventionally indented.)

 > This is admittedly less serious for interactive editing than for
 > keyboard macros (and templates/skeletons/snippets), but I find the
 > behavior to be handy.

In case of such things, I'd want to do

    C-x ( C-SPC ... macro keys ... C-x C-x M-x indent-region C-x )

(except in Python, where you're screwed because block structure is
determined by indentation, so situations where determining the
appropriate number of dedents requires knowing the intended semantics
are common).

 > > For all others, just swapping C-j and RET bindings would've worked just
 > > as well, and I think it would result in simpler code.
 > 
 > Again "just swapping" sounds simple, but I'm not sure what patch you
 > have in mind.  I think it's important for the user to be able to easily
 > say something like (electric-indent-mode -1) (and/or its buffer-local
 > equivalent) to recover the Emacs-23 behavior.

"Just swapping" is entirely independent of electric-indent-mode.  It
wouldn't change the Emacs-23 behavior, just have it on different keys.




reply via email to

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