unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan <monnier@iro.umontreal.ca>
To: Alan Mackenzie <acm@muc.de>
Cc: emacs-devel@gnu.org
Subject: Re: [Emacs-diffs] trunk r116461: Connect electric-indent-mode up with CC Mode. Bug #15478.
Date: Sat, 22 Mar 2014 12:14:54 -0400	[thread overview]
Message-ID: <jwvzjkijkh7.fsf-monnier+emacsdiffs@gnu.org> (raw)
In-Reply-To: <20140322131350.GA3163@acm.acm> (Alan Mackenzie's message of "Sat, 22 Mar 2014 13:13:50 +0000")

>> No, I don't agree.  First because most people don't use C-j but use
>> RET instead, and second because typing text linearly is far from being
>> the only important editing pattern.

> ????  That's a non-sequitur.  The indentation of an elisp line of code is
> solely dependent on the the lines before it - its indentation is
> completely determined before any of its contents are typed in.  Therefore
> there is nothing to be gained by reindenting this line at any subsequent
> time, i.e. electric indentation.
> Whether a user uses C-j or RET to terminate this line is irrelevant.

Then I have no idea what you're talking about.  "electric-indent" to me
means "try to keep code indented without having to hit TAB".  In Elisp,
without electric-indent you have to use C-j or TAB if you want your
code indented.  So whether the user hits C-j or RET is relevant.

> Using electric indentation on RET is poor, because it only works when you
> actually type a RET (or a C-j).

That doesn't mean it's poor.  Just that it's not sufficient.
And I fully agree on this, which is why we have electric-indent-chars.

> This is often not the case, e.g. when you open up a line (e.g. with
> C-M-o) then type in a new line of code.

Last I checked, RET is used more commonly than C-M-o.

> If you are typing in comments at the end of code lines, you won't want
> electric indentation messing up their alignment.

If auto-indentation gets it wrong, then indeed electric-indent will get
in the way.  That's true whether RET is electric or not.

> electric indentation is needed on keys other than RET; when that is the
> case, e-i on RET is superfluous.

Having RET in electric-indent-chars is not always indispensable, indeed.
But that doesn't make it harmful.  And of course, if you want, you can
remove it from electric-indent-chars either in your .emacs or in c-mode.

>> >> There are details about *how* e-i-m works which depend on the mode.
>> >> Yes.  That's why e-i-m has mode-local settings (e.g. which keys are
>> >> electric, or whether the indentation algorithm can reliably reindent).
>> > Any "indentation algorithm" can reliably reindent.  It is the context
>> > in which the algorithm is used which is important, not the algorithm
>> > itself.
>> No: python-mode, haskell-mode, and coffeescript-mode can't.
> We're in violent agreement, here.  It is the context (i.e. the major
> mode) these indentation algorithms are used in, not the algorithms
> themselves.  The algorithms themselves are perfectly capable of
> reindentation.

To me, the algorithm used by haskell-mode could not be used in
another context, so this distinction makes no sense.

> You've cut out the necessary context again, and put me to unnecessary
> work to restore it.

No, it's because the context did not manage to explain to me the text
that I quoted.  I stripped this context because it was not useful for me
to explain precisely which part I failed to understand.

> Here is that context, restored:
>>>> But the global e-i-m setting is about deciding whether the user wants
>>>> his code to be automatically indented as he types (to the extent
>>>> possible).  It is *defined* as a person-dependent preference.
>>> Clearly.  I am pointing out that this definition is perhaps a suboptimal
>>> one.
>> I don't see what you mean by "definition" not "suboptimal"
> I think it's now clear which definition, your definition, we're talking
> about.

Thanks, yes, that makes sense.

> I put it to you, once more, that this "person-dependent" preference,
> as contrasted with a major-mode or buffer dependent one,
> is suboptimal.

What would be more optimal?

Clearly, having the major mode decide for the user is not better because
I can assure you that there are users who want electric indentation in
C-mode and there are others who don't.

> Minor modes which want to hook up their functionality to a key like "{"
> should do just that, not attempt to supersede other functionality.
> Mechanisms for this exist - electric-indent-mode uses one of these, for
> example.

Well, mechanisms to do that were added at the same time as
electric-indent-mode.

But so it seems the part of the design you dislike in
electric-indent-mode is not the use of post-self-insert-hook (as
I assumed) but something else.  What is it?

