GNU bug report logs -
#60094
current-column returns an incorrect number of columns for some characters
Previous Next
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 60094 in the body.
You can then email your comments to 60094 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#60094
; Package
emacs
.
(Thu, 15 Dec 2022 16:42:01 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Rodrigo Morales <moralesrodrigo1100 <at> gmail.com>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Thu, 15 Dec 2022 16:42:01 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
TL; DR: `current-column' returns `2' when the cursor is in the first
column and the line contains a single emoji or a Chinese character. The
expected value is `1' as happens when the line contains `a' or even the
highest defined codepoint in Unicode: `U+10FFFD'.
In the minimal working example below, you can see that `current-columns'
returns `1' when the line contains the character `a' and the cursor is
located after it.
,----
| cat ~/e/main.el
`----
,----
| (with-temp-buffer
| (insert "a")
| (end-of-line)
| (princ (current-column)))
`----
,----
| emacs -Q --batch -l ~/e/main.el
`----
,----
| 1
`----
In the minimal working example below, you can see that `current-columns'
returns `1' when the line contains the character `' (highest defined
codepoint in Unicode, U+10FFFD) and the cursor is located after it.
,----
| cat ~/e/main.el
`----
,----
| (with-temp-buffer
| (insert "")
| (end-of-line)
| (princ (current-column)))
`----
,----
| emacs -Q --batch -l ~/e/main.el
`----
,----
| 1
`----
In the minimal working example below, you can see that `current-columns'
returns `2' when the line contains an emoji and the cursor is located
after it.
,----
| cat ~/e/main.el
`----
,----
| (with-temp-buffer
| (insert "👋")
| (end-of-line)
| (princ (current-column)))
`----
,----
| emacs -Q --batch -l ~/e/main.el
`----
,----
| 2
`----
In the minimal working example below, you can see that `current-columns'
returns `2' when the line contains a Chinese character and the cursor is
located after it.
,----
| cat ~/e/main.el
`----
,----
| (with-temp-buffer
| (insert "你")
| (end-of-line)
| (princ (current-column)))
`----
,----
| emacs -Q --batch -l ~/e/main.el
`----
,----
| 2
`----
[Message part 2 (text/html, inline)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#60094
; Package
emacs
.
(Thu, 15 Dec 2022 16:57:01 GMT)
Full text and
rfc822 format available.
Message #8 received at 60094 <at> debbugs.gnu.org (full text, mbox):
tags 60094 notabug
thanks
> From: Rodrigo Morales <moralesrodrigo1100 <at> gmail.com>
> Date: Thu, 15 Dec 2022 11:40:55 -0500
>
> In the minimal working example below, you can see that `current-columns'
> returns `2' when the line contains an emoji and the cursor is located
> after it.
>
> ,----
> | cat ~/e/main.el
> `----
>
> ,----
> | (with-temp-buffer
> | (insert "👋")
> | (end-of-line)
> | (princ (current-column)))
> `----
>
> ,----
> | emacs -Q --batch -l ~/e/main.el
> `----
>
> ,----
> | 2
> `----
>
> In the minimal working example below, you can see that `current-columns'
> returns `2' when the line contains a Chinese character and the cursor is
> located after it.
>
> ,----
> | cat ~/e/main.el
> `----
>
> ,----
> | (with-temp-buffer
> | (insert "你")
> | (end-of-line)
> | (princ (current-column)))
> `----
>
> ,----
> | emacs -Q --batch -l ~/e/main.el
> `----
>
> ,----
> | 2
> `----
These are the expected and correct results: these characters have
width that is very close to 2 canonical columns. And current-column
counts canonical columns, not just characters.
If you type regular characters, like 'a', above or below this Emoji or
the Chinese character, you will see that for each such Emoji you can
type 2 regular characters.
So there's no bug here: Emacs does what it's supposed to do. The doc
string of current-column says:
This is calculated by adding together the widths of all the displayed
representations of the character between the start of the previous line
and point (e.g., control characters will have a width of 2 or 4, tabs
will have a variable width).
Note the "displayed representations" part.
Added tag(s) notabug.
Request was from
Eli Zaretskii <eliz <at> gnu.org>
to
control <at> debbugs.gnu.org
.
(Thu, 15 Dec 2022 16:57:02 GMT)
Full text and
rfc822 format available.
Reply sent
to
Stefan Kangas <stefankangas <at> gmail.com>
:
You have taken responsibility.
(Mon, 04 Sep 2023 21:12:02 GMT)
Full text and
rfc822 format available.
Notification sent
to
Rodrigo Morales <moralesrodrigo1100 <at> gmail.com>
:
bug acknowledged by developer.
(Mon, 04 Sep 2023 21:12:02 GMT)
Full text and
rfc822 format available.
Message #15 received at 60094-done <at> debbugs.gnu.org (full text, mbox):
Eli Zaretskii <eliz <at> gnu.org> writes:
> tags 60094 notabug
> thanks
[...]
> So there's no bug here: Emacs does what it's supposed to do. The doc
> string of current-column says:
>
> This is calculated by adding together the widths of all the displayed
> representations of the character between the start of the previous line
> and point (e.g., control characters will have a width of 2 or 4, tabs
> will have a variable width).
>
> Note the "displayed representations" part.
Thanks, I'm therefore closing this bug report.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Tue, 03 Oct 2023 11:24:13 GMT)
Full text and
rfc822 format available.
This bug report was last modified 1 year and 220 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.