From unknown Fri Aug 15 19:37:13 2025 X-Loop: help-debbugs@gnu.org Subject: bug#60094: current-column returns an incorrect number of columns for some characters Resent-From: Rodrigo Morales Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 15 Dec 2022 16:42:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 60094 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 60094@debbugs.gnu.org X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.167112248032490 (code B ref -1); Thu, 15 Dec 2022 16:42:01 +0000 Received: (at submit) by debbugs.gnu.org; 15 Dec 2022 16:41:20 +0000 Received: from localhost ([127.0.0.1]:43659 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p5rIN-0008Ry-Su for submit@debbugs.gnu.org; Thu, 15 Dec 2022 11:41:20 -0500 Received: from lists.gnu.org ([209.51.188.17]:57474) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p5rIM-0008Rs-RV for submit@debbugs.gnu.org; Thu, 15 Dec 2022 11:41:19 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p5rIL-0005vR-Vy for bug-gnu-emacs@gnu.org; Thu, 15 Dec 2022 11:41:18 -0500 Received: from mail-vs1-xe2a.google.com ([2607:f8b0:4864:20::e2a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p5rII-0003XJ-5w for bug-gnu-emacs@gnu.org; Thu, 15 Dec 2022 11:41:16 -0500 Received: by mail-vs1-xe2a.google.com with SMTP id m2so3420501vsv.9 for ; Thu, 15 Dec 2022 08:41:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=GcxFl9U95otX01426m5EtrIG57iK/hrq46HjLWALeFI=; b=OIuZny9b10PtB43DX/XwI5vJadnWIQkYDUAjeXvH763HrlPVSyhWPQ2w6cEOneh9i1 qOxuY2oq8d8ZTsWztqkwIr9Wg/G1PU4FiR9+A5+vGVMQuRBq6hqkMggqgAzFi/0fDmry Eyw1Jg91ILfYrxKPIr9prCThY1WrFYfJHatRdZo4DTQxoeqjfUmzAriVXGWrMTfeYi0O TlmrLRlySu4x/5poIPZbdYTNkCZaYqiLsStQ/n1mDvgQ04wogPFqv262Z1Pc3iEuN1Y5 Up2FmlzlX8yy3mXr+JHEK/44xKvwQktMGPQ3Xr8q8dj+tA/AL551d3bBOPKWBxOkHLF5 1nhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=GcxFl9U95otX01426m5EtrIG57iK/hrq46HjLWALeFI=; b=EnQVZIKPs6xnG5fsBGNwQYDSNhcP1x4L3FUQKb5XZad8Jp8GvklQuEXOSW5mEzXR32 48jgbSaXPTjJiDeF8KRY4LiEw8cCQagichstnckynIKKGJD00reDnI31pweuTqBSvOZz iRhrXpALKl/Uf3SxyoDlwH8IRgY42xR6ZlEOL/8CduOXgloWMwR3g0NKZjKY0yTdU+jb pxecit0sOCQtG7hBrfNu+J3esqeZO8euS38YDN2qEeSIQkAN1xD4NxHSP3kHnZaTgYg8 3puC+Nc5N5DXBS6Mg61wQGBqHEraHkyo++2ZNSnBcQBty/6cshDtR3qsHRI3rkXXyxn7 rlGQ== X-Gm-Message-State: ANoB5pl7qBuQW51U9DkCtspdULeboKFv9Gt2jNRPQQ8Cf+LBAvUJ2uBZ F8DzGT/AXmCrI7Nwo8U17sUIEy635quliUsxKSl9tPEmZvU= X-Google-Smtp-Source: AA0mqf71HYqppVmVSXc19hX/CTiIBe5839uFQz+UfgN2sNTcnlMwphGCtrDnMc6D4ihTkCbdsXCUI5OgBO+WzAdW4Ps= X-Received: by 2002:a05:6102:5ee:b0:3b1:a1c:3cab with SMTP id w14-20020a05610205ee00b003b10a1c3cabmr19159634vsf.46.1671122471787; Thu, 15 Dec 2022 08:41:11 -0800 (PST) MIME-Version: 1.0 From: Rodrigo Morales Date: Thu, 15 Dec 2022 11:40:55 -0500 Message-ID: Content-Type: multipart/alternative; boundary="0000000000004ea38905efe08584" Received-SPF: pass client-ip=2607:f8b0:4864:20::e2a; envelope-from=moralesrodrigo1100@gmail.com; helo=mail-vs1-xe2a.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.1 (-) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.1 (--) --0000000000004ea38905efe08584 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 `=F4=8F=BF=BD' (highest de= fined codepoint in Unicode, U+10FFFD) and the cursor is located after it. ,---- | cat ~/e/main.el `---- ,---- | (with-temp-buffer | (insert "=F4=8F=BF=BD") | (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 "=F0=9F=91=8B") | (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 "=E4=BD=A0") | (end-of-line) | (princ (current-column))) `---- ,---- | emacs -Q --batch -l ~/e/main.el `---- ,---- | 2 `---- --0000000000004ea38905efe08584 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
TL; DR: `current-column' returns `2' when the curs= or is in the first
column and the line contains a single emoji or a Chin= ese character. The
expected value is `1' as happens when the line co= ntains `a' or even the
highest defined codepoint in Unicode: `U+10FF= FD'.

In the minimal working example below, you can see that `cur= rent-columns'
returns `1' when the line contains the character `= a' and the cursor is
located after it.

