Subject: Re: bug#47360: 27.1; using 'bar cursor, mouseclick is rounded to the wrong char position

From: Julian Rohrhuber <[email-masked]>
Date: Wed, 24 Mar 2021 17:38:41 +0000

> On 24. Mar 2021, at 18:25, Eli Zaretskii <[email-masked]> wrote:
>
>>
>> Date: Wed, 24 Mar 2021 07:42:28 +0000
>> From:  Julian Rohrhuber via "Bug reports for GNU Emacs,
>> the Swiss army knife of text editors" <[email-masked]>
>>
>> When using 'bar as cursor, the click location is truncated to the value before the character one clicks on (as expected when using a 'box). When using a 'bar, however, one expects that the "hill" is in the center of each character, and the valley between them. I've made an illustration, where the green color shows the watershed, so to speak.
>>
>> This behavior feels subtly broken.
>>
>> A solution to the issue has been suggested https://emacs.stackexchange.com/questions/20279/mouse-pointer-between-characters-and-the-text-cursor-misplacement
>>
>> Using the modified function posn-set-point below fixes the issue for me. I find the behavior also reasonable for 'box, but that might be a matter of discussion.
>
> I don't think I see the problem you describe.  If I click exactly on
> the bar cursor, the cursor doesn't move, as I'd expect.

Sorry, I may not have described the issue well.

When clicking into a text, at a random position, the  position where the cursor jumps to is calculated. Now this is a bit subtle: when you click on a character, does the cursor jump to the left of that character or to its right?

When in box mode, it jumps to the left, and here this is correct.

But when in bar mode, it should jump to the right when the click is right of the middle of the character, and only left when to its left of the middle.

Instead, it also jumps to the left.

> In any case, please note that in Emacs the bar cursor is never exactly
> between two characters, it is at the left side of a character cell, so
> closer to the character on the right (for left-to-right text).

That is completely fine, what matters is only how the right-vs-left is calculated.