Subject: bug#64574: [PATCH] Support not jumping to bol in beginning-of-defun

From: Stefan Kangas <[email-masked]>
Date: Sun, 23 Feb 2025 14:15:55 +0000

Eli Zaretskii <[email-masked]> writes:

>> Actually, thinking about this, we use this function not just as a
>> command, but also in a lot of code that is built on the assumption that
>> point moves to point zero.
>
> What do you mean by "point zero"?

Sorry, typo.  I meant to say "column zero".

>> So wouldn't installing this, as proposed, risk leading to a lot of
>> things breaking?
>
> The default behavior is unchanged.  As for when users change the
> default, the only difference is that beginning-of-defun will end not
> necessarily at column zero, but at some other column in the same line,
> where the function's declaration begins.  I don't see how this could
> break things, but maybe I'm missing something?  Can you point to
> places where we assume pointy is at column zero after calling
> beginning-of-defun?

I can't point to any specific such places no, but grepping for
`beginning-of-defun` yields a concerning number of hits, especially in
progmodes.  Note that the assumption that it always goes to column zero
has been documented since forever.  Who knows how this is used in the wild.

IOW, yes, the behavior is optional, but my concern is that when users
set it, modes will start breaking.  I still think it could be useful,
but perhaps it should be a defvar and under the control of major modes?
OTOH, then we have minor modes, but maybe it's used less frequently
there?

If someone could look into this more and run some experiments, perhaps
we can convince ourselves that this is fine after all, but to me this
currently feels a bit risky.