Subject: bug#44823: 27.1.50; c-context-line-break misbehaves at end of comment

From: Alan Mackenzie <[email-masked]>
Date: Tue, 24 Nov 2020 16:22:46 +0000

Hello, Eli.

On Mon, Nov 23, 2020 at 19:33:35 +0200, Eli Zaretskii wrote:
> To reproduce:

>   emacs -Q
>   C-x C-f src/xdisp.c
>   C-u 19 M-g g
>   C-e

> This should bring you to the end of this line in xdisp.c:

>   along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.  */

> It is the end of a comment.  Now do this:

>   M-: (local-set-key "\C-m" 'c-context-line-break) RET

> Then press RET.  I expect Emacs to open a new line, indent it
> according to the context, and put point after the indentation.
> Instead, the new line is inserted _before_ the point's line, and point
> stays at the end of the comment as it was before.

> This is a regression wrt Emacs 26.

> I had this customization of RET in CC mode since about forever, and it
> always worked like I expected.  Until Emacs 27.1.

> Can this be fixed for Emacs 27.2, please?

This is an off-by-one error, and was fixed in master with the following
commit:

commit 7574390099f0de11939a0e3626cf222b58863290
Author: Alan Mackenzie <[email-masked]>
Date:   Thu Jun 25 17:07:16 2020 +0000

    CC Mode.  Fix an off by one error.  Fixes bug #41809

    * lisp/progmodes/cc-engine.el (c-full-pp-to-literal): Change > to >= (twice).

I can't remember why I didn't commit this to the emacs-27 branch.
Possibly it was too close to the release.

I'll cherry-pick it back to the emacs-27 branch.

> In GNU Emacs 27.1.50 (build 107, i686-pc-mingw32)
>  of 2020-11-23 built on HOME-C4E4A596F7
> Repository revision: 2b1cec559202d5985b7431ffce943bf4b019fb95
> Repository branch: emacs-27
> Windowing system distributor 'Microsoft Corp.', version 5.1.2600
> System Description: Microsoft Windows XP Service Pack 3 (v5.1.0.2600)

[ .... ]

-- 
Alan Mackenzie (Nuremberg, Germany).