all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#46400: Sporadically breaking newline-indentation in c-mode
@ 2021-02-09 12:45 Konstantin Kharlamov
  2021-02-09 22:13 ` bug#46400: [BISECTED] " Konstantin Kharlamov
  0 siblings, 1 reply; 9+ messages in thread
From: Konstantin Kharlamov @ 2021-02-09 12:45 UTC (permalink / raw)
  To: 46400

This is a regression, but I'm not sure when it was introduced. Upon pressing
RET, sometimes indentation gets inserted and you get the caret is on top of
indentation; other times no indentation is inserted and the caret ends up at the
beginning of a new line.

There is not pattern, and both cases may happen many times in the row upon
pressing RET.

It is worth noting that this only happens in certain syntax parts of c-code.

To reproduce the problem you basically put the caret at certain location in
text, and spam RET and undo till some "RET" results in no indentation inserted
(indentation seems expected by default, so it's not expected bahavior).

# Steps to reproduce

1. Create /tmp/.emacs file with the following content:

    (defun test ()
      (let ((i 0)
            (searching t))
        (while (and (< i 10) searching)
          (setq i (+ i 1))
          (call-interactively 'newline)
          (if (eq (line-beginning-position) (point))
              (setq searching nil)
            (call-interactively 'undo))
          )
        (format "exiting with i = %d" i)))

2. Create `test.c` file with the following content:

    void foo() {
        if (-1 == dest)
        {
            bar("Couldn't open %s", to);
            goto exit;
        }
    }

3. Run emacs as `env HOME=/tmp/ emacs test.c`
4. Put caret at the end of `bar("Couldn't open %s", to);` text, right after the
semicolon
5. Evaluate (test)

NOTE: to make this work I had to evaluate the 5-th step twice. The reason is
that `undo` in here behaves oddly: often it just refuses to undo with "No
further undo unformation", thus making function evaluation stop. I'm not sure
what to do about that problem; however repeating the call second time seems to
always reproduce the problem for me.

## Expected

Whenever `(test)` completes, the text is unchanged.

## Actual

At some point you end up with caret being at the beginning of a new line (i.e.
no indentation on that line)

# Version

Latest Emacs build:

    GNU Emacs 28.0.50 (build 12, x86_64-pc-linux-gnu, GTK+ Version 3.24.24,
cairo version 1.17.4) of 2021-02-09

Also tested on a build from a few weeks ago, commit 9503f8d96c







^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2021-02-23 11:32 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-02-09 12:45 bug#46400: Sporadically breaking newline-indentation in c-mode Konstantin Kharlamov
2021-02-09 22:13 ` bug#46400: [BISECTED] " Konstantin Kharlamov
2021-02-12 14:08   ` Konstantin Kharlamov
2021-02-12 14:56     ` Alan Mackenzie
2021-02-12 15:46       ` Konstantin Kharlamov
2021-02-17 21:59       ` Konstantin Kharlamov
2021-02-18 11:21         ` Alan Mackenzie
2021-02-23 11:26           ` Alan Mackenzie
     [not found]           ` <YDTmW5Fi8xBc0Wja@ACM>
2021-02-23 11:32             ` Konstantin Kharlamov

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.