unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Dmitry Gutov <dgutov@yandex.ru>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: "Harald Jörg" <haj@posteo.de>,
	"Emacs Developer List" <emacs-devel@gnu.org>
Subject: Re: newline-and-indent vs. electric-indent-mode
Date: Sun, 24 Jan 2021 04:54:10 +0200	[thread overview]
Message-ID: <02e60113-66f4-0217-d8c4-abe8cb3bdb6d@yandex.ru> (raw)
In-Reply-To: <jwva6t0s6vj.fsf-monnier+emacs@gnu.org>

On 23.01.2021 05:16, Stefan Monnier wrote:
>> I'm not sure how it is a bug. It's "reindentation" in both cases, right?
>> And electric-indent-inhibit's docstring refers to reindentation.
> 
> But with the current behavior, a char other than \n into
> `electric-indent-chars` can never have any effect when
> `electric-indent-inhibit` is non-nil.  So I'd argue that a char other
> than \n should take precedence over `electric-indent-inhibit`,
> especially because such a char can only be there if it's been
> explicitly added.

All right, filed as bug#46064.

I suppose of a user wants to have those over vars not have effect, they 
can set those to nil in the major mode hook.

>>>> It's just that in my mental model \n doesn't belong to the current line,
>>>> only to the next one. So it shouldn't reindent the original line.
>>> It's often useful for me, as in typing
>>>       foo RET else RET blabla
>>> where the else benefits from being reindented upon the second RET.
>> I see. Well, ruby--electric-indent-p covers this scenario already.
> 
> Indeed, this approach can work as well.
> [ BTW, here's another one where ruby-mode is saved by the reindentation
>    done by `newline`: foo RET endl DEL RET  ;-)  ]

This one can be also solved by 'undo' instead of DEL, but yes.

>> Perhaps your approach is simpler, but always reindenting the original line
>> gets annoying if the indentation function sometimes produces suboptimal
>> results.
> 
> I think `electric-indent-mode` is annoying in any case if the
> indentation code disagrees with your style.

True, but my present complaint is about it being annoying *twice* for 
the same line. And if it's being annoying while point is still on that 
line, it's marginally easier to fix.

> There are lots of knobs to
> play with deciding when and were indentation happens, and it's hard to
> know what the statistically optimal heuristic.  So I won't try to argue
> that the current choice is best, but I think it's equally hard to argue
> that some other choice is best.

Agreed.

> If we could automatically detect when a reindentation is immediately
> undone by the user, maybe we could collect statistics.

That might help with indentation defaults (if the statistics is sent 
back to us somehow), but not with specific cases, I think. And the 
indentation code has to be capable of producing the needed indentation 
patterns, at least with some values of indentation-related options.

>> again, or undo the change and go with C-o C-n TAB.
> 
> I think `C-j TAB` is quicker (but I must admit that my muscle memory
> often makes me do `C-q C-j TAB`)

Oh, right.

In the meantime, I'll try running with RET bound to newline-and-indent, 
like in good old days.



  reply	other threads:[~2021-01-24  2:54 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-22 13:53 newline-and-indent vs. electric-indent-mode Harald Jörg
2021-01-22 14:49 ` Stefan Monnier
2021-01-22 15:02   ` Dmitry Gutov
2021-01-22 15:09     ` Stefan Monnier
2021-01-22 22:43       ` Dmitry Gutov
2021-01-22 22:56         ` Stefan Monnier
2021-01-22 23:00           ` Dmitry Gutov
2021-01-22 23:16             ` Stefan Monnier
2021-01-23  0:45               ` Dmitry Gutov
2021-01-23  3:16                 ` Stefan Monnier
2021-01-24  2:54                   ` Dmitry Gutov [this message]
2021-01-24  5:29                     ` Stefan Monnier
2021-01-24 21:45                       ` Dmitry Gutov
2021-01-25  1:56                   ` Madhu
2021-01-25  2:29                     ` Dmitry Gutov
2021-01-25 10:45                       ` Madhu
2021-01-25 11:59                         ` Dmitry Gutov
2021-01-25 14:36                         ` Stefan Monnier
2021-01-25 14:42                           ` Dmitry Gutov
2021-01-25 15:15                             ` Stefan Monnier
2021-01-25 20:10                               ` Rudolf Schlatte
2021-01-26  2:04                               ` Dmitry Gutov
2021-01-26  2:43                                 ` Stefan Monnier
2021-01-26 15:58                               ` martin rudalics
2021-01-25  3:33                     ` Eli Zaretskii
2021-01-22 19:33   ` Harald Jörg
2021-01-22 22:05     ` Stefan Monnier
2021-01-23  2:19       ` Harald Jörg
2021-01-23  3:29         ` Stefan Monnier
2021-01-23 16:27           ` Harald Jörg

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=02e60113-66f4-0217-d8c4-abe8cb3bdb6d@yandex.ru \
    --to=dgutov@yandex.ru \
    --cc=emacs-devel@gnu.org \
    --cc=haj@posteo.de \
    --cc=monnier@iro.umontreal.ca \
    /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).