Subject: bug#72420: set-goal-column misbehaves with a line-prefix and visual-line-mode

From: "Martin Edstrom" <[email-masked]>
Date: Wed, 07 Aug 2024 16:53:53 +0200 (CEST)

> > From: "Martin Edstrom" <[email-masked]>
> > CC: "72420" <[email-masked]>
> > Date: Wed, 07 Aug 2024 16:03:40 +0200 (CEST)
> > 
> > > > From: "Martin Edstrom" <[email-masked]>
> > > > CC: "72420" <[email-masked]>
> > > > Date: Wed, 07 Aug 2024 14:07:45 +0200 (CEST)
> > > > 
> > > > But, it's odd that visual-line-mode does not affect it for you - it does for me. 
> > > > 
> > > > If I leave visual-line-mode off, then I get the behavior I expect (i.e. set-goal-column at column 2 is treated as column 6), which is useful.  Turning it on causes the command to behave in a way that is not useful, as I described.
> > > 
> > > If you leave visual-line-mode off, then type C-p twice from "z", don't
> > > you see point go to the 3rd "*" of the line "**** h4"?  And if so,
> > > isn't that what you meant by "the goal column actually seems to be
> > > offset in some way influenced by the line prefix"?  Or did I
> > > misunderstand what you consider a problem in the existing behavior?
> > 
> > Indeed, on that line, the behavior is the same with and without visual-line-mode, going to the 3rd "*".
> > 
> > However if I go up to a list item such as "- x...........", I observe different behavior.  With visual-line-mode, point ends up on the bullet, not on "x".
> > 
> > That is surprising, no?
> 
> Not to me, it isn't, but then I've hacked on that code too much...
> 
> Anyway, the problem is the difference in behavior between
> visual-line-mode on and off, and you consider the behavior with the
> mode off as correct?  Because this was not what your original report
> said, AFAICT.

That is correct. Language is hard, sorry ;-) but it's what I meant when I wrote "Now I would expect moving point upwards with C-p any number of times should still make point land on the text after the list bullet", and by list bullet I could have clarified I meant the list items that start with "-".

Anyway, whichever behavior is considered correct... I don't think visual-line-mode has any business altering the behavior. That is a bug to me!

I noticed this bug because I habitually have Org files open with org-indent-mode, and I was going to use the goal-column trick to add some text to the beginning of several list items.  In practice with this bug, I have to move point forwards by some X characters before typing C-x C-n, which is just weird.  Let me show you:

Say as a toy case, I want to turn this list

** Stuff to do
- Get Igor to dispose of bodies
- Research pig blood
- Raid blood bank

into this

** Stuff to do
- [ ] Get Igor to dispose of bodies
- [ ] Research pig blood
- [ ] Raid blood bank

Everywhere else in Emacs, I can use set-goal-column as one of the many techniques to do this editing comfortably.  With visual-line-mode enabled, I have to move point to somewhere inside the word "Raid", before typing C-x C-n will have the intended effect of ensuring that point will land right after "- " on each line.