Subject: Re: bug#72667: 31.0.50; gud-print moves the cursor after execution

From: Eli Zaretskii <[email-masked]>
Date: Sat, 17 Aug 2024 13:34:26 +0300

> From: TatriX <[email-masked]>
> Date: Fri, 16 Aug 2024 13:38:26 +0200
> 
> When one runs `gud-print' with `C-x C-a C-p`, point moves to a line that
>  is the debugger stopped at instead of staying where it was. I'm not
>  sure if it is an intended behaviour. If it is, it would be very nice if
>  one could override it, since I find that I want the point to keep it's
>  position after I print a value. I can always run `C-x C-a C-l` to jump
>  to the currently executing line.
> 
> Here's a an illustration. Suppose you have a program `test.c':
> 
> ```
>     int main() {
>       int a = 42;
>       int b = 13;
>       int c = 69;
>       return a + b + c;
>     }
> ```
> 
> Which you can compile for example like this: `gcc -g -Wall -o test01 test.c'.
> Now, if you stop execution at `int b', move the point to `int a' and run
> `C-x C-a C-p' the point will jump back to `int b' instead of staying at
> `int a'.

I think this is an intentional feature: after each GUD command Emacs
returns point to the current line as indicated by the debugger.  The
intent is to keep the current line always visible on display.  Since
Emacs doesn't really understand the effect of debugger commands, it
must restore point after each such command.

May I ask why you use gud-print and not gud-tooltip-mode?  The latter
will allow you to show values of variables without moving point.