From unknown Mon Jun 23 06:00:20 2025 X-Loop: owner@emacsbugs.donarmstrong.com Subject: bug#1808: 23.0.60; picture-mode not considering double-width characters alignment Reply-To: poppyer , 1808@debbugs.gnu.org Resent-From: poppyer Resent-To: bug-submit-list@lists.donarmstrong.com Resent-CC: Emacs Bugs Resent-Date: Tue, 06 Jan 2009 17:15:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-Emacs-PR-Message: report 1808 X-Emacs-PR-Package: emacs X-Emacs-PR-Keywords: Received: via spool by submit@emacsbugs.donarmstrong.com id=B.123126163013083 (code B ref -1); Tue, 06 Jan 2009 17:15:03 +0000 Received: (at submit) by emacsbugs.donarmstrong.com; 6 Jan 2009 17:07:10 +0000 X-Spam-Checker-Version: SpamAssassin 3.2.5-bugs.debian.org_2005_01_02 (2008-06-10) on rzlab.ucr.edu X-Spam-Level: X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available. hammytokens:Tokens not available. X-Spam-Status: No, score=0.1 required=4.0 tests=FOURLA autolearn=no version=3.2.5-bugs.debian.org_2005_01_02 Received: from fencepost.gnu.org (fencepost.gnu.org [140.186.70.10]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id n06H73sW013076 for ; Tue, 6 Jan 2009 09:07:04 -0800 Received: from mail.gnu.org ([199.232.76.166]:47319 helo=mx10.gnu.org) by fencepost.gnu.org with esmtp (Exim 4.67) (envelope-from ) id 1LKFNI-0005hY-7T for emacs-pretest-bug@gnu.org; Tue, 06 Jan 2009 12:05:52 -0500 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1LKFOM-0005MF-SA for emacs-pretest-bug@gnu.org; Tue, 06 Jan 2009 12:07:02 -0500 Received: from ti-out-0910.google.com ([209.85.142.191]:32262) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LKFOM-0005Lt-68 for emacs-pretest-bug@gnu.org; Tue, 06 Jan 2009 12:06:58 -0500 Received: by ti-out-0910.google.com with SMTP id u5so6656050tia.10 for ; Tue, 06 Jan 2009 09:06:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:date:message-id:from:to :subject; bh=iaXO6m5qqVOFzFwF6DhZq/dI+YNJtbHQtQvEuZlL33E=; b=kyqlOc4vA83MgcQv6F3rJVipLI2u2p6AecmKxyBTevriui3oDQ0yZeP0zEnvdQxSCh CJYdRLl6dZ07Dty81uRyQNJL86m+hIfmuCZdCKoTU/a74bowI0zncHbUQSzqen4XpSFi tuGpQy1svApsJPDJMAr/IvOJgKmAPPY9y0PdY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:message-id:from:to:subject; b=S/Tke/A6y/CiqCjb8wa2uhrw99SnMuOjlSkfZEV/8QjK5OLSJUxvEI6a/FegcqECwX USC6l2Kf8A5yg+oT7othw6qP5GNEAUW+M5AfRHLbbk7Q+4qftg1fO09+DAvcSy1JNHO9 i04fIGF26tqssfXlIKkflfC0rhqsZtJI2sigg= Received: by 10.110.62.4 with SMTP id k4mr33806557tia.17.1231261615397; Tue, 06 Jan 2009 09:06:55 -0800 (PST) Received: from nusnet-97-126.dynip.nus.edu.sg.yourcompany.com (nusnet-97-126.dynip.nus.edu.sg [137.132.97.126]) by mx.google.com with ESMTPS id 14sm1292065tim.30.2009.01.06.09.06.52 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 06 Jan 2009 09:06:54 -0800 (PST) Date: Wed, 07 Jan 2009 01:06:47 +0800 Message-Id: From: poppyer To: emacs-pretest-bug@gnu.org X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) This is not a new bug of EMACS 23; but it is there in EMACS22 for a long time. In M-x picture-mode, emacs acts in a "replace" typing mode, i.e. when you type a char, it replace the old one such that the alignment is maintained. But when mixing with double-width characters (e.g. CJK chars), one to one char replacing become problematic, e.g. if we replace a single-width char with a double-wdith char, the alignment will be destroyed. So, what I suggests is: if we replace a double-width to a single-width, we should add a extra single-width space; and if we replace a single-width to a double-witdh, we should check its following char: if it is single-width, delete it; otherwise replace it with a single-width space. In GNU Emacs 23.0.60.1 (i386-apple-darwin9.6.0, NS apple-appkit-949.43) of 2008-12-25 on neutron.local Windowing system distributor `Apple', version 97.112.112.108.101.45.97.112.112.107.105.116.45.57.52.57.46.52.51 configured using `configure '--with-ns'' Important settings: value of $LC_ALL: nil value of $LC_COLLATE: nil value of $LC_CTYPE: zh_CN.UTF-8 value of $LC_MESSAGES: nil value of $LC_MONETARY: nil value of $LC_NUMERIC: nil value of $LC_TIME: nil value of $LANG: nil value of $XMODIFIERS: @im=fcitx locale-coding-system: utf-8-unix default-enable-multibyte-characters: t Major mode: Group Minor modes in effect: erc-log-mode: t erc-list-mode: t erc-menu-mode: t erc-autojoin-mode: t erc-ring-mode: t erc-networks-mode: t erc-pcomplete-mode: t erc-track-mode: t erc-track-minor-mode: t erc-match-mode: t erc-button-mode: t erc-fill-mode: t erc-stamp-mode: t erc-netsplit-mode: t erc-irccontrols-mode: t erc-noncommands-mode: t erc-move-to-prompt-mode: t erc-readonly-mode: t gnus-undo-mode: t recentf-mode: t which-function-mode: t show-paren-mode: t mouse-sel-mode: t global-hl-line-mode: t pinbar-mode: t shell-dirtrack-mode: t tooltip-mode: t tool-bar-mode: t mouse-wheel-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t global-auto-composition-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t column-number-mode: t line-number-mode: t transient-mark-mode: t Recent input: C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p 9 RET C-n C-n SPC F C-\ x t u SPC g f SPC j e r r SPC w b SPC s h n SPC w d t SPC w f t c b SPC . RET y i SPC j SPC y u SPC d SPC 1 s o v SPC g n g DEL SPC 4 s o v SPC u j SPC e SPC DEL e t SPC g SPC w h SPC A A P DEL DEL DEL k h t SPC m g SPC DEL m g j SPC DEL m g SPC DEL m h SPC t SPC g SPC w h SPC A P r a w k SPC g SPC g h SPC DEL w h SPC x g SPC ? DEL . RET RET ESC [ A ESC [ A C-e ESC [ D ESC [ D DEL t s SPC w y SPC u t h p SPC ESC [ C DEL ESC [ B C-x k C-g C-x k y q g C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n ESC < n RET SPC n SPC q ESC < ESC > ESC < ESC x n e w s C-p C-p RET U N o o o N o o o ESC x n e w s C-p C-p RET ESC 1 ESC < ESC > ESC < C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n ESC x r e p o TAB r TAB RET Recent messages: Reading... done. Preparing newsticker buffer... Newsticker stopped! Mark set [3 times] Reading active file from gmail via nnimap... nnimap: Checking mailboxes...done Reading active file from freenews.netfront.net via nntp... Reading active file from news.motzarella.org via nntp... Checking new news...done Making completion list... From unknown Mon Jun 23 06:00:20 2025 X-Loop: help-debbugs@gnu.org Subject: bug#1808: 23.0.60; picture-mode not considering double-width characters alignment Resent-From: Alan J Third Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 09 Jan 2016 22:44:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 1808 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: poppyer Cc: 1808@debbugs.gnu.org Received: via spool by 1808-submit@debbugs.gnu.org id=B1808.145237942627791 (code B ref 1808); Sat, 09 Jan 2016 22:44:01 +0000 Received: (at 1808) by debbugs.gnu.org; 9 Jan 2016 22:43:46 +0000 Received: from localhost ([127.0.0.1]:44723 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aI2Ec-0007EA-Hv for submit@debbugs.gnu.org; Sat, 09 Jan 2016 17:43:46 -0500 Received: from mail-wm0-f50.google.com ([74.125.82.50]:37733) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aI2Ea-0007Dw-La for 1808@debbugs.gnu.org; Sat, 09 Jan 2016 17:43:44 -0500 Received: by mail-wm0-f50.google.com with SMTP id f206so218920247wmf.0 for <1808@debbugs.gnu.org>; Sat, 09 Jan 2016 14:43:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=sender:from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type:content-transfer-encoding; bh=F6LPO9d59RrSdODsSm/YmOiQSdZHYFS5GqyoZJR5oAc=; b=E0bQ+TDuhdc6G6pzruXqMN3pnTnKhfEC/SXpE/0adY677eNo8KmGMF2Z/ty2NEnkzc grja9c0MOLJcdQL8GmY9Eekp0zcbMT+G/9IcEnlynMRj0b6nrjvB2IURHM0LVNRiCk9O 4mxhoA6xpCwOaaIz9KX1+OLnkRc9kekqd9kITXGVKNFMBxXT4CeqX4W9LpspT6qgxaYI 6HzkBWU+G382eoALQ4wBAP7FmqmV2CnR1XFCaSgZHkjMi8VeXhHrcGJc6+9AQlotZrPf l4LX4cRRetfI5hO8j3YgHSYb4o3JwCclm4PYW4FTsWvNzOWtvo21vasa8/OF2aLOPcQz EICg== X-Received: by 10.28.93.140 with SMTP id r134mr5998995wmb.80.1452379419120; Sat, 09 Jan 2016 14:43:39 -0800 (PST) Received: from galloway.idiocy.org (0.7.b.e.8.2.9.3.1.4.b.f.c.3.0.3.9.2.1.8.8.f.3.0.0.b.8.0.1.0.0.2.ip6.arpa. [2001:8b0:3f8:8129:303c:fb41:3928:eb70]) by smtp.gmail.com with ESMTPSA id c203sm5678468wmd.5.2016.01.09.14.43.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 09 Jan 2016 14:43:38 -0800 (PST) From: Alan J Third References: Date: Sat, 09 Jan 2016 22:43:36 +0000 In-Reply-To: (poppyer@gmail.com's message of "Wed, 07 Jan 2009 01:06:47 +0800") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (darwin) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -0.5 (/) 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: -0.5 (/) poppyer writes: > This is not a new bug of EMACS 23; but it is there in EMACS22 for a > long time. In M-x picture-mode, emacs acts in a "replace" typing > mode, i.e. when you type a char, it replace the old one such that the > alignment is maintained. > > But when mixing with double-width characters (e.g. CJK chars), one to > one char replacing become problematic, e.g. if we replace a > single-width char with a double-wdith char, the alignment will be > destroyed. Sorry it's taken this long for someone to get back to you. First, do you know if this is still a problem for you? If so, how are you entering the CJK characters? I find in Emacs 25 that if I try entering a greek alpha by typing: C-x 8 RET GREEK SMALL LETTER ALPHA It inserts the character, however when I bind the same character to a key, eg.: (global-set-key (kbd "C-c a") "=CE=B1") and enter it that way it works as expected. Is this similar? --=20 Alan Third From unknown Mon Jun 23 06:00:20 2025 X-Loop: help-debbugs@gnu.org Subject: bug#1808: 23.0.60; picture-mode not considering double-width characters alignment Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 10 Jan 2016 15:42:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 1808 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Alan J Third Cc: poppyer@gmail.com, 1808@debbugs.gnu.org Reply-To: Eli Zaretskii Received: via spool by 1808-submit@debbugs.gnu.org id=B1808.145244048116516 (code B ref 1808); Sun, 10 Jan 2016 15:42:01 +0000 Received: (at 1808) by debbugs.gnu.org; 10 Jan 2016 15:41:21 +0000 Received: from localhost ([127.0.0.1]:45670 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aII7N-0004IJ-64 for submit@debbugs.gnu.org; Sun, 10 Jan 2016 10:41:21 -0500 Received: from eggs.gnu.org ([208.118.235.92]:34105) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aII7L-0004I7-G6 for 1808@debbugs.gnu.org; Sun, 10 Jan 2016 10:41:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aII7C-0002Zm-QB for 1808@debbugs.gnu.org; Sun, 10 Jan 2016 10:41:14 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,RP_MATCHES_RCVD autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:43865) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aII7C-0002Zi-N7; Sun, 10 Jan 2016 10:41:10 -0500 Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:3095 helo=HOME-C4E4A596F7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.82) (envelope-from ) id 1aII7C-0005ip-0U; Sun, 10 Jan 2016 10:41:10 -0500 Date: Sun, 10 Jan 2016 17:41:14 +0200 Message-Id: <83io31moh1.fsf@gnu.org> From: Eli Zaretskii In-reply-to: (message from Alan J Third on Sat, 09 Jan 2016 22:43:36 +0000) References: MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-Spam-Score: -5.0 (-----) 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: -5.0 (-----) > From: Alan J Third > Date: Sat, 09 Jan 2016 22:43:36 +0000 > Cc: 1808@debbugs.gnu.org > > > This is not a new bug of EMACS 23; but it is there in EMACS22 for a > > long time. In M-x picture-mode, emacs acts in a "replace" typing > > mode, i.e. when you type a char, it replace the old one such that the > > alignment is maintained. > > > > But when mixing with double-width characters (e.g. CJK chars), one to > > one char replacing become problematic, e.g. if we replace a > > single-width char with a double-wdith char, the alignment will be > > destroyed. > > Sorry it's taken this long for someone to get back to you. > > First, do you know if this is still a problem for you? I think I still see it in the current Emacs-25 branch. > If so, how are you entering the CJK characters? The point is double-width characters, not necessarily CJK character, AFAIU. There's a list of such characters in lisp/international/character.el (search for "full-width"). Typing any of the characters for which the char-width-table entry holds 2 should exhibit the problem. > I find in Emacs 25 that if I try entering a greek alpha by typing: > > C-x 8 RET GREEK SMALL LETTER ALPHA > > It inserts the character, however when I bind the same character to a > key, eg.: > > (global-set-key (kbd "C-c a") "α") > > and enter it that way it works as expected. Yes, binding it to a key is the way to go. And when inserting such a character, it looks like picture-mode does TRT: you will see in picture-insert that it looks at the character width. But I think the bug report is not about inserting double-width characters, it's about replacing them with a single-width character. If I type a double-width character, the alignment is kept reasonably well ("reasonably" because the double-width characters don't always take up exactly twice the number of pixels of a single-width character, the exact ration depends on the font being used for the double-width character). To keep the alignment, picture-insert replaces 2 single-width characters with the double-width one. However, if I then replace it with a single-width character, the alignment is destroyed. And I think this bug report is about that latter use case. Thanks for working on this. From unknown Mon Jun 23 06:00:20 2025 X-Loop: help-debbugs@gnu.org Subject: bug#1808: 23.0.60; picture-mode not considering double-width characters alignment Resent-From: Alan J Third Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 10 Jan 2016 20:12:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 1808 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Eli Zaretskii Cc: poppyer@gmail.com, 1808@debbugs.gnu.org Received: via spool by 1808-submit@debbugs.gnu.org id=B1808.14524567208742 (code B ref 1808); Sun, 10 Jan 2016 20:12:01 +0000 Received: (at 1808) by debbugs.gnu.org; 10 Jan 2016 20:12:00 +0000 Received: from localhost ([127.0.0.1]:45738 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aIMLH-0002Gv-TV for submit@debbugs.gnu.org; Sun, 10 Jan 2016 15:12:00 -0500 Received: from mail-wm0-f53.google.com ([74.125.82.53]:34697) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aIMLG-0002Gh-QY for 1808@debbugs.gnu.org; Sun, 10 Jan 2016 15:11:59 -0500 Received: by mail-wm0-f53.google.com with SMTP id u188so192345603wmu.1 for <1808@debbugs.gnu.org>; Sun, 10 Jan 2016 12:11:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=sender:from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type; bh=fA7NtElVbTEicQrrz49ilRIk3ZfsztnBnssk1wBQLDo=; b=xPnjpIVHjOR8qXu1e0OwRNSCMdI4p2og2IvAQTvckoETQfYkrWwgFwIigkwSvEICsC pFL0Qq/oFoQjoPQs5IK9WlOixzYDA1doWNqsXxitl2iMG4vugxK247TaPmLhD6uGAiCe eTHw9T+T3X60LvfB23AJPfZF8tNg1Kcbb9j+DVaotfvnQFO3WH0/nIWlwd8inSwRYr0A KpV5Frgchl5GDYSORS2qar57z8t4JCeTqNsChhaCwDkqhLQBUNUBCybPMWAozdjoZTB6 KqRntSSaguFzt61H4vBHGVB3zEbSosQ5cPejho9WE+5tHY+F1Fk7VZ8F89jjD2EnCF/k yx+A== X-Received: by 10.28.144.196 with SMTP id s187mr10254990wmd.9.1452456713098; Sun, 10 Jan 2016 12:11:53 -0800 (PST) Received: from galloway.idiocy.org (2.d.d.e.0.6.c.f.1.4.9.b.d.f.0.8.9.2.1.8.8.f.3.0.0.b.8.0.1.0.0.2.ip6.arpa. [2001:8b0:3f8:8129:80fd:b941:fc60:edd2]) by smtp.gmail.com with ESMTPSA id e2sm1371731wma.1.2016.01.10.12.11.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 10 Jan 2016 12:11:52 -0800 (PST) From: Alan J Third References: <83io31moh1.fsf@gnu.org> Date: Sun, 10 Jan 2016 20:11:45 +0000 In-Reply-To: <83io31moh1.fsf@gnu.org> (Eli Zaretskii's message of "Sun, 10 Jan 2016 17:41:14 +0200") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (darwin) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.5 (/) 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: -0.5 (/) Eli Zaretskii writes: > The point is double-width characters, not necessarily CJK character, > AFAIU. There's a list of such characters in > lisp/international/character.el (search for "full-width"). > > Typing any of the characters for which the char-width-table entry > holds 2 should exhibit the problem. I hadn't realised there was such a thing, I had assumed it was two byte unicode type characters. Now I know different. :) > Yes, binding it to a key is the way to go. And when inserting such a > character, it looks like picture-mode does TRT: you will see in > picture-insert that it looks at the character width. But I think the > bug report is not about inserting double-width characters, it's about > replacing them with a single-width character. If I type a > double-width character, the alignment is kept reasonably well > ("reasonably" because the double-width characters don't always take up > exactly twice the number of pixels of a single-width character, the > exact ration depends on the font being used for the double-width > character). To keep the alignment, picture-insert replaces 2 > single-width characters with the double-width one. However, if I then > replace it with a single-width character, the alignment is destroyed. > And I think this bug report is about that latter use case. It turns out that insertion sometimes does TRT, but not in the case where you have a single-width char followed by a double-width, and you try to overwrite the single-width char with a double-width. Both the single and double-width chars are overwritten, and everything to the right moves left one column, therefore going out of alignment. I've written a small patch that I think fixes all these issues. It works out how many columns the characters that are about to be over-written take up, then deletes them as before, and finally inserts a number of spaces to fill the gap (if they're needed). Then the old code inserts the new character. Spaces seemed the like the safest option, but it could be easily changed. diff -c /Users/alan/src/emacs/picture.el /Users/alan/src/emacs/new-picture.el *** /Users/alan/src/emacs/picture.el 2016-01-10 18:26:02.000000000 +0000 --- /Users/alan/src/emacs/new-picture.el 2016-01-10 19:51:53.000000000 +0000 *************** *** 272,278 **** (or (eolp) (let ((pos (point))) (move-to-column col t) ! (delete-region pos (point))))) (insert ch) (forward-char -1) (picture-move)))) --- 272,282 ---- (or (eolp) (let ((pos (point))) (move-to-column col t) ! (let ((old-width (string-width (buffer-substring pos (point))))) ! (delete-region pos (point)) ! (when (> old-width width) ! (insert-char ? (- old-width width)) ! (goto-char pos)))))) (insert ch) (forward-char -1) (picture-move)))) Diff finished. Sun Jan 10 19:51:57 2016 -- Alan Third From unknown Mon Jun 23 06:00:20 2025 X-Loop: help-debbugs@gnu.org Subject: bug#1808: 23.0.60; picture-mode not considering double-width characters alignment Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 11 Jan 2016 18:29:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 1808 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Alan J Third Cc: poppyer@gmail.com, 1808@debbugs.gnu.org Reply-To: Eli Zaretskii Received: via spool by 1808-submit@debbugs.gnu.org id=B1808.14525368946930 (code B ref 1808); Mon, 11 Jan 2016 18:29:02 +0000 Received: (at 1808) by debbugs.gnu.org; 11 Jan 2016 18:28:14 +0000 Received: from localhost ([127.0.0.1]:46755 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aIhCQ-0001ni-KI for submit@debbugs.gnu.org; Mon, 11 Jan 2016 13:28:14 -0500 Received: from eggs.gnu.org ([208.118.235.92]:56627) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aIhCP-0001nW-4V for 1808@debbugs.gnu.org; Mon, 11 Jan 2016 13:28:13 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aIhCJ-0004He-2b for 1808@debbugs.gnu.org; Mon, 11 Jan 2016 13:28:07 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,RP_MATCHES_RCVD autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:46844) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aIhCD-0004Gc-IT; Mon, 11 Jan 2016 13:28:01 -0500 Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:2257 helo=HOME-C4E4A596F7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.82) (envelope-from ) id 1aIhCC-0006FU-QF; Mon, 11 Jan 2016 13:28:01 -0500 Date: Mon, 11 Jan 2016 20:28:07 +0200 Message-Id: <83a8ockm2w.fsf@gnu.org> From: Eli Zaretskii In-reply-to: (message from Alan J Third on Sun, 10 Jan 2016 20:11:45 +0000) References: <83io31moh1.fsf@gnu.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-Spam-Score: -5.0 (-----) 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: -5.0 (-----) > From: Alan J Third > Cc: 1808@debbugs.gnu.org, poppyer@gmail.com > Date: Sun, 10 Jan 2016 20:11:45 +0000 > > I've written a small patch that I think fixes all these issues. > > It works out how many columns the characters that are about to be > over-written take up, then deletes them as before, and finally inserts a > number of spaces to fill the gap (if they're needed). Then the old code > inserts the new character. > > Spaces seemed the like the safest option, but it could be easily changed. Thanks, this looks correct to me. Please commit, and I think we can close the bug. From unknown Mon Jun 23 06:00:20 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: poppyer Subject: bug#1808: closed (Re: bug#1808: 23.0.60; picture-mode not considering double-width characters alignment) Message-ID: References: <83vb6vfdq3.fsf@gnu.org> X-Gnu-PR-Message: they-closed 1808 X-Gnu-PR-Package: emacs Reply-To: 1808@debbugs.gnu.org Date: Fri, 15 Jan 2016 08:30:03 +0000 Content-Type: multipart/mixed; boundary="----------=_1452846603-23491-1" This is a multi-part message in MIME format... ------------=_1452846603-23491-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #1808: 23.0.60; picture-mode not considering double-width characters alignm= ent 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 1808@debbugs.gnu.org. --=20 1808: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D1808 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1452846603-23491-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 1808-done) by debbugs.gnu.org; 15 Jan 2016 08:29:07 +0000 Received: from localhost ([127.0.0.1]:49601 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aJzkp-00065L-BN for submit@debbugs.gnu.org; Fri, 15 Jan 2016 03:29:07 -0500 Received: from eggs.gnu.org ([208.118.235.92]:51753) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aJzkn-00064p-Dq for 1808-done@debbugs.gnu.org; Fri, 15 Jan 2016 03:29:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aJzke-0007z9-W0 for 1808-done@debbugs.gnu.org; Fri, 15 Jan 2016 03:29:00 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=BAYES_40,RP_MATCHES_RCVD autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:34065) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aJzke-0007z5-Si; Fri, 15 Jan 2016 03:28:56 -0500 Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:4640 helo=HOME-C4E4A596F7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.82) (envelope-from ) id 1aJzkd-0002vX-6D; Fri, 15 Jan 2016 03:28:56 -0500 Date: Fri, 15 Jan 2016 10:28:52 +0200 Message-Id: <83vb6vfdq3.fsf@gnu.org> From: Eli Zaretskii To: alan@idiocy.org, poppyer@gmail.com In-reply-to: <83a8ockm2w.fsf@gnu.org> (message from Eli Zaretskii on Mon, 11 Jan 2016 20:28:07 +0200) Subject: Re: bug#1808: 23.0.60; picture-mode not considering double-width characters alignment References: <83io31moh1.fsf@gnu.org> <83a8ockm2w.fsf@gnu.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: 1808-done Cc: 1808-done@debbugs.gnu.org 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: , Reply-To: Eli Zaretskii Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) > Date: Mon, 11 Jan 2016 20:28:07 +0200 > From: Eli Zaretskii > Cc: poppyer@gmail.com, 1808@debbugs.gnu.org > > > From: Alan J Third > > Cc: 1808@debbugs.gnu.org, poppyer@gmail.com > > Date: Sun, 10 Jan 2016 20:11:45 +0000 > > > > I've written a small patch that I think fixes all these issues. > > > > It works out how many columns the characters that are about to be > > over-written take up, then deletes them as before, and finally inserts a > > number of spaces to fill the gap (if they're needed). Then the old code > > inserts the new character. > > > > Spaces seemed the like the safest option, but it could be easily changed. > > Thanks, this looks correct to me. Please commit, and I think we can > close the bug. Fixed with commit b70dba4 for Emacs 25.1. Closing. ------------=_1452846603-23491-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by emacsbugs.donarmstrong.com; 6 Jan 2009 17:07:10 +0000 X-Spam-Checker-Version: SpamAssassin 3.2.5-bugs.debian.org_2005_01_02 (2008-06-10) on rzlab.ucr.edu X-Spam-Level: X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available. hammytokens:Tokens not available. X-Spam-Status: No, score=0.1 required=4.0 tests=FOURLA autolearn=no version=3.2.5-bugs.debian.org_2005_01_02 Received: from fencepost.gnu.org (fencepost.gnu.org [140.186.70.10]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id n06H73sW013076 for ; Tue, 6 Jan 2009 09:07:04 -0800 Received: from mail.gnu.org ([199.232.76.166]:47319 helo=mx10.gnu.org) by fencepost.gnu.org with esmtp (Exim 4.67) (envelope-from ) id 1LKFNI-0005hY-7T for emacs-pretest-bug@gnu.org; Tue, 06 Jan 2009 12:05:52 -0500 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1LKFOM-0005MF-SA for emacs-pretest-bug@gnu.org; Tue, 06 Jan 2009 12:07:02 -0500 Received: from ti-out-0910.google.com ([209.85.142.191]:32262) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LKFOM-0005Lt-68 for emacs-pretest-bug@gnu.org; Tue, 06 Jan 2009 12:06:58 -0500 Received: by ti-out-0910.google.com with SMTP id u5so6656050tia.10 for ; Tue, 06 Jan 2009 09:06:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:date:message-id:from:to :subject; bh=iaXO6m5qqVOFzFwF6DhZq/dI+YNJtbHQtQvEuZlL33E=; b=kyqlOc4vA83MgcQv6F3rJVipLI2u2p6AecmKxyBTevriui3oDQ0yZeP0zEnvdQxSCh CJYdRLl6dZ07Dty81uRyQNJL86m+hIfmuCZdCKoTU/a74bowI0zncHbUQSzqen4XpSFi tuGpQy1svApsJPDJMAr/IvOJgKmAPPY9y0PdY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:message-id:from:to:subject; b=S/Tke/A6y/CiqCjb8wa2uhrw99SnMuOjlSkfZEV/8QjK5OLSJUxvEI6a/FegcqECwX USC6l2Kf8A5yg+oT7othw6qP5GNEAUW+M5AfRHLbbk7Q+4qftg1fO09+DAvcSy1JNHO9 i04fIGF26tqssfXlIKkflfC0rhqsZtJI2sigg= Received: by 10.110.62.4 with SMTP id k4mr33806557tia.17.1231261615397; Tue, 06 Jan 2009 09:06:55 -0800 (PST) Received: from nusnet-97-126.dynip.nus.edu.sg.yourcompany.com (nusnet-97-126.dynip.nus.edu.sg [137.132.97.126]) by mx.google.com with ESMTPS id 14sm1292065tim.30.2009.01.06.09.06.52 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 06 Jan 2009 09:06:54 -0800 (PST) Date: Wed, 07 Jan 2009 01:06:47 +0800 Message-Id: From: poppyer To: emacs-pretest-bug@gnu.org Subject: 23.0.60; picture-mode not considering double-width characters alignment X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) This is not a new bug of EMACS 23; but it is there in EMACS22 for a long time. In M-x picture-mode, emacs acts in a "replace" typing mode, i.e. when you type a char, it replace the old one such that the alignment is maintained. But when mixing with double-width characters (e.g. CJK chars), one to one char replacing become problematic, e.g. if we replace a single-width char with a double-wdith char, the alignment will be destroyed. So, what I suggests is: if we replace a double-width to a single-width, we should add a extra single-width space; and if we replace a single-width to a double-witdh, we should check its following char: if it is single-width, delete it; otherwise replace it with a single-width space. In GNU Emacs 23.0.60.1 (i386-apple-darwin9.6.0, NS apple-appkit-949.43) of 2008-12-25 on neutron.local Windowing system distributor `Apple', version 97.112.112.108.101.45.97.112.112.107.105.116.45.57.52.57.46.52.51 configured using `configure '--with-ns'' Important settings: value of $LC_ALL: nil value of $LC_COLLATE: nil value of $LC_CTYPE: zh_CN.UTF-8 value of $LC_MESSAGES: nil value of $LC_MONETARY: nil value of $LC_NUMERIC: nil value of $LC_TIME: nil value of $LANG: nil value of $XMODIFIERS: @im=fcitx locale-coding-system: utf-8-unix default-enable-multibyte-characters: t Major mode: Group Minor modes in effect: erc-log-mode: t erc-list-mode: t erc-menu-mode: t erc-autojoin-mode: t erc-ring-mode: t erc-networks-mode: t erc-pcomplete-mode: t erc-track-mode: t erc-track-minor-mode: t erc-match-mode: t erc-button-mode: t erc-fill-mode: t erc-stamp-mode: t erc-netsplit-mode: t erc-irccontrols-mode: t erc-noncommands-mode: t erc-move-to-prompt-mode: t erc-readonly-mode: t gnus-undo-mode: t recentf-mode: t which-function-mode: t show-paren-mode: t mouse-sel-mode: t global-hl-line-mode: t pinbar-mode: t shell-dirtrack-mode: t tooltip-mode: t tool-bar-mode: t mouse-wheel-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t global-auto-composition-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t column-number-mode: t line-number-mode: t transient-mark-mode: t Recent input: C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p 9 RET C-n C-n SPC F C-\ x t u SPC g f SPC j e r r SPC w b SPC s h n SPC w d t SPC w f t c b SPC . RET y i SPC j SPC y u SPC d SPC 1 s o v SPC g n g DEL SPC 4 s o v SPC u j SPC e SPC DEL e t SPC g SPC w h SPC A A P DEL DEL DEL k h t SPC m g SPC DEL m g j SPC DEL m g SPC DEL m h SPC t SPC g SPC w h SPC A P r a w k SPC g SPC g h SPC DEL w h SPC x g SPC ? DEL . RET RET ESC [ A ESC [ A C-e ESC [ D ESC [ D DEL t s SPC w y SPC u t h p SPC ESC [ C DEL ESC [ B C-x k C-g C-x k y q g C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n ESC < n RET SPC n SPC q ESC < ESC > ESC < ESC x n e w s C-p C-p RET U N o o o N o o o ESC x n e w s C-p C-p RET ESC 1 ESC < ESC > ESC < C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n ESC x r e p o TAB r TAB RET Recent messages: Reading... done. Preparing newsticker buffer... Newsticker stopped! Mark set [3 times] Reading active file from gmail via nnimap... nnimap: Checking mailboxes...done Reading active file from freenews.netfront.net via nntp... Reading active file from news.motzarella.org via nntp... Checking new news...done Making completion list... ------------=_1452846603-23491-1--