GNU bug report logs - #47360
27.1; using 'bar cursor, mouseclick is rounded to the wrong char position

Previous Next

Package: emacs;

Reported by: Julian Rohrhuber <rohrhuber <at> protonmail.com>

Date: Wed, 24 Mar 2021 12:52:01 UTC

Severity: normal

Found in version 27.1

Full log


Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Julian Rohrhuber <rohrhuber <at> protonmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 27.1;
 using 'bar cursor, mouseclick is rounded to the wrong char position
Date: Wed, 24 Mar 2021 07:42:28 +0000
[Message part 1 (text/plain, inline)]
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.

(defun posn-set-point (position)
"Move point to POSITION.
Select the corresponding window as well."
(if (not (windowp (posn-window position)))
(error "Position not in text area of window"))
(select-window (posn-window position))
(let ((pos (posn-point position)))
(if (numberp pos)
(goto-char (if (and (eq 'bar (or (car-safe cursor-type) cursor-type))
(< pos (point-max))
(consp position)
(numberp (car-safe (posn-object-x-y position)))
(numberp (car-safe (posn-object-width-height position)))
(> (* 2 (car (posn-object-x-y position)))
(car (posn-object-width-height position))))
(1+ pos)
pos)))))

Configured features:
NOTIFY KQUEUE ACL GNUTLS LIBXML2 ZLIB TOOLKIT_SCROLL_BARS NS MODULES
THREADS JSON PDUMPER

Important settings:
value of $LANG: en_DE.UTF-8
locale-coding-system: utf-8-unix

Major mode: Markdown

Minor modes in effect:
shell-dirtrack-mode: t
org-roam-mode: t
recentf-mode: t
ivy-mode: t
desktop-save-mode: t
show-paren-mode: t
tooltip-mode: t
global-eldoc-mode: t
eldoc-mode: t
electric-indent-mode: t
mouse-wheel-mode: t
menu-bar-mode: t
file-name-shadow-mode: t
global-font-lock-mode: t
font-lock-mode: t
auto-composition-mode: t
auto-encryption-mode: t
auto-compression-mode: t
line-number-mode: t
global-visual-line-mode: t
visual-line-mode: t
transient-mark-mode: t
[Message part 2 (text/html, inline)]
[ohnehin.jpg (image/jpeg, inline)]

This bug report was last modified 4 years and 121 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.