bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#60094: current-column returns an incorrect number of columns for som


From: Rodrigo Morales
Subject: bug#60094: current-column returns an incorrect number of columns for some characters
Date: Thu, 15 Dec 2022 11:40:55 -0500

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
`----

reply via email to

[Prev in Thread] Current Thread [Next in Thread]