]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix bug with point-adjustment after M-x COMMAND
authorEli Zaretskii <eliz@gnu.org>
Mon, 5 Jun 2023 12:57:05 +0000 (15:57 +0300)
committerEli Zaretskii <eliz@gnu.org>
Mon, 5 Jun 2023 12:57:05 +0000 (15:57 +0300)
* src/keyboard.c (command_loop_1): Preserve 'last_point_position'
across command execution, to avoid bugs in
'adjust_point_for_property' if the command invokes
'recursive-edit'.  Reported by Mats Lidell <matsl@gnu.org>.

src/keyboard.c

index 14c556667687ec05cbcc3c5fd5284dbf50864475..a1cddf9d145c2b57c0de9e8fa6a3e7cb6e0ca994 100644 (file)
@@ -1436,6 +1436,7 @@ command_loop_1 (void)
       prev_buffer = current_buffer;
       prev_modiff = MODIFF;
       last_point_position = PT;
+      ptrdiff_t last_pt = PT;
 
       /* By default, we adjust point to a boundary of a region that
          has such a property that should be treated intangible
@@ -1513,6 +1514,9 @@ command_loop_1 (void)
             unbind_to (scount, Qnil);
 #endif
           }
+      /* Restore last PT position value, possibly clobbered by
+         recursive-edit invoked by the command we just executed.  */
+      last_point_position = last_pt;
       kset_last_prefix_arg (current_kboard, Vcurrent_prefix_arg);
 
       safe_run_hooks_maybe_narrowed (Qpost_command_hook,