GNU bug report logs - #60094
current-column returns an incorrect number of columns for some characters

Previous Next

Package: emacs;

Reported by: Rodrigo Morales <moralesrodrigo1100 <at> gmail.com>

Date: Thu, 15 Dec 2022 16:42:01 UTC

Severity: normal

Tags: notabug

Done: Stefan Kangas <stefankangas <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Stefan Kangas <stefankangas <at> gmail.com>
Cc: tracker <at> debbugs.gnu.org
Subject: bug#60094: closed (current-column returns an incorrect number of
 columns for some characters)
Date: Mon, 04 Sep 2023 21:12:02 +0000
[Message part 1 (text/plain, inline)]
Your message dated Mon, 4 Sep 2023 14:11:42 -0700
with message-id <CADwFkmndDTDDO0wVTht_q7vXgvAkVqiE_5r9aNL2aRH7RL28XQ <at> mail.gmail.com>
and subject line Re: bug#60094: current-column returns an incorrect number of columns for some characters
has caused the debbugs.gnu.org bug report #60094,
regarding current-column returns an incorrect number of columns for some characters
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs <at> gnu.org.)


-- 
60094: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=60094
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Rodrigo Morales <moralesrodrigo1100 <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: current-column returns an incorrect number of columns for some
 characters
Date: Thu, 15 Dec 2022 11:40:55 -0500
[Message part 3 (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 4 (text/html, inline)]
[Message part 5 (message/rfc822, inline)]
From: Stefan Kangas <stefankangas <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 60094-done <at> debbugs.gnu.org, Rodrigo Morales <moralesrodrigo1100 <at> gmail.com>
Subject: Re: bug#60094: current-column returns an incorrect number of columns
 for some characters
Date: Mon, 4 Sep 2023 14:11:42 -0700
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.


This bug report was last modified 1 year and 316 days ago.

Previous Next


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