From 9a28600a97351bccadb3473b0a7829b09b1bc413 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Mon, 5 Jun 2023 15:57:05 +0300 Subject: [PATCH] Fix bug with point-adjustment after M-x COMMAND * 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 . --- src/keyboard.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/keyboard.c b/src/keyboard.c index 14c55666768..a1cddf9d145 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -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, -- 2.39.2