,----
| cat ~/e/mai= n.el
`----

,----
| (with-temp-buffer
| =C2=A0 (insert "= ;a")
| =C2=A0 (end-of-line)
| =C2=A0 (princ (current-column)))`----

,----
| emacs -Q --batch -l ~/e/main.el
`----

,= ----
| 1
`----

In the minimal working example below, you can s= ee that `current-columns'
returns `1' when the line contains the= character `=F4=8F=BF=BD' (highest defined
codepoint in Unicode, U+1= 0FFFD) and the cursor is located after it.

,----
| cat ~/e/main.e= l
`----

,----
| (with-temp-buffer
| =C2=A0 (insert "= =F4=8F=BF=BD")
| =C2=A0 (end-of-line)
| =C2=A0 (princ (current-c= olumn)))
`----

,----
| 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 co= ntains an emoji and the cursor is located
after it.

,----
| ca= t ~/e/main.el
`----

,----
| (with-temp-buffer
| =C2=A0 (ins= ert "=F0=9F=91=8B")
| =C2=A0 (end-of-line)
| =C2=A0 (princ = (current-column)))
`----

,----
| emacs -Q --batch -l ~/e/main.= el
`----

,----
| 2
`----

In the minimal working exam= ple below, you can see that `current-columns'
returns `2' when t= he line contains a Chinese character and the cursor is
located after it.=

,----
| cat ~/e/main.el
`----

,----
| (with-temp-bu= ffer
| =C2=A0 (insert "=E4=BD=A0")
| =C2=A0 (end-of-line)| =C2=A0 (princ (current-column)))
`----

