[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: |
Sun, 30 Mar 2014 14:57:17 +0000 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
Hello, Dmitry.
On Thu, Mar 27, 2014 at 10:02:49AM +0200, Dmitry Gutov wrote:
> On 26.03.2014 22:53, Alan Mackenzie wrote:
> > Indentation (in the sense of what `indent-line-function' does) only makes
> > sense in programming (etc.) modes. In text modes, and the like,
> > indentation is, in practice, done with adaptive fill prefices.
> This could be considered a reason to improve the indent-line-function in
> text-mode. `indent-relative' offers behavior that's pretty close. Maybe
> it could be made to follow the behavior of auto-fill even closer.
Notice, here, how we're no longer talking about electric indentation, but
rather about newline-and-indent. The two topics are distinct.
> > Having RET do `newline-and-indent' in Emacs Lisp Mode while doing
> > `newline' in Text Mode makes a lot of sense to me. A trickier question
> > is to identify which of the non-programming modes really want this sort
> > of indentation.
> I'd rather make exceptions for specific "non-programming modes", where
> indentation of the next line is really hard to guess.
Yes, but how? fundamental-mode is a non-programming mode, so the global
key map needs RET set up for newline, C-j for newline-and-indent. That
leaves lots of mode key maps to be set up. At this point, your
suggestion and mine become the same.
> Many modes that don't inherit from prog-mode have something to do with
> structured content, and often define their own specific indentation
> functions (sgml-mode, markdown-mode inherit from text-mode, css-mode and
> yaml-mode inherit from fundamental-mode).
> I'd really expect typing <div> and pressing RET in html-mode to offer
> hard +2 indentation on the next line, but I wouldn't call it a
> programming mode.
Yes.
> In Markdown, I'm often typing code blocks, and I expect RET to bring me
> to the column which the previous line was indented to, so I don't have
> to press TAB each time. And if I'm outside of a code block, the lines
> usually either have no indentation (then indent-relative indents to the
> 0th column as well), or they serve as continuation of a paragraph, and I
> want each next line to have the same extra indentation until the
> paragraph ends (and indent-relative does that well enough).
I usually think of html, markdown, and such like, as the "etc." in
"programming modes (etc.)".
> The last time I used text-mode, it was for a similar purpose (a couple
> of code blocks, and the rest of the text is indented to column 0).
> `M-x fill-paragraph' would slaughter the code blocks, and it wouldn't
> improve the indentation anywhere else.
If you edit the non-code blocks a lot in text mode, `fill-paragraph' is
_exactly_ what's wanted to restore the filling. I think, in text mode,
M-q preserves existing indentation.
> >> There's a certain class of users who've been binding RET to
> >> `newline-and-indent' for a long time (myself included), and I
> >> haven't seen anyone mention only doing that in prog-mode, instead of
> >> globally.
> > That was what we collectively decided last Autumn when the topic came up.
> Okay: I haven't seen anyone mention doing it outside of emacs-devel.
> > Richard Stallman alluded to it in his disgust at bug #16156, when what
> > was bound to RET at the time zapped his indentation.
> > I personally would not be unhappy at leaving the traditional binding in
> > place for RET and C-j, but wouldn't mind them swapping in "indenting"
> > modes. I'd object strongly to RET in text mode messing around with
> > indentation.
> Maybe text-mode by itself should be a special case. I don't use it often
> enough to have a strong opinion.
I think RET should do the most natural sort of newline, and C-j the
subsidiary one, whatever they may happen to be for a particular mode.
> >> How hard can it be for a user to change the key bindings without a
> >> mode?
> > Middling, not very. Such a minor mode might serve to damp down the
> > inevitable complaints the change in defaults will provoke.
> As long as this new mode is divorced from electric-indent-mode, I'd be
> happy.
This is a key point.
> > By "makes sense" I think you mean "seems a sensible thing to do". I take
> > issue with you here and say that, in Text Mode, it's a bizarre thing to
> > do. I can't think of any normal circumstances where this behaviour would
> > be commonly desired; just how often in Text Mode do you not want RET just
> > to insert a new line when you type it at the beginning of a line?
> This specific behavior is a consequence of using `newline-and-indent'.
No, not at all. It's a consequence of electric behaviour getting
entangled with newline-and-indent. Electric indentation doesn't belong
in Text Mode. It's useful only where the indentation of a line of code
can be changed by what's in the line.
> One answer may be "Don't want that? Use `open-line'", which I sometimes
> do, but special-casing indent-line-function in text-mode not to reindent
> on the first invocation (when point is at bol followed by whitespace and
> then non-whitespace on the same line) could well be another option.
;-) That would be papering over the cracks. Banishing electric
indentation from major modes where it's silly is what we really want.
> What makes sense to me, is using `newline-and-indent' itself. Richard
> doesn't like
> foo
> | bar
> turning into
> foo
> |bar
> I can understand that, but I don't like
> foo
> bar|baz
> turning into
> foo
> bar
> |baz (note the missing indentation)
> Which situation do you think occurs more frequently?
The two are completely non-competing situations. RMS's happened because
electric indentation was active where it shouldn't be. Your situation is
a matter of binding (RET C-j) to ('newline 'newline-and-indent) the
appropriate way round. Don't confuse these.
I think Text Mode is about typing natural language text in paragraphs.
The "indentation" will be the adaptive fill prefix inserted by
auto-fill-mode. Normally, you'll be typing RET to start a new paragraph,
and this will either be at column 0, or at some column not dependent on
the previous text. newline-and-indent isn't the Right Thing here.
--
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., 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, 2014/03/24
- 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 <=
- 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
- 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., Stephen J. Turnbull, 2014/03/24
- Re: [Emacs-diffs] trunk r116461: Connect electric-indent-mode up with CC Mode. Bug #15478., Dmitry Gutov, 2014/03/24