* electric-indent-mode: abolition of `newline' function is not the Right Thing.
@ 2013-10-13 10:13 Alan Mackenzie
2013-10-13 13:23 ` Stefan Monnier
2013-10-13 20:00 ` electric-indent-mode: abolition of `newline' function is not the Right Thing Matthias Meulien
0 siblings, 2 replies; 72+ messages in thread
From: Alan Mackenzie @ 2013-10-13 10:13 UTC (permalink / raw)
To: emacs-devel
Hi, Emacs.
`electric-indent-post-self-insert-function' effectively redefines
`newline' to `newline-and-indent'. So, whilst `electric-indent-mode' is
enabled, there is no easy way to invoke the traditional functionality of
`newline'. This is a Bad Thing.
I discovered this whilst trying `electric-indent-mode' in Text Mode.
I have a command which starts a new paragraph thusly:
(i) It calls `newline' and inserts, e.g. "(vi) ".
(ii) It calls `fill-paragraph' for the text in the new paragraph.
Unfortunately, `newline' indents the "(vi) " to the level of the
old paragraph, so that the following `fill-paragraph' joins the old and
new paragraphs together. This is bad.
`newline-and-indent' exists as its own command, traditionally bound to
C-j. A better way for `electric-indent-mode' to achieve the effect it
wants is to get users to rebind <CR> to `newline-and-indent' or suggest
the use of C-j.
`newline' must continue to exist, both as a command and as a lisp
function.
--
Alan Mackenzie (Nuremberg, Germany).
^ permalink raw reply [flat|nested] 72+ messages in thread
* Re: electric-indent-mode: abolition of `newline' function is not the Right Thing.
2013-10-13 10:13 electric-indent-mode: abolition of `newline' function is not the Right Thing Alan Mackenzie
@ 2013-10-13 13:23 ` Stefan Monnier
2013-10-13 14:09 ` Alan Mackenzie
2013-10-13 20:00 ` electric-indent-mode: abolition of `newline' function is not the Right Thing Matthias Meulien
1 sibling, 1 reply; 72+ messages in thread
From: Stefan Monnier @ 2013-10-13 13:23 UTC (permalink / raw)
To: Alan Mackenzie; +Cc: emacs-devel
> I discovered this whilst trying `electric-indent-mode' in Text Mode.
> I have a command which starts a new paragraph thusly:
> (i) It calls `newline' and inserts, e.g. "(vi) ".
Use (insert "\n") rather than (newline).
Stefan
^ permalink raw reply [flat|nested] 72+ messages in thread
* Re: electric-indent-mode: abolition of `newline' function is not the Right Thing.
2013-10-13 13:23 ` Stefan Monnier
@ 2013-10-13 14:09 ` Alan Mackenzie
2013-10-13 16:22 ` Stefan Monnier
0 siblings, 1 reply; 72+ messages in thread
From: Alan Mackenzie @ 2013-10-13 14:09 UTC (permalink / raw)
To: Stefan Monnier; +Cc: emacs-devel
'morning, Stefan!
On Sun, Oct 13, 2013 at 09:23:49AM -0400, Stefan Monnier wrote:
> > I discovered this whilst trying `electric-indent-mode' in Text Mode.
> > I have a command which starts a new paragraph thusly:
> > (i) It calls `newline' and inserts, e.g. "(vi) ".
> Use (insert "\n") rather than (newline).
:-) Of course there are workarounds, but that's not the point. There
are approximately 198 calls to `newline' in the Emacs Lisp sources, and
an unknown further number in other Lisp files and users' .emacsen. Some
of these calls are going to get broken by the effective change to
`newline'.
Redefining `newline' as `newline-and-indent' whilst
`electric-indent-mode' is active is not the Right Thing to do.
> Stefan
--
Alan Mackenzie (Nuremberg, Germany).
^ permalink raw reply [flat|nested] 72+ messages in thread
* Re: electric-indent-mode: abolition of `newline' function is not the Right Thing.
2013-10-13 14:09 ` Alan Mackenzie
@ 2013-10-13 16:22 ` Stefan Monnier
2013-10-13 17:28 ` Alan Mackenzie
0 siblings, 1 reply; 72+ messages in thread
From: Stefan Monnier @ 2013-10-13 16:22 UTC (permalink / raw)
To: Alan Mackenzie; +Cc: emacs-devel
> :-) Of course there are workarounds, but that's not the point. There
> are approximately 198 calls to `newline' in the Emacs Lisp sources, and
> an unknown further number in other Lisp files and users' .emacsen. Some
> of these calls are going to get broken by the effective change to
> `newline'.
Right. But the problem is that this is not specific to
electric-indent-mode: newline calls self-insert-command, which runs
expand-abbrev and (since Emacs24) post-self-insert-hook. Any caller
which only wants a \n and no extra doo-dads should not call `newline'.
electric-indent-mode just makes this problem more apparent.
Stefan
^ permalink raw reply [flat|nested] 72+ messages in thread
* Re: electric-indent-mode: abolition of `newline' function is not the Right Thing.
2013-10-13 16:22 ` Stefan Monnier
@ 2013-10-13 17:28 ` Alan Mackenzie
2013-10-14 12:56 ` Stefan Monnier
2013-10-15 18:28 ` martin rudalics
0 siblings, 2 replies; 72+ messages in thread
From: Alan Mackenzie @ 2013-10-13 17:28 UTC (permalink / raw)
To: Stefan Monnier; +Cc: emacs-devel
Hello, Stefan.
On Sun, Oct 13, 2013 at 12:22:33PM -0400, Stefan Monnier wrote:
> > :-) Of course there are workarounds, but that's not the point.
> > There are approximately 198 calls to `newline' in the Emacs Lisp
> > sources, and an unknown further number in other Lisp files and users'
> > .emacsen. Some of these calls are going to get broken by the
> > effective change to `newline'.
> Right. But the problem is that this is not specific to
> electric-indent-mode: newline calls self-insert-command, which runs
> expand-abbrev and (since Emacs24) post-self-insert-hook. Any caller
> which only wants a \n and no extra doo-dads should not call `newline'.
> electric-indent-mode just makes this problem more apparent.
Sorry Stefan, but that is disingenuous. If you look again at
`electric-indent-post-self-insert-function', you will see that that
function deliberately converts `newline' into `newline-and-indent'. It
even says so in the comments. _This_ is the problem.
What is the justification for this extension in functionality of
`newline' to do the same as `newline-and-indent'?
And people calling `newline' do not simply want a \n. They want
abbreviations to be processed, they want auto-fill to be run, trailing
space to be removed from otherwise blank lines, and so on. What they
_don't_ want is indentation inserted on the new line.
Please take this indent-newline functionality out of
e-i-post-s-i-function (or let me do it).
Incidentally, each call of e-i-post-s-i-function creates a new marker,
bound to the let variable `before'. This is not set to point nowhere
before `before' becomes unbound. I think it probably should.
> Stefan
--
Alan Mackenzie (Nuremberg, Germany).
^ permalink raw reply [flat|nested] 72+ messages in thread
* Re: electric-indent-mode: abolition of `newline' function is not the Right Thing.
2013-10-13 17:28 ` Alan Mackenzie
@ 2013-10-14 12:56 ` Stefan Monnier
2013-10-16 18:46 ` Alan Mackenzie
2013-10-15 18:28 ` martin rudalics
1 sibling, 1 reply; 72+ messages in thread
From: Stefan Monnier @ 2013-10-14 12:56 UTC (permalink / raw)
To: Alan Mackenzie; +Cc: emacs-devel
> And people calling `newline' do not simply want a \n. They want
> abbreviations to be processed, they want auto-fill to be run, trailing
> space to be removed from otherwise blank lines, and so on. What they
> _don't_ want is indentation inserted on the new line.
Not sure who is your "they". In my experience, what I've seen users
want is "auto-indentation" and by that they mean that the text should be
kept indented when they hit RET and a few other keys.
E.g. a question I've seen many times is
So I tried this Emacs thingy which claims to do indentation for me,
but all my text stays at the left-margin. What am I doing wrong.
and the answer I generally see given is:
You want to bind RET to newline-and-indent.
Are these the majority, users? I don't know. But so far, you're the
only person who's complained about ?\n being in the default value of
electric-indent-chars, so I see no evidence that your preference in this
regard is representative.
> Please take this indent-newline functionality out of
> e-i-post-s-i-function (or let me do it).
Very easy: remove ?\n from electric-indent-chars.
IOW (setq-default electric-indent-chars nil) should do that for you.
> Incidentally, each call of e-i-post-s-i-function creates a new marker,
> bound to the let variable `before'. This is not set to point nowhere
> before `before' becomes unbound. I think it probably should.
Let's see if/when this leads to a concrete performance problem, and at
that point we'll see how to fix it. Making a marker point nowhere is an
annoyance and is itself a costly operation (O(N) for N markers), so
I don't much like using the workaround you suggest.
Stefan
^ permalink raw reply [flat|nested] 72+ messages in thread
* Re: electric-indent-mode: abolition of `newline' function is not the Right Thing.
2013-10-14 12:56 ` Stefan Monnier
@ 2013-10-16 18:46 ` Alan Mackenzie
0 siblings, 0 replies; 72+ messages in thread
From: Alan Mackenzie @ 2013-10-16 18:46 UTC (permalink / raw)
To: Stefan Monnier; +Cc: emacs-devel
Hello, Stefan.
On Mon, Oct 14, 2013 at 08:56:25AM -0400, Stefan Monnier wrote:
> > And people calling `newline' do not simply want a \n. They want
> > abbreviations to be processed, they want auto-fill to be run, trailing
> > space to be removed from otherwise blank lines, and so on. What they
> > _don't_ want is indentation inserted on the new line.
> Not sure who is your "they".
The people who have written Emacs Lisp code which calls `newline' (as
contrasted with `newline-and-indent').
> In my experience, what I've seen users want is "auto-indentation" and
> by that they mean that the text should be kept indented when they hit
> RET and a few other keys.
That is a different topic from this thread's. The question which should
be asked, should have been asked some while ago, is what is the best way
of giving these users what they want. The answer is not, and can not be,
to have an Emacs without the traditional functionality of `newline'.
[ .... ]
> But so far, you're the only person who's complained about ?\n being in
> the default value of electric-indent-chars, so I see no evidence that
> your preference in this regard is representative.
Have I complained about \n being in electric-indent-chars? I don't think
I have, but might be mistaken. My complaint, and I've been perfectly
clear about it, is the abolition of the traditional functionality of the
`newline' function whenever electric-indent-mode is enabled. You haven't
really addressed this issue in your past few posts.
> > Please take this indent-newline functionality out of
> > e-i-post-s-i-function (or let me do it).
> Very easy: remove ?\n from electric-indent-chars.
> IOW (setq-default electric-indent-chars nil) should do that for you.
Is that your solution to the ~198 uses of `newline' in Emacs and
countless others in other code and users' .emacsen? Each caller of
`newline' should first ensure that \n is not in electric-indent-chars?
> > Incidentally, each call of e-i-post-s-i-function creates a new marker,
> > bound to the let variable `before'. This is not set to point nowhere
> > before `before' becomes unbound. I think it probably should.
> Let's see if/when this leads to a concrete performance problem, and at
> that point we'll see how to fix it. Making a marker point nowhere is an
> annoyance and is itself a costly operation (O(N) for N markers), so
> I don't much like using the workaround you suggest.
Well, it's not really my suggestion, it's standard advice in the Elisp
manual on page "Overview of Markers". Without doing this, a buffer's
performance is gradually going to worsen as a heap of useless markers
accumulates, until such time as garbage collection eventually gets rid of
them. The cost of making a marker point nowhere, less than once per
keystroke, is hardly high.
> Stefan
--
Alan Mackenzie (Nuremberg, Germany).
^ permalink raw reply [flat|nested] 72+ messages in thread
* Re: electric-indent-mode: abolition of `newline' function is not the Right Thing.
2013-10-13 17:28 ` Alan Mackenzie
2013-10-14 12:56 ` Stefan Monnier
@ 2013-10-15 18:28 ` martin rudalics
2013-10-16 17:12 ` Alan Mackenzie
1 sibling, 1 reply; 72+ messages in thread
From: martin rudalics @ 2013-10-15 18:28 UTC (permalink / raw)
To: Alan Mackenzie; +Cc: Stefan Monnier, emacs-devel
> And people calling `newline' do not simply want a \n. They want
> abbreviations to be processed, they want auto-fill to be run, trailing
> space to be removed from otherwise blank lines, and so on. What they
> _don't_ want is indentation inserted on the new line.
What I want is RET to always indent the new line. And when I'm at the
beginning of a line I want that RET opens a new line here and indents
it. And that's why I'm hopelessly lost when I have to work with emacs
-Q.
martin
^ permalink raw reply [flat|nested] 72+ messages in thread
* Re: electric-indent-mode: abolition of `newline' function is not the Right Thing.
2013-10-15 18:28 ` martin rudalics
@ 2013-10-16 17:12 ` Alan Mackenzie
2013-10-16 17:59 ` Stefan Monnier
2013-10-16 18:34 ` martin rudalics
0 siblings, 2 replies; 72+ messages in thread
From: Alan Mackenzie @ 2013-10-16 17:12 UTC (permalink / raw)
To: martin rudalics; +Cc: Stefan Monnier, emacs-devel
Hello, Martin.
On Tue, Oct 15, 2013 at 08:28:22PM +0200, martin rudalics wrote:
> > And people calling `newline' do not simply want a \n. They want
> > abbreviations to be processed, they want auto-fill to be run, trailing
> > space to be removed from otherwise blank lines, and so on. What they
> > _don't_ want is indentation inserted on the new line.
> What I want is RET to always indent the new line. And when I'm at the
> beginning of a line I want that RET opens a new line here and indents
> it. And that's why I'm hopelessly lost when I have to work with emacs
> -Q.
With respect, that is not the topic of this thread. That topic is that
with electric-indent-mode enabled, there is now no command, also no
elisp function which has the traditional functionality of `newline'.
That is a significant loss to Emacs. The change in the functionality of
`newline' will break existing elisp code which calls `newline'. Also,
there will be no way for a user to set up traditional Emacs behaviour
wrt <ret> and C-j.
For what you want, `newline-and-indent' exists, as you know.
> martin
>
^ permalink raw reply [flat|nested] 72+ messages in thread
* Re: electric-indent-mode: abolition of `newline' function is not the Right Thing.
2013-10-16 17:12 ` Alan Mackenzie
@ 2013-10-16 17:59 ` Stefan Monnier
2013-10-16 18:58 ` Alan Mackenzie
2013-10-16 23:22 ` Stephen J. Turnbull
2013-10-16 18:34 ` martin rudalics
1 sibling, 2 replies; 72+ messages in thread
From: Stefan Monnier @ 2013-10-16 17:59 UTC (permalink / raw)
To: Alan Mackenzie; +Cc: martin rudalics, emacs-devel
> With respect, that is not the topic of this thread. That topic is that
> with electric-indent-mode enabled, there is now no command, also no
> elisp function which has the traditional functionality of `newline'.
Quick, without looking at the source code of newline: what does
`newline' do that (insert "\n") or C-q C-j doesn't do?
> That is a significant loss to Emacs.
I don't know what that is supposed to mean.
Stefan
^ permalink raw reply [flat|nested] 72+ messages in thread
* Re: electric-indent-mode: abolition of `newline' function is not the Right Thing.
2013-10-16 17:59 ` Stefan Monnier
@ 2013-10-16 18:58 ` Alan Mackenzie
2013-10-16 20:55 ` chad
2013-10-16 23:22 ` Stephen J. Turnbull
1 sibling, 1 reply; 72+ messages in thread
From: Alan Mackenzie @ 2013-10-16 18:58 UTC (permalink / raw)
To: Stefan Monnier; +Cc: martin rudalics, emacs-devel
Hello, Stefan.
On Wed, Oct 16, 2013 at 01:59:07PM -0400, Stefan Monnier wrote:
> > With respect, that is not the topic of this thread. That topic is that
> > with electric-indent-mode enabled, there is now no command, also no
> > elisp function which has the traditional functionality of `newline'.
> Quick, without looking at the source code of newline: what does
> `newline' do that (insert "\n") or C-q C-j doesn't do?
The answer you're not looking for is "It inserts a newline, whilst doing
lots of Right Things on the previous line that I don't need to worry
about too much.", but it's my preferred answer.
Answering you literally, I think newline invokes filling, abbreviation
expansion and possibly other things, but (insert "\n") and C-q C-j
don't.
> > That is a significant loss to Emacs.
> I don't know what that is supposed to mean.
For one thing, it would prevent somebody using a mode with {e-i-m using
\n} and retaining the classical difference betweeen <ret> and C-j.
For another thing, it will stop lots of Emacs Lisp from working.
> Stefan
--
Alan Mackenzie (Nuremberg, Germany).
^ permalink raw reply [flat|nested] 72+ messages in thread
* Re: electric-indent-mode: abolition of `newline' function is not the Right Thing.
2013-10-16 18:58 ` Alan Mackenzie
@ 2013-10-16 20:55 ` chad
2013-10-16 21:07 ` Daniel Colascione
2013-10-18 16:51 ` Alan Mackenzie
0 siblings, 2 replies; 72+ messages in thread
From: chad @ 2013-10-16 20:55 UTC (permalink / raw)
To: Alan Mackenzie; +Cc: emacs-devel@gnu.org devel
On 16 Oct 2013, at 11:58, Alan Mackenzie <acm@muc.de> wrote:
>
> For another thing, it will stop lots of Emacs Lisp from working.
What specific packages/libraries/etc break with the current
electric-indent-mode enabled?
~Chad
^ permalink raw reply [flat|nested] 72+ messages in thread
* Re: electric-indent-mode: abolition of `newline' function is not the Right Thing.
2013-10-16 20:55 ` chad
@ 2013-10-16 21:07 ` Daniel Colascione
2013-10-18 16:51 ` Alan Mackenzie
1 sibling, 0 replies; 72+ messages in thread
From: Daniel Colascione @ 2013-10-16 21:07 UTC (permalink / raw)
To: chad, Alan Mackenzie; +Cc: emacs-devel@gnu.org devel
On 10/16/13 1:55 PM, chad wrote:
> On 16 Oct 2013, at 11:58, Alan Mackenzie <acm@muc.de> wrote:
>>
>> For another thing, it will stop lots of Emacs Lisp from working.
>
> What specific packages/libraries/etc break with the current
> electric-indent-mode enabled?
>
FWIW, I've seen a lot of crufty site-specific elisp that barely works as
it is. (Monkeypatching cc-mode seems perennially popular.) Can we please
try not to break it further? I don't see why we have to change newline's
behavior in order to make newline-and-indent behavior the default, which
I agree we should do.
^ permalink raw reply [flat|nested] 72+ messages in thread
* Re: electric-indent-mode: abolition of `newline' function is not the Right Thing.
2013-10-16 20:55 ` chad
2013-10-16 21:07 ` Daniel Colascione
@ 2013-10-18 16:51 ` Alan Mackenzie
1 sibling, 0 replies; 72+ messages in thread
From: Alan Mackenzie @ 2013-10-18 16:51 UTC (permalink / raw)
To: chad; +Cc: emacs-devel@gnu.org devel
On Wed, Oct 16, 2013 at 01:55:07PM -0700, chad wrote:
> On 16 Oct 2013, at 11:58, Alan Mackenzie <acm@muc.de> wrote:
> > For another thing, it will stop lots of Emacs Lisp from working.
> What specific packages/libraries/etc break with the current
> electric-indent-mode enabled?
Haven't a clue. Some will though. One of my personal defuns breaks,
with the following sequence:
(newline)
(insert "(vi)")
(fill-paragraph)
Because of the unwanted indentation attached to `insert', which indents
the new "(vi)" to the same level as the previous line of text, the
`fill-paragraph' joins it to the previous paragraph.
> ~Chad
--
Alan Mackenzie (Nuremberg, Germany).
^ permalink raw reply [flat|nested] 72+ messages in thread
* Re: electric-indent-mode: abolition of `newline' function is not the Right Thing.
2013-10-16 17:59 ` Stefan Monnier
2013-10-16 18:58 ` Alan Mackenzie
@ 2013-10-16 23:22 ` Stephen J. Turnbull
1 sibling, 0 replies; 72+ messages in thread
From: Stephen J. Turnbull @ 2013-10-16 23:22 UTC (permalink / raw)
To: Stefan Monnier; +Cc: Alan Mackenzie, emacs-devel, martin rudalics
Stefan Monnier writes:
> > With respect, that is not the topic of this thread. That topic is that
> > with electric-indent-mode enabled, there is now no command, also no
> > elisp function which has the traditional functionality of `newline'.
>
> Quick, without looking at the source code of newline: what does
> `newline' do that (insert "\n") or C-q C-j doesn't do?
`newline' is an interactive built-in compiled Lisp function
-- loaded from "/playpen/src/XEmacs/xemacs/lisp/simple.elc"
(newline &optional N)
Documentation:
Insert a newline, and move to left margin of the new line if it's blank.
The newline is marked with the text-property `hard'.
With optional arg N, insert that many newlines.
In Auto Fill mode, if no numeric arg, break the preceding line if it's
long.
Look ma, no code browsing! (N.B. The Emacs docstring is worded
differently but it says the same thing, modulo being more accurate
about `use-hard-newlines' and auto-fill-mode.)
^ permalink raw reply [flat|nested] 72+ messages in thread
* Re: electric-indent-mode: abolition of `newline' function is not the Right Thing.
2013-10-16 17:12 ` Alan Mackenzie
2013-10-16 17:59 ` Stefan Monnier
@ 2013-10-16 18:34 ` martin rudalics
2013-10-16 19:26 ` Default behaviour of RET Alan Mackenzie
1 sibling, 1 reply; 72+ messages in thread
From: martin rudalics @ 2013-10-16 18:34 UTC (permalink / raw)
To: Alan Mackenzie; +Cc: emacs-devel
> For what you want, `newline-and-indent' exists, as you know.
I've been talking about the command run by RET and that I'm lost when I
run emacs -Q and try to do some editing. Otherwise, I don't care about
the standard behavior because I obviously have RET run my own command.
But if I were new to Emacs, I certainly would want RET to indent the new
line out of the box.
martin
^ permalink raw reply [flat|nested] 72+ messages in thread
* Default behaviour of RET.
2013-10-16 18:34 ` martin rudalics
@ 2013-10-16 19:26 ` Alan Mackenzie
2013-10-16 19:47 ` Eli Zaretskii
2013-10-16 23:17 ` Stephen J. Turnbull
0 siblings, 2 replies; 72+ messages in thread
From: Alan Mackenzie @ 2013-10-16 19:26 UTC (permalink / raw)
To: martin rudalics; +Cc: emacs-devel
Hi, Martin.
On Wed, Oct 16, 2013 at 08:34:56PM +0200, martin rudalics wrote:
> > For what you want, `newline-and-indent' exists, as you know.
> I've been talking about the command run by RET and that I'm lost when I
> run emacs -Q and try to do some editing. Otherwise, I don't care about
> the standard behavior because I obviously have RET run my own command.
> But if I were new to Emacs, I certainly would want RET to indent the new
> line out of the box.
I might agree with you, at least for programming modes. I'm not so sure
about things like Text Mode. But there must also be a ready way of doing
what RET currently does, inserting a new line without indenting it.
> martin
--
Alan Mackenzie (Nuremberg, Germany).
^ permalink raw reply [flat|nested] 72+ messages in thread
* Re: Default behaviour of RET.
2013-10-16 19:26 ` Default behaviour of RET Alan Mackenzie
@ 2013-10-16 19:47 ` Eli Zaretskii
2013-10-16 23:17 ` Stephen J. Turnbull
1 sibling, 0 replies; 72+ messages in thread
From: Eli Zaretskii @ 2013-10-16 19:47 UTC (permalink / raw)
To: Alan Mackenzie; +Cc: rudalics, emacs-devel
> Date: Wed, 16 Oct 2013 19:26:42 +0000
> From: Alan Mackenzie <acm@muc.de>
> Cc: emacs-devel@gnu.org
>
> But there must also be a ready way of doing what RET currently does,
> inserting a new line without indenting it.
What's wrong with "C-q C-j"?
^ permalink raw reply [flat|nested] 72+ messages in thread
* Default behaviour of RET.
2013-10-16 19:26 ` Default behaviour of RET Alan Mackenzie
2013-10-16 19:47 ` Eli Zaretskii
@ 2013-10-16 23:17 ` Stephen J. Turnbull
2013-10-17 0:47 ` Stefan Monnier
2013-10-18 16:57 ` Alan Mackenzie
1 sibling, 2 replies; 72+ messages in thread
From: Stephen J. Turnbull @ 2013-10-16 23:17 UTC (permalink / raw)
To: Alan Mackenzie; +Cc: martin rudalics, emacs-devel
Alan Mackenzie writes:
> On Wed, Oct 16, 2013 at 08:34:56PM +0200, martin rudalics wrote:
> > I've been talking about the command run by RET
Which is easy enough to change.
> I might agree with you, at least for programming modes. I'm not so sure
> about things like Text Mode.
I suspect I would find it really annoying, by analogy with the overly
aggressive quote-prefixing that is done by `filladapt'.
> But there must also be a ready way of doing what RET currently
> does, inserting a new line without indenting it.
You're enabling the confusaholics. If the user doesn't like what RET
does, the the user can bind it to a different function (or, more
likely, invoke a mode that does that for her and perhaps customize the
mode). Despite the subject, the interesting issue is "what should
`newline' do when invoked from code?"
The traditional docstring says that it moves to the left margin and
handles auto-filling. Eli's suggestion of `(insert "\n")' doesn't do
that, and it's not what `newline' does when corrupted by
`electric-shock-mode'. But I think it's useful behavior, and I think
programs should be able to rely on it (as opposed to users who can
modify the behavior of `One-Flew-Over-the-Cuckoos-Nest-mode' by
removing ?\n, or not invoke the mode in the first place).
Of course Stefan is correct that in Emacs, nothing is reliable. I
don't understand why he thinks it's a virtue, though.
^ permalink raw reply [flat|nested] 72+ messages in thread
* Re: Default behaviour of RET.
2013-10-16 23:17 ` Stephen J. Turnbull
@ 2013-10-17 0:47 ` Stefan Monnier
2013-10-18 17:03 ` Alan Mackenzie
2013-10-18 16:57 ` Alan Mackenzie
1 sibling, 1 reply; 72+ messages in thread
From: Stefan Monnier @ 2013-10-17 0:47 UTC (permalink / raw)
To: Stephen J. Turnbull; +Cc: Alan Mackenzie, emacs-devel, martin rudalics
> The traditional docstring says that it moves to the left margin and
> handles auto-filling. Eli's suggestion of `(insert "\n")' doesn't do
> that, and it's not what `newline' does when corrupted by
> `electric-shock-mode'. But I think it's useful behavior, and I think
> programs should be able to rely on it (as opposed to users who can
> modify the behavior of `One-Flew-Over-the-Cuckoos-Nest-mode' by
> removing ?\n, or not invoke the mode in the first place).
I can't remember ever seeing a piece of code which wants "the Emacs-23
newline behavior". Usually it either wants to (insert "\n") or it wants
to simulate hitting RET.
This discussion would benefit from actual examples of code that
fall into neither "do whatever RET does" nor "insert \n".
Stefan
^ permalink raw reply [flat|nested] 72+ messages in thread
* Re: Default behaviour of RET.
2013-10-17 0:47 ` Stefan Monnier
@ 2013-10-18 17:03 ` Alan Mackenzie
2013-10-18 19:52 ` Stefan Monnier
0 siblings, 1 reply; 72+ messages in thread
From: Alan Mackenzie @ 2013-10-18 17:03 UTC (permalink / raw)
To: Stefan Monnier; +Cc: martin rudalics, Stephen J. Turnbull, emacs-devel
Hello, Stefan.
On Wed, Oct 16, 2013 at 08:47:04PM -0400, Stefan Monnier wrote:
> > The traditional docstring says that it moves to the left margin and
> > handles auto-filling. Eli's suggestion of `(insert "\n")' doesn't do
> > that, and it's not what `newline' does when corrupted by
> > `electric-shock-mode'. But I think it's useful behavior, and I think
> > programs should be able to rely on it (as opposed to users who can
> > modify the behavior of `One-Flew-Over-the-Cuckoos-Nest-mode' by
> > removing ?\n, or not invoke the mode in the first place).
> I can't remember ever seeing a piece of code which wants "the Emacs-23
> newline behavior". Usually it either wants to (insert "\n") or it wants
> to simulate hitting RET.
I gave an example of such code in the post which opened this thread. To
recap:
(newline)
(insert "(vi)")
(fill-paragraph)
The `-and-indent' behaviour messes up the indentation of "(vi)" and
causes it to get re-attached to the previous paragraph.
> This discussion would benefit from actual examples of code that
> fall into neither "do whatever RET does" nor "insert \n".
See above. Any code which is interested in filling (or, possibly, even
margins, if anything actually uses these) will get broken by the
`-and-indent'.
> Stefan
--
Alan Mackenzie (Nuremberg, Germany).
^ permalink raw reply [flat|nested] 72+ messages in thread
* Re: Default behaviour of RET.
2013-10-18 17:03 ` Alan Mackenzie
@ 2013-10-18 19:52 ` Stefan Monnier
2013-10-18 20:45 ` Alan Mackenzie
0 siblings, 1 reply; 72+ messages in thread
From: Stefan Monnier @ 2013-10-18 19:52 UTC (permalink / raw)
To: Alan Mackenzie; +Cc: martin rudalics, Stephen J. Turnbull, emacs-devel
>> > The traditional docstring says that it moves to the left margin and
>> > handles auto-filling. Eli's suggestion of `(insert "\n")' doesn't do
>> > that, and it's not what `newline' does when corrupted by
>> > `electric-shock-mode'. But I think it's useful behavior, and I think
>> > programs should be able to rely on it (as opposed to users who can
>> > modify the behavior of `One-Flew-Over-the-Cuckoos-Nest-mode' by
>> > removing ?\n, or not invoke the mode in the first place).
>> I can't remember ever seeing a piece of code which wants "the Emacs-23
>> newline behavior". Usually it either wants to (insert "\n") or it wants
>> to simulate hitting RET.
> I gave an example of such code in the post which opened this thread. To
> recap:
> (newline)
> (insert "(vi)")
> (fill-paragraph)
> The `-and-indent' behaviour messes up the indentation of "(vi)" and
> causes it to get re-attached to the previous paragraph.
I see why the above doesn't want the "simulate RET" behavior.
But I don't see why it wouldn't work just fine with the (insert
"\n") behavior?
>> This discussion would benefit from actual examples of code that
>> fall into neither "do whatever RET does" nor "insert \n".
> See above. Any code which is interested in filling (or, possibly, even
> margins, if anything actually uses these) will get broken by the
> `-and-indent'.
"any code which..." is not concrete.
Stefan
^ permalink raw reply [flat|nested] 72+ messages in thread
* Re: Default behaviour of RET.
2013-10-18 19:52 ` Stefan Monnier
@ 2013-10-18 20:45 ` Alan Mackenzie
2013-10-19 1:59 ` Stefan Monnier
0 siblings, 1 reply; 72+ messages in thread
From: Alan Mackenzie @ 2013-10-18 20:45 UTC (permalink / raw)
To: Stefan Monnier; +Cc: martin rudalics, Stephen J. Turnbull, emacs-devel
Hello, Stefan.
On Fri, Oct 18, 2013 at 03:52:22PM -0400, Stefan Monnier wrote:
> >> > The traditional docstring says that it moves to the left margin and
> >> > handles auto-filling. Eli's suggestion of `(insert "\n")' doesn't do
> >> > that, and it's not what `newline' does when corrupted by
> >> > `electric-shock-mode'. But I think it's useful behavior, and I think
> >> > programs should be able to rely on it (as opposed to users who can
> >> > modify the behavior of `One-Flew-Over-the-Cuckoos-Nest-mode' by
> >> > removing ?\n, or not invoke the mode in the first place).
> >> I can't remember ever seeing a piece of code which wants "the Emacs-23
> >> newline behavior". Usually it either wants to (insert "\n") or it wants
> >> to simulate hitting RET.
> > I gave an example of such code in the post which opened this thread. To
> > recap:
> > (newline)
> > (insert "(vi)")
> > (fill-paragraph)
> > The `-and-indent' behaviour messes up the indentation of "(vi)" and
> > causes it to get re-attached to the previous paragraph.
> I see why the above doesn't want the "simulate RET" behavior.
> But I don't see why it wouldn't work just fine with the (insert
> "\n") behavior?
The `newline' tidies up the previous paragraph, in particular it fills
it. It might also cause abbreviations to be expanded.
I could easily adapt this piece of code to cope with the `-and-indent'
which has been attached to `newline', but that's not the point.
The point is that there are a near infinite number of invocations of
`newline' in the wild, and an unknown proportion of these, possibly
quite high, will depend on `newline' doing precisely what its doc string
says. Their existence makes the utility of electric-indent-mode, at the
moment, questionable.
> >> This discussion would benefit from actual examples of code that
> >> fall into neither "do whatever RET does" nor "insert \n".
> > See above. Any code which is interested in filling (or, possibly, even
> > margins, if anything actually uses these) will get broken by the
> > `-and-indent'.
> "any code which..." is not concrete.
I've given you a concrete example of such code, several times. It's not
a particularly bizarre piece of code, either.
electric-indent-mode's indentation of a new line is broken. Please take
this behaviour out.
> Stefan
--
Alan Mackenzie (Nuremberg, Germany).
^ permalink raw reply [flat|nested] 72+ messages in thread
* Re: Default behaviour of RET.
2013-10-18 20:45 ` Alan Mackenzie
@ 2013-10-19 1:59 ` Stefan Monnier
2013-10-19 10:58 ` Alan Mackenzie
0 siblings, 1 reply; 72+ messages in thread
From: Stefan Monnier @ 2013-10-19 1:59 UTC (permalink / raw)
To: Alan Mackenzie; +Cc: martin rudalics, Stephen J. Turnbull, emacs-devel
> The point is that there are a near infinite number of invocations of
> `newline' in the wild, and an unknown proportion of these, possibly
> quite high, will depend on `newline' doing precisely what its doc string
but also possibly quite low.
> says. Their existence makes the utility of electric-indent-mode, at the
> moment, questionable.
As long as we're in the "unknown proportion", we can't tell.
>> >> This discussion would benefit from actual examples of code that
>> >> fall into neither "do whatever RET does" nor "insert \n".
>> > See above. Any code which is interested in filling (or, possibly, even
>> > margins, if anything actually uses these) will get broken by the
>> > `-and-indent'.
>> "any code which..." is not concrete.
> I've given you a concrete example of such code, several times.
Right, but I said "examples" not "example". So far I've seen one
concrete example, from your ~/.emacs (i.e. a problem that will affect
O(1) user). That's not very compelling.
Stefan
^ permalink raw reply [flat|nested] 72+ messages in thread
* Re: Default behaviour of RET.
2013-10-19 1:59 ` Stefan Monnier
@ 2013-10-19 10:58 ` Alan Mackenzie
2013-10-19 15:07 ` Drew Adams
2013-10-19 22:20 ` Stefan Monnier
0 siblings, 2 replies; 72+ messages in thread
From: Alan Mackenzie @ 2013-10-19 10:58 UTC (permalink / raw)
To: Stefan Monnier; +Cc: martin rudalics, Stephen J. Turnbull, emacs-devel
Hello, Stefan.
On Fri, Oct 18, 2013 at 09:59:54PM -0400, Stefan Monnier wrote:
> > The point is that there are a near infinite number of invocations of
> > `newline' in the wild, and an unknown proportion of these, possibly
> > quite high, will depend on `newline' doing precisely what its doc string
> but also possibly quite low.
Just how low does it have to be before we can ignore it?
> > says. Their existence makes the utility of electric-indent-mode, at the
> > moment, questionable.
> As long as we're in the "unknown proportion", we can't tell.
> >> >> This discussion would benefit from actual examples of code that
> >> >> fall into neither "do whatever RET does" nor "insert \n".
> >> > See above. Any code which is interested in filling (or, possibly, even
> >> > margins, if anything actually uses these) will get broken by the
> >> > `-and-indent'.
> >> "any code which..." is not concrete.
> > I've given you a concrete example of such code, several times.
> Right, but I said "examples" not "example". So far I've seen one
> concrete example, from your ~/.emacs (i.e. a problem that will affect
> O(1) user). That's not very compelling.
OK. I've done a find-grep in .../lisp for all *.el matching
'^[^;\n]*(newline\([ )]\|$\)'. There are 199 matches.
There are 27 occurences of the exact string "(or (bolp) (newline))",
which looks like making sure point is at BOL in an output file. For
example, in uce.el, we have the following code at L359:
;; If message doesn't end with a newline, insert it.
(goto-char (point-max))
(or (bolp) (newline)))
. In org-datetree.el, we have this, at L83:
(goto-char (point-max))
(or (bolp) (newline))
(org-datetree-insert-line year))
. This same idiom appears two other times in this file alone. I looked
at quite a few other occurences of "(or (bolp) (newline))" and all the
ones I could understand instantly were about ensuring point is at BOL, as
indeed was my own personal code.
> Stefan
--
Alan Mackenzie (Nuremberg, Germany).
^ permalink raw reply [flat|nested] 72+ messages in thread
* RE: Default behaviour of RET.
2013-10-19 10:58 ` Alan Mackenzie
@ 2013-10-19 15:07 ` Drew Adams
2013-10-20 14:55 ` Alan Mackenzie
2013-10-19 22:20 ` Stefan Monnier
1 sibling, 1 reply; 72+ messages in thread
From: Drew Adams @ 2013-10-19 15:07 UTC (permalink / raw)
To: Alan Mackenzie, Stefan Monnier
Cc: martin rudalics, Stephen J. Turnbull, emacs-devel
> OK. I've done a find-grep in .../lisp for all *.el matching
> '^[^;\n]*(newline\([ )]\|$\)'. There are 199 matches.
> There are 27 occurences of the exact string "(or (bolp) (newline))",
> which looks like making sure point is at BOL in an output file.
I haven't been following this thread; sorry. I don't have any calls
to `newline' in my code, FWIW.
Is the following a reasonable summary of the question & positions?
1. One position wants to change the behavior of `newline', so that
all uses of it automatically benefit from the new behavior.
2. The other position wants to keep `newline' as it is, perhaps for
some existing calls and in any case for some future calls. This
position holds that the "old" behavior can be useful in some contexts.
Sounds like two different functions are in order, for the old and new
behaviors - au choix. If so, it's not a big deal to update the Emacs
sources one way or the other.
But in case there is 3rd-party code that uses `newline', it seems
like the prudent choice would be to keep the existing name for the
existing behavior and give the new behavior a new name. 3rd-party
code that wants to "upgrade" to the new behavior can do that. And
there would be no surprises.
Is there more to it that this?
^ permalink raw reply [flat|nested] 72+ messages in thread
* Re: Default behaviour of RET.
2013-10-19 15:07 ` Drew Adams
@ 2013-10-20 14:55 ` Alan Mackenzie
2013-10-20 22:26 ` Richard Stallman
0 siblings, 1 reply; 72+ messages in thread
From: Alan Mackenzie @ 2013-10-20 14:55 UTC (permalink / raw)
To: Drew Adams
Cc: martin rudalics, Stephen J. Turnbull, Stefan Monnier, emacs-devel
[ personal mail ]
Hi, Drew.
On Sat, Oct 19, 2013 at 08:07:35AM -0700, Drew Adams wrote:
> > OK. I've done a find-grep in .../lisp for all *.el matching
> > '^[^;\n]*(newline\([ )]\|$\)'. There are 199 matches.
> > There are 27 occurences of the exact string "(or (bolp) (newline))",
> > which looks like making sure point is at BOL in an output file.
> I haven't been following this thread; sorry. I don't have any calls
> to `newline' in my code, FWIW.
> Is the following a reasonable summary of the question & positions?
> 1. One position wants to change the behavior of `newline', so that
> all uses of it automatically benefit from the new behavior.
> 2. The other position wants to keep `newline' as it is, perhaps for
> some existing calls and in any case for some future calls. This
> position holds that the "old" behavior can be useful in some contexts.
More or less.
> Sounds like two different functions are in order, for the old and new
> behaviors - au choix. If so, it's not a big deal to update the Emacs
> sources one way or the other.
I think I've managed to persuade SM of that, now. But I'm not convinced
his latest patch is the right thing. It's probably the best I'll manage,
though.
> But in case there is 3rd-party code that uses `newline', it seems
> like the prudent choice would be to keep the existing name for the
> existing behavior and give the new behavior a new name. 3rd-party
> code that wants to "upgrade" to the new behavior can do that. And
> there would be no surprises.
That command already exists, and is called `newline-and-indent'.
> Is there more to it that this?
'Fraid so! The mechanism by which `newline' was changed was by adding a
function to `post-self-insert-hook' when electric-indent-mode is active,
and this function checked whether a newline had been added, and indented
the new line if it had. My task, which seems to have been inordinately
difficult, was to persuade SM that this roundabout means of turning
`newline' into `newline-and-indent' is just as bad as the direct means.
It's been exhausting. I hope the argument has now been won.
--
Alan Mackenzie (Nuremberg, Germany).
^ permalink raw reply [flat|nested] 72+ messages in thread
* Re: Default behaviour of RET.
2013-10-20 14:55 ` Alan Mackenzie
@ 2013-10-20 22:26 ` Richard Stallman
2013-10-21 2:38 ` Eli Zaretskii
0 siblings, 1 reply; 72+ messages in thread
From: Richard Stallman @ 2013-10-20 22:26 UTC (permalink / raw)
To: Alan Mackenzie; +Cc: rudalics, stephen, monnier, drew.adams, emacs-devel
[ To any NSA and FBI agents reading my email: please consider
[ whether defending the US Constitution against all enemies,
[ foreign or domestic, requires you to follow Snowden's example.
I don't think the default behavior of RET should be changed, even in
programming modes. We have two commands, RET and C-j, which insert a newline.
C-j indents, and RET doesn't.
--
Dr Richard Stallman
President, Free Software Foundation
51 Franklin St
Boston MA 02110
USA
www.fsf.org www.gnu.org
Skype: No way! That's nonfree (freedom-denying) software.
Use Ekiga or an ordinary phone call.
^ permalink raw reply [flat|nested] 72+ messages in thread
* Re: Default behaviour of RET.
2013-10-20 22:26 ` Richard Stallman
@ 2013-10-21 2:38 ` Eli Zaretskii
0 siblings, 0 replies; 72+ messages in thread
From: Eli Zaretskii @ 2013-10-21 2:38 UTC (permalink / raw)
To: rms; +Cc: emacs-devel, rudalics, monnier, acm, stephen, drew.adams
> Date: Sun, 20 Oct 2013 18:26:31 -0400
> From: Richard Stallman <rms@gnu.org>
> Cc: rudalics@gmx.at, stephen@xemacs.org, monnier@iro.umontreal.ca,
> drew.adams@oracle.com, emacs-devel@gnu.org
>
> I don't think the default behavior of RET should be changed, even in
> programming modes. We have two commands, RET and C-j, which insert a newline.
> C-j indents, and RET doesn't.
The days when keyboards had an LFD key that produced C-j are long
gone. Nowadays, keyboards have only the RET key, and users expect it
to indent in programming modes, at least by default. As things are
now, I need to customize every programming mode I use to do that. I
think it's time for a change.
^ permalink raw reply [flat|nested] 72+ messages in thread
* Re: Default behaviour of RET.
2013-10-19 10:58 ` Alan Mackenzie
2013-10-19 15:07 ` Drew Adams
@ 2013-10-19 22:20 ` Stefan Monnier
2013-10-20 15:00 ` Alan Mackenzie
1 sibling, 1 reply; 72+ messages in thread
From: Stefan Monnier @ 2013-10-19 22:20 UTC (permalink / raw)
To: Alan Mackenzie; +Cc: martin rudalics, Stephen J. Turnbull, emacs-devel
>> but also possibly quite low.
> Just how low does it have to be before we can ignore it?
That was not the question.
Anyway, it does look like there are indeed many incorrect uses of
newline (most of those (or (bolp) (newline)) will break sooner or later
because of unexpected filling and/or abbrev/skeleton expansion).
So I installed a patch which makes `newline' only run
post-self-insert-hook when called interactively, so as to try and
preserve compatibility with those dubious uses.
Stefan
^ permalink raw reply [flat|nested] 72+ messages in thread
* Re: Default behaviour of RET.
2013-10-19 22:20 ` Stefan Monnier
@ 2013-10-20 15:00 ` Alan Mackenzie
0 siblings, 0 replies; 72+ messages in thread
From: Alan Mackenzie @ 2013-10-20 15:00 UTC (permalink / raw)
To: Stefan Monnier; +Cc: martin rudalics, Stephen J. Turnbull, emacs-devel
Hello, Stefan.
On Sat, Oct 19, 2013 at 06:20:24PM -0400, Stefan Monnier wrote:
> >> but also possibly quite low.
> > Just how low does it have to be before we can ignore it?
> That was not the question.
> Anyway, it does look like there are indeed many incorrect uses of
> newline (most of those (or (bolp) (newline)) will break sooner or later
> because of unexpected filling and/or abbrev/skeleton expansion).
We don't know that the filling, etc., is unexpected. The crucial point
is that all these secondary actions of `newline' happen on the _previous_
line, leaving the main point of newline: "Insert a newline, and move to
left margin of the new line ...." unaffected.
> So I installed a patch which makes `newline' only run
> post-self-insert-hook when called interactively, so as to try and
> preserve compatibility with those dubious uses.
Thanks.
> Stefan
--
Alan Mackenzie (Nuremberg, Germany).
^ permalink raw reply [flat|nested] 72+ messages in thread
* Re: Default behaviour of RET.
2013-10-16 23:17 ` Stephen J. Turnbull
2013-10-17 0:47 ` Stefan Monnier
@ 2013-10-18 16:57 ` Alan Mackenzie
1 sibling, 0 replies; 72+ messages in thread
From: Alan Mackenzie @ 2013-10-18 16:57 UTC (permalink / raw)
To: Stephen J. Turnbull; +Cc: martin rudalics, emacs-devel
Hi, Stephen.
On Thu, Oct 17, 2013 at 08:17:01AM +0900, Stephen J. Turnbull wrote:
> Alan Mackenzie writes:
> > On Wed, Oct 16, 2013 at 08:34:56PM +0200, martin rudalics wrote:
> > > I've been talking about the command run by RET
> Which is easy enough to change.
> > I might agree with you, at least for programming modes. I'm not so sure
> > about things like Text Mode.
> I suspect I would find it really annoying, by analogy with the overly
> aggressive quote-prefixing that is done by `filladapt'.
> > But there must also be a ready way of doing what RET currently
> > does, inserting a new line without indenting it.
> You're enabling the confusaholics. If the user doesn't like what RET
> does, the the user can bind it to a different function (or, more
> likely, invoke a mode that does that for her and perhaps customize the
> mode). Despite the subject, the interesting issue is "what should
> `newline' do when invoked from code?"
Indeed, that was in the title of the original post in the thread. But
you seem to have misunderstood the situation: the current
electric-indent-mode effectively transforms `newline' into
`newline-and-indent', leaving no command for the user who doesn't like
this to bind RET to.
> The traditional docstring says that it moves to the left margin and
> handles auto-filling. Eli's suggestion of `(insert "\n")' doesn't do
> that, and it's not what `newline' does when corrupted by
> `electric-shock-mode'. But I think it's useful behavior, and I think
> programs should be able to rely on it (as opposed to users who can
> modify the behavior of `One-Flew-Over-the-Cuckoos-Nest-mode' by
> removing ?\n, or not invoke the mode in the first place).
Yes.
--
Alan Mackenzie (Nuremberg, Germany).
^ permalink raw reply [flat|nested] 72+ messages in thread
* Re: electric-indent-mode: abolition of `newline' function is not the Right Thing.
2013-10-13 10:13 electric-indent-mode: abolition of `newline' function is not the Right Thing Alan Mackenzie
2013-10-13 13:23 ` Stefan Monnier
@ 2013-10-13 20:00 ` Matthias Meulien
2013-10-14 13:21 ` Stefan Monnier
1 sibling, 1 reply; 72+ messages in thread
From: Matthias Meulien @ 2013-10-13 20:00 UTC (permalink / raw)
To: Alan Mackenzie; +Cc: emacs-devel
> (...) I discovered this whilst trying `electric-indent-mode' in
> Text Mode.
For the same reason it is impossible to write Python code with
both `python-skeleton-autoinsert' set to t and Electric Indent
mode enabled...
Say a buffer contains the following three lines:
class base(object):
pass
-!-
Now you hit c l a s s SPC d e r i v e d RET b a s e RET RET
which results in:
class base(object):
pass
class derived(base):
"""-!-"""
Unexpected isn't it?
--
Matthias Meulien
^ permalink raw reply [flat|nested] 72+ messages in thread
* Re: electric-indent-mode: abolition of `newline' function is not the Right Thing.
2013-10-13 20:00 ` electric-indent-mode: abolition of `newline' function is not the Right Thing Matthias Meulien
@ 2013-10-14 13:21 ` Stefan Monnier
2013-10-14 13:31 ` Matthias Meulien
0 siblings, 1 reply; 72+ messages in thread
From: Stefan Monnier @ 2013-10-14 13:21 UTC (permalink / raw)
To: Matthias Meulien; +Cc: Alan Mackenzie, emacs-devel
> For the same reason it is impossible to write Python code with both
> python-skeleton-autoinsert' set to t and Electric Indent mode enabled...
> Say a buffer contains the following three lines:
> class base(object): pass
> -!-
> Now you hit c l a s s SPC d e r i v e d RET b a s e RET RET
> which results in:
> class base(object): pass
> class derived(base):
> """-!-"""
> Unexpected isn't it?
I can't reproduce it on trunk, probably thanks to the new
electric-indent-inhibit, which is set in python-mode.
Stefan
^ permalink raw reply [flat|nested] 72+ messages in thread
* Re: electric-indent-mode: abolition of `newline' function is not the Right Thing.
2013-10-14 13:21 ` Stefan Monnier
@ 2013-10-14 13:31 ` Matthias Meulien
2013-10-14 16:46 ` Stefan Monnier
0 siblings, 1 reply; 72+ messages in thread
From: Matthias Meulien @ 2013-10-14 13:31 UTC (permalink / raw)
To: Stefan Monnier; +Cc: Alan Mackenzie, emacs-devel
[-- Attachment #1: Type: text/plain, Size: 481 bytes --]
> (...) I can't reproduce it on trunk, probably thanks to the new
> electric-indent-inhibit, which is set in python-mode.
Good news! I encounter the problem I described with 24.3.1. Note that my
comment was misleading: It has nothing to do with
`python-skeleton-autoinsert'... And my post was badly formatted (I don't
know why): The `pass' keyword must be on its own indented line, like this:
class base(object):
> pass
>
Sorry for the noise and many thanks!
--
Matthias
[-- Attachment #2: Type: text/html, Size: 763 bytes --]
^ permalink raw reply [flat|nested] 72+ messages in thread
* Re: electric-indent-mode: abolition of `newline' function is not the Right Thing.
2013-10-14 13:31 ` Matthias Meulien
@ 2013-10-14 16:46 ` Stefan Monnier
2013-10-15 15:54 ` Davis Herring
2013-10-15 20:03 ` Matthias Meulien
0 siblings, 2 replies; 72+ messages in thread
From: Stefan Monnier @ 2013-10-14 16:46 UTC (permalink / raw)
To: Matthias Meulien; +Cc: Alan Mackenzie, emacs-devel
>> (...) I can't reproduce it on trunk, probably thanks to the new
>> electric-indent-inhibit, which is set in python-mode.
> Good news! I encounter the problem I described with 24.3.1. Note that my
> comment was misleading: It has nothing to do with
> `python-skeleton-autoinsert'... And my post was badly formatted (I don't
> know why): The `pass' keyword must be on its own indented line, like this:
> class base(object):
>> pass
>>
Hmm, then I don't know if it happens in trunk or not, because I don't
really know how to reproduce it or what result would be correct or not
(I don't know/use Python).
Stefan
^ permalink raw reply [flat|nested] 72+ messages in thread
* Re: electric-indent-mode: abolition of `newline' function is not the Right Thing.
2013-10-14 16:46 ` Stefan Monnier
@ 2013-10-15 15:54 ` Davis Herring
2013-10-15 20:03 ` Matthias Meulien
1 sibling, 0 replies; 72+ messages in thread
From: Davis Herring @ 2013-10-15 15:54 UTC (permalink / raw)
To: Stefan Monnier; +Cc: Alan Mackenzie, Matthias Meulien, emacs-devel
>> class base(object):
>>> pass
>
> Hmm, then I don't know if it happens in trunk or not, because I don't
> really know how to reproduce it or what result would be correct or not
> (I don't know/use Python).
I can help with the basic idea: most colons require a following
statement, either on the same line (one statement) or on all the
following lines indented more than the line with the colon. (We're only
concerned with the latter case, which Python calls a suite.)
"pass" is a no-op used in such a context where no (real) statement is
desired. Therefore, it makes sense for an Emacs Python mode to notice a
"pass" (along with certain other choices like "return") and presume that
the user wants it to end the suite -- that is, to use one fewer level of
indentation on the next line. (Sometimes the user wants even less
indentation, so they type p a s s C-j DEL or so.)
The bug (if it exists) is that newline/newline-and-indent/whatever are
not implementing this behavior properly, resulting in blocks that the
user "obviously" means to be siblings being nested instead (when no DEL
is used).
Davis
--
This product is sold by volume, not by mass. If it appears too dense or
too sparse, it is because mass-energy conversion has occurred during
shipping.
^ permalink raw reply [flat|nested] 72+ messages in thread
* Re: electric-indent-mode: abolition of `newline' function is not the Right Thing.
2013-10-14 16:46 ` Stefan Monnier
2013-10-15 15:54 ` Davis Herring
@ 2013-10-15 20:03 ` Matthias Meulien
2013-10-16 2:44 ` Stefan Monnier
1 sibling, 1 reply; 72+ messages in thread
From: Matthias Meulien @ 2013-10-15 20:03 UTC (permalink / raw)
To: Stefan Monnier; +Cc: Alan Mackenzie, emacs-devel
>>> (...) I can't reproduce it on trunk, probably thanks to the
>>> new electric-indent-inhibit, which is set in python-mode.
You are right: I've compiled the trunk (git revision: b670693) and it
works as expected!
--
Matthias
^ permalink raw reply [flat|nested] 72+ messages in thread
[parent not found: <<525EDC50.8010401@gmx.at>]
[parent not found: <<febb6245-ceda-4c33-a220-b0f24a1c34d2@default>]
* RE: Default behaviour of RET.
@ 2013-10-21 23:09 Drew Adams
2013-10-22 0:37 ` Dmitry Gutov
0 siblings, 1 reply; 72+ messages in thread
From: Drew Adams @ 2013-10-21 23:09 UTC (permalink / raw)
To: Dmitry Gutov
Cc: rms, emacs-devel, rudalics, monnier, acm, Eli Zaretskii, stephen
> >> The question is what would be the sane default.
> >
> > The default Emacs behavior for this is quite sane, and has been so
> > for almost 40 years now.
>
> It is sane because it is old? That's a bad argument.
That's not the argument. I gave my opinion that the Emacs behavior
is sane. And that it has been so for 40 years. No one said that
_because_ the behavior is old it must be sane. The behavior is sane,
_and_ it is longstanding behavior, used by thousands for a long time.
But yes, one could make the argument that that longevity provides
_some_ measure of support for an assertion that the behavior is not
insane. Some measure of support does not mean old-therefore-sane.
> > That it is not the same as the default behavior of this or that
> > other application does not make the Emacs default behavior insane.
>
> The Emacs default settings are considered outdated by many of its
> users (here's one tiny example:
> https://github.com/technomancy/better-defaults). So discussing
> changes in long-established behaviors can be useful.
Of course it can be useful. And change is sometimes good. That
doesn't mean that all change is good. It doesn't mean that this
particular change would be the right thing to do.
You are making sweeping generalizations that do not help advance
reasons why this change should be made.
Yes, long-established behaviors can always be questioned. And the
questions and answers _here_ are? So far, we have as arguments only
that (a) IDEs use RET instead of C-j, and (b) RET is, in some minds,
more convenient than C-j.
Emacs offers both keys/behaviors, which is good (IMHO). Perhaps your
argument should be that the keys should be reversed? That would be
a more reasonable request (IMO) than just making RET also do what C-j
does.
> >> You seem to be under impression that Eli is somehow new to using
> >> Emacs.
> >
> > You seem to be fantasizing. The "foreign vantage point" is an
> > outside view, nothing more.
>
> Yeah, and who's outside? One of the most prolific Emacs contributors?
No one is outside. You keep repeating that strawman. RET does outside
what C-j does inside. From the point of view outside, RET is the right
key and C-j is the wrong key. For Emacs, the opposite is the case -
so far.
> > That is the argument, no? "All the other guys are doing it another
> > way."
>
> Read it this way: "won't somebody think of the poor new users?"
We all are doing so, no? It's not like someone is forcing a contorted
key combination here. C-j is a simple key sequence, as simple as C-f.
Or else it's not. Either it is convenient, as has apparently been
thought for a long time by many users, or it is not and this is finally
being realized.
And inherently not, not just because someone might have a habit
developed elsewhere - that is a separate argument from the relative
difficulty of typing C-j.
IOW, there are two separate arguments that those proposing to make
RET do what C-j does have advanced:
1. C-j is "much less convenient" to type than RET.
2. RET is what the "poor new users" are used to using.
I've argued against #1 - I'm not convinced that C-j is "much less
convenient".
But especially, I am in favor of keeping _both_ behaviors. The keys
could be swapped, if people think that is the way to go.
Against #2 I have less to say. I've argued that if "others are doing
it" is the _only_ argument then that is pretty lame. If that is it,
then we are essentially back to the discussion about turning on CUA
mode by default: same argument exactly. I would hope for a better
argument.
> And: "quite often standard behavior emerges for a reason".
Yet another platitude - yap, yap. (And what/whom are you quoting?)
> > There is nothing new that makes the difference in convenience
> > between `C-j' and `RET' any greater now than it has been at any
> > point in the past. Exactly the same difference: same mole hill.
>
> It's not the greatest of problems one might find with Emacs, true.
>
> > For Emacs, `C-j' has been considered convenient for this behavior
> > for a very long time. And I, for one, still find it convenient.
> > It doesn't get much more convenient than `C-j'. Circulez ; il
> > n'y a rien a voir.
>
> You still haven't answered why you want RET to be bound to
> `newline'.
I like having both keys, for the two different behaviors. I use both.
I can't tell you just when I use RET, but I do.
I don't really care much which key provides which behavior. I don't
mind using either - I already use both.
I would put it exactly the way Richard put it: (a) "I don't think the
default behavior of RET should be changed" and (b) "We have two
commands, RET and C-j", with two different behaviors.
For me, (b) is more important: keep the two behaviors. For (a), I'm
adding my voice to agree that "I don't think the default behavior of
RET should be changed." That's all.
^ permalink raw reply [flat|nested] 72+ messages in thread
* Re: Default behaviour of RET.
2013-10-21 23:09 Drew Adams
@ 2013-10-22 0:37 ` Dmitry Gutov
0 siblings, 0 replies; 72+ messages in thread
From: Dmitry Gutov @ 2013-10-22 0:37 UTC (permalink / raw)
To: Drew Adams
Cc: rms, emacs-devel, rudalics, monnier, acm, Eli Zaretskii, stephen
Drew Adams <drew.adams@oracle.com> writes:
> But especially, I am in favor of keeping _both_ behaviors. The keys
> could be swapped, if people think that is the way to go.
Swapping wouldn't be the worst idea, but there's also a related default
`M-j' keybinding, which invokes a related, but even fancier command.
Have `C-j' insert newline, but still have `M-j' do lots more additional
stuff would make it less consistent.
^ permalink raw reply [flat|nested] 72+ messages in thread
end of thread, other threads:[~2013-10-24 13:35 UTC | newest]
Thread overview: 72+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-13 10:13 electric-indent-mode: abolition of `newline' function is not the Right Thing Alan Mackenzie
2013-10-13 13:23 ` Stefan Monnier
2013-10-13 14:09 ` Alan Mackenzie
2013-10-13 16:22 ` Stefan Monnier
2013-10-13 17:28 ` Alan Mackenzie
2013-10-14 12:56 ` Stefan Monnier
2013-10-16 18:46 ` Alan Mackenzie
2013-10-15 18:28 ` martin rudalics
2013-10-16 17:12 ` Alan Mackenzie
2013-10-16 17:59 ` Stefan Monnier
2013-10-16 18:58 ` Alan Mackenzie
2013-10-16 20:55 ` chad
2013-10-16 21:07 ` Daniel Colascione
2013-10-18 16:51 ` Alan Mackenzie
2013-10-16 23:22 ` Stephen J. Turnbull
2013-10-16 18:34 ` martin rudalics
2013-10-16 19:26 ` Default behaviour of RET Alan Mackenzie
2013-10-16 19:47 ` Eli Zaretskii
2013-10-16 23:17 ` Stephen J. Turnbull
2013-10-17 0:47 ` Stefan Monnier
2013-10-18 17:03 ` Alan Mackenzie
2013-10-18 19:52 ` Stefan Monnier
2013-10-18 20:45 ` Alan Mackenzie
2013-10-19 1:59 ` Stefan Monnier
2013-10-19 10:58 ` Alan Mackenzie
2013-10-19 15:07 ` Drew Adams
2013-10-20 14:55 ` Alan Mackenzie
2013-10-20 22:26 ` Richard Stallman
2013-10-21 2:38 ` Eli Zaretskii
2013-10-19 22:20 ` Stefan Monnier
2013-10-20 15:00 ` Alan Mackenzie
2013-10-18 16:57 ` Alan Mackenzie
2013-10-13 20:00 ` electric-indent-mode: abolition of `newline' function is not the Right Thing Matthias Meulien
2013-10-14 13:21 ` Stefan Monnier
2013-10-14 13:31 ` Matthias Meulien
2013-10-14 16:46 ` Stefan Monnier
2013-10-15 15:54 ` Davis Herring
2013-10-15 20:03 ` Matthias Meulien
2013-10-16 2:44 ` Stefan Monnier
[not found] <<525EDC50.8010401@gmx.at>
[not found] ` <<20131016192642.GD3125@acm.acm>
[not found] ` <<87mwm8g61e.fsf@uwakimon.sk.tsukuba.ac.jp>
[not found] ` <<jwv4n8globm.fsf-monnier+emacs@gnu.org>
[not found] ` <<20131018170320.GC2569@acm.acm>
[not found] ` <<jwvzjq6pdek.fsf-monnier+emacs@gnu.org>
[not found] ` <<20131018204551.GC3012@acm.acm>
[not found] ` <<jwvzjq6c9da.fsf-monnier+emacs@gnu.org>
[not found] ` <<20131019105836.GA2991@acm.acm>
[not found] ` <<762fa4a6-1a42-48b2-97ba-0f3ab7ef7ba5@default>
[not found] ` <<20131020145513.GC3484@acm.acm>
[not found] ` <<E1VY1SB-0006V5-EH@fencepost.gnu.org>
[not found] ` <<83a9i3l554.fsf@gnu.org>
2013-10-21 3:26 ` Default behaviour of RET Drew Adams
2013-10-21 12:12 ` Rustom Mody
2013-10-22 1:25 ` Richard Stallman
2013-10-23 1:20 ` Stephen J. Turnbull
2013-10-22 13:53 ` Kenichi Handa
2013-10-21 16:13 ` Eli Zaretskii
[not found] <<febb6245-ceda-4c33-a220-b0f24a1c34d2@default>
[not found] ` <<8361sqli02.fsf@gnu.org>
2013-10-21 17:01 ` Drew Adams
2013-10-21 20:04 ` Dmitry Gutov
2013-10-21 20:53 ` Drew Adams
2013-10-21 21:15 ` Dmitry Gutov
2013-10-21 22:03 ` chad
2013-10-21 22:12 ` Daniel Colascione
2013-10-21 23:10 ` Drew Adams
2013-10-22 6:49 ` Lars Brinkhoff
2013-10-23 20:23 ` Alan Mackenzie
2013-10-21 22:13 ` Davis Herring
2013-10-21 23:12 ` Drew Adams
2013-10-21 22:59 ` Jorgen Schaefer
2013-10-22 14:02 ` Stefan Monnier
2013-10-23 0:10 ` Richard Stallman
2013-10-23 4:36 ` Josh
2013-10-23 12:29 ` Stefan Monnier
2013-10-23 18:15 ` Josh
2013-10-24 13:35 ` Stefan Monnier
2013-10-21 23:10 ` Drew Adams
2013-10-22 7:45 ` Jarek Czekalski
2013-10-22 12:03 ` Rustom Mody
2013-10-23 20:18 ` Alan Mackenzie
2013-10-23 23:43 ` Stephen J. Turnbull
2013-10-24 1:53 ` Dmitry Gutov
2013-10-21 22:59 ` Xue Fuqiao
-- strict thread matches above, loose matches on Subject: below --
2013-10-21 23:09 Drew Adams
2013-10-22 0:37 ` Dmitry Gutov
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).