,----
| emacs -Q --= batch -l ~/e/main.el
`----

,----
| 2
`----
--0000000000004ea38905efe08584-- From unknown Fri Aug 15 19:37:13 2025 X-Loop: help-debbugs@gnu.org Subject: bug#60094: current-column returns an incorrect number of columns for some characters Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 15 Dec 2022 16:57:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 60094 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Rodrigo Morales Cc: 60094@debbugs.gnu.org Received: via spool by 60094-submit@debbugs.gnu.org id=B60094.1671123416882 (code B ref 60094); Thu, 15 Dec 2022 16:57:01 +0000 Received: (at 60094) by debbugs.gnu.org; 15 Dec 2022 16:56:56 +0000 Received: from localhost ([127.0.0.1]:43744 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p5rXU-0000E9-82 for submit@debbugs.gnu.org; Thu, 15 Dec 2022 11:56:56 -0500 Received: from eggs.gnu.org ([209.51.188.92]:46986) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p5rXO-0000Dv-IX; Thu, 15 Dec 2022 11:56:54 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p5rXJ-0002Ca-6D; Thu, 15 Dec 2022 11:56:45 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=zOxZbmskNIOxyypgCOB35sqgnlS69AyxdSwwqeS/fe8=; b=c2C91o2yAcPpKEKs2CFk NyONfs7szvQthMUxEy82xDlB1M2ebmX9yxLqGFVXduMMoQBTfy/VRnG7C9UWtLYrPYa2S88UqtcpV GHfnSwWRf8BhTQya5z3hbUzGPCzNcQ6xNDO7nVyRrQUkGCJQk388QoxN5H3kCbBsYlyD1lbnpbH4b WIhq2NglvCjV3+HtOwCivmCkl3Q0PhzbhC+tM7e6v06gbIvwxjfsGzpwjFfH1J/jEuNFrV7Z96pak YkxohUrFdf7NbtTPe50F8W/R4JXbFjBJxmj4aeVKxzbWSiK6SwW+jot19V/Ioo9uZ/5MTqd2/nl8n Q1W9aTZJiGwGNg==; Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p5rXI-0001E1-4O; Thu, 15 Dec 2022 11:56:44 -0500 Date: Thu, 15 Dec 2022 18:56:43 +0200 Message-Id: <83wn6sk3lg.fsf@gnu.org> From: Eli Zaretskii In-Reply-To: (message from Rodrigo Morales on Thu, 15 Dec 2022 11:40:55 -0500) References: MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) tags 60094 notabug thanks > From: Rodrigo Morales > 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. From unknown Fri Aug 15 19:37:13 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Rodrigo Morales Subject: bug#60094: closed (Re: bug#60094: current-column returns an incorrect number of columns for some characters) Message-ID: References: X-Gnu-PR-Message: they-closed 60094 X-Gnu-PR-Package: emacs X-Gnu-PR-Keywords: notabug Reply-To: 60094@debbugs.gnu.org Date: Mon, 04 Sep 2023 21:12:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1693861922-1116-1" This is a multi-part message in MIME format... ------------=_1693861922-1116-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #60094: current-column returns an incorrect number of columns for some char= acters which was filed against the emacs package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 60094@debbugs.gnu.org. --=20 60094: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D60094 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1693861922-1116-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 60094-done) by debbugs.gnu.org; 4 Sep 2023 21:11:52 +0000 Received: from localhost ([127.0.0.1]:52797 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qdGrP-0000Hd-Pp for submit@debbugs.gnu.org; Mon, 04 Sep 2023 17:11:52 -0400 Received: from mail-lf1-x12e.google.com ([2a00:1450:4864:20::12e]:60924) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qdGrN-0000HP-33 for 60094-done@debbugs.gnu.org; Mon, 04 Sep 2023 17:11:50 -0400 Received: by mail-lf1-x12e.google.com with SMTP id 2adb3069b0e04-50087d47d4dso3106238e87.1 for <60094-done@debbugs.gnu.org>; Mon, 04 Sep 2023 14:11:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1693861903; x=1694466703; darn=debbugs.gnu.org; h=cc:to:subject:message-id:date:mime-version:references:in-reply-to :from:from:to:cc:subject:date:message-id:reply-to; bh=8KibH0gi6ECIzJ27NcnSimyWnSFZbEAwpsFjvU2pQBM=; b=aS17xtLxNV94qiEQg/+DGnSWmlNI20PdnAOP7dbJjQgrqEUCM+kMEWo3AL9SEDMR/A GCo3iOJZ2H/AZ7qTR0G1JxZMv54PUJN7xVYpfygDtPR8iK0V7DQ6BcTN2Frbokb4SSz2 FCkuY/QEMCy2hThCRjzVqQXR4U7A2VogHoff/aZsgyOfwzznr2Xv8U+mGHym6CodSF9B qPxz3ouh8Xwl/AH8MMA5QbnWqOTUgFtAoTGZBY3VlII+/gtTeEYBxV9kQuj9irtPoMU8 32eDKcqxn9lbBvgT3TP/gO67geD/NO39743doxLdSy1phENe8OwlqGQF/UvvwLrDUeuX AgUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693861903; x=1694466703; h=cc:to:subject:message-id:date:mime-version:references:in-reply-to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=8KibH0gi6ECIzJ27NcnSimyWnSFZbEAwpsFjvU2pQBM=; b=GBuIp9Evotz/bMYr4PlrJgKS4ummUOGtHDO9KPCGK8tAR0yu61iH8c3PPXTEo/M66P PrGMQUVnab7wNT6SFYWsuyMHLXKzMgRPO/I4UPQRMSKhDNkA8CoU+fsSw58ESNNpvglC FPwsHufvb/UALd91giSzGJz/ErbhEyhEgpcnYj8rtW1RtzksnOab0acTCiCCxslpFUHn S9tq/l4Kb52+Nav0vtKBdB+kElUgtnziUyDXzGHPTRZwJFaXSOrAZHGpIqjQ1r2tZAqc D2kSgFQFrTcuqHw1zYrqNYuF1MXNpq4LenREP7UN5GekvBJQS3w1RJ4p6rlIT/Ic9Gdi WVEA== X-Gm-Message-State: AOJu0Yy/66aCSEwSdY42TFfEci3pV5odLZEKjX5786K1fJXJJKB0xmG2 w/VfSsE5lp874zP/1LNBdn+QIMeO8rQa4e9gj0g= X-Google-Smtp-Source: AGHT+IGFNj9/5L1s9/uobnPGs2cVGtZAZRu64N95I1LbTYRNd5lxDHDHJXWEaK1ZDShLAB+RK8xVwPyZpZSkGREh2gc= X-Received: by 2002:ac2:504d:0:b0:4fe:1681:9377 with SMTP id a13-20020ac2504d000000b004fe16819377mr6264859lfm.44.1693861902869; Mon, 04 Sep 2023 14:11:42 -0700 (PDT) Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Mon, 4 Sep 2023 14:11:42 -0700 From: Stefan Kangas In-Reply-To: <83wn6sk3lg.fsf@gnu.org> (Eli Zaretskii's message of "Thu, 15 Dec 2022 18:56:43 +0200") References: <83wn6sk3lg.fsf@gnu.org> MIME-Version: 1.0 Date: Mon, 4 Sep 2023 14:11:42 -0700 Message-ID: Subject: Re: bug#60094: current-column returns an incorrect number of columns for some characters To: Eli Zaretskii Content-Type: text/plain; charset="UTF-8" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 60094-done Cc: 60094-done@debbugs.gnu.org, Rodrigo Morales X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Eli Zaretskii 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. ------------=_1693861922-1116-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 15 Dec 2022 16:41:20 +0000 Received: from localhost ([127.0.0.1]:43659 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p5rIN-0008Ry-Su for submit@debbugs.gnu.org; Thu, 15 Dec 2022 11:41:20 -0500 Received: from lists.gnu.org ([209.51.188.17]:57474) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p5rIM-0008Rs-RV for submit@debbugs.gnu.org; Thu, 15 Dec 2022 11:41:19 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p5rIL-0005vR-Vy for bug-gnu-emacs@gnu.org; Thu, 15 Dec 2022 11:41:18 -0500 Received: from mail-vs1-xe2a.google.com ([2607:f8b0:4864:20::e2a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p5rII-0003XJ-5w for bug-gnu-emacs@gnu.org; Thu, 15 Dec 2022 11:41:16 -0500 Received: by mail-vs1-xe2a.google.com with SMTP id m2so3420501vsv.9 for ; Thu, 15 Dec 2022 08:41:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=GcxFl9U95otX01426m5EtrIG57iK/hrq46HjLWALeFI=; b=OIuZny9b10PtB43DX/XwI5vJadnWIQkYDUAjeXvH763HrlPVSyhWPQ2w6cEOneh9i1 qOxuY2oq8d8ZTsWztqkwIr9Wg/G1PU4FiR9+A5+vGVMQuRBq6hqkMggqgAzFi/0fDmry Eyw1Jg91ILfYrxKPIr9prCThY1WrFYfJHatRdZo4DTQxoeqjfUmzAriVXGWrMTfeYi0O TlmrLRlySu4x/5poIPZbdYTNkCZaYqiLsStQ/n1mDvgQ04wogPFqv262Z1Pc3iEuN1Y5 Up2FmlzlX8yy3mXr+JHEK/44xKvwQktMGPQ3Xr8q8dj+tA/AL551d3bBOPKWBxOkHLF5 1nhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=GcxFl9U95otX01426m5EtrIG57iK/hrq46HjLWALeFI=; b=EnQVZIKPs6xnG5fsBGNwQYDSNhcP1x4L3FUQKb5XZad8Jp8GvklQuEXOSW5mEzXR32 48jgbSaXPTjJiDeF8KRY4LiEw8cCQagichstnckynIKKGJD00reDnI31pweuTqBSvOZz iRhrXpALKl/Uf3SxyoDlwH8IRgY42xR6ZlEOL/8CduOXgloWMwR3g0NKZjKY0yTdU+jb pxecit0sOCQtG7hBrfNu+J3esqeZO8euS38YDN2qEeSIQkAN1xD4NxHSP3kHnZaTgYg8 3puC+Nc5N5DXBS6Mg61wQGBqHEraHkyo++2ZNSnBcQBty/6cshDtR3qsHRI3rkXXyxn7 rlGQ== X-Gm-Message-State: ANoB5pl7qBuQW51U9DkCtspdULeboKFv9Gt2jNRPQQ8Cf+LBAvUJ2uBZ F8DzGT/AXmCrI7Nwo8U17sUIEy635quliUsxKSl9tPEmZvU= X-Google-Smtp-Source: AA0mqf71HYqppVmVSXc19hX/CTiIBe5839uFQz+UfgN2sNTcnlMwphGCtrDnMc6D4ihTkCbdsXCUI5OgBO+WzAdW4Ps= X-Received: by 2002:a05:6102:5ee:b0:3b1:a1c:3cab with SMTP id w14-20020a05610205ee00b003b10a1c3cabmr19159634vsf.46.1671122471787; Thu, 15 Dec 2022 08:41:11 -0800 (PST) MIME-Version: 1.0 From: Rodrigo Morales Date: Thu, 15 Dec 2022 11:40:55 -0500 Message-ID: Subject: current-column returns an incorrect number of columns for some characters To: bug-gnu-emacs@gnu.org Content-Type: multipart/alternative; boundary="0000000000004ea38905efe08584" Received-SPF: pass client-ip=2607:f8b0:4864:20::e2a; envelope-from=moralesrodrigo1100@gmail.com; helo=mail-vs1-xe2a.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.1 (-) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.1 (--) --0000000000004ea38905efe08584 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 `=F4=8F=BF=BD' (highest de= fined codepoint in Unicode, U+10FFFD) and the cursor is located after it. ,---- | cat ~/e/main.el `---- ,---- | (with-temp-buffer | (insert "=F4=8F=BF=BD") | (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 "=F0=9F=91=8B") | (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 "=E4=BD=A0") | (end-of-line) | (princ (current-column))) `---- ,---- | emacs -Q --batch -l ~/e/main.el `---- ,---- | 2 `---- --0000000000004ea38905efe08584 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
TL; DR: `current-column' returns `2' when the curs= or is in the first
column and the line contains a single emoji or a Chin= ese character. The
expected value is `1' as happens when the line co= ntains `a' or even the
highest defined codepoint in Unicode: `U+10FF= FD'.

In the minimal working example below, you can see that `cur= rent-columns'
returns `1' when the line contains the character `= a' and the cursor is
located after it.