It seems now that your main (only?) objection is having RET do
reindent-then-newline-and-indent instead of having it only do
newline-and-indent.  If that's the case, then let's focus on this.
In what scenario is it a problem?


        Stefan



  reply	other threads:[~2014-03-22 16:14 UTC|newest]

Thread overview: 64+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <E1WFSpO-0001e7-Gm@vcs.savannah.gnu.org>
2014-02-18  0:11 ` [Emacs-diffs] trunk r116461: Connect electric-indent-mode up with CC Mode. Bug #15478 Stefan Monnier
2014-02-22 18:27   ` Alan Mackenzie
2014-02-25  3:24     ` Stefan Monnier
2014-02-28 19:50       ` Alan Mackenzie
2014-03-01 15:57         ` Stefan Monnier
2014-03-02 11:51           ` Alan Mackenzie
2014-03-04  3:48             ` Stefan Monnier
2014-03-08 22:58               ` Alan Mackenzie
2014-03-09  1:57                 ` Stefan Monnier
2014-03-09 12:37                   ` Alan Mackenzie
2014-03-10  3:37                     ` Stefan Monnier
2014-03-10  6:59                       ` Glenn Morris
2014-03-10 12:24                       ` João Távora
2014-03-10 18:30                         ` Stefan Monnier
2014-03-16 22:35                       ` Alan Mackenzie
2014-03-17 15:48                         ` Stefan
2014-03-19 22:42                           ` Alan Mackenzie
2014-03-20  1:46                             ` Stefan
2014-03-20  8:35                               ` Thien-Thi Nguyen
2014-03-21  8:24                                 ` João Távora
2014-03-22 13:13                               ` Alan Mackenzie
2014-03-22 16:14                                 ` Stefan [this message]
2014-03-22 20:19                                   ` David Caldwell
2014-03-22 22:05                                     ` David Kastrup
2014-03-22 22:32                                       ` David Caldwell
2014-03-24  1:13                                     ` Stefan
2014-03-22 22:34                                   ` Alan Mackenzie
2014-03-24  1:37                                     ` Stefan
2014-03-24 22:40                                       ` Alan Mackenzie
2014-03-25  1:37                                         ` Dmitry Gutov
2014-03-26 20:53                                           ` Alan Mackenzie
2014-03-27  8:02                                             ` Dmitry Gutov
2014-03-30 14:57                                               ` Alan Mackenzie
2014-03-31 17:11                                                 ` Dmitry Gutov
2014-04-03 21:53                                                   ` Alan Mackenzie
2014-03-25  1:54                                         ` Stefan
2014-03-26 21:21                                           ` Alan Mackenzie
2014-03-27 14:49                                             ` Stefan Monnier
2014-03-30 11:37                                               ` Alan Mackenzie
2014-03-30 16:46                                                 ` Stefan Monnier
2014-03-22 23:10                                   ` Alan Mackenzie
2014-03-24  1:39                                     ` Stefan
2014-03-24  6:59                                       ` Stephen J. Turnbull
2014-03-24  9:08                                         ` Dmitry Gutov
2014-03-24 17:19                                           ` Eli Zaretskii
2014-03-24 17:29                                             ` David Kastrup
2014-03-24 17:39                                               ` David Kastrup
2014-03-24 17:38                                             ` Dmitry Gutov
2014-03-24 17:52                                               ` Eli Zaretskii
2014-03-25  1:53                                                 ` Dmitry Gutov
2014-03-25  3:49                                                   ` Eli Zaretskii
2014-03-24 18:32                                           ` Stefan
2014-03-25  1:49                                             ` Dmitry Gutov
2014-03-25  7:44                                             ` Stephen J. Turnbull
2014-03-25  8:08                                               ` Steinar Bang
2014-03-25 16:49                                                 ` Stephen J. Turnbull
2014-03-25 17:08                                                   ` Steinar Bang
2014-03-25 17:31                                                     ` Dmitry Gutov
2014-03-25 19:28                                                       ` Steinar Bang
2014-03-25 19:49                                                         ` David Kastrup
2014-03-25 19:54                                                           ` Dmitry Gutov
2014-03-25 13:26                                               ` Stefan Monnier
2014-03-27  7:51                                                 ` Stephen J. Turnbull
2014-03-24 21:12                                         ` Alan Mackenzie

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvzjkijkh7.fsf-monnier+emacsdiffs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=acm@muc.de \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).