[gnu.emacs.bug] bug in command_loop_1

Duchier-Denys@cs.yale.edu (Denys Duchier) (01/25/90)

As I keep optimizing one thing here, another thing there, I seem to
run across bugs that did not previously show up.

In command_loop_1 (keyboard.c), there is an optimization for the
common case of forward-char. The test is:

  if (lose >= ' ' && lose < 0177
      && (XFASTINT (XWINDOW (selected_window)->last_modified)
	  >= bf_modified)
      && (XFASTINT (XWINDOW (selected_window)->last_point)
	  == point)
      && !windows_or_buffers_changed
      && EQ (bf_cur->selective_display, Qnil)
      && !detect_input_pending ()
      && NULL (Vexecuting_macro))

I find the 4th conjunct really confusing. Shouldn't it be:

      && (XFASTINT (XWINDOW (selected_window)->last_point)
	  == point - 1)

The problem is that, just before the conditional, we have the
instruction:

  SetPoint (point + 1)

I don't see how the original test could succeed. Similarly for the
optimization of backward-char: point should be point + 1.

I just tried this fix, and the behaviour is now as expected. Can
somebody tell if I am right?

--Denys