,----
| cat ~/e/mai= n.el
`----

,----
| (with-temp-buffer
| =C2=A0 (insert "= ;a")
| =C2=A0 (end-of-line)
| =C2=A0 (princ (current-column)))`----

,----
| emacs -Q --batch -l ~/e/main.el
`----

,= ----
| 1
`----

In the minimal working example below, you can s= ee that `current-columns'
returns `1' when the line contains the= character `=F4=8F=BF=BD' (highest defined
codepoint in Unicode, U+1= 0FFFD) and the cursor is located after it.

,----
| cat ~/e/main.e= l
`----

,----
| (with-temp-buffer
| =C2=A0 (insert "= =F4=8F=BF=BD")
| =C2=A0 (end-of-line)
| =C2=A0 (princ (current-c= olumn)))
`----

,----
| 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 co= ntains an emoji and the cursor is located
after it.

,----
| ca= t ~/e/main.el
`----

,----
| (with-temp-buffer
| =C2=A0 (ins= ert "=F0=9F=91=8B")
| =C2=A0 (end-of-line)
| =C2=A0 (princ = (current-column)))
`----

,----
| emacs -Q --batch -l ~/e/main.= el
`----

,----
| 2
`----

In the minimal working exam= ple below, you can see that `current-columns'
returns `2' when t= he line contains a Chinese character and the cursor is
located after it.=

,----
| cat ~/e/main.el
`----

,----
| (with-temp-bu= ffer
| =C2=A0 (insert "=E4=BD=A0")
| =C2=A0 (end-of-line)| =C2=A0 (princ (current-column)))
`----

,----
| emacs -Q --= batch -l ~/e/main.el
`----

,----
| 2
`----
--0000000000004ea38905efe08584-- ------------=_1693861922-1116-1--