all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#60094: current-column returns an incorrect number of columns for some characters
@ 2022-12-15 16:40 Rodrigo Morales
  2022-12-15 16:56 ` Eli Zaretskii
  0 siblings, 1 reply; 3+ messages in thread
From: Rodrigo Morales @ 2022-12-15 16:40 UTC (permalink / raw)
  To: 60094

[-- 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 --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-09-04 21:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2023-09-04 21:11   ` Stefan Kangas

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.