[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#35254: 27.0.50; cc-mode/electric-pair-mode/electric-layout-mode: bad
From: |
Alan Mackenzie |
Subject: |
bug#35254: 27.0.50; cc-mode/electric-pair-mode/electric-layout-mode: bad trailing whitespace behavior in cc-mode |
Date: |
Tue, 14 May 2019 09:27:35 +0000 |
User-agent: |
Mutt/1.10.1 (2018-07-13) |
Hello, Stefan.
On Mon, May 13, 2019 at 19:32:49 -0400, Stefan Monnier wrote:
> >> Electric indent mode's post-self-insert hook entry has 3 effects:
> >> 1. Indent the previous line.
> >> 2. Remove trailing whitespace from the previous line.
> >> 3. Indent the current line (when at beginning of line).
> Note that `newline` itself already does some subset of 2 (before running
> electric-indent's post-self-insert hook).
> > I interpret the problem a little differently.
> > electric-indent-post-self-insert-function, when electric-indent-inhibit
> > is set, is inhibiting actions which are not really part of electric
> > indentation, in particular action 2 (above). This is the heart of the
> > bug. The following patch fixes the bug. It would need tidying up before
> > being committed:
> I haven't followed enough of the discussion to understand why that might
> cause a bug.
The bug is, type lots of <CR>s in a row; the indentation WS isn't
getting removed from the blank lines. Currently electric-indent-inhibit
is inhibiting this removal.
> > diff --git a/lisp/electric.el b/lisp/electric.el
> > index 07da2f1d9e..15a42930c1 100644
> > --- a/lisp/electric.el
> > +++ b/lisp/electric.el
> > @@ -282,9 +282,15 @@ electric-indent-post-self-insert-function
> > (condition-case-unless-debug ()
> > (indent-according-to-mode)
> > (error (throw 'indent-error nil)))
> > - ;; The goal here will be to remove the trailing
> > - ;; whitespace after reindentation of the previous line
> > - ;; because that may have (re)introduced it.
> > + )
> > + (unless (memq indent-line-function
> > + electric-indent-functions-without-reindent)
> > + ;; The goal here will be to remove the indentation
> > + ;; whitespace from an otherwise blank line after
> > + ;; typing <CR> twice in succession. Also to remove
> > + ;; trailing whitespace after reindentation of the
> > + ;; previous line because that may have
> > + ;; (re)introduced it.
> > (goto-char before)
> > ;; We were at EOL in marker `before' before the call
> > ;; to `indent-according-to-mode' but after we may
> I don't understand why you distinguish
> electric-indent-inhibit
> from
> (memq indent-line-function
> electric-indent-functions-without-reindent)
It was quite late when I worked out the patch. I just did it
mechanically, to get the discussion moving.
> When I introduced these, electric-indent-functions-without-reindent was
> only meant to paper over those pre-existing cases that don't set
> electric-indent-inhibit.
> So, I'd suggest an even simpler patch which just closes the `unless`
> earlier. Would that work?
Probably. Maybe João should check this, once he's fully back with us.
> Stefan
> diff --git a/lisp/electric.el b/lisp/electric.el
> index 07da2f1d9e..beb3348755 100644
> --- a/lisp/electric.el
> +++ b/lisp/electric.el
> @@ -281,7 +281,7 @@ electric-indent-post-self-insert-function
> (goto-char before)
> (condition-case-unless-debug ()
> (indent-according-to-mode)
> - (error (throw 'indent-error nil)))
> + (error (throw 'indent-error nil))))
> ;; The goal here will be to remove the trailing
> ;; whitespace after reindentation of the previous line
> ;; because that may have (re)introduced it.
> @@ -290,7 +290,7 @@ electric-indent-post-self-insert-function
> ;; to `indent-according-to-mode' but after we may
> ;; not be (Bug#15767).
> (when (and (eolp))
> - (delete-horizontal-space t))))))
> + (delete-horizontal-space t)))))
> (unless (and electric-indent-inhibit
> (not at-newline))
> (condition-case-unless-debug ()
--
Alan Mackenzie (Nuremberg, Germany).
- bug#35254: 27.0.50; cc-mode/electric-pair-mode/electric-layout-mode: bad trailing whitespace behavior in cc-mode, (continued)
- bug#35254: 27.0.50; cc-mode/electric-pair-mode/electric-layout-mode: bad trailing whitespace behavior in cc-mode, Alan Mackenzie, 2019/05/13
- bug#35254: 27.0.50; cc-mode/electric-pair-mode/electric-layout-mode: bad trailing whitespace behavior in cc-mode, Stefan Monnier, 2019/05/14
- bug#35254: 27.0.50; cc-mode/electric-pair-mode/electric-layout-mode: bad trailing whitespace behavior in cc-mode,
Alan Mackenzie <=
- bug#35254: 27.0.50; cc-mode/electric-pair-mode/electric-layout-mode: bad trailing whitespace behavior in cc-mode, João Távora, 2019/05/14
- bug#35254: 27.0.50; cc-mode/electric-pair-mode/electric-layout-mode: bad trailing whitespace behavior in cc-mode, Alan Mackenzie, 2019/05/15
- bug#35254: 27.0.50; cc-mode/electric-pair-mode/electric-layout-mode: bad trailing whitespace behavior in cc-mode, João Távora, 2019/05/15
- bug#35254: 27.0.50; cc-mode/electric-pair-mode/electric-layout-mode: bad trailing whitespace behavior in cc-mode, Stefan Monnier, 2019/05/15
- bug#35254: 27.0.50; cc-mode/electric-pair-mode/electric-layout-mode: bad trailing whitespace behavior in cc-mode, João Távora, 2019/05/15
- bug#35254: 27.0.50; cc-mode/electric-pair-mode/electric-layout-mode: bad trailing whitespace behavior in cc-mode, João Távora, 2019/05/15
- bug#35254: 27.0.50; cc-mode/electric-pair-mode/electric-layout-mode: bad trailing whitespace behavior in cc-mode, Alan Mackenzie, 2019/05/14
- bug#35254: 27.0.50; cc-mode/electric-pair-mode/electric-layout-mode: bad trailing whitespace behavior in cc-mode, Stefan Monnier, 2019/05/14