From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#60094: current-column returns an incorrect number of columns for some characters Date: Thu, 15 Dec 2022 18:56:43 +0200 Message-ID: <83wn6sk3lg.fsf@gnu.org> References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="5707"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 60094@debbugs.gnu.org To: Rodrigo Morales Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Dec 15 17:57:32 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p5rY3-0001Ex-U1 for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 15 Dec 2022 17:57:32 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p5rXi-00037l-03; Thu, 15 Dec 2022 11:57:11 -0500 Original-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 1p5rXa-00037I-C2 for bug-gnu-emacs@gnu.org; Thu, 15 Dec 2022 11:57:04 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p5rXa-0002FR-46 for bug-gnu-emacs@gnu.org; Thu, 15 Dec 2022 11:57:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1p5rXZ-0000EU-Kt for bug-gnu-emacs@gnu.org; Thu, 15 Dec 2022 11:57:01 -0500 X-Loop: help-debbugs@gnu.org 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 Original-Received: via spool by 60094-submit@debbugs.gnu.org id=B60094.1671123416882 (code B ref 60094); Thu, 15 Dec 2022 16:57:01 +0000 Original-Received: (at 60094) by debbugs.gnu.org; 15 Dec 2022 16:56:56 +0000 Original-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 Original-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 Original-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==; Original-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 In-Reply-To: (message from Rodrigo Morales on Thu, 15 Dec 2022 11:40:55 -0500) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:251120 Archived-At: 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.