From: Eli Zaretskii <eliz@gnu.org>
To: Rodrigo Morales <moralesrodrigo1100@gmail.com>
Cc: 60094@debbugs.gnu.org
Subject: bug#60094: current-column returns an incorrect number of columns for some characters
Date: Thu, 15 Dec 2022 18:56:43 +0200 [thread overview]
Message-ID: <83wn6sk3lg.fsf@gnu.org> (raw)
In-Reply-To: <CAGxMbPayCcy+_LDGRJvWiCpw83u8nyE+TQ3b0QHnKfehVOkkLw@mail.gmail.com> (message from Rodrigo Morales on Thu, 15 Dec 2022 11:40:55 -0500)
tags 60094 notabug
thanks
> From: Rodrigo Morales <moralesrodrigo1100@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.
next prev parent reply other threads:[~2022-12-15 16:56 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-15 16:40 bug#60094: current-column returns an incorrect number of columns for some characters Rodrigo Morales
2022-12-15 16:56 ` Eli Zaretskii [this message]
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=83wn6sk3lg.fsf@gnu.org \
--to=eliz@gnu.org \
--cc=60094@debbugs.gnu.org \
--cc=moralesrodrigo1100@gmail.com \
/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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.