From: Rodrigo Morales <moralesrodrigo1100@gmail.com>
To: 60094@debbugs.gnu.org
Subject: bug#60094: current-column returns an incorrect number of columns for some characters
Date: Thu, 15 Dec 2022 11:40:55 -0500 [thread overview]
Message-ID: <CAGxMbPayCcy+_LDGRJvWiCpw83u8nyE+TQ3b0QHnKfehVOkkLw@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 1836 bytes --]
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
`----
[-- Attachment #2: Type: text/html, Size: 2163 bytes --]
next reply other threads:[~2022-12-15 16:40 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-15 16:40 Rodrigo Morales [this message]
2022-12-15 16:56 ` bug#60094: current-column returns an incorrect number of columns for some characters Eli Zaretskii
2023-09-04 21:11 ` Stefan Kangas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAGxMbPayCcy+_LDGRJvWiCpw83u8nyE+TQ3b0QHnKfehVOkkLw@mail.gmail.com \
--to=moralesrodrigo1100@gmail.com \
--cc=60094@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).